summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Messenger.c12
-rw-r--r--core/Messenger.h16
2 files changed, 22 insertions, 6 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index eb151a6a..af102406 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -269,10 +269,18 @@ int setname(Messenger *m, uint8_t * name, uint16_t length)
269 put it in name 269 put it in name
270 name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes. 270 name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes.
271 return the length of the name */ 271 return the length of the name */
272uint16_t getself_name(Messenger *m, uint8_t *name) 272uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen)
273{ 273{
274 uint16_t len;
275
276 if (name == NULL || nlen == 0) {
277 return 0;
278 }
279
280 len = MIN(nlen, m->name_length);
274 memcpy(name, m->name, m->name_length); 281 memcpy(name, m->name, m->name_length);
275 return m->name_length; 282
283 return len;
276} 284}
277 285
278/* get name of friendnumber 286/* get name of friendnumber
diff --git a/core/Messenger.h b/core/Messenger.h
index fa69d104..aa9611a4 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -196,10 +196,18 @@ int m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t lengt
196 return -1 if failure */ 196 return -1 if failure */
197int setname(Messenger *m, uint8_t *name, uint16_t length); 197int setname(Messenger *m, uint8_t *name, uint16_t length);
198 198
199/* get our nickname 199/**
200 put it in name 200 * @brief Get your nickname.
201 return the length of the name*/ 201 *
202uint16_t getself_name(Messenger *m, uint8_t *name); 202 * @param[in] m The messanger context to use.
203 *
204 * @param[inout] name Pointer to a string for the name.
205 *
206 * @param[in] nlen The length of the string buffer.
207 *
208 * @return Return the length of the name, 0 on error.
209 */
210uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen);
203 211
204/* get name of friendnumber 212/* get name of friendnumber
205 put it in name 213 put it in name