38 |
|
DOUBLE, |
39 |
|
STRING, |
40 |
|
INT, |
41 |
+ |
BOOL, |
42 |
|
DUPLEX |
43 |
|
} stat_type; |
44 |
|
|
375 |
|
|
376 |
|
add_stat(INT, &iface[i].speed, |
377 |
|
"net", name, "speed", NULL); |
378 |
+ |
add_stat(BOOL, &iface[i].up, |
379 |
+ |
"net", name, "up", NULL); |
380 |
|
add_stat(DUPLEX, &iface[i].dup, |
381 |
|
"net", name, "duplex", NULL); |
382 |
|
} |
449 |
|
t->populate(); |
450 |
|
} |
451 |
|
|
452 |
< |
qsort(stats, num_stats, sizeof *stats, stats_compare); |
452 |
> |
if (stats != NULL) |
453 |
> |
qsort(stats, num_stats, sizeof *stats, stats_compare); |
454 |
|
} |
455 |
|
|
456 |
|
/* Print the value of a stat. */ |
478 |
|
case INT: |
479 |
|
printf("%d", *(int *)v); |
480 |
|
break; |
481 |
+ |
case BOOL: |
482 |
+ |
printf("%s", *(int *)v ? "true" : "false"); |
483 |
+ |
break; |
484 |
|
case DUPLEX: |
485 |
< |
switch (*(duplex *) v) { |
485 |
> |
switch (*(statgrab_duplex *) v) { |
486 |
|
case FULL_DUPLEX: |
487 |
|
printf("full"); |
488 |
|
break; |
536 |
|
else |
537 |
|
compare = stats_compare; |
538 |
|
|
539 |
< |
s = (const stat *)bsearch(&key, stats, num_stats, |
540 |
< |
sizeof *stats, compare); |
539 |
> |
if (stats == NULL) { |
540 |
> |
s = NULL; |
541 |
> |
} else { |
542 |
> |
s = (const stat *)bsearch(&key, stats, |
543 |
> |
num_stats, |
544 |
> |
sizeof *stats, |
545 |
> |
compare); |
546 |
> |
} |
547 |
> |
|
548 |
|
if (s == NULL) { |
549 |
|
printf("Unknown stat %s\n", name); |
550 |
|
continue; |