summaryrefslogtreecommitdiff
path: root/noncore/games/zsame/dropin/kapplication.h
Unidiff
Diffstat (limited to 'noncore/games/zsame/dropin/kapplication.h') (more/less context) (ignore 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 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <fcntl.h>
6#include <unistd.h>
7#include <time.h>
8
9static int _random() {
10 static int init = false;
11 if (!init) {
12 unsigned int seed;
13 init = true;
14 int fd = ::open("/dev/urandom", O_RDONLY);
15 if( fd<=0 || ::read(fd, &seed, sizeof(seed)) != sizeof(seed) ) {
16 srand(getpid());
17 seed = rand()+time(0);
18 }
19 if(fd>=0) close( fd );
20 srand(seed);
21 }
22 return rand();
23}