1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-30 03:56:45 +02:00

wrap tox_get_name in function that truncates name if it's too long

This commit is contained in:
Jfreegman
2014-07-08 14:31:59 -04:00
parent e74212cb9e
commit 442f68cd31
5 changed files with 29 additions and 40 deletions

View File

@ -224,3 +224,13 @@ void str_to_lower(char *str)
for (i = 0; str[i]; ++i)
str[i] = tolower(str[i]);
}
/* puts friendnum's nick in buf, truncating at TOXIC_MAX_NAME_LENGTH if necessary.
Returns nick len on success, -1 on failure */
int get_nick_truncate(Tox *m, char *buf, int friendnum)
{
int len = tox_get_name(m, friendnum, (uint8_t *) buf);
len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1);
buf[len] = '\0';
return len;
}