Index: src/contrib/bsnmp/gensnmpdef/gensnmpdef.c =================================================================== RCS file: /home/ncvs/src/contrib/bsnmp/gensnmpdef/gensnmpdef.c,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 gensnmpdef.c --- src/contrib/bsnmp/gensnmpdef/gensnmpdef.c 30 May 2006 07:46:52 -0000 1.1.1.3 +++ src/contrib/bsnmp/gensnmpdef/gensnmpdef.c 30 May 2006 18:58:59 -0000 @@ -51,6 +51,9 @@ "MIBs are searched according to the libsmi(3) search rules and can\n" "be specified either by path or module name\n"; +/* path to include in libsmi MIB search, must start with `:' */ +static const char mibpath[] = ":/usr/share/snmp/mibs"; + static SmiNode *last_node; static u_int cut = 3; @@ -504,11 +507,13 @@ int opt; int flags; SmiModule **mods; + unsigned int mods_count; char *name; SmiNode *n, *last; u_int level; long u; char *end; + char *path; smiInit(NULL); @@ -547,18 +552,32 @@ flags |= SMI_FLAG_ERRORS; smiSetFlags(flags); + /* add the default MIB directory */ + end = smiGetPath(); + path = malloc(strlen(end) + sizeof(mibpath) + 1); + if (path == NULL) + err(1, NULL); + strcpy(path, end); + strcat(path, mibpath); + smiSetPath(path); + mods = malloc(sizeof(mods[0]) * argc); if (mods == NULL) err(1, NULL); - for (opt = 0; opt < argc; opt++) { + for (opt = 0, mods_count = 0; opt < argc; opt++) { + /* tries to load each module requested */ if ((name = smiLoadModule(argv[opt])) == NULL) err(1, "%s: cannot load", argv[opt]); - mods[opt] = smiGetModule(name); + else { + /* module loaded successfully -- count it */ + mods[opt] = smiGetModule(name); + mods_count++; + } } level = 0; last = NULL; - for (opt = 0; opt < argc; opt++) { + for (opt = 0; opt < mods_count; opt++) { n = smiGetFirstNode(mods[opt], SMI_NODEKIND_ANY); for (;;) { if (do_typedef == 0) {