fixed the ncurses client i believe

This commit is contained in:
Oliver Hunt 2013-07-14 02:57:09 +01:00
parent b3e5da125c
commit 9f38ab582c
2 changed files with 18 additions and 12 deletions

View File

@ -346,11 +346,11 @@ void doMessenger()
if(DHT_handlepacket(data, length, ip_port) && LosslessUDP_handlepacket(data, length, ip_port)) if(DHT_handlepacket(data, length, ip_port) && LosslessUDP_handlepacket(data, length, ip_port))
{ {
//if packet is discarded //if packet is discarded
printf("Received unhandled packet with length: %u\n", length); //printf("Received unhandled packet with length: %u\n", length);
} }
else else
{ {
printf("Received handled packet with length: %u\n", length); //printf("Received handled packet with length: %u\n", length);
} }
//} //}
} }

View File

@ -10,6 +10,7 @@ void new_lines(char *line)
strcpy(lines[i],lines[i-1]); strcpy(lines[i],lines[i-1]);
} }
strcpy(lines[0],line); strcpy(lines[0],line);
do_refresh();
} }
unsigned char * hex_string_to_bin(char hex_string[]) unsigned char * hex_string_to_bin(char hex_string[])
@ -65,7 +66,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
strcat(command, line); strcat(command, line);
new_lines(command); new_lines(command);
} else { } else {
new_lines(line); //new_lines(line);
} }
} }
@ -186,17 +187,22 @@ int main(int argc, char *argv[])
bootstrap_ip_port.port = htons(atoi(argv[2])); bootstrap_ip_port.port = htons(atoi(argv[2]));
bootstrap_ip_port.ip.i = inet_addr(argv[1]); bootstrap_ip_port.ip.i = inet_addr(argv[1]);
DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
nodelay(stdscr, TRUE);
while(true) { while(true) {
c=getch(); c=getch();
if (c != 27) { if (c != ERR) {
getmaxyx(stdscr,y,x); if (c != 27) {
if (c == '\n') { getmaxyx(stdscr,y,x);
line_eval(lines, line); if (c == '\n') {
strcpy(line, ""); line_eval(lines, line);
} else if (c == 127) { strcpy(line, "");
line[strlen(line)-1] = '\0'; } else if (c == 127) {
} else if (isalnum(c) || ispunct(c) || c == ' ') { line[strlen(line)-1] = '\0';
strcpy(line,appender(line, (char) c)); } else if (isalnum(c) || ispunct(c) || c == ' ') {
strcpy(line,appender(line, (char) c));
}
} else {
break;
} }
} }
doMessenger(); doMessenger();