Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/sys.cc33
-rw-r--r--src/sys/sys.h18
2 files changed, 44 insertions, 7 deletions
diff --git a/src/sys/sys.cc b/src/sys/sys.cc
index dc342bd..9957408 100644
--- a/src/sys/sys.cc
+++ b/src/sys/sys.cc
@@ -14,14 +14,18 @@
#else
+#include <unistd.h>
#include <signal.h>
+#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif
#include <stdlib.h>
-bool sys::mkdir(const char *path)
+namespace sys {
+
+bool mkdir(const char *path)
{
#ifdef _WIN32
::mkdir(path);
@@ -32,7 +36,7 @@ bool sys::mkdir(const char *path)
#endif
}
-void sys::signal(int signum, signalfunc handler)
+void signal(int signum, signalfunc handler)
{
#ifndef _WIN32
struct sigaction sa;
@@ -44,6 +48,27 @@ void sys::signal(int signum, signalfunc handler)
#endif
}
-void sys::quit(int status) {
- exit(status);
+unsigned long time()
+{
+#ifndef _WIN32
+ struct ::tm localtime;
+ time_t epochtime = ::time(0);
+ ::localtime_r(&epochtime, &localtime);
+ return ((unsigned long) (localtime.tm_sec + localtime.tm_min*60 + localtime.tm_hour*3600));
+#else
+ retrun 0;
+#endif
+}
+
+void sleep(float seconds)
+{
+#ifndef _WIN32
+ ::usleep((useconds_t) seconds * (useconds_t) 1000000.0 );
+#endif
+}
+
+void quit(int status) {
+ ::exit(status);
+}
+
}
diff --git a/src/sys/sys.h b/src/sys/sys.h
index 86642e5..dec5ab9 100644
--- a/src/sys/sys.h
+++ b/src/sys/sys.h
@@ -9,18 +9,30 @@
#include "config.h"
+/// maximum line size throught the game
+#define MAXCMDSIZE 1024
+
/// contains operating system dependent functions
+/** sys is a core subsystem
+ */
namespace sys {
typedef void (* signalfunc)(int signum);
/// create a directory
- bool mkdir(const char *path);
+ extern bool mkdir(const char *path);
/// intercept OS signals
- void signal(int signum, signalfunc handler);
+ extern void signal(int signum, signalfunc handler);
/// quit
/** @param status return value
*/
- void quit(int status);
+ extern void quit(int status);
+
+ /// suspend process for a number of seconds
+ extern void sleep(float seconds);
+
+ /// return the current system time of day, in seconds after midnight
+ extern unsigned long time();
+
}
#include "sys/consoleinterface.h"