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

Comparing projects/libstatgrab/examples/network_iface_stats.c (file contents):
Revision 1.5 by tdb, Tue Apr 6 14:52:56 2004 UTC vs.
Revision 1.6 by ats, Thu Apr 8 13:44:44 2004 UTC

# Line 46 | Line 46 | int main(int argc, char **argv){
46                  exit(1);
47          }
48  
49 +        if (argc != 1) {
50 +                /* If an argument is given, use bsearch to find just that
51 +                 * interface. */
52 +                sg_network_iface_stats key;
53 +
54 +                key.interface_name = argv[1];
55 +                network_iface_stats = bsearch(&key, network_iface_stats,
56 +                                              iface_count,
57 +                                              sizeof *network_iface_stats,
58 +                                              sg_network_iface_compare_name);
59 +                if (network_iface_stats == NULL) {
60 +                        fprintf(stderr, "Interface %s not found\n", argv[1]);
61 +                        exit(1);
62 +                }
63 +                iface_count = 1;
64 +        }
65 +
66          printf("Name\tSpeed\tDuplex\n");
67          for(i = 0; i < iface_count; i++) {
68                  printf("%s\t%d\t", network_iface_stats->interface_name, network_iface_stats->speed);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines