Merge pull request #38 from ollieh/ncursesclient

Ncursesclient
This commit is contained in:
irungentoo 2013-07-13 19:06:58 -07:00
commit 383630b3d4
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 packet is discarded
printf("Received unhandled packet with length: %u\n", length);
//printf("Received unhandled packet with length: %u\n", length);
}
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[0],line);
do_refresh();
}
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);
new_lines(command);
} else {
new_lines(line);
//new_lines(line);
}
}
@ -186,8 +187,10 @@ int main(int argc, char *argv[])
bootstrap_ip_port.port = htons(atoi(argv[2]));
bootstrap_ip_port.ip.i = inet_addr(argv[1]);
DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
nodelay(stdscr, TRUE);
while(true) {
c=getch();
if (c != ERR) {
if (c != 27) {
getmaxyx(stdscr,y,x);
if (c == '\n') {
@ -198,6 +201,9 @@ int main(int argc, char *argv[])
} else if (isalnum(c) || ispunct(c) || c == ' ') {
strcpy(line,appender(line, (char) c));
}
} else {
break;
}
}
doMessenger();
do_refresh();