diff options
author | irungentoo <irungentoo@tox.im> | 2014-02-21 21:00:55 -0500 |
---|---|---|
committer | irungentoo <irungentoo@tox.im> | 2014-02-21 21:00:55 -0500 |
commit | 6992e8c75986e7c32b795cb854a5c73d00e9a8f4 (patch) | |
tree | aae758d3bc439fcc9a86b3ad994cd87dbea9e894 /toxcore/tox.c | |
parent | 554afe11d7c3e286b6f286405a1a1857b9f55c81 (diff) | |
parent | 36adc48b781105e55790d0049fec1b190104e480 (diff) |
Merge pull request #757 from nurupo/api-fix-1
Added size functions for names and status messages
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r-- | toxcore/tox.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index ae824697..f91879ea 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -210,6 +210,21 @@ int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name) | |||
210 | return getname(m, friendnumber, name); | 210 | return getname(m, friendnumber, name); |
211 | } | 211 | } |
212 | 212 | ||
213 | /* returns the length of name on success. | ||
214 | * returns -1 on failure. | ||
215 | */ | ||
216 | int tox_get_name_size(Tox *tox, int32_t friendnumber) | ||
217 | { | ||
218 | Messenger *m = tox; | ||
219 | return m_get_name_size(m, friendnumber); | ||
220 | } | ||
221 | |||
222 | int tox_get_self_name_size(Tox *tox) | ||
223 | { | ||
224 | Messenger *m = tox; | ||
225 | return m_get_self_name_size(m); | ||
226 | } | ||
227 | |||
213 | /* Set our user status; | 228 | /* Set our user status; |
214 | * you are responsible for freeing status after. | 229 | * you are responsible for freeing status after. |
215 | * | 230 | * |
@@ -227,8 +242,8 @@ int tox_set_user_status(Tox *tox, TOX_USERSTATUS status) | |||
227 | return m_set_userstatus(m, status); | 242 | return m_set_userstatus(m, status); |
228 | } | 243 | } |
229 | 244 | ||
230 | /* return the length of friendnumber's status message, including null. | 245 | /* returns the length of status message on success. |
231 | * Pass it into malloc. | 246 | * returns -1 on failure. |
232 | */ | 247 | */ |
233 | int tox_get_status_message_size(Tox *tox, int32_t friendnumber) | 248 | int tox_get_status_message_size(Tox *tox, int32_t friendnumber) |
234 | { | 249 | { |
@@ -236,6 +251,12 @@ int tox_get_status_message_size(Tox *tox, int32_t friendnumber) | |||
236 | return m_get_statusmessage_size(m, friendnumber); | 251 | return m_get_statusmessage_size(m, friendnumber); |
237 | } | 252 | } |
238 | 253 | ||
254 | int tox_get_self_status_message_size(Tox *tox) | ||
255 | { | ||
256 | Messenger *m = tox; | ||
257 | return m_get_self_statusmessage_size(m, friendnumber); | ||
258 | } | ||
259 | |||
239 | /* Copy friendnumber's status message into buf, truncating if size is over maxlen. | 260 | /* Copy friendnumber's status message into buf, truncating if size is over maxlen. |
240 | * Get the size you need to allocate from m_get_statusmessage_size. | 261 | * Get the size you need to allocate from m_get_statusmessage_size. |
241 | * The self variant will copy our own status message. | 262 | * The self variant will copy our own status message. |