author | zecke <zecke> | 2004-02-17 15:55:24 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-17 15:55:24 (UTC) |
commit | 1207607ebbc59841718b79508fc222cb4eee9fde (patch) (unidiff) | |
tree | 60c292a98621385006fbacca82dd11326765c0ab /noncore/games/zsame/dropin/kapplication.h | |
parent | 2ec4085cc290a212c7bec8bdf7a2475f3ee6e069 (diff) | |
download | opie-1207607ebbc59841718b79508fc222cb4eee9fde.zip opie-1207607ebbc59841718b79508fc222cb4eee9fde.tar.gz opie-1207607ebbc59841718b79508fc222cb4eee9fde.tar.bz2 |
Add the source of zsame
Diffstat (limited to 'noncore/games/zsame/dropin/kapplication.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/zsame/dropin/kapplication.h | 23 |
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 | |||
9 | static 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 | } | ||