summaryrefslogtreecommitdiff
path: root/mib/parse-net-snmp.patch
blob: 04435c1f748c52e5694b7f171f538298676149d4 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
--- parse.c.orig	2006-01-27 14:11:27.000000000
+++ parse.c	2006-04-04 16:04:46.000000000
@@ -1,4 +1,11 @@
 /*
+ * Nate Nielsen
+ * 
+ * Borrowed from net-snmp. Cleaned up a bit (see parse-net-snmp.patch)
+ * and readied for inclusion in rrdbot. Most of the additional code
+ * is at the top.
+ */
+/*
  * parse.c
  *
  * Update: 1998-09-22 <mslifcak@iss.net>
@@ -47,75 +54,22 @@
  * Use is subject to license terms specified in the COPYING file
  * distributed with the Net-SNMP package.
  */
-#include <net-snmp/net-snmp-config.h>
 
-#include <stdio.h>
-#if HAVE_STDLIB_H
+/* -----------------------------------------------------------------------------
+ * ADDITIONAL RRDBOT COMPATIBILITY CODE 
+ */
+ 
+#include <sys/types.h>
 #include <stdlib.h>
-#endif
-#if HAVE_STRING_H
+#include <stdio.h>
 #include <string.h>
-#else
-#include <strings.h>
-#endif
 #include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <dirent.h>
+#include <syslog.h>
 
-/*
- * Wow.  This is ugly.  -- Wes 
- */
-#if HAVE_DIRENT_H
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# if HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-#  include <ndir.h>
-# endif
-#endif
-#if TIME_WITH_SYS_TIME
-# ifdef WIN32
-#  include <sys/timeb.h>
-# else
-#  include <sys/time.h>
-# endif
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-#if HAVE_WINSOCK_H
-#include <winsock.h>
-#endif
-#if HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP)
-#include <regex.h>
-#endif
-#if HAVE_DMALLOC_H
-#include <dmalloc.h>
-#endif
+#include "parse.h"
 
-#include <net-snmp/types.h>
-#include <net-snmp/output_api.h>
-#include <net-snmp/config_api.h>
-#include <net-snmp/utilities.h>
-
-#include <net-snmp/library/parse.h>
-#include <net-snmp/library/mib.h>
-#include <net-snmp/library/snmp_api.h>
+/* -------------------------------------------------------------------------- */
 
 /*
  * This is one element of an object identifier with either an integer
@@ -138,8 +92,8 @@
     struct range_list *ranges;
 } tclist[MAXTC];
 
-int             mibLine = 0;
-const char     *File = "(none)";
+static int             mibLine = 0;
+static const char     *File = "(none)";
 static int      anonymous = 0;
 
 struct objgroup {
@@ -4569,51 +4523,8 @@
     char            token[MAXTOKEN], token2[MAXTOKEN];
     char            tmpstr[300];
     int             count = 0;
-#if !(defined(WIN32) || defined(cygwin))
-    char space;
-    char newline;
-    struct stat     dir_stat, idx_stat;
-    char            tmpstr1[300];
-#endif
 
     DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
-#if !(defined(WIN32) || defined(cygwin))
-    snprintf(token, sizeof(token), "%s/%s", dirname, ".index");
-    token[ sizeof(token)-1 ] = 0;
-    if (stat(token, &idx_stat) == 0 && stat(dirname, &dir_stat) == 0) {
-        if (dir_stat.st_mtime < idx_stat.st_mtime) {
-            DEBUGMSGTL(("parse-mibs", "The index is good\n"));
-            if ((ip = fopen(token, "r")) != NULL) {
-                while (fscanf(ip, "%127s%c%299s%c", token, &space, tmpstr,
-		    &newline) == 4) {
-
-		    /*
-		     * If an overflow of the token or tmpstr buffers has been
-		     * found log a message and break out of the while loop,
-		     * thus the rest of the file tokens will be ignored.
-		     */
-		    if (space != ' ' || newline != '\n') {
-			snmp_log(LOG_ERR,
-			    "add_mibdir: strings scanned in from %s/%s " \
-			    "are too large.  count = %d\n ", dirname,
-			    ".index", count);
-			    break;
-		    }
-		   
-		    snprintf(tmpstr1, sizeof(tmpstr1), "%s/%s", dirname, tmpstr);
-                    tmpstr1[ sizeof(tmpstr1)-1 ] = 0;
-                    new_module(token, tmpstr1);
-                    count++;
-                }
-                fclose(ip);
-                return count;
-            } else
-                DEBUGMSGTL(("parse-mibs", "Can't read index\n"));
-        } else
-            DEBUGMSGTL(("parse-mibs", "Index outdated\n"));
-    } else
-        DEBUGMSGTL(("parse-mibs", "No index\n"));
-#endif
 
     if ((dir = opendir(dirname))) {
         snprintf(tmpstr, sizeof(tmpstr), "%s/.index", dirname);
--- parse.h.orig	2003-05-08 11:32:04.000000000
+++ parse.h	2006-01-27 12:56:14.000000000
@@ -119,11 +119,6 @@
         struct varbind_list *varbinds;
         char           *hint;
         char           *units;
-        int             (*printomat) (u_char **, size_t *, size_t *, int,
-                                      const netsnmp_variable_list *,
-                                      const struct enum_list *, const char *,
-                                      const char *);
-        void            (*printer) (char *, const netsnmp_variable_list *, const struct enum_list *, const char *, const char *);   /* Value printing function */
         char           *description;    /* description (a quoted string) */
         int             reported;       /* 1=report started in print_subtree... */
         char           *defaultValue;