summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@tox.im>2014-02-21 21:00:55 -0500
committerirungentoo <irungentoo@tox.im>2014-02-21 21:00:55 -0500
commit6992e8c75986e7c32b795cb854a5c73d00e9a8f4 (patch)
treeaae758d3bc439fcc9a86b3ad994cd87dbea9e894 /toxcore/Messenger.c
parent554afe11d7c3e286b6f286405a1a1857b9f55c81 (diff)
parent36adc48b781105e55790d0049fec1b190104e480 (diff)
Merge pull request #757 from nurupo/api-fix-1
Added size functions for names and status messages
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 9f75f89f..e3dcf2a1 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -533,6 +533,19 @@ int getname(Messenger *m, int32_t friendnumber, uint8_t *name)
533 return m->friendlist[friendnumber].name_length; 533 return m->friendlist[friendnumber].name_length;
534} 534}
535 535
536int m_get_name_size(Messenger *m, int32_t friendnumber)
537{
538 if (friend_not_valid(m, friendnumber))
539 return -1;
540
541 return m->friendlist[friendnumber].name_length;
542}
543
544int m_get_self_name_size(Messenger *m)
545{
546 return m->name_length;
547}
548
536int m_set_statusmessage(Messenger *m, uint8_t *status, uint16_t length) 549int m_set_statusmessage(Messenger *m, uint8_t *status, uint16_t length)
537{ 550{
538 if (length > MAX_STATUSMESSAGE_LENGTH) 551 if (length > MAX_STATUSMESSAGE_LENGTH)
@@ -588,6 +601,14 @@ int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint3
588 return MIN(maxlen, m->friendlist[friendnumber].statusmessage_length); 601 return MIN(maxlen, m->friendlist[friendnumber].statusmessage_length);
589} 602}
590 603
604/* return the size of friendnumber's user status.
605 * Guaranteed to be at most MAX_STATUSMESSAGE_LENGTH.
606 */
607int m_get_self_statusmessage_size(Messenger *m)
608{
609 return m->statusmessage_length;
610}
611
591int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen) 612int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen)
592{ 613{
593 memset(buf, 0, maxlen); 614 memset(buf, 0, maxlen);