/* * Reads the named file as an SMI module. Returns an array containing * the module name and a Hash with OID symbols as keys and the numeric * OIDs as values. */ static VALUE fsmi_load_smi_module(VALUE self, VALUE filename) { int init_ret; char* load_ret; char* cfilename; SmiModule* module; VALUE module_name; VALUE oid_hash; init_ret = smiInit(NULL); if (init_ret != 0) { rb_raise(rb_eRuntimeError, "libsmi init error: %d", init_ret); } cfilename = STR2CSTR(filename); load_ret = smiLoadModule(cfilename); if (load_ret == NULL) { rb_raise(rb_eRuntimeError, "%s for module '%s'", strerror(errno), cfilename); } module = smiGetFirstModule(); if (module == NULL) { rb_raise(rb_eRuntimeError, "No module found in %s", cfilename); } module_name = rb_str_new2(module->name); oid_hash = get_oid_hash(module); return rb_ary_new3(2, module_name, oid_hash); }
void MibEditor::VerifyMIB(void) { int flags = smiGetFlags(); int saved_flags = flags; flags |= SMI_FLAG_ERRORS; flags |= SMI_FLAG_NODESCR; smiSetFlags(flags); s->MainUI()->MIBLog->clear(); CurrentEditorObject = this; smiSetErrorHandler(ErrorHdlr); smiSetErrorLevel(9); num_error = 0; num_warning = 0; num_info = 0; QString start_msg = QString("Starting MIB verification ..."); s->MainUI()->MIBLog->addItem(new QListWidgetItem(start_msg, s->MainUI()->MIBLog)); smiLoadModule(QDir::toNativeSeparators(LoadedFile).toLatin1().data()); QString stop_msg = QString("Verification completed. %1 errors, %2 warnings, %3 infos") .arg(num_error).arg(num_warning).arg(num_info); s->MainUI()->MIBLog->addItem(new QListWidgetItem(stop_msg, s->MainUI()->MIBLog)); smiSetFlags(saved_flags); // Reload everything s->MibModuleObj()->Refresh(); }
int nd_load_smi_module(const char *module, char *errbuf, size_t errbuf_size) { #ifdef USE_LIBSMI if (smiLoadModule(module) == 0) { snprintf(errbuf, errbuf_size, "could not load MIB module %s", module); return (-1); } nd_smi_module_loaded = 1; return (0); #else snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support", module); return (-1); #endif }
void MibViewLoader::Load(QStringList &modules) { char *modulename; SmiModule *smiModule; SmiModule **modv = NULL; int modc = 0; modv = (SmiModule **)malloc(modules.count() * sizeof(SmiModule *)); modc = 0; QString module; for (int j=0; j < views.count(); j++) { views[j]->SetDirty(); views[j]->clear(); } for (int i=0; i < modules.count(); i++) { module = modules[i]; modulename = smiLoadModule(module.toLatin1().data()); smiModule = modulename ? smiGetModule(modulename) : NULL; if (smiModule) modv[modc++] = smiModule; else { emit LogError(QString("Error: `%1` module cannot be loaded (not in PATHS)") .arg(module.toLatin1().data())); } } pmodc = modc; if (pmodv) free(pmodv); pmodv = modv; }