Test new interfaces.

This commit is contained in:
Nicolás Ortega Froysa 2017-11-08 02:25:35 +01:00
parent d513080baa
commit 72fae99e89
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF

View File

@ -18,14 +18,7 @@
#include <neocomm.h> #include <neocomm.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <string.h>
int run = 1;
void quit(int sig) {
puts("\nInterrupt signal received.");
run = 0;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if(argc != 2 && argc != 4) if(argc != 2 && argc != 4)
@ -49,11 +42,20 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
signal(SIGINT, quit);
if(connect_address) if(connect_address)
NeoComm_connect(connect_address, connect_port); NeoComm_connect(connect_address, connect_port);
while(run) { } while(1) {
char in[128];
printf("> ");
scanf("%s", in);
if(strcmp(in, "/exit") == 0 || strcmp(in, "/quit") == 0)
break;
else if(strcmp(in, "/stats") == 0)
printf("%s", NeoComm_get_node_stats());
else if(strcmp(in, "/num_nodes") == 0)
printf("%u", NeoComm_count_connected_nodes());
}
NeoComm_deinit(); NeoComm_deinit();
return 0; return 0;