diff options
author | Astonex <softukitu@gmail.com> | 2013-08-03 11:33:46 +0100 |
---|---|---|
committer | Astonex <softukitu@gmail.com> | 2013-08-03 11:33:46 +0100 |
commit | 892249eabb66a435953d0289a7111e8e0dcab281 (patch) | |
tree | 7fd3bc0549c2a5a537825ab2b4b6bb3f77eedba7 /testing | |
parent | c1a8bc52f6eddaf075436eb1a57d978a4526dd56 (diff) | |
parent | e029b65eceef49f3cf5a29d612dde0c184f74287 (diff) |
Merge remote-tracking branch 'ProjectTox/master'
Diffstat (limited to 'testing')
-rw-r--r-- | testing/nTox.c | 76 |
1 files changed, 34 insertions, 42 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 81cac0b6..24d40ead 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -44,13 +44,37 @@ int x, y; | |||
44 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; | 44 | uint8_t pending_requests[256][CLIENT_ID_SIZE]; |
45 | uint8_t num_requests = 0; | 45 | uint8_t num_requests = 0; |
46 | 46 | ||
47 | void get_id(char *data) | ||
48 | { | ||
49 | char idstring0[200]; | ||
50 | char idstring1[PUB_KEY_BYTES][5]; | ||
51 | char idstring2[PUB_KEY_BYTES][5]; | ||
52 | int i = 0; | ||
53 | for(i = 0; i < PUB_KEY_BYTES; i++) | ||
54 | { | ||
55 | if (self_public_key[i] < (PUB_KEY_BYTES / 2)) | ||
56 | strcpy(idstring1[i],"0"); | ||
57 | else | ||
58 | strcpy(idstring1[i], ""); | ||
59 | sprintf(idstring2[i], "%hhX",self_public_key[i]); | ||
60 | } | ||
61 | strcpy(idstring0,"[i] ID: "); | ||
62 | int j = 0; | ||
63 | for (j = 0; j < PUB_KEY_BYTES; j++) { | ||
64 | strcat(idstring0,idstring1[j]); | ||
65 | strcat(idstring0,idstring2[j]); | ||
66 | } | ||
67 | |||
68 | memcpy(data, idstring0, strlen(idstring0)); | ||
69 | } | ||
70 | |||
47 | void new_lines(char *line) | 71 | void new_lines(char *line) |
48 | { | 72 | { |
49 | int i; | 73 | int i = 0; |
50 | for (i = HISTORY-1; i > 0; i--) | 74 | for (i = HISTORY-1; i > 0; i--) |
51 | strcpy(lines[i], lines[i-1]); | 75 | strncpy(lines[i], lines[i-1], STRING_LENGTH - 1); |
52 | 76 | ||
53 | strcpy(lines[0], line); | 77 | strncpy(lines[0], line, STRING_LENGTH - 1); |
54 | do_refresh(); | 78 | do_refresh(); |
55 | } | 79 | } |
56 | 80 | ||
@@ -216,26 +240,9 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
216 | new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); | 240 | new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); |
217 | } | 241 | } |
218 | else if (inpt_command == 'i') { //info | 242 | else if (inpt_command == 'i') { //info |
219 | char idstring0[200]; | 243 | char idstring[200]; |
220 | char idstring1[PUB_KEY_BYTES][5]; | 244 | get_id(idstring); |
221 | char idstring2[PUB_KEY_BYTES][5]; | 245 | new_lines(idstring); |
222 | int i; | ||
223 | for (i = 0; i < PUB_KEY_BYTES; i++) | ||
224 | { | ||
225 | if (self_public_key[i] < (PUB_KEY_BYTES/2)) | ||
226 | strcpy(idstring1[i],"0"); | ||
227 | else | ||
228 | strcpy(idstring1[i], ""); | ||
229 | sprintf(idstring2[i], "%hhX", self_public_key[i]); | ||
230 | } | ||
231 | // | ||
232 | strcpy(idstring0,"[i] ID: "); | ||
233 | int j; | ||
234 | for (j = 0; j < PUB_KEY_BYTES; j++) { | ||
235 | strcat(idstring0,idstring1[j]); | ||
236 | strcat(idstring0,idstring2[j]); | ||
237 | } | ||
238 | new_lines(idstring0); | ||
239 | } | 246 | } |
240 | 247 | ||
241 | else if (inpt_command == 'q') { //exit | 248 | else if (inpt_command == 'q') { //exit |
@@ -396,29 +403,14 @@ int main(int argc, char *argv[]) | |||
396 | m_callback_friendmessage(print_message); | 403 | m_callback_friendmessage(print_message); |
397 | m_callback_namechange(print_nickchange); | 404 | m_callback_namechange(print_nickchange); |
398 | m_callback_userstatus(print_statuschange); | 405 | m_callback_userstatus(print_statuschange); |
399 | char idstring0[200]; | 406 | |
400 | char idstring1[PUB_KEY_BYTES][5]; | 407 | char idstring[200]; |
401 | char idstring2[PUB_KEY_BYTES][5]; | 408 | get_id(idstring); |
402 | int i; | ||
403 | for(i = 0; i < PUB_KEY_BYTES; i++) | ||
404 | { | ||
405 | if (self_public_key[i] < (PUB_KEY_BYTES / 2)) | ||
406 | strcpy(idstring1[i],"0"); | ||
407 | else | ||
408 | strcpy(idstring1[i], ""); | ||
409 | sprintf(idstring2[i], "%hhX",self_public_key[i]); | ||
410 | } | ||
411 | strcpy(idstring0,"[i] your ID: "); | ||
412 | int j; | ||
413 | for (j = 0; j < PUB_KEY_BYTES; j++) { | ||
414 | strcat(idstring0,idstring1[j]); | ||
415 | strcat(idstring0,idstring2[j]); | ||
416 | } | ||
417 | initscr(); | 409 | initscr(); |
418 | noecho(); | 410 | noecho(); |
419 | raw(); | 411 | raw(); |
420 | getmaxyx(stdscr, y, x); | 412 | getmaxyx(stdscr, y, x); |
421 | new_lines(idstring0); | 413 | new_lines(idstring); |
422 | new_lines(help); | 414 | new_lines(help); |
423 | strcpy(line, ""); | 415 | strcpy(line, ""); |
424 | IP_Port bootstrap_ip_port; | 416 | IP_Port bootstrap_ip_port; |