summaryrefslogtreecommitdiff
path: root/testing/nTox.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/nTox.c')
-rw-r--r--testing/nTox.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index 24d40ead..13db58d7 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -18,7 +18,7 @@
18 * 18 *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 20 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
21 * 21 *
22 */ 22 */
23#include "nTox.h" 23#include "nTox.h"
24#include "misc_tools.h" 24#include "misc_tools.h"
@@ -54,7 +54,7 @@ void get_id(char *data)
54 { 54 {
55 if (self_public_key[i] < (PUB_KEY_BYTES / 2)) 55 if (self_public_key[i] < (PUB_KEY_BYTES / 2))
56 strcpy(idstring1[i],"0"); 56 strcpy(idstring1[i],"0");
57 else 57 else
58 strcpy(idstring1[i], ""); 58 strcpy(idstring1[i], "");
59 sprintf(idstring2[i], "%hhX",self_public_key[i]); 59 sprintf(idstring2[i], "%hhX",self_public_key[i]);
60 } 60 }
@@ -71,9 +71,9 @@ void get_id(char *data)
71void new_lines(char *line) 71void new_lines(char *line)
72{ 72{
73 int i = 0; 73 int i = 0;
74 for (i = HISTORY-1; i > 0; i--) 74 for (i = HISTORY-1; i > 0; i--)
75 strncpy(lines[i], lines[i-1], STRING_LENGTH - 1); 75 strncpy(lines[i], lines[i-1], STRING_LENGTH - 1);
76 76
77 strncpy(lines[0], line, STRING_LENGTH - 1); 77 strncpy(lines[0], line, STRING_LENGTH - 1);
78 do_refresh(); 78 do_refresh();
79} 79}
@@ -133,7 +133,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
133 if (inpt_command == 'f') { // add friend command: /f ID 133 if (inpt_command == 'f') { // add friend command: /f ID
134 int i; 134 int i;
135 char temp_id[128]; 135 char temp_id[128];
136 for (i = 0; i < 128; i++) 136 for (i = 0; i < 128; i++)
137 temp_id[i] = line[i+prompt_offset]; 137 temp_id[i] = line[i+prompt_offset];
138 138
139 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); 139 int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
@@ -166,8 +166,8 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
166 } 166 }
167 else if (inpt_command == 'm') { //message command: /m friendnumber messsage 167 else if (inpt_command == 'm') { //message command: /m friendnumber messsage
168 size_t len = strlen(line); 168 size_t len = strlen(line);
169 if(len < 3) 169 if(len < 3)
170 return; 170 return;
171 171
172 char numstring[len-3]; 172 char numstring[len-3];
173 char message[len-3]; 173 char message[len-3];
@@ -248,7 +248,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
248 else if (inpt_command == 'q') { //exit 248 else if (inpt_command == 'q') { //exit
249 endwin(); 249 endwin();
250 exit(EXIT_SUCCESS); 250 exit(EXIT_SUCCESS);
251 } else { 251 } else {
252 new_lines("[i] invalid command"); 252 new_lines("[i] invalid command");
253 } 253 }
254 } else { 254 } else {
@@ -335,7 +335,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length)
335 new_lines(format_message((char*)string, friendnumber)); 335 new_lines(format_message((char*)string, friendnumber));
336} 336}
337 337
338void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) 338void print_nickchange(int friendnumber, uint8_t *string, uint16_t length)
339{ 339{
340 char name[MAX_NAME_LENGTH]; 340 char name[MAX_NAME_LENGTH];
341 getname(friendnumber, (uint8_t*)name); 341 getname(friendnumber, (uint8_t*)name);
@@ -344,7 +344,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length)
344 new_lines(msg); 344 new_lines(msg);
345} 345}
346 346
347void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) 347void print_statuschange(int friendnumber, uint8_t *string, uint16_t length)
348{ 348{
349 char name[MAX_NAME_LENGTH]; 349 char name[MAX_NAME_LENGTH];
350 getname(friendnumber, (uint8_t*)name); 350 getname(friendnumber, (uint8_t*)name);
@@ -353,7 +353,7 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length)
353 new_lines(msg); 353 new_lines(msg);
354} 354}
355 355
356void load_key() 356void load_key()
357{ 357{
358 FILE *data_file = NULL; 358 FILE *data_file = NULL;
359 data_file = fopen("data","r"); 359 data_file = fopen("data","r");
@@ -368,7 +368,7 @@ void load_key()
368 exit(1); 368 exit(1);
369 } 369 }
370 Messenger_load(data, size); 370 Messenger_load(data, size);
371 } else { 371 } else {
372 //else save new keys 372 //else save new keys
373 int size = Messenger_size(); 373 int size = Messenger_size();
374 uint8_t data[size]; 374 uint8_t data[size];
@@ -418,9 +418,9 @@ int main(int argc, char *argv[])
418 int resolved_address = resolve_addr(argv[1]); 418 int resolved_address = resolve_addr(argv[1]);
419 if (resolved_address != 0) 419 if (resolved_address != 0)
420 bootstrap_ip_port.ip.i = resolved_address; 420 bootstrap_ip_port.ip.i = resolved_address;
421 else 421 else
422 exit(1); 422 exit(1);
423 423
424 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); 424 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
425 nodelay(stdscr, TRUE); 425 nodelay(stdscr, TRUE);
426 while(true) { 426 while(true) {
@@ -441,7 +441,7 @@ int main(int argc, char *argv[])
441 if (c == '\n') { 441 if (c == '\n') {
442 line_eval(lines, line); 442 line_eval(lines, line);
443 strcpy(line, ""); 443 strcpy(line, "");
444 } else if (c == 127) { 444 } else if (c == 8 || c == 127) {
445 line[strlen(line)-1] = '\0'; 445 line[strlen(line)-1] = '\0';
446 } else if (isalnum(c) || ispunct(c) || c == ' ') { 446 } else if (isalnum(c) || ispunct(c) || c == ' ') {
447 strcpy(line, appender(line, (char) c)); 447 strcpy(line, appender(line, (char) c));