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.4 by tdb, Mon Apr 5 16:23:08 2004 UTC vs.
Revision 1.6 by ats, Thu Apr 8 13:44:44 2004 UTC

# Line 1 | Line 1
1   /*
2 < * i-scream central monitoring system
2 > * i-scream libstatgrab
3   * http://www.i-scream.org
4   * Copyright (C) 2000-2004 i-scream
5   *
# Line 44 | Line 44 | int main(int argc, char **argv){
44          if(network_iface_stats == NULL){
45                  fprintf(stderr, "Failed to get network interface stats\n");
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");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines