diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-09 17:19:41 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-12 09:19:02 +0000 |
commit | 37f8f566d53a3e2603467aa0bbe1e29581ddd561 (patch) | |
tree | ed49d6b26816a47b37cf3a691909cdf5178d2b6f /toxcore/onion.h | |
parent | 0b7e29e0197f18ea38a62f8f89a1fe60edb462a0 (diff) |
Fix style in some header files.
* Enums must by typedef'd.
* Comments at end of `#define` must be `//` comments.
* Typedef structs must not be anonymous.
* `;` at the end of a `#define` is invalid.
* Callback typedefs must list their parameter names.
* No nested structs.
* No inline use of function pointer types. Only typedef'd callback types
are allowed.
* Enum types are spelled in Camelsnake_Case.
* The argument to `#error` must be a string literal.
Diffstat (limited to 'toxcore/onion.h')
-rw-r--r-- | toxcore/onion.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/toxcore/onion.h b/toxcore/onion.h index 8762d1e1..0e025a1c 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h | |||
@@ -26,7 +26,9 @@ | |||
26 | 26 | ||
27 | #include "DHT.h" | 27 | #include "DHT.h" |
28 | 28 | ||
29 | typedef struct { | 29 | typedef int onion_recv_1_cb(void *object, IP_Port dest, const uint8_t *data, uint16_t length); |
30 | |||
31 | typedef struct Onion { | ||
30 | DHT *dht; | 32 | DHT *dht; |
31 | Networking_Core *net; | 33 | Networking_Core *net; |
32 | uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE]; | 34 | uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE]; |
@@ -36,7 +38,7 @@ typedef struct { | |||
36 | Shared_Keys shared_keys_2; | 38 | Shared_Keys shared_keys_2; |
37 | Shared_Keys shared_keys_3; | 39 | Shared_Keys shared_keys_3; |
38 | 40 | ||
39 | int (*recv_1_function)(void *, IP_Port, const uint8_t *, uint16_t); | 41 | onion_recv_1_cb *recv_1_function; |
40 | void *callback_object; | 42 | void *callback_object; |
41 | } Onion; | 43 | } Onion; |
42 | 44 | ||
@@ -56,7 +58,7 @@ typedef struct { | |||
56 | 58 | ||
57 | #define ONION_PATH_LENGTH 3 | 59 | #define ONION_PATH_LENGTH 3 |
58 | 60 | ||
59 | typedef struct { | 61 | typedef struct Onion_Path { |
60 | uint8_t shared_key1[CRYPTO_SHARED_KEY_SIZE]; | 62 | uint8_t shared_key1[CRYPTO_SHARED_KEY_SIZE]; |
61 | uint8_t shared_key2[CRYPTO_SHARED_KEY_SIZE]; | 63 | uint8_t shared_key2[CRYPTO_SHARED_KEY_SIZE]; |
62 | uint8_t shared_key3[CRYPTO_SHARED_KEY_SIZE]; | 64 | uint8_t shared_key3[CRYPTO_SHARED_KEY_SIZE]; |
@@ -150,8 +152,6 @@ int send_onion_response(Networking_Core *net, IP_Port dest, const uint8_t *data, | |||
150 | */ | 152 | */ |
151 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce); | 153 | int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, IP_Port source, const uint8_t *nonce); |
152 | 154 | ||
153 | typedef int onion_recv_1_cb(void *, IP_Port, const uint8_t *, uint16_t); | ||
154 | |||
155 | /* Set the callback to be called when the dest ip_port doesn't have TOX_AF_INET6 or TOX_AF_INET as the family. | 155 | /* Set the callback to be called when the dest ip_port doesn't have TOX_AF_INET6 or TOX_AF_INET as the family. |
156 | * | 156 | * |
157 | * Format: function(void *object, IP_Port dest, uint8_t *data, uint16_t length) | 157 | * Format: function(void *object, IP_Port dest, uint8_t *data, uint16_t length) |