summaryrefslogtreecommitdiff
path: root/recipes/net-tools/files/net-tools-1.60-parse.patch
blob: 25890f1b049b132cc21cd431257c9e27d409e40b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--- net-tools-1.60/statistics.c.parse	2004-09-06 10:45:35.595130240 +0200
+++ net-tools-1.60/statistics.c	2004-09-06 10:43:11.000000000 +0200
@@ -289,7 +289,7 @@
 	return &dummytab;
 }
 
-void process_fd(FILE *f)
+void process_fd(FILE *f,int file_desc)   // added file_desc to show propriate error mesg
 {
     char buf1[1024], buf2[1024];
     char *sp, *np, *p;
@@ -297,12 +297,16 @@
 	int endflag;
 	struct tabtab *tab;
 
+	if (strcmp(buf1,"\n") == 0)  // cut leading break
+	    if (!fgets(buf1, sizeof buf1, f))
+	    break;
 	if (!fgets(buf2, sizeof buf2, f))
 	    break;
+
 	sp = strchr(buf1, ':');
-	np = strchr(buf2, ':');
-	if (!np || !sp)
-	    goto formaterr;
+	np = strchr(buf2, ':'); 
+	if (!np || !sp) 
+	    goto formaterr; 
 	*sp = '\0';
 
 	tab = newtable(snmptabs, buf1);
@@ -333,7 +337,12 @@
   return;
   
 formaterr:
-  perror(_("error parsing /proc/net/snmp"));
+ switch(file_desc) {
+    case 0: perror(_("error parsing /proc/net/snmp"));
+	break;
+    case 1: perror(_("error parsing /proc/net/netstat"));
+	break;
+  }
   return;
 }
 
@@ -343,13 +352,13 @@
     FILE *f;
 
     f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp;
-    
+
     f = fopen("/proc/net/snmp", "r");
     if (!f) {
 	perror(_("cannot open /proc/net/snmp"));
 	return(1);
     }
-    process_fd(f);
+    process_fd(f,0);
 
     if (ferror(f)) {
 	perror("/proc/net/snmp");
@@ -361,7 +370,7 @@
     f = fopen("/proc/net/netstat", "r");
 
     if (f) {
-    	process_fd(f);
+    	process_fd(f,1);
 
         if (ferror(f)) {
 	  perror("/proc/net/netstat");