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.18 by ats, Fri Feb 13 12:52:40 2004 UTC vs.
Revision 1.22 by ats, Sat Mar 6 22:34:36 2004 UTC

# Line 38 | Line 38 | typedef enum {
38          DOUBLE,
39          STRING,
40          INT,
41 +        BOOL,
42          DUPLEX
43   } stat_type;
44  
# Line 362 | Line 363 | void populate_net() {
363                                   "net", name, "tx", NULL);
364                          add_stat(LONG_LONG, &net[i].rx,
365                                   "net", name, "rx", NULL);
366 +                        add_stat(LONG_LONG, &net[i].ipackets,
367 +                                 "net", name, "ipackets", NULL);
368 +                        add_stat(LONG_LONG, &net[i].opackets,
369 +                                 "net", name, "opackets", NULL);
370 +                        add_stat(LONG_LONG, &net[i].ierrors,
371 +                                 "net", name, "ierrors", NULL);
372 +                        add_stat(LONG_LONG, &net[i].oerrors,
373 +                                 "net", name, "oerrors", NULL);
374 +                        add_stat(LONG_LONG, &net[i].collisions,
375 +                                 "net", name, "collisions", NULL);
376                          add_stat(TIME_T, &net[i].systime,
377                                   "net", name, "systime", NULL);
378                  }
# Line 374 | Line 385 | void populate_net() {
385  
386                          add_stat(INT, &iface[i].speed,
387                                   "net", name, "speed", NULL);
388 +                        add_stat(BOOL, &iface[i].up,
389 +                                 "net", name, "up", NULL);
390                          add_stat(DUPLEX, &iface[i].dup,
391                                   "net", name, "duplex", NULL);
392                  }
# Line 446 | Line 459 | void get_stats() {
459                          t->populate();
460          }
461  
462 <        qsort(stats, num_stats, sizeof *stats, stats_compare);
462 >        if (stats != NULL)
463 >                qsort(stats, num_stats, sizeof *stats, stats_compare);
464   }
465  
466   /* Print the value of a stat. */
# Line 474 | Line 488 | void print_stat_value(const stat *s) {
488          case INT:
489                  printf("%d", *(int *)v);
490                  break;
491 +        case BOOL:
492 +                printf("%s", *(int *)v ? "true" : "false");
493 +                break;
494          case DUPLEX:
495 <                switch (*(duplex *) v) {
495 >                switch (*(statgrab_duplex *) v) {
496                  case FULL_DUPLEX:
497                          printf("full");
498                          break;
# Line 529 | Line 546 | void print_stats(int argc, char **argv) {
546                          else
547                                  compare = stats_compare;
548  
549 <                        s = (const stat *)bsearch(&key, stats, num_stats,
550 <                                                  sizeof *stats, compare);
549 >                        if (stats == NULL) {
550 >                                s = NULL;
551 >                        } else {
552 >                                s = (const stat *)bsearch(&key, stats,
553 >                                                          num_stats,
554 >                                                          sizeof *stats,
555 >                                                          compare);
556 >                        }
557 >
558                          if (s == NULL) {
559                                  printf("Unknown stat %s\n", name);
560                                  continue;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines