diff options
-rw-r--r-- | testing/nTox.c | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 81cac0b6..9d44d757 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -44,13 +44,40 @@ 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 new_lines(char *line) | 47 | // 01513F29A0483B3F482478B4A039041E19571249AE1F4E323E4C1C6A446BFF06 |
48 | // 01513F29A0483B3F482478B4A039041E19571249AE1F4E323E4C1C6A446BFF06 | ||
49 | // 01513F29A0483B3F482478B4A039041E19571249AE1F4E323E4C1C6A446BFF0 | ||
50 | void get_id(char *data) | ||
48 | { | 51 | { |
52 | char idstring0[200]; | ||
53 | char idstring1[PUB_KEY_BYTES][5]; | ||
54 | char idstring2[PUB_KEY_BYTES][5]; | ||
49 | int i; | 55 | int i; |
56 | for(i = 0; i < PUB_KEY_BYTES; i++) | ||
57 | { | ||
58 | if (self_public_key[i] < (PUB_KEY_BYTES / 2)) | ||
59 | strcpy(idstring1[i],"0"); | ||
60 | else | ||
61 | strcpy(idstring1[i], ""); | ||
62 | sprintf(idstring2[i], "%hhX",self_public_key[i]); | ||
63 | } | ||
64 | strcpy(idstring0,"[i] ID: "); | ||
65 | int j; | ||
66 | for (j = 0; j < PUB_KEY_BYTES; j++) { | ||
67 | strcat(idstring0,idstring1[j]); | ||
68 | strcat(idstring0,idstring2[j]); | ||
69 | } | ||
70 | |||
71 | memcpy(data, idstring0, strlen(idstring0)); | ||
72 | } | ||
73 | |||
74 | void new_lines(char *line) | ||
75 | { | ||
76 | int i = 0; | ||
50 | for (i = HISTORY-1; i > 0; i--) | 77 | for (i = HISTORY-1; i > 0; i--) |
51 | strcpy(lines[i], lines[i-1]); | 78 | strncpy(lines[i], lines[i-1], STRING_LENGTH - 1); |
52 | 79 | ||
53 | strcpy(lines[0], line); | 80 | strncpy(lines[0], line, STRING_LENGTH - 1); |
54 | do_refresh(); | 81 | do_refresh(); |
55 | } | 82 | } |
56 | 83 | ||
@@ -216,26 +243,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)"); | 243 | new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)"); |
217 | } | 244 | } |
218 | else if (inpt_command == 'i') { //info | 245 | else if (inpt_command == 'i') { //info |
219 | char idstring0[200]; | 246 | char idstring[200]; |
220 | char idstring1[PUB_KEY_BYTES][5]; | 247 | get_id(idstring); |
221 | char idstring2[PUB_KEY_BYTES][5]; | 248 | 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 | } | 249 | } |
240 | 250 | ||
241 | else if (inpt_command == 'q') { //exit | 251 | else if (inpt_command == 'q') { //exit |
@@ -396,29 +406,14 @@ int main(int argc, char *argv[]) | |||
396 | m_callback_friendmessage(print_message); | 406 | m_callback_friendmessage(print_message); |
397 | m_callback_namechange(print_nickchange); | 407 | m_callback_namechange(print_nickchange); |
398 | m_callback_userstatus(print_statuschange); | 408 | m_callback_userstatus(print_statuschange); |
399 | char idstring0[200]; | 409 | |
400 | char idstring1[PUB_KEY_BYTES][5]; | 410 | char idstring[200]; |
401 | char idstring2[PUB_KEY_BYTES][5]; | 411 | 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(); | 412 | initscr(); |
418 | noecho(); | 413 | noecho(); |
419 | raw(); | 414 | raw(); |
420 | getmaxyx(stdscr, y, x); | 415 | getmaxyx(stdscr, y, x); |
421 | new_lines(idstring0); | 416 | new_lines(idstring); |
422 | new_lines(help); | 417 | new_lines(help); |
423 | strcpy(line, ""); | 418 | strcpy(line, ""); |
424 | IP_Port bootstrap_ip_port; | 419 | IP_Port bootstrap_ip_port; |