diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-28 20:00:05 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-28 20:05:07 +0100 |
commit | 8e0eeff79f8cf355221b457bf458765ba1f59537 (patch) | |
tree | 6d67a990323764692f65cb6f92170f716493a016 | |
parent | 13ae9e9a93a1c02fad9475002c0391b86b7ad7bb (diff) |
Expose constants as functions.
These functions simply return the constants. They are a stable ABI, so that if
constants change, the ABI of these functions won't. Code solely relying on these
functions will remain compatible with future values of those constants.
The functions are currently not exposed in tox.h, because this is pending a
change in apidsl to generate accessors for "const" values.
-rw-r--r-- | toxcore/tox.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index 4b96afa8..1063f806 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -95,6 +95,25 @@ bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch) | |||
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | #define CONST_FUNCTION(lowercase, uppercase) \ | ||
99 | uint32_t tox_##lowercase(void) \ | ||
100 | { \ | ||
101 | return TOX_##uppercase; \ | ||
102 | } | ||
103 | |||
104 | CONST_FUNCTION(public_key_size, PUBLIC_KEY_SIZE) | ||
105 | CONST_FUNCTION(secret_key_size, SECRET_KEY_SIZE) | ||
106 | CONST_FUNCTION(address_size, ADDRESS_SIZE) | ||
107 | CONST_FUNCTION(max_name_length, MAX_NAME_LENGTH) | ||
108 | CONST_FUNCTION(max_status_message_length, MAX_STATUS_MESSAGE_LENGTH) | ||
109 | CONST_FUNCTION(max_friend_request_length, MAX_FRIEND_REQUEST_LENGTH) | ||
110 | CONST_FUNCTION(max_message_length, MAX_MESSAGE_LENGTH) | ||
111 | CONST_FUNCTION(max_custom_packet_size, MAX_CUSTOM_PACKET_SIZE) | ||
112 | CONST_FUNCTION(hash_length, HASH_LENGTH) | ||
113 | CONST_FUNCTION(file_id_length, FILE_ID_LENGTH) | ||
114 | CONST_FUNCTION(max_filename_length, MAX_FILENAME_LENGTH) | ||
115 | |||
116 | |||
98 | void tox_options_default(struct Tox_Options *options) | 117 | void tox_options_default(struct Tox_Options *options) |
99 | { | 118 | { |
100 | if (options) { | 119 | if (options) { |