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

Comparing projects/libstatgrab/src/libstatgrab/network_stats.c (file contents):
Revision 1.47 by tdb, Sat Mar 6 21:49:13 2004 UTC vs.
Revision 1.52 by tdb, Mon Mar 8 11:58:53 2004 UTC

# Line 129 | Line 129 | network_stat_t *get_network_stats(int *entries){
129          /* Horrible big enough, but it should be easily big enough */
130          char line[8096];
131          regex_t regex;
132 <        regmatch_t line_match[4];
132 >        regmatch_t line_match[9];
133   #endif
134   #ifdef ALLBSD
135          struct ifaddrs *net, *net_ptr;
# Line 230 | Line 230 | network_stat_t *get_network_stats(int *entries){
230          fgets(line, sizeof(line), f);
231  
232  
233 <        if((regcomp(&regex, "^[[:space:]]*([^:]+):[[:space:]]*([[:digit:]]+)[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+([[:digit:]]+)", REG_EXTENDED))!=0){
233 >        if((regcomp(&regex, "^ *([^:]+): *([0-9]+) +([0-9]+) +([0-9]+) +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +([0-9]+) +([0-9]+) +([0-9]+) +[0-9]+ +[0-9]+ +([0-9]+)", REG_EXTENDED))!=0){
234                  return NULL;
235          }
236  
237          interfaces=0;
238  
239          while((fgets(line, sizeof(line), f)) != NULL){
240 <                if((regexec(&regex, line, 4, line_match, 0))!=0){
240 >                if((regexec(&regex, line, 9, line_match, 0))!=0){
241                          continue;
242                  }
243                  network_stats=network_stat_malloc((interfaces+1), &sizeof_network_stats, network_stats);
# Line 252 | Line 252 | network_stat_t *get_network_stats(int *entries){
252  
253                  network_stat_ptr->interface_name=get_string_match(line, &line_match[1]);
254                  network_stat_ptr->rx=get_ll_match(line, &line_match[2]);
255 <                network_stat_ptr->tx=get_ll_match(line, &line_match[3]);
255 >                network_stat_ptr->tx=get_ll_match(line, &line_match[5]);
256 >                network_stat_ptr->ipackets=get_ll_match(line, &line_match[3]);
257 >                network_stat_ptr->opackets=get_ll_match(line, &line_match[6]);
258 >                network_stat_ptr->ierrors=get_ll_match(line, &line_match[4]);
259 >                network_stat_ptr->oerrors=get_ll_match(line, &line_match[7]);
260 >                network_stat_ptr->collisions=get_ll_match(line, &line_match[8]);
261                  network_stat_ptr->systime=time(NULL);
262  
263                  interfaces++;
# Line 273 | Line 278 | network_stat_t *get_network_stats(int *entries){
278  
279   long long transfer_diff(long long new, long long old){
280   #if defined(SOL7) || defined(LINUX) || defined(FREEBSD) || defined(DFBSD)
281 < #define MAXVAL 4294967296LL
281 > #define MAXVAL 0xffffffffLL
282   #else
283 < #define MAXVAL 18446744073709551616LL
283 > #define MAXVAL 0xffffffffffffffffLL
284   #endif
285          long long result;
286          if(new>=old){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines