made setfriendname part of public api

This commit is contained in:
Jfreegman 2013-09-23 04:30:24 -04:00
parent 59170c7d01
commit c4702985a5
4 changed files with 34 additions and 3 deletions

View File

@ -352,13 +352,13 @@ static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t le
* return 0 if success.
* return -1 if failure.
*/
static int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t len)
int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length)
{
if (friend_not_valid(m, friendnumber))
return -1;
m->friendlist[friendnumber].name_length = len;
memcpy(m->friendlist[friendnumber].name, name, len);
m->friendlist[friendnumber].name_length = length;
memcpy(m->friendlist[friendnumber].name, name, length);
return 0;
}

View File

@ -246,6 +246,13 @@ uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, ui
*/
int m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length);
/* Set the name and name_length of a friend.
*
* return 0 if success.
* return -1 if failure.
*/
int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length);
/* Set our nickname.
* name must be a string of maximum MAX_NAME_LENGTH length.
* length must be at least 1 byte.

View File

@ -153,6 +153,20 @@ int tox_sendaction(void *tox, int friendnumber, uint8_t *action, uint32_t length
return m_sendaction(m, friendnumber, action, length);
}
/* Set friendnumber's nickname.
* name must be a string of maximum MAX_NAME_LENGTH length.
* length must be at least 1 byte.
* length is the length of name with the NULL terminator.
*
* return 0 if success.
* return -1 if failure.
*/
int tox_setfriendname(void *tox, int friendnumber, uint8_t *name, uint16_t length)
{
Messenger *m = tox;
return setfriendname(m, friendnumber, name, length);
}
/* Set our nickname.
* name must be a string of maximum MAX_NAME_LENGTH length.
* length must be at least 1 byte.

View File

@ -214,6 +214,16 @@ uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint
*/
int tox_sendaction(Tox *tox, int friendnumber, uint8_t *action, uint32_t length);
/* Set friendnumber's nickname.
* name must be a string of maximum MAX_NAME_LENGTH length.
* length must be at least 1 byte.
* length is the length of name with the NULL terminator.
*
* return 0 if success.
* return -1 if failure.
*/
int tox_setfriendname(void *tox, int friendnumber, uint8_t *name, uint16_t length);
/* Set our nickname.
* name must be a string of maximum MAX_NAME_LENGTH length.
* length must be at least 1 byte.