Apparently enums are bad for wrappers and doing this makes wrapping

toxcore easier.
This commit is contained in:
irungentoo 2015-02-18 18:22:04 -05:00
parent 61ca9529a1
commit 52a0753e52
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98

View File

@ -83,7 +83,7 @@ extern "C" {
* It is possible to run multiple concurrent threads with a Tox instance for
* each thread. It is also possible to run all Tox instances in the same thread.
* A common way to run Tox (multiple or single instance) is to have one thread
* running a simple tox_iteration loop, sleeping for tox_iteration_time
* running a simple tox_iteration loop, sleeping for tox_iteration_interval
* milliseconds on each iteration.
*
* If you want to access a single Tox instance from multiple threads, access
@ -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.
*/
typedef enum TOX_STATUS {
enum TOX_STATUS {
/**
* User is online and available.
*/
@ -279,8 +279,8 @@ typedef enum TOX_STATUS {
* Invalid status used when function returns an error.
*/
TOX_STATUS_INVALID
} TOX_STATUS;
};
typedef uint8_t TOX_STATUS;
/*******************************************************************************
*
@ -289,7 +289,7 @@ typedef enum TOX_STATUS {
******************************************************************************/
typedef enum TOX_PROXY_TYPE {
enum TOX_PROXY_TYPE {
/**
* Don't use a proxy.
*/
@ -302,8 +302,8 @@ typedef enum TOX_PROXY_TYPE {
* SOCKS proxy for simple socket pipes.
*/
TOX_PROXY_TYPE_SOCKS5
} TOX_PROXY_TYPE;
};
typedef uint8_t TOX_PROXY_TYPE;
/**
* This struct contains all the startup options for Tox. You can either allocate
@ -370,13 +370,14 @@ struct Tox_Options {
void tox_options_default(struct Tox_Options *options);
typedef enum TOX_ERR_OPTIONS_NEW {
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
} TOX_ERR_OPTIONS_NEW;
};
typedef uint8_t TOX_ERR_OPTIONS_NEW;
/**
* Allocates a new Tox_Options object and initialises it with the default
@ -407,7 +408,7 @@ void tox_options_free(struct Tox_Options *options);
******************************************************************************/
typedef enum TOX_ERR_NEW {
enum TOX_ERR_NEW {
TOX_ERR_NEW_OK,
TOX_ERR_NEW_NULL,
/**
@ -450,8 +451,8 @@ typedef enum TOX_ERR_NEW {
* causes this error.
*/
TOX_ERR_NEW_LOAD_BAD_FORMAT
} TOX_ERR_NEW;
};
typedef uint8_t TOX_ERR_NEW;
/**
* @brief Creates and initialises a new Tox instance with the options passed.
@ -511,7 +512,7 @@ void tox_save(Tox const *tox, uint8_t *data);
******************************************************************************/
typedef enum TOX_ERR_BOOTSTRAP {
enum TOX_ERR_BOOTSTRAP {
TOX_ERR_BOOTSTRAP_OK,
TOX_ERR_BOOTSTRAP_NULL,
/**
@ -523,7 +524,8 @@ typedef enum TOX_ERR_BOOTSTRAP {
* The port passed was invalid. The valid port range is (1, 65535).
*/
TOX_ERR_BOOTSTRAP_BAD_PORT
} TOX_ERR_BOOTSTRAP;
};
typedef uint8_t TOX_ERR_BOOTSTRAP;
/**
* Sends a "get nodes" request to the given bootstrap node with IP, port, and
@ -564,7 +566,7 @@ bool tox_add_tcp_relay(Tox *tox, char const *address, uint16_t port, uint8_t con
TOX_ERR_BOOTSTRAP *error);
typedef enum TOX_CONNECTION {
enum TOX_CONNECTION {
/**
* There is no connection. This instance, or the friend the state change is
* about, is now offline.
@ -583,8 +585,8 @@ typedef enum TOX_CONNECTION {
* particular friend was built using direct UDP packets.
*/
TOX_CONNECTION_UDP
} TOX_CONNECTION;
};
typedef uint8_t TOX_CONNECTION;
/**
* Return whether we are connected to the DHT. The return value is equal to the
@ -687,15 +689,15 @@ void tox_self_get_private_key(Tox const *tox, uint8_t *private_key);
* Common error codes for all functions that set a piece of user-visible
* client information.
*/
typedef enum TOX_ERR_SET_INFO {
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
} TOX_ERR_SET_INFO;
};
typedef uint8_t TOX_ERR_SET_INFO;
/**
* Set the nickname for the Tox client.
@ -789,7 +791,7 @@ TOX_STATUS tox_self_get_status(Tox const *tox);
******************************************************************************/
typedef enum TOX_ERR_FRIEND_ADD {
enum TOX_ERR_FRIEND_ADD {
TOX_ERR_FRIEND_ADD_OK,
TOX_ERR_FRIEND_ADD_NULL,
/**
@ -823,7 +825,8 @@ typedef enum TOX_ERR_FRIEND_ADD {
* A memory allocation failed when trying to increase the friend list size.
*/
TOX_ERR_FRIEND_ADD_MALLOC
} TOX_ERR_FRIEND_ADD;
};
typedef uint8_t TOX_ERR_FRIEND_ADD;
/**
* Add a friend to the friend list and send a friend request.
@ -872,13 +875,14 @@ uint32_t tox_friend_add(Tox *tox, uint8_t const *address, uint8_t const *message
uint32_t tox_friend_add_norequest(Tox *tox, uint8_t const *public_key, TOX_ERR_FRIEND_ADD *error);
typedef enum TOX_ERR_FRIEND_DELETE {
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
} TOX_ERR_FRIEND_DELETE;
};
typedef uint8_t TOX_ERR_FRIEND_DELETE;
/**
* Remove a friend from the friend list.
@ -901,14 +905,15 @@ bool tox_friend_delete(Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_DELETE *
******************************************************************************/
typedef enum TOX_ERR_FRIEND_BY_PUBLIC_KEY {
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
} TOX_ERR_FRIEND_BY_PUBLIC_KEY;
};
typedef uint8_t TOX_ERR_FRIEND_BY_PUBLIC_KEY;
/**
* Return the friend number associated with that Public Key.
@ -919,14 +924,15 @@ typedef enum TOX_ERR_FRIEND_BY_PUBLIC_KEY {
uint32_t tox_friend_by_public_key(Tox const *tox, uint8_t const *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error);
typedef enum TOX_ERR_FRIEND_GET_PUBLIC_KEY {
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
} TOX_ERR_FRIEND_GET_PUBLIC_KEY;
};
typedef uint8_t TOX_ERR_FRIEND_GET_PUBLIC_KEY;
/**
* Copies the Public Key associated with a given friend number to a byte array.
@ -979,7 +985,7 @@ void tox_friend_list(Tox const *tox, uint32_t *list);
/**
* Common error codes for friend state query functions.
*/
typedef enum TOX_ERR_FRIEND_QUERY {
enum TOX_ERR_FRIEND_QUERY {
TOX_ERR_FRIEND_QUERY_OK,
/**
* The pointer parameter for storing the query result (name, message) was
@ -991,8 +997,8 @@ typedef enum TOX_ERR_FRIEND_QUERY {
* The friend_number did not designate a valid friend.
*/
TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND
} TOX_ERR_FRIEND_QUERY;
};
typedef uint8_t TOX_ERR_FRIEND_QUERY;
/**
* Return the length of the friend's name. If the friend number is invalid, the
@ -1180,13 +1186,14 @@ void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *function, void *
******************************************************************************/
typedef enum TOX_ERR_SET_TYPING {
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
} TOX_ERR_SET_TYPING;
};
typedef uint8_t TOX_ERR_SET_TYPING;
/**
* Set the client's typing status for a friend.
@ -1201,7 +1208,7 @@ typedef enum TOX_ERR_SET_TYPING {
bool tox_self_set_typing(Tox *tox, uint32_t friend_number, bool is_typing, TOX_ERR_SET_TYPING *error);
typedef enum TOX_ERR_SEND_MESSAGE {
enum TOX_ERR_SEND_MESSAGE {
TOX_ERR_SEND_MESSAGE_OK,
TOX_ERR_SEND_MESSAGE_NULL,
/**
@ -1224,7 +1231,8 @@ typedef enum TOX_ERR_SEND_MESSAGE {
* Attempted to send a zero-length message.
*/
TOX_ERR_SEND_MESSAGE_EMPTY
} TOX_ERR_SEND_MESSAGE;
};
typedef uint8_t TOX_ERR_SEND_MESSAGE;
/**
* Send a text chat message to an online friend.
@ -1363,7 +1371,7 @@ void tox_callback_friend_action(Tox *tox, tox_friend_action_cb *function, void *
******************************************************************************/
typedef enum TOX_FILE_KIND {
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.
@ -1386,8 +1394,8 @@ typedef enum TOX_FILE_KIND {
* transfer if it matches.
*/
TOX_FILE_KIND_AVATAR
} TOX_FILE_KIND;
};
typedef uint8_t TOX_FILE_KIND;
/**
* Generates a cryptographic hash of the given data.
@ -1411,7 +1419,7 @@ typedef enum TOX_FILE_KIND {
bool tox_hash(uint8_t *hash, uint8_t const *data, size_t length);
typedef enum TOX_FILE_CONTROL {
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.
@ -1429,10 +1437,10 @@ typedef enum TOX_FILE_CONTROL {
* commands are sent. Also sent by either side to terminate a file transfer.
*/
TOX_FILE_CONTROL_CANCEL
} TOX_FILE_CONTROL;
};
typedef uint8_t TOX_FILE_CONTROL;
typedef enum TOX_ERR_FILE_CONTROL {
enum TOX_ERR_FILE_CONTROL {
TOX_ERR_FILE_CONTROL_OK,
/**
* The friend_number passed did not designate a valid friend.
@ -1459,7 +1467,8 @@ typedef enum TOX_ERR_FILE_CONTROL {
* A PAUSE control was sent, but the file transfer was already paused.
*/
TOX_ERR_FILE_CONTROL_ALREADY_PAUSED
} TOX_ERR_FILE_CONTROL;
};
typedef uint8_t TOX_ERR_FILE_CONTROL;
/**
* Sends a file control command to a friend for a given file transfer.
@ -1505,7 +1514,7 @@ void tox_callback_file_control(Tox *tox, tox_file_control_cb *function, void *us
******************************************************************************/
typedef enum TOX_ERR_FILE_SEND {
enum TOX_ERR_FILE_SEND {
TOX_ERR_FILE_SEND_OK,
TOX_ERR_FILE_SEND_NULL,
/**
@ -1529,7 +1538,8 @@ typedef enum TOX_ERR_FILE_SEND {
* is 256 per friend per direction (sending and receiving).
*/
TOX_ERR_FILE_SEND_TOO_MANY
} TOX_ERR_FILE_SEND;
};
typedef uint8_t TOX_ERR_FILE_SEND;
/**
* Send a file transmission request.
@ -1590,7 +1600,7 @@ uint32_t tox_file_send(Tox *tox, uint32_t friend_number, TOX_FILE_KIND kind, uin
uint8_t const *filename, size_t filename_length, TOX_ERR_FILE_SEND *error);
typedef enum TOX_ERR_FILE_SEND_CHUNK {
enum TOX_ERR_FILE_SEND_CHUNK {
TOX_ERR_FILE_SEND_CHUNK_OK,
/**
* The length parameter was non-zero, but data was NULL.
@ -1614,7 +1624,8 @@ typedef 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
} TOX_ERR_FILE_SEND_CHUNK;
};
typedef uint8_t TOX_ERR_FILE_SEND_CHUNK;
/**
* Send a chunk of file data to a friend.
@ -1752,7 +1763,7 @@ void tox_callback_file_receive_chunk(Tox *tox, tox_file_receive_chunk_cb *functi
******************************************************************************/
typedef enum TOX_ERR_SEND_CUSTOM_PACKET {
enum TOX_ERR_SEND_CUSTOM_PACKET {
TOX_ERR_SEND_CUSTOM_PACKET_OK,
TOX_ERR_SEND_CUSTOM_PACKET_NULL,
/**
@ -1780,8 +1791,8 @@ typedef enum TOX_ERR_SEND_CUSTOM_PACKET {
* Send queue size exceeded.
*/
TOX_ERR_SEND_CUSTOM_PACKET_SENDQ
} TOX_ERR_SEND_CUSTOM_PACKET;
};
typedef uint8_t TOX_ERR_SEND_CUSTOM_PACKET;
/**
* Send a custom lossy packet to a friend.
@ -1880,13 +1891,14 @@ void tox_callback_friend_lossless_packet(Tox *tox, tox_friend_lossless_packet_cb
void tox_get_dht_id(Tox const *tox, uint8_t *dht_id);
typedef enum TOX_ERR_GET_PORT {
enum TOX_ERR_GET_PORT {
TOX_ERR_GET_PORT_OK,
/**
* The instance was not bound to any port.
*/
TOX_ERR_GET_PORT_NOT_BOUND
} TOX_ERR_GET_PORT;
};
typedef uint8_t TOX_ERR_GET_PORT;
/**
* Return the UDP port this Tox instance is bound to.