summaryrefslogtreecommitdiff
path: root/testing/nTox.c
diff options
context:
space:
mode:
authorOliver Hunt <oliver.huntuk@gmail.com>2013-07-14 03:27:23 +0100
committerOliver Hunt <oliver.huntuk@gmail.com>2013-07-14 03:27:23 +0100
commita58a6f5c7b77de3d2491d4b51d2f9239e4eccb73 (patch)
tree5ebaff54ead388b4bb69d07e40ebc41fceebad6b /testing/nTox.c
parentb69fbb15e277effe0dc620c9d26d1741848b5ce6 (diff)
prettier output
Diffstat (limited to 'testing/nTox.c')
-rw-r--r--testing/nTox.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index b2ac6a71..a492a52b 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -30,6 +30,9 @@ unsigned char * hex_string_to_bin(char hex_string[])
30void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) 30void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
31{ 31{
32 if (line[0] == '/') { 32 if (line[0] == '/') {
33 char command[STRING_LENGTH + 2] = "> ";
34 strcat(command, line);
35 new_lines(command);
33 if (line[1] == 'f') { // add friend command: /f ID 36 if (line[1] == 'f') { // add friend command: /f ID
34 int i; 37 int i;
35 char temp_id[128]; 38 char temp_id[128];
@@ -38,7 +41,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
38 } 41 }
39 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); 42 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
40 char numstring[100]; 43 char numstring[100];
41 sprintf(numstring, "%d", num); 44 sprintf(numstring, "Friend added, number: %d", num);
42 new_lines(numstring); 45 new_lines(numstring);
43 do_refresh(); 46 do_refresh();
44 } else if (line[1] == 'd') { 47 } else if (line[1] == 'd') {
@@ -62,9 +65,6 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
62 int num = atoi(numstring); 65 int num = atoi(numstring);
63 m_sendmessage(num, (uint8_t*) message, sizeof((uint8_t*)message)); 66 m_sendmessage(num, (uint8_t*) message, sizeof((uint8_t*)message));
64 } 67 }
65 char command[STRING_LENGTH + 2] = "> ";
66 strcat(command, line);
67 new_lines(command);
68 } else { 68 } else {
69 //new_lines(line); 69 //new_lines(line);
70 } 70 }
@@ -139,14 +139,17 @@ void print_request(uint8_t * public_key, uint8_t * data, uint16_t length)
139 { 139 {
140 new_lines("Friend request accepted."); 140 new_lines("Friend request accepted.");
141 do_refresh(); 141 do_refresh();
142 m_addfriend_norequest(public_key); 142 int num = m_addfriend_norequest(public_key);
143 char numchar[10];
144 sprintf(numchar, "Friend added, number: %d", num);
145 new_lines(numchar);
143 } 146 }
144} 147}
145void print_message(int friendnumber, uint8_t * string, uint16_t length) 148void print_message(int friendnumber, uint8_t * string, uint16_t length)
146{ 149{
147 new_lines("Message received"); 150 char msg[100+length];
148 do_refresh(); 151 sprintf(msg, "Message [%d]: %s", friendnumber, string);
149 m_sendmessage(friendnumber, (uint8_t*)"Test1", 6); 152 new_lines(msg);
150} 153}
151int main(int argc, char *argv[]) 154int main(int argc, char *argv[])
152{ 155{
@@ -181,7 +184,7 @@ int main(int argc, char *argv[])
181 raw(); 184 raw();
182 getmaxyx(stdscr,y,x); 185 getmaxyx(stdscr,y,x);
183 new_lines(idstring0); 186 new_lines(idstring0);
184 do_refresh(); 187 new_lines("/f ID (to add friend), /m friendnumber message (to send message)");
185 strcpy(line, ""); 188 strcpy(line, "");
186 IP_Port bootstrap_ip_port; 189 IP_Port bootstrap_ip_port;
187 bootstrap_ip_port.port = htons(atoi(argv[2])); 190 bootstrap_ip_port.port = htons(atoi(argv[2]));