From f66f9fe76ee491dfb0882860d0bcfd6acbbfe95f Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 5 Mar 2015 12:49:38 -0500 Subject: enums are no longer typedefed to uint8_t. --- toxcore/Messenger.c | 4 +- toxcore/Messenger.h | 9 +++-- toxcore/tox.h | 114 +++++++++++++++++++++++----------------------------- 3 files changed, 58 insertions(+), 69 deletions(-) diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 94cb93dd..373fc334 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -829,7 +829,7 @@ void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, uint3 m->friend_statusmessagechange_userdata = userdata; } -void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), void *userdata) +void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, unsigned int, void *), void *userdata) { m->friend_userstatuschange = function; m->friend_userstatuschange_userdata = userdata; @@ -847,7 +847,7 @@ void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32 m->read_receipt_userdata = userdata; } -void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), +void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, unsigned int, void *), void *userdata) { m->friend_connectionstatuschange = function; diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 67c2358d..90c66e2c 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -230,13 +230,13 @@ struct Messenger { void *friend_namechange_userdata; void (*friend_statusmessagechange)(struct Messenger *m, uint32_t, const uint8_t *, size_t, void *); void *friend_statusmessagechange_userdata; - void (*friend_userstatuschange)(struct Messenger *m, uint32_t, uint8_t, void *); + void (*friend_userstatuschange)(struct Messenger *m, uint32_t, unsigned int, void *); void *friend_userstatuschange_userdata; void (*friend_typingchange)(struct Messenger *m, uint32_t, _Bool, void *); void *friend_typingchange_userdata; void (*read_receipt)(struct Messenger *m, uint32_t, uint32_t, void *); void *read_receipt_userdata; - void (*friend_connectionstatuschange)(struct Messenger *m, uint32_t, uint8_t, void *); + void (*friend_connectionstatuschange)(struct Messenger *m, uint32_t, unsigned int, void *); void *friend_connectionstatuschange_userdata; void (*friend_connectionstatuschange_internal)(struct Messenger *m, uint32_t, uint8_t, void *); void *friend_connectionstatuschange_internal_userdata; @@ -495,7 +495,8 @@ void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, uint3 /* Set the callback for status type changes. * Function(uint32_t friendnumber, USERSTATUS kind) */ -void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), void *userdata); +void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, unsigned int, void *), + void *userdata); /* Set the callback for typing changes. * Function(uint32_t friendnumber, uint8_t is_typing) @@ -524,7 +525,7 @@ void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, uint32 * being previously online" part. * It's assumed that when adding friends, their connection status is offline. */ -void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), +void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, uint32_t, unsigned int, void *), void *userdata); /* Same as previous but for internal A/V core usage only */ void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, uint32_t, uint8_t, void *), diff --git a/toxcore/tox.h b/toxcore/tox.h index 8a489411..23d37cd9 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -260,7 +260,7 @@ bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch); /** * Represents the possible statuses a client can have. */ -enum TOX_STATUS { +typedef enum TOX_STATUS { /** * User is online and available. */ @@ -279,8 +279,8 @@ enum TOX_STATUS { * Invalid status used when function returns an error. */ TOX_STATUS_INVALID -}; -typedef uint8_t TOX_STATUS; +} TOX_STATUS; + /******************************************************************************* * @@ -289,7 +289,7 @@ typedef uint8_t TOX_STATUS; ******************************************************************************/ -enum TOX_PROXY_TYPE { +typedef enum TOX_PROXY_TYPE { /** * Don't use a proxy. */ @@ -302,8 +302,8 @@ enum TOX_PROXY_TYPE { * SOCKS proxy for simple socket pipes. */ TOX_PROXY_TYPE_SOCKS5 -}; -typedef uint8_t TOX_PROXY_TYPE; +} TOX_PROXY_TYPE; + /** * This struct contains all the startup options for Tox. You can either allocate @@ -389,14 +389,13 @@ struct Tox_Options { void tox_options_default(struct Tox_Options *options); -enum TOX_ERR_OPTIONS_NEW { +typedef enum TOX_ERR_OPTIONS_NEW { TOX_ERR_OPTIONS_NEW_OK, /** * The function failed to allocate enough memory for the options struct. */ TOX_ERR_OPTIONS_NEW_MALLOC -}; -typedef uint8_t TOX_ERR_OPTIONS_NEW; +} TOX_ERR_OPTIONS_NEW; /** * Allocates a new Tox_Options object and initialises it with the default @@ -427,7 +426,7 @@ void tox_options_free(struct Tox_Options *options); ******************************************************************************/ -enum TOX_ERR_NEW { +typedef enum TOX_ERR_NEW { TOX_ERR_NEW_OK, TOX_ERR_NEW_NULL, /** @@ -478,8 +477,8 @@ enum TOX_ERR_NEW { * causes this error. */ TOX_ERR_NEW_LOAD_BAD_FORMAT -}; -typedef uint8_t TOX_ERR_NEW; +} TOX_ERR_NEW; + /** * @brief Creates and initialises a new Tox instance with the options passed. @@ -539,7 +538,7 @@ void tox_save(const Tox *tox, uint8_t *data); ******************************************************************************/ -enum TOX_ERR_BOOTSTRAP { +typedef enum TOX_ERR_BOOTSTRAP { TOX_ERR_BOOTSTRAP_OK, TOX_ERR_BOOTSTRAP_NULL, /** @@ -551,8 +550,7 @@ enum TOX_ERR_BOOTSTRAP { * The port passed was invalid. The valid port range is (1, 65535). */ TOX_ERR_BOOTSTRAP_BAD_PORT -}; -typedef uint8_t TOX_ERR_BOOTSTRAP; +} TOX_ERR_BOOTSTRAP; /** * Sends a "get nodes" request to the given bootstrap node with IP, port, and @@ -593,7 +591,7 @@ bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8 TOX_ERR_BOOTSTRAP *error); -enum TOX_CONNECTION { +typedef enum TOX_CONNECTION { /** * There is no connection. This instance, or the friend the state change is * about, is now offline. @@ -612,8 +610,8 @@ enum TOX_CONNECTION { * particular friend was built using direct UDP packets. */ TOX_CONNECTION_UDP -}; -typedef uint8_t TOX_CONNECTION; +} TOX_CONNECTION; + /** * Return whether we are connected to the DHT. The return value is equal to the @@ -716,15 +714,15 @@ void tox_self_get_private_key(const Tox *tox, uint8_t *private_key); * Common error codes for all functions that set a piece of user-visible * client information. */ -enum TOX_ERR_SET_INFO { +typedef enum TOX_ERR_SET_INFO { TOX_ERR_SET_INFO_OK, TOX_ERR_SET_INFO_NULL, /** * Information length exceeded maximum permissible size. */ TOX_ERR_SET_INFO_TOO_LONG -}; -typedef uint8_t TOX_ERR_SET_INFO; +} TOX_ERR_SET_INFO; + /** * Set the nickname for the Tox client. @@ -818,7 +816,7 @@ TOX_STATUS tox_self_get_status(const Tox *tox); ******************************************************************************/ -enum TOX_ERR_FRIEND_ADD { +typedef enum TOX_ERR_FRIEND_ADD { TOX_ERR_FRIEND_ADD_OK, TOX_ERR_FRIEND_ADD_NULL, /** @@ -852,8 +850,7 @@ enum TOX_ERR_FRIEND_ADD { * A memory allocation failed when trying to increase the friend list size. */ TOX_ERR_FRIEND_ADD_MALLOC -}; -typedef uint8_t TOX_ERR_FRIEND_ADD; +} TOX_ERR_FRIEND_ADD; /** * Add a friend to the friend list and send a friend request. @@ -902,14 +899,13 @@ uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error); -enum TOX_ERR_FRIEND_DELETE { +typedef enum TOX_ERR_FRIEND_DELETE { TOX_ERR_FRIEND_DELETE_OK, /** * There was no friend with the given friend number. No friends were deleted. */ TOX_ERR_FRIEND_DELETE_FRIEND_NOT_FOUND -}; -typedef uint8_t TOX_ERR_FRIEND_DELETE; +} TOX_ERR_FRIEND_DELETE; /** * Remove a friend from the friend list. @@ -932,15 +928,14 @@ bool tox_friend_delete(Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_DELETE * ******************************************************************************/ -enum TOX_ERR_FRIEND_BY_PUBLIC_KEY { +typedef enum TOX_ERR_FRIEND_BY_PUBLIC_KEY { TOX_ERR_FRIEND_BY_PUBLIC_KEY_OK, TOX_ERR_FRIEND_BY_PUBLIC_KEY_NULL, /** * No friend with the given Public Key exists on the friend list. */ TOX_ERR_FRIEND_BY_PUBLIC_KEY_NOT_FOUND -}; -typedef uint8_t TOX_ERR_FRIEND_BY_PUBLIC_KEY; +} TOX_ERR_FRIEND_BY_PUBLIC_KEY; /** * Return the friend number associated with that Public Key. @@ -951,15 +946,14 @@ typedef uint8_t TOX_ERR_FRIEND_BY_PUBLIC_KEY; uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error); -enum TOX_ERR_FRIEND_GET_PUBLIC_KEY { +typedef enum TOX_ERR_FRIEND_GET_PUBLIC_KEY { TOX_ERR_FRIEND_GET_PUBLIC_KEY_OK, TOX_ERR_FRIEND_GET_PUBLIC_KEY_NULL, /** * No friend with the given number exists on the friend list. */ TOX_ERR_FRIEND_GET_PUBLIC_KEY_FRIEND_NOT_FOUND -}; -typedef uint8_t TOX_ERR_FRIEND_GET_PUBLIC_KEY; +} TOX_ERR_FRIEND_GET_PUBLIC_KEY; /** * Copies the Public Key associated with a given friend number to a byte array. @@ -1012,7 +1006,7 @@ void tox_friend_list(const Tox *tox, uint32_t *list); /** * Common error codes for friend state query functions. */ -enum TOX_ERR_FRIEND_QUERY { +typedef enum TOX_ERR_FRIEND_QUERY { TOX_ERR_FRIEND_QUERY_OK, /** * The pointer parameter for storing the query result (name, message) was @@ -1024,8 +1018,8 @@ enum TOX_ERR_FRIEND_QUERY { * The friend_number did not designate a valid friend. */ TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND -}; -typedef uint8_t TOX_ERR_FRIEND_QUERY; +} TOX_ERR_FRIEND_QUERY; + /** * Return the length of the friend's name. If the friend number is invalid, the @@ -1213,14 +1207,13 @@ void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *function, void * ******************************************************************************/ -enum TOX_ERR_SET_TYPING { +typedef enum TOX_ERR_SET_TYPING { TOX_ERR_SET_TYPING_OK, /** * The friend number did not designate a valid friend. */ TOX_ERR_SET_TYPING_FRIEND_NOT_FOUND -}; -typedef uint8_t TOX_ERR_SET_TYPING; +} TOX_ERR_SET_TYPING; /** * Set the client's typing status for a friend. @@ -1235,7 +1228,7 @@ typedef uint8_t TOX_ERR_SET_TYPING; bool tox_self_set_typing(Tox *tox, uint32_t friend_number, bool is_typing, TOX_ERR_SET_TYPING *error); -enum TOX_ERR_SEND_MESSAGE { +typedef enum TOX_ERR_SEND_MESSAGE { TOX_ERR_SEND_MESSAGE_OK, TOX_ERR_SEND_MESSAGE_NULL, /** @@ -1258,8 +1251,7 @@ enum TOX_ERR_SEND_MESSAGE { * Attempted to send a zero-length message. */ TOX_ERR_SEND_MESSAGE_EMPTY -}; -typedef uint8_t TOX_ERR_SEND_MESSAGE; +} TOX_ERR_SEND_MESSAGE; /** * Send a text chat message to an online friend. @@ -1398,7 +1390,7 @@ void tox_callback_friend_action(Tox *tox, tox_friend_action_cb *function, void * ******************************************************************************/ -enum TOX_FILE_KIND { +typedef enum TOX_FILE_KIND { /** * Arbitrary file data. Clients can choose to handle it based on the file name * or magic or any other way they choose. @@ -1421,8 +1413,8 @@ enum TOX_FILE_KIND { * transfer if it matches. */ TOX_FILE_KIND_AVATAR -}; -typedef uint8_t TOX_FILE_KIND; +} TOX_FILE_KIND; + /** * Generates a cryptographic hash of the given data. @@ -1446,7 +1438,7 @@ typedef uint8_t TOX_FILE_KIND; bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length); -enum TOX_FILE_CONTROL { +typedef enum TOX_FILE_CONTROL { /** * Sent by the receiving side to accept a file send request. Also sent after a * TOX_FILE_CONTROL_PAUSE command to continue sending or receiving. @@ -1464,10 +1456,10 @@ enum TOX_FILE_CONTROL { * commands are sent. Also sent by either side to terminate a file transfer. */ TOX_FILE_CONTROL_CANCEL -}; -typedef uint8_t TOX_FILE_CONTROL; +} TOX_FILE_CONTROL; -enum TOX_ERR_FILE_CONTROL { + +typedef enum TOX_ERR_FILE_CONTROL { TOX_ERR_FILE_CONTROL_OK, /** * The friend_number passed did not designate a valid friend. @@ -1494,8 +1486,7 @@ enum TOX_ERR_FILE_CONTROL { * A PAUSE control was sent, but the file transfer was already paused. */ TOX_ERR_FILE_CONTROL_ALREADY_PAUSED -}; -typedef uint8_t TOX_ERR_FILE_CONTROL; +} TOX_ERR_FILE_CONTROL; /** * Sends a file control command to a friend for a given file transfer. @@ -1541,7 +1532,7 @@ void tox_callback_file_control(Tox *tox, tox_file_control_cb *function, void *us ******************************************************************************/ -enum TOX_ERR_FILE_SEND { +typedef enum TOX_ERR_FILE_SEND { TOX_ERR_FILE_SEND_OK, TOX_ERR_FILE_SEND_NULL, /** @@ -1565,8 +1556,7 @@ enum TOX_ERR_FILE_SEND { * is 256 per friend per direction (sending and receiving). */ TOX_ERR_FILE_SEND_TOO_MANY -}; -typedef uint8_t TOX_ERR_FILE_SEND; +} TOX_ERR_FILE_SEND; /** * Send a file transmission request. @@ -1627,7 +1617,7 @@ uint32_t tox_file_send(Tox *tox, uint32_t friend_number, TOX_FILE_KIND kind, uin const uint8_t *filename, size_t filename_length, TOX_ERR_FILE_SEND *error); -enum TOX_ERR_FILE_SEND_CHUNK { +typedef enum TOX_ERR_FILE_SEND_CHUNK { TOX_ERR_FILE_SEND_CHUNK_OK, /** * The length parameter was non-zero, but data was NULL. @@ -1651,8 +1641,7 @@ enum TOX_ERR_FILE_SEND_CHUNK { * the file. Trying to send more will result in no data being sent. */ TOX_ERR_FILE_SEND_CHUNK_TOO_LARGE -}; -typedef uint8_t TOX_ERR_FILE_SEND_CHUNK; +} TOX_ERR_FILE_SEND_CHUNK; /** * Send a chunk of file data to a friend. @@ -1790,7 +1779,7 @@ void tox_callback_file_receive_chunk(Tox *tox, tox_file_receive_chunk_cb *functi ******************************************************************************/ -enum TOX_ERR_SEND_CUSTOM_PACKET { +typedef enum TOX_ERR_SEND_CUSTOM_PACKET { TOX_ERR_SEND_CUSTOM_PACKET_OK, TOX_ERR_SEND_CUSTOM_PACKET_NULL, /** @@ -1818,8 +1807,8 @@ enum TOX_ERR_SEND_CUSTOM_PACKET { * Send queue size exceeded. */ TOX_ERR_SEND_CUSTOM_PACKET_SENDQ -}; -typedef uint8_t TOX_ERR_SEND_CUSTOM_PACKET; +} TOX_ERR_SEND_CUSTOM_PACKET; + /** * Send a custom lossy packet to a friend. @@ -1918,14 +1907,13 @@ void tox_callback_friend_lossless_packet(Tox *tox, tox_friend_lossless_packet_cb void tox_get_dht_id(const Tox *tox, uint8_t *dht_id); -enum TOX_ERR_GET_PORT { +typedef enum TOX_ERR_GET_PORT { TOX_ERR_GET_PORT_OK, /** * The instance was not bound to any port. */ TOX_ERR_GET_PORT_NOT_BOUND -}; -typedef uint8_t TOX_ERR_GET_PORT; +} TOX_ERR_GET_PORT; /** * Return the UDP port this Tox instance is bound to. -- cgit v1.2.3