Merge branch 'new_api' of https://github.com/dubslow/toxcore into new_api

This commit is contained in:
irungentoo 2015-02-19 17:16:48 -05:00
commit 53d0eb8937
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 82 additions and 82 deletions

View File

@ -88,7 +88,7 @@ void tox_options_free(struct Tox_Options *options)
free(options); free(options);
} }
Tox *tox_new(struct Tox_Options const *options, uint8_t const *data, size_t length, TOX_ERR_NEW *error) Tox *tox_new(const struct Tox_Options *options, const uint8_t *data, size_t length, TOX_ERR_NEW *error)
{ {
if (!logger_get_global()) if (!logger_get_global())
logger_set_global(logger_new(LOGGER_OUTPUT_FILE, LOGGER_LEVEL, "toxcore")); logger_set_global(logger_new(LOGGER_OUTPUT_FILE, LOGGER_LEVEL, "toxcore"));
@ -177,13 +177,13 @@ void tox_kill(Tox *tox)
logger_kill_global(); logger_kill_global();
} }
size_t tox_save_size(Tox const *tox) size_t tox_save_size(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return messenger_size(m); return messenger_size(m);
} }
void tox_save(Tox const *tox, uint8_t *data) void tox_save(const Tox *tox, uint8_t *data)
{ {
if (data) { if (data) {
const Messenger *m = tox; const Messenger *m = tox;
@ -191,7 +191,7 @@ void tox_save(Tox const *tox, uint8_t *data)
} }
} }
static int address_to_ip(Messenger *m, char const *address, IP_Port *ip_port, IP_Port *ip_port_v4) static int address_to_ip(Messenger *m, const char *address, IP_Port *ip_port, IP_Port *ip_port_v4)
{ {
if (!addr_parse_ip(address, &ip_port->ip)) { if (!addr_parse_ip(address, &ip_port->ip)) {
if (m->options.udp_disabled) { /* Disable DNS when udp is disabled. */ if (m->options.udp_disabled) { /* Disable DNS when udp is disabled. */
@ -216,7 +216,7 @@ static int address_to_ip(Messenger *m, char const *address, IP_Port *ip_port, IP
return 0; return 0;
} }
bool tox_bootstrap(Tox *tox, char const *address, uint16_t port, uint8_t const *public_key, TOX_ERR_BOOTSTRAP *error) bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error)
{ {
if (!address || !public_key) { if (!address || !public_key) {
SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL); SET_ERROR_PARAMETER(error, TOX_ERR_BOOTSTRAP_NULL);
@ -243,7 +243,7 @@ bool tox_bootstrap(Tox *tox, char const *address, uint16_t port, uint8_t const *
} }
} }
bool tox_add_tcp_relay(Tox *tox, char const *address, uint16_t port, uint8_t const *public_key, bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key,
TOX_ERR_BOOTSTRAP *error) TOX_ERR_BOOTSTRAP *error)
{ {
if (!address || !public_key) { if (!address || !public_key) {
@ -272,7 +272,7 @@ bool tox_add_tcp_relay(Tox *tox, char const *address, uint16_t port, uint8_t con
return 1; return 1;
} }
TOX_CONNECTION tox_get_connection_status(Tox const *tox) TOX_CONNECTION tox_get_connection_status(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
@ -293,7 +293,7 @@ void tox_callback_connection_status(Tox *tox, tox_connection_status_cb *function
//TODO //TODO
} }
uint32_t tox_iteration_interval(Tox const *tox) uint32_t tox_iteration_interval(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return messenger_run_interval(m); return messenger_run_interval(m);
@ -306,7 +306,7 @@ void tox_iteration(Tox *tox)
do_groupchats(m->group_chat_object); do_groupchats(m->group_chat_object);
} }
void tox_self_get_address(Tox const *tox, uint8_t *address) void tox_self_get_address(const Tox *tox, uint8_t *address)
{ {
if (address) { if (address) {
const Messenger *m = tox; const Messenger *m = tox;
@ -320,13 +320,13 @@ void tox_self_set_nospam(Tox *tox, uint32_t nospam)
set_nospam(&(m->fr), nospam); set_nospam(&(m->fr), nospam);
} }
uint32_t tox_self_get_nospam(Tox const *tox) uint32_t tox_self_get_nospam(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return get_nospam(&(m->fr)); return get_nospam(&(m->fr));
} }
void tox_self_get_public_key(Tox const *tox, uint8_t *public_key) void tox_self_get_public_key(const Tox *tox, uint8_t *public_key)
{ {
const Messenger *m = tox; const Messenger *m = tox;
@ -334,7 +334,7 @@ void tox_self_get_public_key(Tox const *tox, uint8_t *public_key)
memcpy(public_key, m->net_crypto->self_public_key, crypto_box_PUBLICKEYBYTES); memcpy(public_key, m->net_crypto->self_public_key, crypto_box_PUBLICKEYBYTES);
} }
void tox_self_get_private_key(Tox const *tox, uint8_t *private_key) void tox_self_get_private_key(const Tox *tox, uint8_t *private_key)
{ {
const Messenger *m = tox; const Messenger *m = tox;
@ -342,7 +342,7 @@ void tox_self_get_private_key(Tox const *tox, uint8_t *private_key)
memcpy(private_key, m->net_crypto->self_secret_key, crypto_box_SECRETKEYBYTES); memcpy(private_key, m->net_crypto->self_secret_key, crypto_box_SECRETKEYBYTES);
} }
bool tox_self_set_name(Tox *tox, uint8_t const *name, size_t length, TOX_ERR_SET_INFO *error) bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, TOX_ERR_SET_INFO *error)
{ {
if (!name && length != 0) { if (!name && length != 0) {
SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL); SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL);
@ -362,13 +362,13 @@ bool tox_self_set_name(Tox *tox, uint8_t const *name, size_t length, TOX_ERR_SET
} }
} }
size_t tox_self_get_name_size(Tox const *tox) size_t tox_self_get_name_size(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return m_get_self_name_size(m); return m_get_self_name_size(m);
} }
void tox_self_get_name(Tox const *tox, uint8_t *name) void tox_self_get_name(const Tox *tox, uint8_t *name)
{ {
if (name) { if (name) {
const Messenger *m = tox; const Messenger *m = tox;
@ -376,7 +376,7 @@ void tox_self_get_name(Tox const *tox, uint8_t *name)
} }
} }
bool tox_self_set_status_message(Tox *tox, uint8_t const *status, size_t length, TOX_ERR_SET_INFO *error) bool tox_self_set_status_message(Tox *tox, const uint8_t *status, size_t length, TOX_ERR_SET_INFO *error)
{ {
if (!status && length != 0) { if (!status && length != 0) {
SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL); SET_ERROR_PARAMETER(error, TOX_ERR_SET_INFO_NULL);
@ -394,13 +394,13 @@ bool tox_self_set_status_message(Tox *tox, uint8_t const *status, size_t length,
} }
} }
size_t tox_self_get_status_message_size(Tox const *tox) size_t tox_self_get_status_message_size(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return m_get_self_statusmessage_size(m); return m_get_self_statusmessage_size(m);
} }
void tox_self_get_status_message(Tox const *tox, uint8_t *status) void tox_self_get_status_message(const Tox *tox, uint8_t *status)
{ {
if (status) { if (status) {
const Messenger *m = tox; const Messenger *m = tox;
@ -414,7 +414,7 @@ void tox_self_set_status(Tox *tox, TOX_STATUS user_status)
m_set_userstatus(m, user_status); m_set_userstatus(m, user_status);
} }
TOX_STATUS tox_self_get_status(Tox const *tox) TOX_STATUS tox_self_get_status(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return m_get_self_userstatus(m); return m_get_self_userstatus(m);
@ -454,7 +454,7 @@ static void set_friend_error(int32_t ret, TOX_ERR_FRIEND_ADD *error)
} }
} }
uint32_t tox_friend_add(Tox *tox, uint8_t const *address, uint8_t const *message, size_t length, uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length,
TOX_ERR_FRIEND_ADD *error) TOX_ERR_FRIEND_ADD *error)
{ {
if (!address || !message) { if (!address || !message) {
@ -474,7 +474,7 @@ uint32_t tox_friend_add(Tox *tox, uint8_t const *address, uint8_t const *message
return UINT32_MAX; return UINT32_MAX;
} }
uint32_t tox_friend_add_norequest(Tox *tox, uint8_t const *public_key, TOX_ERR_FRIEND_ADD *error) uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error)
{ {
if (!public_key) { if (!public_key) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_ADD_NULL); SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_ADD_NULL);
@ -508,7 +508,7 @@ bool tox_friend_delete(Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_DELETE *
return 1; return 1;
} }
uint32_t tox_friend_by_public_key(Tox const *tox, uint8_t const *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error) uint32_t tox_friend_by_public_key(const Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error)
{ {
if (!public_key) { if (!public_key) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_BY_PUBLIC_KEY_NULL); SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_BY_PUBLIC_KEY_NULL);
@ -527,7 +527,7 @@ uint32_t tox_friend_by_public_key(Tox const *tox, uint8_t const *public_key, TOX
return ret; return ret;
} }
bool tox_friend_get_public_key(Tox const *tox, uint32_t friend_number, uint8_t *public_key, bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, uint8_t *public_key,
TOX_ERR_FRIEND_GET_PUBLIC_KEY *error) TOX_ERR_FRIEND_GET_PUBLIC_KEY *error)
{ {
if (!public_key) { if (!public_key) {
@ -546,19 +546,19 @@ bool tox_friend_get_public_key(Tox const *tox, uint32_t friend_number, uint8_t *
return 1; return 1;
} }
bool tox_friend_exists(Tox const *tox, uint32_t friend_number) bool tox_friend_exists(const Tox *tox, uint32_t friend_number)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return m_friend_exists(m, friend_number); return m_friend_exists(m, friend_number);
} }
size_t tox_friend_list_size(Tox const *tox) size_t tox_friend_list_size(const Tox *tox)
{ {
const Messenger *m = tox; const Messenger *m = tox;
return count_friendlist(m); return count_friendlist(m);
} }
void tox_friend_list(Tox const *tox, uint32_t *list) void tox_friend_list(const Tox *tox, uint32_t *list)
{ {
if (list) { if (list) {
const Messenger *m = tox; const Messenger *m = tox;
@ -567,7 +567,7 @@ void tox_friend_list(Tox const *tox, uint32_t *list)
} }
} }
size_t tox_friend_get_name_size(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) size_t tox_friend_get_name_size(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error)
{ {
const Messenger *m = tox; const Messenger *m = tox;
int ret = m_get_name_size(m, friend_number); int ret = m_get_name_size(m, friend_number);
@ -581,7 +581,7 @@ size_t tox_friend_get_name_size(Tox const *tox, uint32_t friend_number, TOX_ERR_
return ret; return ret;
} }
bool tox_friend_get_name(Tox const *tox, uint32_t friend_number, uint8_t *name, TOX_ERR_FRIEND_QUERY *error) bool tox_friend_get_name(const Tox *tox, uint32_t friend_number, uint8_t *name, TOX_ERR_FRIEND_QUERY *error)
{ {
if (!name) { if (!name) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_NULL); SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_NULL);
@ -606,7 +606,7 @@ void tox_callback_friend_name(Tox *tox, tox_friend_name_cb *function, void *user
m_callback_friendmessage(m, function, user_data); m_callback_friendmessage(m, function, user_data);
} }
size_t tox_friend_get_status_message_size(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error) size_t tox_friend_get_status_message_size(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error)
{ {
const Messenger *m = tox; const Messenger *m = tox;
int ret = m_get_statusmessage_size(m, friend_number); int ret = m_get_statusmessage_size(m, friend_number);
@ -620,7 +620,7 @@ size_t tox_friend_get_status_message_size(Tox const *tox, uint32_t friend_number
return ret; return ret;
} }
bool tox_friend_get_status_message(Tox const *tox, uint32_t friend_number, uint8_t *message, bool tox_friend_get_status_message(const Tox *tox, uint32_t friend_number, uint8_t *message,
TOX_ERR_FRIEND_QUERY *error) TOX_ERR_FRIEND_QUERY *error)
{ {
if (!message) { if (!message) {

View File

@ -344,7 +344,7 @@ struct Tox_Options {
* *
* This member is ignored (it can be NULL) if proxy_enabled is false. * This member is ignored (it can be NULL) if proxy_enabled is false.
*/ */
char const *proxy_address; const char *proxy_address;
/** /**
* The port to use to connect to the proxy server. * The port to use to connect to the proxy server.
@ -474,7 +474,7 @@ typedef uint8_t TOX_ERR_NEW;
* *
* @see tox_iteration for the event loop. * @see tox_iteration for the event loop.
*/ */
Tox *tox_new(struct Tox_Options const *options, uint8_t const *data, size_t length, TOX_ERR_NEW *error); Tox *tox_new(const struct Tox_Options *options, const uint8_t *data, size_t length, TOX_ERR_NEW *error);
/** /**
@ -493,7 +493,7 @@ void tox_kill(Tox *tox);
* *
* @see threading for concurrency implications. * @see threading for concurrency implications.
*/ */
size_t tox_save_size(Tox const *tox); size_t tox_save_size(const Tox *tox);
/** /**
* Store all information associated with the tox instance to a byte array. * Store all information associated with the tox instance to a byte array.
@ -502,7 +502,7 @@ size_t tox_save_size(Tox const *tox);
* Call tox_save_size to find the number of bytes required. If this parameter * Call tox_save_size to find the number of bytes required. If this parameter
* is NULL, this function has no effect. * is NULL, this function has no effect.
*/ */
void tox_save(Tox const *tox, uint8_t *data); void tox_save(const Tox *tox, uint8_t *data);
/******************************************************************************* /*******************************************************************************
@ -546,7 +546,7 @@ typedef uint8_t TOX_ERR_BOOTSTRAP;
* (TOX_PUBLIC_KEY_SIZE bytes). * (TOX_PUBLIC_KEY_SIZE bytes).
* @return true on success. * @return true on success.
*/ */
bool tox_bootstrap(Tox *tox, char const *address, uint16_t port, uint8_t const *public_key, TOX_ERR_BOOTSTRAP *error); bool tox_bootstrap(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key, TOX_ERR_BOOTSTRAP *error);
/** /**
@ -562,7 +562,7 @@ bool tox_bootstrap(Tox *tox, char const *address, uint16_t port, uint8_t const *
* (TOX_PUBLIC_KEY_SIZE bytes). * (TOX_PUBLIC_KEY_SIZE bytes).
* @return true on success. * @return true on success.
*/ */
bool tox_add_tcp_relay(Tox *tox, char const *address, uint16_t port, uint8_t const *public_key, bool tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key,
TOX_ERR_BOOTSTRAP *error); TOX_ERR_BOOTSTRAP *error);
@ -592,7 +592,7 @@ typedef uint8_t TOX_CONNECTION;
* Return whether we are connected to the DHT. The return value is equal to the * Return whether we are connected to the DHT. The return value is equal to the
* last value received through the `connection_status` callback. * last value received through the `connection_status` callback.
*/ */
TOX_CONNECTION tox_get_connection_status(Tox const *tox); TOX_CONNECTION tox_get_connection_status(const Tox *tox);
/** /**
* The function type for the `connection_status` callback. * The function type for the `connection_status` callback.
@ -620,7 +620,7 @@ void tox_callback_connection_status(Tox *tox, tox_connection_status_cb *function
* Return the time in milliseconds before tox_iteration() should be called again * Return the time in milliseconds before tox_iteration() should be called again
* for optimal performance. * for optimal performance.
*/ */
uint32_t tox_iteration_interval(Tox const *tox); uint32_t tox_iteration_interval(const Tox *tox);
/** /**
@ -646,7 +646,7 @@ void tox_iteration(Tox *tox);
* parameter is NULL, this function has no effect. * parameter is NULL, this function has no effect.
* @see TOX_ADDRESS_SIZE for the address format. * @see TOX_ADDRESS_SIZE for the address format.
*/ */
void tox_self_get_address(Tox const *tox, uint8_t *address); void tox_self_get_address(const Tox *tox, uint8_t *address);
/** /**
@ -659,7 +659,7 @@ void tox_self_set_nospam(Tox *tox, uint32_t nospam);
/** /**
* Get the 4-byte nospam part of the address. * Get the 4-byte nospam part of the address.
*/ */
uint32_t tox_self_get_nospam(Tox const *tox); uint32_t tox_self_get_nospam(const Tox *tox);
/** /**
* Copy the Tox Public Key (long term public key) from the Tox object. * Copy the Tox Public Key (long term public key) from the Tox object.
@ -667,7 +667,7 @@ uint32_t tox_self_get_nospam(Tox const *tox);
* @param public_key A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If * @param public_key A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If
* this parameter is NULL, this function has no effect. * this parameter is NULL, this function has no effect.
*/ */
void tox_self_get_public_key(Tox const *tox, uint8_t *public_key); void tox_self_get_public_key(const Tox *tox, uint8_t *public_key);
/** /**
* Copy the private key from the Tox object. * Copy the private key from the Tox object.
@ -675,7 +675,7 @@ void tox_self_get_public_key(Tox const *tox, uint8_t *public_key);
* @param private_key A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If * @param private_key A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If
* this parameter is NULL, this function has no effect. * this parameter is NULL, this function has no effect.
*/ */
void tox_self_get_private_key(Tox const *tox, uint8_t *private_key); void tox_self_get_private_key(const Tox *tox, uint8_t *private_key);
/******************************************************************************* /*******************************************************************************
@ -710,7 +710,7 @@ typedef uint8_t TOX_ERR_SET_INFO;
* *
* @return true on success. * @return true on success.
*/ */
bool tox_self_set_name(Tox *tox, uint8_t const *name, size_t length, TOX_ERR_SET_INFO *error); bool tox_self_set_name(Tox *tox, const uint8_t *name, size_t length, TOX_ERR_SET_INFO *error);
/** /**
* Return the length of the current nickname as passed to tox_self_set_name. * Return the length of the current nickname as passed to tox_self_set_name.
@ -720,7 +720,7 @@ bool tox_self_set_name(Tox *tox, uint8_t const *name, size_t length, TOX_ERR_SET
* *
* @see threading for concurrency implications. * @see threading for concurrency implications.
*/ */
size_t tox_self_get_name_size(Tox const *tox); size_t tox_self_get_name_size(const Tox *tox);
/** /**
* Write the nickname set by tox_self_set_name to a byte array. * Write the nickname set by tox_self_set_name to a byte array.
@ -734,7 +734,7 @@ size_t tox_self_get_name_size(Tox const *tox);
* @param name A valid memory location large enough to hold the nickname. * @param name A valid memory location large enough to hold the nickname.
* If this parameter is NULL, the function has no effect. * If this parameter is NULL, the function has no effect.
*/ */
void tox_self_get_name(Tox const *tox, uint8_t *name); void tox_self_get_name(const Tox *tox, uint8_t *name);
/** /**
* Set the client's status message. * Set the client's status message.
@ -743,7 +743,7 @@ void tox_self_get_name(Tox const *tox, uint8_t *name);
* length is 0, the status parameter is ignored (it can be NULL), and the * length is 0, the status parameter is ignored (it can be NULL), and the
* user status is set back to empty. * user status is set back to empty.
*/ */
bool tox_self_set_status_message(Tox *tox, uint8_t const *status, size_t length, TOX_ERR_SET_INFO *error); bool tox_self_set_status_message(Tox *tox, const uint8_t *status, size_t length, TOX_ERR_SET_INFO *error);
/** /**
* Return the length of the current status message as passed to * Return the length of the current status message as passed to
@ -754,7 +754,7 @@ bool tox_self_set_status_message(Tox *tox, uint8_t const *status, size_t length,
* *
* @see threading for concurrency implications. * @see threading for concurrency implications.
*/ */
size_t tox_self_get_status_message_size(Tox const *tox); size_t tox_self_get_status_message_size(const Tox *tox);
/** /**
* Write the status message set by tox_self_set_status_message to a byte array. * Write the status message set by tox_self_set_status_message to a byte array.
@ -768,7 +768,7 @@ size_t tox_self_get_status_message_size(Tox const *tox);
* @param status A valid memory location large enough to hold the status message. * @param status A valid memory location large enough to hold the status message.
* If this parameter is NULL, the function has no effect. * If this parameter is NULL, the function has no effect.
*/ */
void tox_self_get_status_message(Tox const *tox, uint8_t *status); void tox_self_get_status_message(const Tox *tox, uint8_t *status);
/** /**
@ -781,7 +781,7 @@ void tox_self_set_status(Tox *tox, TOX_STATUS user_status);
/** /**
* Returns the client's user status. * Returns the client's user status.
*/ */
TOX_STATUS tox_self_get_status(Tox const *tox); TOX_STATUS tox_self_get_status(const Tox *tox);
/******************************************************************************* /*******************************************************************************
@ -850,7 +850,7 @@ typedef uint8_t TOX_ERR_FRIEND_ADD;
* *
* @return the friend number on success, UINT32_MAX on failure. * @return the friend number on success, UINT32_MAX on failure.
*/ */
uint32_t tox_friend_add(Tox *tox, uint8_t const *address, uint8_t const *message, size_t length, uint32_t tox_friend_add(Tox *tox, const uint8_t *address, const uint8_t *message, size_t length,
TOX_ERR_FRIEND_ADD *error); TOX_ERR_FRIEND_ADD *error);
@ -872,7 +872,7 @@ uint32_t tox_friend_add(Tox *tox, uint8_t const *address, uint8_t const *message
* @return the friend number on success, UINT32_MAX on failure. * @return the friend number on success, UINT32_MAX on failure.
* @see tox_friend_add for a more detailed description of friend numbers. * @see tox_friend_add for a more detailed description of friend numbers.
*/ */
uint32_t tox_friend_add_norequest(Tox *tox, uint8_t const *public_key, TOX_ERR_FRIEND_ADD *error); uint32_t tox_friend_add_norequest(Tox *tox, const uint8_t *public_key, TOX_ERR_FRIEND_ADD *error);
enum TOX_ERR_FRIEND_DELETE { enum TOX_ERR_FRIEND_DELETE {
@ -921,7 +921,7 @@ typedef uint8_t TOX_ERR_FRIEND_BY_PUBLIC_KEY;
* @return the friend number on success, UINT32_MAX on failure. * @return the friend number on success, UINT32_MAX on failure.
* @param public_key A byte array containing the Public Key. * @param public_key A byte array containing the Public Key.
*/ */
uint32_t tox_friend_by_public_key(Tox const *tox, uint8_t const *public_key, TOX_ERR_FRIEND_BY_PUBLIC_KEY *error); 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 { enum TOX_ERR_FRIEND_GET_PUBLIC_KEY {
@ -943,7 +943,7 @@ typedef uint8_t TOX_ERR_FRIEND_GET_PUBLIC_KEY;
* *
* @return true on success. * @return true on success.
*/ */
bool tox_friend_get_public_key(Tox const *tox, uint32_t friend_number, uint8_t *public_key, bool tox_friend_get_public_key(const Tox *tox, uint32_t friend_number, uint8_t *public_key,
TOX_ERR_FRIEND_GET_PUBLIC_KEY *error); TOX_ERR_FRIEND_GET_PUBLIC_KEY *error);
@ -951,7 +951,7 @@ bool tox_friend_get_public_key(Tox const *tox, uint32_t friend_number, uint8_t *
* Checks if a friend with the given friend number exists and returns true if * Checks if a friend with the given friend number exists and returns true if
* it does. * it does.
*/ */
bool tox_friend_exists(Tox const *tox, uint32_t friend_number); bool tox_friend_exists(const Tox *tox, uint32_t friend_number);
/** /**
@ -960,7 +960,7 @@ bool tox_friend_exists(Tox const *tox, uint32_t friend_number);
* This function can be used to determine how much memory to allocate for * This function can be used to determine how much memory to allocate for
* tox_friend_list. * tox_friend_list.
*/ */
size_t tox_friend_list_size(Tox const *tox); size_t tox_friend_list_size(const Tox *tox);
/** /**
@ -971,7 +971,7 @@ size_t tox_friend_list_size(Tox const *tox);
* @param list A memory region with enough space to hold the friend list. If * @param list A memory region with enough space to hold the friend list. If
* this parameter is NULL, this function has no effect. * this parameter is NULL, this function has no effect.
*/ */
void tox_friend_list(Tox const *tox, uint32_t *list); void tox_friend_list(const Tox *tox, uint32_t *list);
@ -1007,7 +1007,7 @@ typedef uint8_t TOX_ERR_FRIEND_QUERY;
* The return value is equal to the `length` argument received by the last * The return value is equal to the `length` argument received by the last
* `friend_name` callback. * `friend_name` callback.
*/ */
size_t tox_friend_get_name_size(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error); size_t tox_friend_get_name_size(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error);
/** /**
* Write the name of the friend designated by the given friend number to a byte * Write the name of the friend designated by the given friend number to a byte
@ -1023,7 +1023,7 @@ size_t tox_friend_get_name_size(Tox const *tox, uint32_t friend_number, TOX_ERR_
* *
* @return true on success. * @return true on success.
*/ */
bool tox_friend_get_name(Tox const *tox, uint32_t friend_number, uint8_t *name, TOX_ERR_FRIEND_QUERY *error); bool tox_friend_get_name(const Tox *tox, uint32_t friend_number, uint8_t *name, TOX_ERR_FRIEND_QUERY *error);
/** /**
* The function type for the `friend_name` callback. * The function type for the `friend_name` callback.
@ -1034,7 +1034,7 @@ bool tox_friend_get_name(Tox const *tox, uint32_t friend_number, uint8_t *name,
* @param length A value equal to the return value of * @param length A value equal to the return value of
* tox_friend_get_name_size. * tox_friend_get_name_size.
*/ */
typedef void tox_friend_name_cb(Tox *tox, uint32_t friend_number, uint8_t const *name, size_t length, void *user_data); typedef void tox_friend_name_cb(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length, void *user_data);
/** /**
* Set the callback for the `friend_name` event. Pass NULL to unset. * Set the callback for the `friend_name` event. Pass NULL to unset.
@ -1048,7 +1048,7 @@ void tox_callback_friend_name(Tox *tox, tox_friend_name_cb *function, void *user
* Return the length of the friend's status message. If the friend number is * Return the length of the friend's status message. If the friend number is
* invalid, the return value is SIZE_MAX. * invalid, the return value is SIZE_MAX.
*/ */
size_t tox_friend_get_status_message_size(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error); size_t tox_friend_get_status_message_size(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error);
/** /**
* Write the name of the friend designated by the given friend number to a byte * Write the name of the friend designated by the given friend number to a byte
@ -1062,7 +1062,7 @@ size_t tox_friend_get_status_message_size(Tox const *tox, uint32_t friend_number
* *
* @param name A valid memory region large enough to store the friend's name. * @param name A valid memory region large enough to store the friend's name.
*/ */
bool tox_friend_get_status_message(Tox const *tox, uint32_t friend_number, uint8_t *message, bool tox_friend_get_status_message(const Tox *tox, uint32_t friend_number, uint8_t *message,
TOX_ERR_FRIEND_QUERY *error); TOX_ERR_FRIEND_QUERY *error);
/** /**
@ -1075,7 +1075,7 @@ bool tox_friend_get_status_message(Tox const *tox, uint32_t friend_number, uint8
* @param length A value equal to the return value of * @param length A value equal to the return value of
* tox_friend_get_status_message_size. * tox_friend_get_status_message_size.
*/ */
typedef void tox_friend_status_message_cb(Tox *tox, uint32_t friend_number, uint8_t const *message, size_t length, typedef void tox_friend_status_message_cb(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length,
void *user_data); void *user_data);
/** /**
@ -1093,7 +1093,7 @@ void tox_callback_friend_status_message(Tox *tox, tox_friend_status_message_cb *
* The status returned is equal to the last status received through the * The status returned is equal to the last status received through the
* `friend_status` callback. * `friend_status` callback.
*/ */
TOX_STATUS tox_friend_get_status(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error); TOX_STATUS tox_friend_get_status(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error);
/** /**
* The function type for the `friend_status` callback. * The function type for the `friend_status` callback.
@ -1124,7 +1124,7 @@ void tox_callback_friend_status(Tox *tox, tox_friend_status_cb *function, void *
* @return the friend's connection status as it was received through the * @return the friend's connection status as it was received through the
* `friend_connection_status` event. * `friend_connection_status` event.
*/ */
TOX_CONNECTION tox_friend_get_connection_status(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error); TOX_CONNECTION tox_friend_get_connection_status(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error);
/** /**
* The function type for the `friend_connection_status` callback. * The function type for the `friend_connection_status` callback.
@ -1159,7 +1159,7 @@ void tox_callback_friend_connection_status(Tox *tox, tox_friend_connection_statu
* @return false if the friend is not typing, or the friend number was * @return false if the friend is not typing, or the friend number was
* invalid. Inspect the error code to determine which case it is. * invalid. Inspect the error code to determine which case it is.
*/ */
bool tox_friend_get_typing(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error); bool tox_friend_get_typing(const Tox *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error);
/** /**
* The function type for the `friend_typing` callback. * The function type for the `friend_typing` callback.
@ -1251,7 +1251,7 @@ typedef uint8_t TOX_ERR_SEND_MESSAGE;
* incremented by 1 each time a message is sent. If UINT32_MAX messages were * incremented by 1 each time a message is sent. If UINT32_MAX messages were
* sent, the next message ID is 0. * sent, the next message ID is 0.
*/ */
uint32_t tox_send_message(Tox *tox, uint32_t friend_number, uint8_t const *message, size_t length, uint32_t tox_send_message(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length,
TOX_ERR_SEND_MESSAGE *error); TOX_ERR_SEND_MESSAGE *error);
@ -1266,7 +1266,7 @@ uint32_t tox_send_message(Tox *tox, uint32_t friend_number, uint8_t const *messa
* *
* @see tox_send_message for more details. * @see tox_send_message for more details.
*/ */
uint32_t tox_send_action(Tox *tox, uint32_t friend_number, uint8_t const *action, size_t length, uint32_t tox_send_action(Tox *tox, uint32_t friend_number, const uint8_t *action, size_t length,
TOX_ERR_SEND_MESSAGE *error); TOX_ERR_SEND_MESSAGE *error);
@ -1310,7 +1310,7 @@ void tox_callback_read_receipt(Tox *tox, tox_read_receipt_cb *function, void *us
* @param message The message they sent along with the request. * @param message The message they sent along with the request.
* @param length The size of the message byte array. * @param length The size of the message byte array.
*/ */
typedef void tox_friend_request_cb(Tox *tox, uint8_t const *public_key, /*uint32_t time_delta, */uint8_t const *message, typedef void tox_friend_request_cb(Tox *tox, const uint8_t *public_key, /*uint32_t time_delta, */const uint8_t *message,
size_t length, void *user_data); size_t length, void *user_data);
/** /**
@ -1331,7 +1331,7 @@ void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *function, void
* *
* @see tox_friend_request_cb for more information on time_delta. * @see tox_friend_request_cb for more information on time_delta.
*/ */
typedef void tox_friend_message_cb(Tox *tox, uint32_t friend_number, /*uint32_t time_delta, */uint8_t const *message, typedef void tox_friend_message_cb(Tox *tox, uint32_t friend_number, /*uint32_t time_delta, */const uint8_t *message,
size_t length, void *user_data); size_t length, void *user_data);
/** /**
@ -1352,7 +1352,7 @@ void tox_callback_friend_message(Tox *tox, tox_friend_message_cb *function, void
* *
* @see tox_friend_request_cb for more information on time_delta. * @see tox_friend_request_cb for more information on time_delta.
*/ */
typedef void tox_friend_action_cb(Tox *tox, uint32_t friend_number, /*uint32_t time_delta, */uint8_t const *action, typedef void tox_friend_action_cb(Tox *tox, uint32_t friend_number, /*uint32_t time_delta, */const uint8_t *action,
size_t length, void *user_data); size_t length, void *user_data);
/** /**
@ -1416,7 +1416,7 @@ typedef uint8_t TOX_FILE_KIND;
* *
* @return true if hash was not NULL. * @return true if hash was not NULL.
*/ */
bool tox_hash(uint8_t *hash, uint8_t const *data, size_t length); bool tox_hash(uint8_t *hash, const uint8_t *data, size_t length);
enum TOX_FILE_CONTROL { enum TOX_FILE_CONTROL {
@ -1597,7 +1597,7 @@ typedef uint8_t TOX_ERR_FILE_SEND;
* number is per friend. File numbers are reused after a transfer terminates. * number is per friend. File numbers are reused after a transfer terminates.
*/ */
uint32_t tox_file_send(Tox *tox, uint32_t friend_number, TOX_FILE_KIND kind, uint64_t file_size, uint32_t tox_file_send(Tox *tox, uint32_t friend_number, TOX_FILE_KIND kind, uint64_t file_size,
uint8_t const *filename, size_t filename_length, TOX_ERR_FILE_SEND *error); const uint8_t *filename, size_t filename_length, TOX_ERR_FILE_SEND *error);
enum TOX_ERR_FILE_SEND_CHUNK { enum TOX_ERR_FILE_SEND_CHUNK {
@ -1640,7 +1640,7 @@ typedef uint8_t TOX_ERR_FILE_SEND_CHUNK;
* *
* @return true on success. * @return true on success.
*/ */
bool tox_file_send_chunk(Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t const *data, size_t length, bool tox_file_send_chunk(Tox *tox, uint32_t friend_number, uint32_t file_number, const uint8_t *data, size_t length,
TOX_ERR_FILE_SEND_CHUNK *error); TOX_ERR_FILE_SEND_CHUNK *error);
@ -1702,7 +1702,7 @@ void tox_callback_file_request_chunk(Tox *tox, tox_file_request_chunk_cb *functi
* associated with. * associated with.
*/ */
typedef void tox_file_receive_cb(Tox *tox, uint32_t friend_number, uint32_t file_number, TOX_FILE_KIND kind, typedef void tox_file_receive_cb(Tox *tox, uint32_t friend_number, uint32_t file_number, TOX_FILE_KIND kind,
uint64_t file_size, uint8_t const *filename, size_t filename_length, void *user_data); uint64_t file_size, const uint8_t *filename, size_t filename_length, void *user_data);
/** /**
* Set the callback for the `file_receive` event. Pass NULL to unset. * Set the callback for the `file_receive` event. Pass NULL to unset.
@ -1734,7 +1734,7 @@ void tox_callback_file_receive(Tox *tox, tox_file_receive_cb *function, void *us
* @param length The length of the received chunk. * @param length The length of the received chunk.
*/ */
typedef void tox_file_receive_chunk_cb(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position, typedef void tox_file_receive_chunk_cb(Tox *tox, uint32_t friend_number, uint32_t file_number, uint64_t position,
uint8_t const *data, size_t length, void *user_data); const uint8_t *data, size_t length, void *user_data);
/** /**
* Set the callback for the `file_receive_chunk` event. Pass NULL to unset. * Set the callback for the `file_receive_chunk` event. Pass NULL to unset.
@ -1814,7 +1814,7 @@ typedef uint8_t TOX_ERR_SEND_CUSTOM_PACKET;
* *
* @return true on success. * @return true on success.
*/ */
bool tox_send_lossy_packet(Tox *tox, uint32_t friend_number, uint8_t const *data, size_t length, bool tox_send_lossy_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
TOX_ERR_SEND_CUSTOM_PACKET *error); TOX_ERR_SEND_CUSTOM_PACKET *error);
/** /**
@ -1824,7 +1824,7 @@ bool tox_send_lossy_packet(Tox *tox, uint32_t friend_number, uint8_t const *data
* @param data A byte array containing the received packet data. * @param data A byte array containing the received packet data.
* @param length The length of the packet data byte array. * @param length The length of the packet data byte array.
*/ */
typedef void tox_friend_lossy_packet_cb(Tox *tox, uint32_t friend_number, uint8_t const *data, size_t length, typedef void tox_friend_lossy_packet_cb(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data); void *user_data);
/** /**
@ -1849,7 +1849,7 @@ void tox_callback_friend_lossy_packet(Tox *tox, tox_friend_lossy_packet_cb *func
* *
* @return true on success. * @return true on success.
*/ */
bool tox_send_lossless_packet(Tox *tox, uint32_t friend_number, uint8_t const *data, size_t length, bool tox_send_lossless_packet(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
TOX_ERR_SEND_CUSTOM_PACKET *error); TOX_ERR_SEND_CUSTOM_PACKET *error);
/** /**
@ -1859,7 +1859,7 @@ bool tox_send_lossless_packet(Tox *tox, uint32_t friend_number, uint8_t const *d
* @param data A byte array containing the received packet data. * @param data A byte array containing the received packet data.
* @param length The length of the packet data byte array. * @param length The length of the packet data byte array.
*/ */
typedef void tox_friend_lossless_packet_cb(Tox *tox, uint32_t friend_number, uint8_t const *data, size_t length, typedef void tox_friend_lossless_packet_cb(Tox *tox, uint32_t friend_number, const uint8_t *data, size_t length,
void *user_data); void *user_data);
/** /**
@ -1888,7 +1888,7 @@ void tox_callback_friend_lossless_packet(Tox *tox, tox_friend_lossless_packet_cb
* @param dht_id A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If this * @param dht_id A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If this
* parameter is NULL, this function has no effect. * parameter is NULL, this function has no effect.
*/ */
void tox_get_dht_id(Tox const *tox, uint8_t *dht_id); void tox_get_dht_id(const Tox *tox, uint8_t *dht_id);
enum TOX_ERR_GET_PORT { enum TOX_ERR_GET_PORT {
@ -1903,13 +1903,13 @@ typedef uint8_t TOX_ERR_GET_PORT;
/** /**
* Return the UDP port this Tox instance is bound to. * Return the UDP port this Tox instance is bound to.
*/ */
uint16_t tox_get_udp_port(Tox const *tox, TOX_ERR_GET_PORT *error); uint16_t tox_get_udp_port(const Tox *tox, TOX_ERR_GET_PORT *error);
/** /**
* Return the TCP port this Tox instance is bound to. This is only relevant if * Return the TCP port this Tox instance is bound to. This is only relevant if
* the instance is acting as a TCP relay. * the instance is acting as a TCP relay.
*/ */
uint16_t tox_get_tcp_port(Tox const *tox, TOX_ERR_GET_PORT *error); uint16_t tox_get_tcp_port(const Tox *tox, TOX_ERR_GET_PORT *error);
#ifdef __cplusplus #ifdef __cplusplus