summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h40
1 files changed, 20 insertions, 20 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index a5efee34..d285e3fc 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -37,8 +37,8 @@ extern "C" {
37#define TOX_MAX_MESSAGE_LENGTH 1368 37#define TOX_MAX_MESSAGE_LENGTH 1368
38#define TOX_MAX_STATUSMESSAGE_LENGTH 1007 38#define TOX_MAX_STATUSMESSAGE_LENGTH 1007
39#define TOX_CLIENT_ID_SIZE 32 39#define TOX_CLIENT_ID_SIZE 32
40#define TOX_MAX_AVATAR_DATA_LENGTH 16384 40#define TOX_AVATAR_MAX_DATA_LENGTH 16384
41#define TOX_AVATAR_HASH_LENGTH 32 41#define TOX_HASH_LENGTH /*crypto_hash_sha256_BYTES*/ 32
42 42
43#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t)) 43#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
44 44
@@ -73,14 +73,14 @@ typedef enum {
73TOX_USERSTATUS; 73TOX_USERSTATUS;
74 74
75 75
76/* AVATARFORMAT - 76/* AVATAR_FORMAT -
77 * Data formats for user avatar images 77 * Data formats for user avatar images
78 */ 78 */
79typedef enum { 79typedef enum {
80 TOX_AVATARFORMAT_NONE, 80 TOX_AVATAR_FORMAT_NONE = 0,
81 TOX_AVATARFORMAT_PNG 81 TOX_AVATAR_FORMAT_PNG
82} 82}
83TOX_AVATARFORMAT; 83TOX_AVATAR_FORMAT;
84 84
85#ifndef __TOX_DEFINED__ 85#ifndef __TOX_DEFINED__
86#define __TOX_DEFINED__ 86#define __TOX_DEFINED__
@@ -538,7 +538,7 @@ uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size);
538 * Function format is: 538 * Function format is:
539 * function(Tox *tox, int32_t friendnumber, uint8_t format, uint8_t *hash, void *userdata) 539 * function(Tox *tox, int32_t friendnumber, uint8_t format, uint8_t *hash, void *userdata)
540 * 540 *
541 * where 'format' is the avatar image format (see TOX_AVATARFORMAT) and 'hash' is the hash of 541 * where 'format' is the avatar image format (see TOX_AVATAR_FORMAT) and 'hash' is the hash of
542 * the avatar data for caching purposes and it is exactly TOX_AVATAR_HASH_LENGTH long. If the 542 * the avatar data for caching purposes and it is exactly TOX_AVATAR_HASH_LENGTH long. If the
543 * image format is NONE, the hash is zeroed. 543 * image format is NONE, the hash is zeroed.
544 * 544 *
@@ -554,7 +554,7 @@ void tox_callback_avatar_info(Tox *tox, void (*function)(Tox *tox, int32_t, uint
554 * Function format is: 554 * Function format is:
555 * function(Tox *tox, int32_t friendnumber, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t datalen, void *userdata) 555 * function(Tox *tox, int32_t friendnumber, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t datalen, void *userdata)
556 * 556 *
557 * where 'format' is the avatar image format (see TOX_AVATARFORMAT); 'hash' is the 557 * where 'format' is the avatar image format (see TOX_AVATAR_FORMAT); 'hash' is the
558 * locally-calculated cryptographic hash of the avatar data and it is exactly 558 * locally-calculated cryptographic hash of the avatar data and it is exactly
559 * TOX_AVATAR_HASH_LENGTH long; 'data' is the avatar image data and 'datalen' is the length 559 * TOX_AVATAR_HASH_LENGTH long; 'data' is the avatar image data and 'datalen' is the length
560 * of such data. 560 * of such data.
@@ -577,9 +577,9 @@ void tox_callback_avatar_data(Tox *tox, void (*function)(Tox *tox, int32_t, uint
577 * Notice that the library treats the image as raw data and does not interpret it by any way. 577 * Notice that the library treats the image as raw data and does not interpret it by any way.
578 * 578 *
579 * Arguments: 579 * Arguments:
580 * format - Avatar image format or NONE for user with no avatar (see TOX_AVATARFORMAT); 580 * format - Avatar image format or NONE for user with no avatar (see TOX_AVATAR_FORMAT);
581 * data - pointer to the avatar data (may be NULL it the format is NONE); 581 * data - pointer to the avatar data (may be NULL it the format is NONE);
582 * length - length of image data. Must be <= TOX_MAX_AVATAR_DATA_LENGTH. 582 * length - length of image data. Must be <= TOX_AVATAR_MAX_DATA_LENGTH.
583 * 583 *
584 * returns 0 on success 584 * returns 0 on success
585 * returns -1 on failure. 585 * returns -1 on failure.
@@ -597,7 +597,7 @@ int tox_set_avatar(Tox *tox, uint8_t format, const uint8_t *data, uint32_t lengt
597 * If any of the pointers format, buf, length, and hash are NULL, that particular field will be ignored. 597 * If any of the pointers format, buf, length, and hash are NULL, that particular field will be ignored.
598 * 598 *
599 * Arguments: 599 * Arguments:
600 * format - destination pointer to the avatar image format (see TOX_AVATARFORMAT); 600 * format - destination pointer to the avatar image format (see TOX_AVATAR_FORMAT);
601 * buf - destination buffer to the image data. Must have at least 'maxlen' bytes; 601 * buf - destination buffer to the image data. Must have at least 'maxlen' bytes;
602 * length - destination pointer to the image data length; 602 * length - destination pointer to the image data length;
603 * maxlen - length of the destination buffer 'buf'; 603 * maxlen - length of the destination buffer 'buf';
@@ -611,21 +611,21 @@ int tox_get_self_avatar(const Tox *tox, uint8_t *format, uint8_t *buf, uint32_t
611 uint8_t *hash); 611 uint8_t *hash);
612 612
613 613
614/* Generates a cryptographic hash of the given avatar data. 614/* Generates a cryptographic hash of the given data.
615 * This function is a wrapper to internal message-digest functions and specifically provided 615 * This function may be used by clients for any purpose, but is provided primarily for
616 * to generate hashes from user avatars that may be memcmp()ed with the values returned by the 616 * validating cached avatars. This use is highly recommended to avoid unnecessary avatar
617 * other avatar functions. It is specially important to validate cached avatars. 617 * updates.
618 * This function is a wrapper to internal message-digest functions.
618 * 619 *
619 * Arguments: 620 * Arguments:
620 * hash - destination buffer for the hash data, it must be exactly TOX_AVATAR_HASH_LENGTH bytes long. 621 * hash - destination buffer for the hash data, it must be exactly TOX_HASH_LENGTH bytes long.
621 * data - avatar image data; 622 * data - data to be hashed;
622 * datalen - length of the avatar image data; it must be <= TOX_MAX_AVATAR_DATA_LENGTH. 623 * datalen - length of the data; for avatars, should be TOX_AVATAR_MAX_DATA_LENGTH
623 * 624 *
624 * returns 0 on success 625 * returns 0 on success
625 * returns -1 on failure. 626 * returns -1 on failure.
626 */ 627 */
627int tox_avatar_hash(const Tox *tox, uint8_t *hash, const uint8_t *data, const uint32_t datalen); 628int tox_hash(const Tox *tox, uint8_t *hash, const uint8_t *data, const uint32_t datalen);
628
629 629
630/* Request avatar information from a friend. 630/* Request avatar information from a friend.
631 * Asks a friend to provide their avatar information (image format and hash). The friend may 631 * Asks a friend to provide their avatar information (image format and hash). The friend may