comparison main.c @ 643:d6792ccefe2f

Use ANSI C srand/rand() instead of POSIX srandom/random().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Jan 2015 20:09:32 +0200
parents c8e5949a8961
children a9d25e083f44
comparison
equal deleted inserted replaced
642:c8e5949a8961 643:d6792ccefe2f
11 #include <unistd.h> 11 #include <unistd.h>
12 #include <fcntl.h> 12 #include <fcntl.h>
13 #ifdef __WIN32 13 #ifdef __WIN32
14 #include <shlwapi.h> 14 #include <shlwapi.h>
15 #include <shfolder.h> 15 #include <shfolder.h>
16 #define srandom srand
17 #define random rand
18 #else 16 #else
19 #include <sys/wait.h> 17 #include <sys/wait.h>
20 #include <sys/stat.h> 18 #include <sys/stat.h>
21 #include <sys/types.h> 19 #include <sys/types.h>
22 #endif 20 #endif
2301 // Initialize user commands 2299 // Initialize user commands
2302 nn_usercmd_init(); 2300 nn_usercmd_init();
2303 2301
2304 // Initialize random numbers 2302 // Initialize random numbers
2305 editState.prevKeepAlive = time(NULL); 2303 editState.prevKeepAlive = time(NULL);
2306 srandom((int) editState.prevKeepAlive); 2304 srand((int) editState.prevKeepAlive);
2307 2305
2308 // Enter mainloop 2306 // Enter mainloop
2309 th_conn_reset(conn); 2307 th_conn_reset(conn);
2310 while (!editState.isError && !appQuitFlag) 2308 while (!editState.isError && !appQuitFlag)
2311 { 2309 {
2357 if (++updateCount > 10) 2355 if (++updateCount > 10)
2358 { 2356 {
2359 time_t tmpTime = time(NULL); 2357 time_t tmpTime = time(NULL);
2360 if (tmpTime - editState.prevKeepAlive > SET_KEEPALIVE) 2358 if (tmpTime - editState.prevKeepAlive > SET_KEEPALIVE)
2361 { 2359 {
2362 size_t n = ((size_t) random()) % th_llist_length(setIdleMessages); 2360 size_t n = ((size_t) rand()) % th_llist_length(setIdleMessages);
2363 qlist_t *node = th_llist_get_nth(setIdleMessages, n); 2361 qlist_t *node = th_llist_get_nth(setIdleMessages, n);
2364 nn_conn_send_msg(conn, optUserNameEnc, node->data); 2362 nn_conn_send_msg(conn, optUserNameEnc, node->data);
2365 editState.prevKeepAlive = tmpTime; 2363 editState.prevKeepAlive = tmpTime;
2366 } 2364 }
2367 2365