diff options
author | Coren[m] <Break@Ocean> | 2013-10-24 22:32:28 +0200 |
---|---|---|
committer | Coren[m] <Break@Ocean> | 2013-10-24 22:32:28 +0200 |
commit | 0a4c3d7e2e080dafd66d25f7a5806b89f7be1bcf (patch) | |
tree | 61409d905b8132bddc9142525cced3368aba0ad8 /toxcore/util.h | |
parent | e9d92606d94837ac24e2583cdfd8d313a0fd9338 (diff) |
Move unix_time(), id_cpy()/id_eq(), is_timeout() to util.*
unix_time():
- returns local value for current epoch
- value is updated explicitly with unix_time_update() called at new_DHT()/doMessenger()/do_DHT()
is_timeout():
- uses the local value for current epoch
id_cpy()/id_eq() => id_copy()/id_equal():
- centralized duplicate definitions
- replaced (most) memcpy()/memcmp() of (*, *, CLIENT_ID_SIZE) with id_copy()/id_equal()
Diffstat (limited to 'toxcore/util.h')
-rw-r--r-- | toxcore/util.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/toxcore/util.h b/toxcore/util.h index 13ab4792..3ecefd9c 100644 --- a/toxcore/util.h +++ b/toxcore/util.h | |||
@@ -11,11 +11,19 @@ | |||
11 | #include <stdbool.h> | 11 | #include <stdbool.h> |
12 | #include <stdint.h> | 12 | #include <stdint.h> |
13 | 13 | ||
14 | uint64_t now(); | ||
15 | uint64_t random_64b(); | 14 | uint64_t random_64b(); |
16 | bool id_eq(uint8_t *dest, uint8_t *src); | ||
17 | void id_cpy(uint8_t *dest, uint8_t *src); | ||
18 | 15 | ||
16 | void unix_time_update(); | ||
17 | uint64_t unix_time(); | ||
18 | int is_timeout(uint64_t timestamp, uint64_t timeout); | ||
19 | |||
20 | |||
21 | /* id functions */ | ||
22 | bool id_equal(uint8_t *dest, uint8_t *src); | ||
23 | uint32_t id_copy(uint8_t *dest, uint8_t *src); /* return value is CLIENT_ID_SIZE */ | ||
24 | |||
25 | |||
26 | /* state load/save */ | ||
19 | typedef int (*load_state_callback_func)(void *outer, uint8_t *data, uint32_t len, uint16_t type); | 27 | typedef int (*load_state_callback_func)(void *outer, uint8_t *data, uint32_t len, uint16_t type); |
20 | int load_state(load_state_callback_func load_state_callback, void *outer, | 28 | int load_state(load_state_callback_func load_state_callback, void *outer, |
21 | uint8_t *data, uint32_t length, uint16_t cookie_inner); | 29 | uint8_t *data, uint32_t length, uint16_t cookie_inner); |