ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/statgrab/statgrab.c
(Generate patch)

Comparing projects/libstatgrab/src/statgrab/statgrab.c (file contents):
Revision 1.19 by ats, Fri Feb 13 15:13:37 2004 UTC vs.
Revision 1.21 by ats, Wed Feb 18 17:29:15 2004 UTC

# Line 38 | Line 38 | typedef enum {
38          DOUBLE,
39          STRING,
40          INT,
41 +        BOOL,
42          DUPLEX
43   } stat_type;
44  
# Line 374 | Line 375 | void populate_net() {
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                  }
# Line 446 | Line 449 | void get_stats() {
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. */
# Line 474 | Line 478 | void print_stat_value(const stat *s) {
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 (*(statgrab_duplex *) v) {
486                  case FULL_DUPLEX:
# Line 529 | Line 536 | void print_stats(int argc, char **argv) {
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines