/*
* parse.c
*/
-#include "config.h"
+#include "squid.h"
+#include "asn1.h"
+#include "cache_snmp.h"
+#include "parse.h"
+#include "snmp_debug.h"
+#include "snmp_pdu.h"
+#include "snmp_vars.h"
+#include "util.h"
#include <stdio.h>
#if HAVE_MEMORY_H
#include <memory.h>
#endif
-#ifdef HAVE_STRING_H
+#if HAVE_STRING_H
#include <string.h>
#endif
-#ifdef HAVE_STRINGS_H
+#if HAVE_STRINGS_H
#include <strings.h>
#endif
#if HAVE_BSTRING_H
#if HAVE_ASSERT_H
#include <assert.h>
#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
-
-#include "asn1.h"
-#include "snmp_vars.h"
-#include "parse.h"
-#include "snmp_debug.h"
-
-#include "util.h"
-
-#include "cache_snmp.h"
/*
* This is one element of an object identifier with either an integer subidentifier,
* or a textual string label, or both.
struct tok *next; /* pointer to next in hash table */
};
-
struct tok tokens[] = {
{"obsolete", sizeof("obsolete") - 1, OBSOLETE},
{"Opaque", sizeof("Opaque") - 1, SNMP_OPAQUE},
}
}
-
static void
print_error(const char *string, const char *token, int type)
{
snmplib_debug(0, "%s: On or around line %d\n", string, Line);
}
-#ifdef TEST
+#if TEST
print_subtree(tree, count)
struct snmp_mib_tree *tree;
int count;
xfree(oldnp);
}
-#ifndef TEST
+#if !TEST
static
#endif
struct snmp_mib_tree *
- build_tree(struct node *nodes) {
+build_tree(struct node *nodes) {
struct node *np;
struct snmp_mib_tree *tp;
int bucket, nodes_left = 0;
init_node_hash(nodes);
/* XXX nodes isn't needed in do_subtree() ??? */
do_subtree(tp, &nodes);
-#ifdef TEST
+#if TEST
print_subtree(tp, 0);
#endif /* TEST */
/* If any nodes are left, the tree is probably inconsistent */
return tp;
}
-
/*
* Parses a token from the file. The type of the token parsed is returned,
* and the text is placed in the string pointed to by token.
}
return count;
-
}
static void
* Returns 0 on error.
*/
static struct node *
- parse_objectid(FILE *fp, char *name) {
+parse_objectid(FILE *fp, char *name) {
int type;
char token[64];
register int count;
* Returns 0 on error.
*/
static struct node *
- parse_objecttype(register FILE *fp, char *name) {
+parse_objecttype(register FILE *fp, char *name) {
register int type;
char token[64];
int count, length;
return np;
}
-
/*
* Parses a mib file and returns a linked list of nodes found in the file.
* Returns NULL on error.
*/
-#ifndef TEST
+#if !TEST
static
#endif
struct node *
- parse(FILE *fp) {
+parse(FILE *fp) {
char token[64];
char name[64];
int type = 1;
return NULL;
}
}
-#ifdef TEST
+#if TEST
{
struct enum_list *ep;
}
struct snmp_mib_tree *
- read_mib(char *filename) {
+read_mib(char *filename) {
FILE *fp;
struct node *nodes;
struct snmp_mib_tree *tree;