mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Added name lengths to friend names.
This commit is contained in:
parent
bb35305d94
commit
7ecd809a59
|
@ -399,7 +399,7 @@ uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen)
|
||||||
/* Get name of friendnumber and put it in name.
|
/* Get name of friendnumber and put it in name.
|
||||||
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes.
|
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes.
|
||||||
*
|
*
|
||||||
* return 0 if success.
|
* return length of name if success.
|
||||||
* return -1 if failure.
|
* return -1 if failure.
|
||||||
*/
|
*/
|
||||||
int getname(Messenger *m, int friendnumber, uint8_t *name)
|
int getname(Messenger *m, int friendnumber, uint8_t *name)
|
||||||
|
@ -407,8 +407,8 @@ int getname(Messenger *m, int friendnumber, uint8_t *name)
|
||||||
if (friend_not_valid(m, friendnumber))
|
if (friend_not_valid(m, friendnumber))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(name, m->friendlist[friendnumber].name, MAX_NAME_LENGTH);
|
memcpy(name, m->friendlist[friendnumber].name, m->friendlist[friendnumber].name_length);
|
||||||
return 0;
|
return m->friendlist[friendnumber].name_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int m_set_statusmessage(Messenger *m, uint8_t *status, uint16_t length)
|
int m_set_statusmessage(Messenger *m, uint8_t *status, uint16_t length)
|
||||||
|
@ -799,11 +799,13 @@ void doFriends(Messenger *m)
|
||||||
if (data_length >= MAX_NAME_LENGTH || data_length == 0)
|
if (data_length >= MAX_NAME_LENGTH || data_length == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (m->friend_namechange)
|
|
||||||
m->friend_namechange(m, i, data, data_length, m->friend_namechange_userdata);
|
|
||||||
|
|
||||||
memcpy(m->friendlist[i].name, data, data_length);
|
memcpy(m->friendlist[i].name, data, data_length);
|
||||||
|
m->friendlist[i].name_length = data_length;
|
||||||
m->friendlist[i].name[data_length - 1] = 0; /* Make sure the NULL terminator is present. */
|
m->friendlist[i].name[data_length - 1] = 0; /* Make sure the NULL terminator is present. */
|
||||||
|
|
||||||
|
if (m->friend_namechange)
|
||||||
|
m->friend_namechange(m, i, m->friendlist[i].name, data_length, m->friend_namechange_userdata);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ typedef struct {
|
||||||
uint8_t status; // 0 if no friend, 1 if added, 2 if friend request sent, 3 if confirmed friend, 4 if online.
|
uint8_t status; // 0 if no friend, 1 if added, 2 if friend request sent, 3 if confirmed friend, 4 if online.
|
||||||
uint8_t info[MAX_DATA_SIZE]; // the data that is sent during the friend requests we do.
|
uint8_t info[MAX_DATA_SIZE]; // the data that is sent during the friend requests we do.
|
||||||
uint8_t name[MAX_NAME_LENGTH];
|
uint8_t name[MAX_NAME_LENGTH];
|
||||||
|
uint16_t name_length;
|
||||||
uint8_t name_sent; // 0 if we didn't send our name to this friend 1 if we have.
|
uint8_t name_sent; // 0 if we didn't send our name to this friend 1 if we have.
|
||||||
uint8_t *statusmessage;
|
uint8_t *statusmessage;
|
||||||
uint16_t statusmessage_length;
|
uint16_t statusmessage_length;
|
||||||
|
@ -253,7 +254,7 @@ uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen);
|
||||||
/* Get name of friendnumber and put it in name.
|
/* Get name of friendnumber and put it in name.
|
||||||
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
||||||
*
|
*
|
||||||
* return 0 if success.
|
* return length of name if success.
|
||||||
* return -1 if failure.
|
* return -1 if failure.
|
||||||
*/
|
*/
|
||||||
int getname(Messenger *m, int friendnumber, uint8_t *name);
|
int getname(Messenger *m, int friendnumber, uint8_t *name);
|
||||||
|
|
|
@ -182,7 +182,7 @@ uint16_t tox_getselfname(Tox *tox, uint8_t *name, uint16_t nlen);
|
||||||
/* Get name of friendnumber and put it in name.
|
/* Get name of friendnumber and put it in name.
|
||||||
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
||||||
*
|
*
|
||||||
* return 0 if success.
|
* return length of name (with the NULL terminator) if success.
|
||||||
* return -1 if failure.
|
* return -1 if failure.
|
||||||
*/
|
*/
|
||||||
int tox_getname(Tox *tox, int friendnumber, uint8_t *name);
|
int tox_getname(Tox *tox, int friendnumber, uint8_t *name);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user