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