summaryrefslogtreecommitdiff
path: root/noncore/games/zsame/dropin/kapplication.h
Side-by-side diff
Diffstat (limited to 'noncore/games/zsame/dropin/kapplication.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/zsame/dropin/kapplication.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/noncore/games/zsame/dropin/kapplication.h b/noncore/games/zsame/dropin/kapplication.h
new file mode 100644
index 0000000..f83d08e
--- a/dev/null
+++ b/noncore/games/zsame/dropin/kapplication.h
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <time.h>
+
+static int _random() {
+ static int init = false;
+ if (!init) {
+ unsigned int seed;
+ init = true;
+ int fd = ::open("/dev/urandom", O_RDONLY);
+ if( fd<=0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed) ) {
+ srand(getpid());
+ seed = rand()+time(0);
+ }
+ if(fd>=0) close( fd );
+ srand(seed);
+ }
+ return rand();
+}