summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJfreegman <Jfreegman@gmail.com>2013-09-23 04:30:24 -0400
committerJfreegman <Jfreegman@gmail.com>2013-09-23 04:30:24 -0400
commitc4702985a502eb80c3eae37f2b5b38fdb7e385e5 (patch)
treef3b8f04df19f933b379b551c02664352c51d52e9
parent59170c7d014c79eab268ebef39d0b20809602903 (diff)
made setfriendname part of public api
-rw-r--r--toxcore/Messenger.c6
-rw-r--r--toxcore/Messenger.h7
-rw-r--r--toxcore/tox.c14
-rw-r--r--toxcore/tox.h10
4 files changed, 34 insertions, 3 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index b5da12ba..9601f2a2 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -352,13 +352,13 @@ static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t le
352 * return 0 if success. 352 * return 0 if success.
353 * return -1 if failure. 353 * return -1 if failure.
354 */ 354 */
355static int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t len) 355int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length)
356{ 356{
357 if (friend_not_valid(m, friendnumber)) 357 if (friend_not_valid(m, friendnumber))
358 return -1; 358 return -1;
359 359
360 m->friendlist[friendnumber].name_length = len; 360 m->friendlist[friendnumber].name_length = length;
361 memcpy(m->friendlist[friendnumber].name, name, len); 361 memcpy(m->friendlist[friendnumber].name, name, length);
362 return 0; 362 return 0;
363} 363}
364 364
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index 2b29896c..1f0361b1 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -246,6 +246,13 @@ uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, ui
246 */ 246 */
247int m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length); 247int m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length);
248 248
249/* Set the name and name_length of a friend.
250 *
251 * return 0 if success.
252 * return -1 if failure.
253 */
254int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length);
255
249/* Set our nickname. 256/* Set our nickname.
250 * name must be a string of maximum MAX_NAME_LENGTH length. 257 * name must be a string of maximum MAX_NAME_LENGTH length.
251 * length must be at least 1 byte. 258 * length must be at least 1 byte.
diff --git a/toxcore/tox.c b/toxcore/tox.c
index fa53e693..1d7118be 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -153,6 +153,20 @@ int tox_sendaction(void *tox, int friendnumber, uint8_t *action, uint32_t length
153 return m_sendaction(m, friendnumber, action, length); 153 return m_sendaction(m, friendnumber, action, length);
154} 154}
155 155
156/* Set friendnumber's nickname.
157 * name must be a string of maximum MAX_NAME_LENGTH length.
158 * length must be at least 1 byte.
159 * length is the length of name with the NULL terminator.
160 *
161 * return 0 if success.
162 * return -1 if failure.
163 */
164int tox_setfriendname(void *tox, int friendnumber, uint8_t *name, uint16_t length)
165{
166 Messenger *m = tox;
167 return setfriendname(m, friendnumber, name, length);
168}
169
156/* Set our nickname. 170/* Set our nickname.
157 * name must be a string of maximum MAX_NAME_LENGTH length. 171 * name must be a string of maximum MAX_NAME_LENGTH length.
158 * length must be at least 1 byte. 172 * length must be at least 1 byte.
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 9c810418..db3621dc 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -214,6 +214,16 @@ uint32_t tox_sendmessage_withid(Tox *tox, int friendnumber, uint32_t theid, uint
214 */ 214 */
215int tox_sendaction(Tox *tox, int friendnumber, uint8_t *action, uint32_t length); 215int tox_sendaction(Tox *tox, int friendnumber, uint8_t *action, uint32_t length);
216 216
217/* Set friendnumber's nickname.
218 * name must be a string of maximum MAX_NAME_LENGTH length.
219 * length must be at least 1 byte.
220 * length is the length of name with the NULL terminator.
221 *
222 * return 0 if success.
223 * return -1 if failure.
224 */
225int tox_setfriendname(void *tox, int friendnumber, uint8_t *name, uint16_t length);
226
217/* Set our nickname. 227/* Set our nickname.
218 * name must be a string of maximum MAX_NAME_LENGTH length. 228 * name must be a string of maximum MAX_NAME_LENGTH length.
219 * length must be at least 1 byte. 229 * length must be at least 1 byte.