summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-09-18 11:11:10 -0400
committerirungentoo <irungentoo@gmail.com>2013-09-18 11:11:10 -0400
commit1a9ee5c95f1864957a25e32c9198f637f7db2032 (patch)
tree50b1b23df26897419245d9af9834886dbbe47770
parent7c5b98397a85394add318cf897eb5b78703e55ea (diff)
Fixed bad code in nTox.
-rw-r--r--testing/nTox.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index 2e394528..a1eea94c 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -269,34 +269,18 @@ void line_eval(Tox *m, char *line)
269 } else if (inpt_command == 'd') { 269 } else if (inpt_command == 'd') {
270 tox_do(m); 270 tox_do(m);
271 } else if (inpt_command == 'm') { //message command: /m friendnumber messsage 271 } else if (inpt_command == 'm') { //message command: /m friendnumber messsage
272 size_t len = strlen(line); 272 char *posi[1];
273 273 int num = strtoul(line + prompt_offset, posi, 0);
274 if (len < 3)
275 return;
276
277 char numstring[len - 3];
278 char message[len - 3];
279 uint32_t i;
280 274
281 for (i = 0; i < len; i++) { 275 if (**posi != 0) {
282 if (line[i + 3] != ' ') { 276 if (tox_sendmessage(m, num, (uint8_t *) *posi + 1, strlen(*posi + 1) + 1) < 1) {
283 numstring[i] = line[i + 3]; 277 char sss[256];
278 sprintf(sss, "[i] could not send message to friend num %u", num);
279 new_lines(sss);
284 } else { 280 } else {
285 uint32_t j; 281 new_lines(format_message(m, *posi + 1, -1));
286
287 for (j = (i + 1); j < (len + 1); j++)
288 message[j - i - 1] = line[j + 3];
289
290 break;
291 } 282 }
292 } 283 new_lines("Error, bad input.");
293
294 int num = atoi(numstring);
295
296 if (tox_sendmessage(m, num, (uint8_t *) message, strlen(message) + 1) < 1) {
297 new_lines("[i] could not send message");
298 } else {
299 new_lines(format_message(m, message, -1));
300 } 284 }
301 } else if (inpt_command == 'n') { 285 } else if (inpt_command == 'n') {
302 uint8_t name[TOX_MAX_NAME_LENGTH]; 286 uint8_t name[TOX_MAX_NAME_LENGTH];