summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/nTox.c76
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;
44uint8_t pending_requests[256][CLIENT_ID_SIZE]; 44uint8_t pending_requests[256][CLIENT_ID_SIZE];
45uint8_t num_requests = 0; 45uint8_t num_requests = 0;
46 46
47void 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
47void new_lines(char *line) 71void 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;