summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-13 19:30:33 -0700
committerirungentoo <irungentoo@gmail.com>2013-07-13 19:30:33 -0700
commit9160a12ee157b90758fef0ee14da06d212930b58 (patch)
tree7dca5beb2dea7e1e95b22c01f32993ca91df4982
parent96b8cb1c43a767c586fb1770fdfb70003de186c0 (diff)
parenta58a6f5c7b77de3d2491d4b51d2f9239e4eccb73 (diff)
Merge pull request #39 from ollieh/ncursesclient
prettier output
-rw-r--r--CMakeLists.txt4
-rw-r--r--testing/nTox.c21
2 files changed, 14 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 552359c4..ec474ffb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,8 +14,8 @@ if(WIN32)
14 testing/Messenger_test.c) 14 testing/Messenger_test.c)
15else() 15else()
16 set(test_sources 16 set(test_sources
17 #testing/nTox.c) 17 testing/nTox.c)
18 testing/Messenger_test.c) 18 #testing/Messenger_test.c)
19endif() 19endif()
20 20
21add_executable(${exe_name} 21add_executable(${exe_name}
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]));