Strip default subnet weight from output.

This commit is contained in:
Guus Sliepen 2012-07-16 01:14:08 +02:00
parent 74646a4afa
commit 6319dc9dde

View file

@ -33,6 +33,13 @@ void logger(int level, int priority, const char *format, ...) {
va_end(ap); va_end(ap);
} }
static char *strip_weight(char *netstr) {
int len = strlen(netstr);
if(len >= 3 && !strcmp(netstr + len - 3, "#10"))
netstr[len - 3] = 0;
return netstr;
}
static int info_node(int fd, const char *item) { static int info_node(int fd, const char *item) {
// Check the list of nodes // Check the list of nodes
sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_NODES, item); sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_NODES, item);
@ -154,7 +161,7 @@ static int info_node(int fd, const char *item) {
return 1; return 1;
} }
if(!strcmp(from, item)) if(!strcmp(from, item))
printf(" %s", subnet); printf(" %s", strip_weight(subnet));
} }
printf("\n"); printf("\n");
@ -224,7 +231,7 @@ static int info_subnet(int fd, const char *item) {
} }
found = true; found = true;
printf("Subnet: %s\n", netstr); printf("Subnet: %s\n", strip_weight(netstr));
printf("Owner: %s\n", owner); printf("Owner: %s\n", owner);
} }