コード例 #1
0
ファイル: events.c プロジェクト: Elemental-IRCd/anope
void event_process_hook(const char *name, int argc, char **argv)
{
    int retVal = 0;
    EvtHook *current = NULL;
    EvtHook *evh;
    if (mod_current_evtbuffer) {
        free(mod_current_evtbuffer);
    }
    /* Do something with the message. */
    evh = find_eventhook(name);
    if (evh) {
        if (evh->func) {
            char *mod_current_module_name_save = mod_current_module_name;
            Module *mod_current_module_save = mod_current_module;
            mod_current_module = findModule(evh->mod_name);
            mod_current_module_name = evh->mod_name;
            retVal = evh->func(argc, argv);
            if (retVal == MOD_CONT) {
                current = evh->next;
                while (current && current->func && retVal == MOD_CONT) {
                    mod_current_module = findModule(current->mod_name);
                    mod_current_module_name = current->mod_name;
                    retVal = current->func(argc, argv);
                    current = current->next;
                }
            }
            mod_current_module_name = mod_current_module_name_save;
            mod_current_module = mod_current_module_save;
        }
    }
}
コード例 #2
0
ファイル: report_list.cpp プロジェクト: cwarden/quasar
void
ReportList::slotRefresh()
{
    QApplication::setOverrideCursor(waitCursor);
    qApp->processEvents();

    clearData();
    _quasar->resourceList("reports", ".name", ".module", _files, _names,
			  _modules);

    for (unsigned int i = 0; i < _names.size(); ++i) {
	ListView* list = findModule(_modules[i]);
	ListViewItem* item = new ListViewItem(list);
	item->extra.push_back(_files[i]);
	item->setValue(0, _names[i]);

	if (_modules[i] != tr("All")) {
	    list = findModule(tr("All"));
	    item = new ListViewItem(list);
	    item->extra.push_back(_files[i]);
	    item->setValue(0, _names[i]);
	    item->setValue(1, _modules[i]);
	}
    }

    if (_module->firstChild() != NULL) {
	_module->setSelected(_module->firstChild(), true);
	_module->setCurrentItem(_module->firstChild());
    }
    slotModuleChange();

    QApplication::restoreOverrideCursor();
}
コード例 #3
0
ファイル: support_exec.cpp プロジェクト: ghewgill/neon-lang
bool RuntimeSupport::loadBytecode(const std::string &name, Bytecode &object)
{
#ifdef USE_RTLX
    for (size_t i = 0; i < sizeof(rtl_bytecode)/sizeof(rtl_bytecode[0]); i++) {
        if (name == rtl_bytecode[i].name) {
            std::vector<unsigned char> bytecode {rtl_bytecode[i].bytecode, rtl_bytecode[i].bytecode + rtl_bytecode[i].length};
            object.load("-builtin-", bytecode);
            return true;
        }
    }
#endif

    std::pair<std::string, std::string> names = findModule(name);
    std::ifstream inf(names.second, std::ios::binary);
    if (not inf.good()) {
        return false;
    }
    std::stringstream buf;
    buf << inf.rdbuf();
    std::vector<unsigned char> bytecode;
    std::string s = buf.str();
    std::copy(s.begin(), s.end(), std::back_inserter(bytecode));
    if (not object.load(names.second, bytecode)) {
        return false;
    }
    return true;
}
コード例 #4
0
ファイル: mal_module.c プロジェクト: cran/MonetDBLite
/*
 * Removal of elements from the symbol table should be
 * done with care. For, it should be assured that
 * there are no references to the definition at the
 * moment of removal. This situation can not easily
 * checked at runtime, without tremendous overhead.
 */
void deleteSymbol(Module scope, Symbol prg){
	InstrPtr sig;
	int t;

	sig = getSignature(prg);
#ifdef _DEBUG_MODULE_
	fprintf(stderr,"#delete symbol %s.%s from %s\n", getModuleId(sig), getFunctionId(sig), prg->name);
#endif
	if (getModuleId(sig) && getModuleId(sig)!= scope->name ){
		/* move the definition to the proper place */
		/* default scope is the last resort */
		Module c= findModule(scope, getModuleId(sig));
		if(c )
			scope = c;
	}
	t = getSymbolIndex(getFunctionId(sig));
	if (scope->space[t] == prg) {
		scope->space[t] = scope->space[t]->peer;
		freeSymbol(prg);
	} else {
		Symbol nxt = scope->space[t];
		while (nxt->peer != NULL) {
			if (nxt->peer == prg) {
				nxt->peer = prg->peer;
				nxt->skip = prg->peer;
				freeSymbol(prg);
				return;
			}
			nxt = nxt->peer;
		}
	}
}
コード例 #5
0
   IContent* ContentManager::load(const String& name)
   {
      IContent* presult = NULL;

      String path = name + UTEXT(".c2d");
      path.toLower();

      File* pfile = FileSystem::getInstance().open(path, File::ERead | File::EBinary);
      if ( pfile != NULL )
      {
         Uuid uuid;
         FileReaderStream stream(*pfile);
         uuid.read(stream);

         ContentModule* pmodule = findModule(uuid);
         if ( pmodule != NULL )
         {
            ContentReader& reader = pmodule->getReader();
            reader.setContentManager(*this);
            reader.setGraphicsDevice(mpDevice);
            reader.setPhysicsSimulator(mpSimulator);
            reader.setSoundManager(mpSoundManager);

            presult = reader.read(stream);
            if ( presult != NULL )
            {
               presult->setFilename(name);
            }
         }
      }

      return presult;
   }
コード例 #6
0
ファイル: report_list.cpp プロジェクト: cwarden/quasar
void
ReportList::clearData()
{
    // Delete existing lists of reports
    for (unsigned int i = 0; i < _views.size(); ++i) {
	_stack->removeWidget(_views[i]);
	delete _views[i];
    }
    _views.clear();

    // Clear module list
    _module->clear();

    // Add modules in standard order
    findModule(tr("All"));
    findModule(tr("Card File"));
    findModule(tr("Ledger"));
    findModule(tr("Cheques"));
    findModule(tr("Inventory"));
    findModule(tr("Sales"));
    findModule(tr("Purchases"));

    // Clear info on reports
    _files.clear();
    _names.clear();
    _modules.clear();
}
コード例 #7
0
ファイル: win32.c プロジェクト: danopia/denora
void Win32LoadCoreDir(char *dirname)
{
#ifdef USE_MODULES
    BOOL fFinished;
    HANDLE hList;
    TCHAR szDir[MAX_PATH + 1];
    TCHAR szSubDir[MAX_PATH + 1];
    WIN32_FIND_DATA FileData;
    char *mname = NULL;
    Module *m;
    int status;
    char buffer[_MAX_PATH];

    /* Get the current working directory: */
    if (_getcwd(buffer, _MAX_PATH) == NULL) {
        alog(LOG_DEBUG, "debug: Unable to set Current working directory");
    }
    ircsnprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirname);

    hList = FindFirstFile(szDir, &FileData);
    if (hList != INVALID_HANDLE_VALUE) {
        fFinished = FALSE;
        while (!fFinished) {
            if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
                mname = sstrdup(FileData.cFileName);
                mname[strlen(FileData.cFileName) - 4] = '\0';
                m = findModule(mname);
                if (!m) {
                    m = createCoreModule(mname);
                    mod_current_module = m;
                    mod_current_user = NULL;
                    alog(LOG_DEBUG, "trying to load [%s]",
                         mod_current_module->name);
                    status = loadCoreModule(mod_current_module, NULL);
                    alog(LOG_DEBUG, langstr(ALOG_MOD_STATUS), status,
                         ModuleGetErrStr(status));
                    if (status != MOD_ERR_OK) {
                        destroyModule(m);
                    }
                    mod_current_module = NULL;
                    mod_current_user = NULL;
                }
                dfree(mname);
            }
            if (!FindNextFile(hList, &FileData)) {
                if (GetLastError() == ERROR_NO_MORE_FILES) {
                    fFinished = TRUE;
                }
            }
        }
    } else {
        printf("Invalid File Handle. GetLastError reports %d\n",
               GetLastError());
    }
    FindClose(hList);
#endif
}
コード例 #8
0
ファイル: BPatch_image.C プロジェクト: vishalmistry/imitate
BPatch_module *BPatch_image::findOrCreateModule(mapped_module *base) {
    BPatch_module *bpm = findModule(base);

    if (bpm == NULL) {
        bpm = new BPatch_module( proc, base, this );
        modlist.push_back( bpm );
    }
    assert(bpm != NULL);
    return bpm;
}
コード例 #9
0
ファイル: modules.c プロジェクト: Rohansi/wren
char* readBuiltInModule(const char* name)
{
  ModuleRegistry* module = findModule(name);
  if (module == NULL) return NULL;

  size_t length = strlen(*module->source);
  char* copy = (char*)malloc(length + 1);
  strncpy(copy, *module->source, length + 1);
  return copy;
}
コード例 #10
0
void PrefModuleTreeView::setPane(const QString pane_name)
{
    QModelIndex newIndex, modelIndex, appearanceIndex, protocolIndex, statIndex;
    QString modelTreeName;
    int row;

    //look for the pane name in the main tree before trying children
    for (row = 0; row < model()->rowCount(); row++)
    {
        modelIndex = model()->index(row, ModulePrefsModel::colName);
        modelTreeName = model()->data(modelIndex, Qt::DisplayRole).toString();

        if (modelTreeName.compare(appearanceName_) == 0) {
            appearanceIndex = modelIndex;
        } else if (modelTreeName.compare("Protocols") == 0) {
            protocolIndex = modelIndex;
        } else if (modelTreeName.compare("Statistics") == 0) {
            statIndex = modelIndex;
        }

        if (modelTreeName.compare(pane_name) == 0) {
            newIndex = modelIndex;
            break;
        }
    }

    //Look through appearance children
    if (!newIndex.isValid()) {
        newIndex = findModule(appearanceIndex, pane_name);
    }

    //Look through protocol children
    if (!newIndex.isValid()) {
        newIndex = findModule(protocolIndex, pane_name);
    }

    //Look through stat children
    if (!newIndex.isValid()) {
        newIndex = findModule(statIndex, pane_name);
    }

    setCurrentIndex(newIndex);
}
コード例 #11
0
ファイル: modules.c プロジェクト: Rohansi/wren
WrenForeignMethodFn bindBuiltInForeignMethod(
    WrenVM* vm, const char* moduleName, const char* className, bool isStatic,
    const char* signature)
{
  // TODO: Assert instead of return NULL?
  ModuleRegistry* module = findModule(moduleName);
  if (module == NULL) return NULL;

  ClassRegistry* clas = findClass(module, className);
  if (clas == NULL) return NULL;

  return findMethod(clas, isStatic, signature);
}
コード例 #12
0
ファイル: VM.cpp プロジェクト: relrod/magpie
  void VM::bindClass(const char* module, CoreClass core, const char* name)
  {
    ASSERT_INDEX(core, CLASS_MAX);
    ASSERT(coreClasses_[core].isNull(), "Class is already bound.");

    Module* moduleObj = findModule(module);
    ASSERT_NOT_NULL(moduleObj);
    
    gc<Object> value = moduleObj->getVariable(name);
    ASSERT(!value.isNull(), "Could not find variable.");

    coreClasses_[core] = asClass(value);
  }
コード例 #13
0
ファイル: VM.cpp プロジェクト: relrod/magpie
  void VM::printUncaughtError(gc<Fiber> fiber, gc<Object> error)
  {
    // Lazy lookup the error channel.
    if (errorChannel_.isNull())
    {
      Module* core = findModule("core");
      ASSERT_NOT_NULL(core);

      errorChannel_ = asChannel(core->getVariable("_errorChannel"));
    }

    // Send the error to the error-printing fiber and suspend the erroring one.
    errorChannel_->send(fiber, error);
  }
コード例 #14
0
ファイル: Loader.c プロジェクト: dmpots/lambdachine
// Postorder traversal
void
loadModule_aux(const char *moduleName, u4 level)
{
  char     *filename;
  Module   *mdl;
  FILE     *f;
  int       i;

  mdl = (Module*)HashTable_lookup(G_loader->loadedModules, moduleName);

  if (mdl != NULL) {
    // Module is either already loaded, or currently in process of
    // being loaded.
      return;
  }

  filename = findModule(moduleName);

  for (i = 0; i < level; i++) fputc(' ', stderr);
  fprintf(stderr, "> Loading %s ...(%s)\n", moduleName, filename);

  f = fopen(filename, "rb");
  if (f == NULL) {
    fprintf(stderr, "ERROR: Could not open file: %s\n",
            filename);
    exit(14);
  }

  mdl = loadModuleHeader(f, filename);

  HashTable_insert(G_loader->loadedModules, moduleName, mdl);

  // Load dependencies first.  This avoids creating many forward
  // references.  The downside is that we keep more file descriptors
  // open.
  for (i = 0; i < mdl->numImports; i++)
    loadModule_aux(mdl->imports[i], level + 1);

  loadModuleBody(filename, f, mdl);

  fclose(f);

  // We now don't need the string table anymore.
  xfree(mdl->strings);
  mdl->strings = NULL;

  for (i = 0; i < level; i++) fputc(' ', stderr);
  fprintf(stderr, "< DONE   (%s)\n", moduleName);
}
コード例 #15
0
static void my_memo_lang(User * u, char *name, int z, char *source, int number, ...)
{
    va_list va;
    char buffer[4096], outbuf[4096];
    char *fmt = NULL;
    int lang = LANG_EN_US;
    char *s, *t, *buf;
    User *u2;

    if ((mod_current_module_name)
        && (!mod_current_module
            || strcmp(mod_current_module_name, mod_current_module->name)))
        mod_current_module = findModule(mod_current_module_name);

    u2 = finduser(name);
    /* Find the users lang, and use it if we cant */
    if (u2 && u2->na && u2->na->nc)
        lang = u2->na->nc->language;

    /* If the users lang isnt supported, drop back to enlgish */
    if (mod_current_module->lang[lang].argc == 0)
        lang = LANG_EN_US;

    /* If the requested lang string exists for the language */
    if (mod_current_module->lang[lang].argc > number) {
        fmt = mod_current_module->lang[lang].argv[number];

        buf = sstrdup(fmt);
        s = buf;
        while (*s) {
            t = s;
            s += strcspn(s, "\n");
            if (*s)
                *s++ = '\0';
            strscpy(outbuf, t, sizeof(outbuf));

            va_start(va, number);
            vsnprintf(buffer, 4095, outbuf, va);
            va_end(va);
            if (source)
                memo_send_from(u, name, buffer, z, source);
            else
                memo_send(u, name, buffer, z);
        }
        free(buf);
    } else {
        alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name, lang, number);
    }
}
コード例 #16
0
ファイル: modules.c プロジェクト: Rohansi/wren
WrenForeignClassMethods bindBuiltInForeignClass(
    WrenVM* vm, const char* moduleName, const char* className)
{
  WrenForeignClassMethods methods = { NULL, NULL };

  ModuleRegistry* module = findModule(moduleName);
  if (module == NULL) return methods;

  ClassRegistry* clas = findClass(module, className);
  if (clas == NULL) return methods;

  methods.allocate = findMethod(clas, true, "<allocate>");
  methods.finalize = findMethod(clas, true, "<finalize>");

  return methods;
}
コード例 #17
0
ファイル: FitLog.cpp プロジェクト: panyfx/mediaServer
/*******************************************************************************
*
* 函数名称:getModPriority
* 函数功能:获取模块日志记录优先级
* 参数说明:sModName: 模块名
nPriority[out]: 模块的日志记录优先级
* 返回值说明:0-表示执行成功; -1-表示执行失败
* 修改列表:(YYYY-MM-DD hh:mm by xxxx)
* 相关性说明:
* 其他:
*
******************************************************************************/
int CFitLog::getModPriority(const string sModName, int& nPriority)
{
	/*在m_vectorModInfo里查找pcModName是否已经注册*/

	int nModId;
	nModId = findModule(sModName);

	/*该模块没有注册*/
	if (nModId == -1)
	{
		cout << "getModPriority: " << sModName << " has not registered." << endl;
		return -1;
	}

	nPriority = m_vectorModInfo[nModId].nPriority;
	return 0;
}
コード例 #18
0
ファイル: import.cpp プロジェクト: nanwu/pyston
static Box* importSub(const std::string& name, BoxedString* full_name, Box* parent_module) {
    BoxedDict* sys_modules = getSysModulesDict();
    if (sys_modules->d.find(full_name) != sys_modules->d.end()) {
        return sys_modules->d[full_name];
    }

    BoxedList* path_list;
    if (parent_module == NULL || parent_module == None) {
        path_list = NULL;
    } else {
        static BoxedString* path_str = internStringImmortal("__path__");
        path_list = static_cast<BoxedList*>(getattrInternal<ExceptionStyle::CXX>(parent_module, path_str));
        if (path_list == NULL || path_list->cls != list_cls) {
            return None;
        }
    }

    SearchResult sr = findModule(name, full_name, path_list);

    if (sr.type != SearchResult::SEARCH_ERROR) {
        Box* module;

        try {
            if (sr.type == SearchResult::PY_SOURCE)
                module = createAndRunModule(full_name, sr.path);
            else if (sr.type == SearchResult::PKG_DIRECTORY)
                module = createAndRunModule(full_name, sr.path + "/__init__.py", sr.path);
            else if (sr.type == SearchResult::C_EXTENSION)
                module = importCExtension(full_name, name, sr.path);
            else if (sr.type == SearchResult::IMP_HOOK) {
                static BoxedString* loadmodule_str = internStringImmortal("load_module");
                CallattrFlags callattr_flags{.cls_only = false,
                                             .null_on_nonexistent = false,
                                             .argspec = ArgPassSpec(1) };
                module = callattr(sr.loader, loadmodule_str, callattr_flags, full_name, NULL, NULL, NULL, NULL);
            } else
                RELEASE_ASSERT(0, "%d", sr.type);
        } catch (ExcInfo e) {
            removeModule(full_name);
            throw e;
        }

        if (parent_module && parent_module != None)
            parent_module->setattr(internStringMortal(name), module, NULL);
        return module;
    }
コード例 #19
0
ファイル: mal_module.c プロジェクト: cran/MonetDBLite
/*
 * After filling in a structure it is added to the multi-level symbol
 * table.  We keep a skip list of similarly named function symbols.
 * This speeds up searching provided the modules adhere to the
 * structure and group the functions as well.
 */
void insertSymbol(Module scope, Symbol prg){
	InstrPtr sig;
	int t;
	Module c;

	assert(scope);
	sig = getSignature(prg);
#ifdef _DEBUG_MODULE_
	fprintf(stderr,"#insertSymbol: %s.%s in %s ", getModuleId(sig), getFunctionId(sig), scope->name);
#endif
	if(getModuleId(sig) && getModuleId(sig)!= scope->name){
		/* move the definition to the proper place */
		/* default scope is the last resort */
		c= findModule(scope,getModuleId(sig));
		if ( c )
			scope = c;
#ifdef _DEBUG_MODULE_
	fprintf(stderr," found alternative module %s ", scope->name);
#endif
	}
	t = getSymbolIndex(getFunctionId(sig));
	if( scope->space == NULL) {
		scope->space = (Symbol *) GDKzalloc(MAXSCOPE * sizeof(Symbol));
		if (scope->space == NULL)
			return;
	}
	assert(scope->space);
	if (scope->space[t] == prg){
		/* already known, last inserted */
#ifdef _DEBUG_MODULE_
	fprintf(stderr," unexpected double insert  ");
#endif
	} else {
		prg->peer= scope->space[t];
		scope->space[t] = prg;
		if( prg->peer &&
			idcmp(prg->name,prg->peer->name) == 0)
			prg->skip = prg->peer->skip;
		else
			prg->skip = prg->peer;
	}
	assert(prg != prg->peer);
#ifdef _DEBUG_MODULE_
	fprintf(stderr,"\n");
#endif
}
コード例 #20
0
ファイル: debug_renderdoc.cpp プロジェクト: CallmeNezha/bgfx
	void* loadRenderDoc()
	{
		if (NULL != s_renderDoc)
		{
			return s_renderDocDll;
		}

		// Skip loading RenderDoc when IntelGPA is present to avoid RenderDoc crash.
		if (findModule(BX_ARCH_32BIT ? "shimloader32.dll" : "shimloader64.dll") )
		{
			return NULL;
		}

		void* renderDocDll = bx::dlopen("renderdoc.dll");

		if (NULL != renderDocDll)
		{
			RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)bx::dlsym(renderDocDll, "RENDERDOC_GetAPI");
			if (NULL != RENDERDOC_GetAPI
			&&  1 == RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_1_0, (void**)&s_renderDoc) )
			{
				s_renderDoc->SetLogFilePathTemplate(BGFX_CONFIG_RENDERDOC_LOG_FILEPATH);

 				s_renderDoc->SetFocusToggleKeys(NULL, 0);

				RENDERDOC_InputButton captureKeys[] = BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS;
				s_renderDoc->SetCaptureKeys(captureKeys, BX_COUNTOF(captureKeys) );

				s_renderDoc->SetCaptureOptionU32(eRENDERDOC_Option_AllowVSync,      1);
				s_renderDoc->SetCaptureOptionU32(eRENDERDOC_Option_SaveAllInitials, 1);

				s_renderDoc->MaskOverlayBits(eRENDERDOC_Overlay_None, eRENDERDOC_Overlay_None);

				s_renderDocDll = renderDocDll;
			}
			else
			{
				bx::dlclose(renderDocDll);
				renderDocDll = NULL;
			}
		}

		return renderDocDll;
	}
コード例 #21
0
ファイル: opt_macro.c プロジェクト: jaiminpan/Monetdb
int
OPTorcamImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	MalBlkPtr target= mb;
	Module s;
	Symbol t;
	str mod,fcn;
	int j;
	str msg;

	(void) cntxt;
	(void) stk;

	if( p->argc == 3){
		mod= getArgDefault(mb,p,1);
		fcn= getArgDefault(mb,p,2);
	} else {
		mod= getArgDefault(mb,p,1);
		fcn= getArgDefault(mb,p,2);
		t= findSymbol(cntxt->nspace, putName(mod, strlen(mod)), fcn);
		if( t == 0)
			return 0;
		target= t->def;
		mod= getArgDefault(mb,p,3);
		fcn= getArgDefault(mb,p,4);
	}
	s = findModule(cntxt->nspace, putName(mod, strlen(mod)));
	if (s == 0)
		return 0;
	if (s->subscope) {
		j = getSubScope(fcn);
		for (t = s->subscope[j]; t != NULL; t = t->peer)
			if (t->def->errors == 0) {
				if (getSignature(t)->token == FUNCTIONsymbol) {
					msg =ORCAMprocessor(cntxt, target, t);
					if( msg) GDKfree(msg);
				}
			}
	}
	return 1;
}
コード例 #22
0
ファイル: prosac.c プロジェクト: gciotto/workspace
void processCommand(enum command command, uint8_t *buffer, uint16_t length) {

    int j;

    switch(command) {

    case IDENT:

        for(int i = 2; i < 32 + 2; ++i)	{

            module_t m = findModule(buffer[i]);

            if(m.type != NONE.type)
                addBoard (m, i - 2);
        }

        if(buffer[1] > 32)
            for (int i = 0; i < 6; i++)
                version[i] = buffer[34 + i];

        setVersion(version);
        break;

    default:

        j = 2;

        for (int i = 0; i < pboards_c; i++) {

            if (j + pboards[i].board.module.readBytesCount + 2 <= length)
                for (int w = 0; w < pboards[i].board.module.readBytesCount + 2; w++) {
                    pboards[i].board.readBytes[w] = buffer[j];
                    j = j + 1;
                }
        }

        break;
    }
}
コード例 #23
0
ファイル: ss_modules.c プロジェクト: wodim/irc-hispano
int do_modinfo(User * u, int ac, char **av)
{
    struct tm tm;
    char timebuf[64];
    Module *m;
    int idx = 0;
    int display = 0;

    if (ac < 1) {
        syntax_error(s_StatServ, u, "MODINFO", STAT_MODULE_INFO_SYNTAX);
        return MOD_CONT;
    }
    m = findModule(av[0]);
    if (m) {
#ifdef _WIN32
        localtime_s(&tm, &m->time);
#else
        tm = *localtime(&m->time);
#endif
        strftime_lang(timebuf, sizeof(timebuf), u,
                      STRFTIME_DATE_TIME_FORMAT, &tm);
        notice_lang(s_StatServ, u, STAT_MODULE_INFO_LIST, m->name,
                    m->version ? m->version : "?",
                    m->author ? m->author : "?", timebuf);
        for (idx = 0; idx < MAX_CMD_HASH; idx++) {
            display += showModuleCmdLoaded(STATSERV[idx], m->name, u);
            display += showModuleMsgLoaded(IRCD[idx], m->name, u);

        }
        if (m->type == PROTOCOL) {
            display++;
        }
    }
    if (display == 0) {
        notice_lang(s_StatServ, u, STAT_MODULE_NO_INFO, av[0]);
    }
    return MOD_CONT;
}
コード例 #24
0
ファイル: ircd_chanurl.c プロジェクト: Elemental-IRCd/anope
int AnopeInit(int argc, char **argv)
{
        EvtHook *hook;

        hook = createEventHook(EVENT_JOIN_CHANNEL, do_chanurl);
        if (moduleAddEventHook(hook) != MOD_ERR_OK) {
        alog("Can't hook to EVENT_JOIN_CHANNEL event");
        return MOD_STOP;
     }

        alog("Loading ircd_chanurl");

        if (findModule("os_raw")) {
                alog("I found os_raw loaded!, Sorry it didn't work out.");
                return MOD_STOP;
        }

        moduleAddAuthor(AUTHOR);
        moduleAddVersion(VERSION);

    return MOD_CONT;

}
コード例 #25
0
ファイル: FitLog.cpp プロジェクト: panyfx/mediaServer
/*******************************************************************************
*
* 函数名称:registerMod
* 函数功能:注册一个应用模块
* 参数说明:sModName: 应用模块名称,在记录日志时会使用该名称
* 返回值说明:应用模块id,可以在其他函数(如:CFitLog::log)里使用,
如果失败则返回-1
* 修改列表:(YYYY-MM-DD hh:mm by xxxx)
* 相关性说明:
* 其他:
*
******************************************************************************/
int CFitLog::registerMod(const string sModName)
{
	int nModId;

	/*在m_vectorModInfo里查找sModName是否已经注册*/
	nModId = findModule(sModName);

	/*该模块已经注册*/
	if (nModId != -1)
	{
		cout << "registerMod: " << sModName << "has been registered." << endl;
		return -1;
	}

	/*在m_vectorModInfo里添加一条记录*/
	ModInfo_t stModInfo;
	stModInfo.sModName = sModName;
	stModInfo.nModId = m_nModId++;
	stModInfo.nPriority = LOG_TYPE_DEBUG;
	m_vectorModInfo.push_back(stModInfo);

	return stModInfo.nModId;
}
コード例 #26
0
ファイル: renderdoc.cpp プロジェクト: AndrewWillmottSI/bgfx
	void* loadRenderDoc()
	{
		// Skip loading RenderDoc when IntelGPA is present to avoid RenderDoc crash.
		if (findModule(BX_ARCH_32BIT ? "shimloader32.dll" : "shimloader64.dll") )
		{
			return NULL;
		}

		void* renderdocdll = bx::dlopen("renderdoc.dll");

		if (NULL != renderdocdll)
		{
			RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)bx::dlsym(renderdocdll, "RENDERDOC_GetAPI");
			if (NULL != RENDERDOC_GetAPI
			&&  1 == RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_0_0, (void**)&s_renderDoc) )
			{
				s_renderDoc->SetLogFilePathTemplate("temp/bgfx");

 				s_renderDoc->SetFocusToggleKeys(NULL, 0);

				RENDERDOC_InputButton captureKey = eRENDERDOC_Key_F11;
				s_renderDoc->SetCaptureKeys(&captureKey, 1);

				s_renderDoc->SetCaptureOptionU32(eRENDERDOC_Option_AllowVSync,      1);
				s_renderDoc->SetCaptureOptionU32(eRENDERDOC_Option_SaveAllInitials, 1);

				s_renderDoc->MaskOverlayBits(eRENDERDOC_Overlay_None, eRENDERDOC_Overlay_None);
			}
			else
			{
				bx::dlclose(renderdocdll);
				renderdocdll = NULL;
			}
		}

		return renderdocdll;
	}
コード例 #27
0
IModule* ModuleManager::load( const std::string& moduleName )
{
	SystemState systemState = getSystem()->getState();

	if( systemState < SystemState_Initializing )
		throw IllegalStateException( "cannot load modules before the system is set up" );

	if( systemState > SystemState_Running )
		throw IllegalStateException( "cannot load modules while the system is being torn down" );

	if( _loaders.empty() )
		throw ModuleLoadException( "there are no installed module loaders" );

	// check if the module was already loaded
	IModule* alreadyLoaded = findModule( moduleName );
	if( alreadyLoaded )
		return alreadyLoaded;

	/*
		Load and initialize ModuleParts. Notice that once we initialize a part,
		it may register a new ModulePartLoader that must also be considered.
	 */

	// the IModule is created on demand
	Module* module = NULL;

	// for error handling: whether a part was being loaded (true) or initialized (false)
	bool wasLoading = true;

	try
	{
		size_t numLoaders = _loaders.size();
		for( size_t i = 0; i < numLoaders; ++i )
		{
			IModulePartLoader* loader = _loaders[i].get();
			if( !loader->canLoadModulePart( moduleName ) )
				continue;

			// load the module part
			wasLoading = true;

			RefPtr<IModulePart> part( loader->loadModulePart( moduleName ) );
			if( !part.isValid() )
				throw ModuleLoadException( "loader returned a null IModulePart" );

			if( !module )
				module = createModule( moduleName );
			module->addPart( part.get() );

			// initialize the module part
			wasLoading = false;
			part->initialize( module );

			// this module part may have added a new IModulePartLoader
			size_t newNumLoaders = _loaders.size();
			assert( newNumLoaders >= numLoaders );
			numLoaders = newNumLoaders;
		}
	}
	catch( std::exception& e )
	{
		// any error while loading or initializing a part aborts the whole module
		if( module )
			module->abort();

		std::stringstream ss;
		if( wasLoading )
			ss << "error loading module '" << moduleName << "': ";
		else
			ss << "exception raised by module '" << moduleName << "' during initialization: ";
		ss << e.what();

		throw ModuleLoadException( ss.str() );
	}

	if( !module )
	{
		CORAL_THROW( ModuleLoadException, "no module loader recognized '" << moduleName <<
			"' as a module (perhaps it was not compiled in " CORAL_BUILD_MODE " mode?)" );
	}

	module->initialize();
	syncModuleWithSystemState( module );

	return module;
}
コード例 #28
0
ファイル: mal_module.c プロジェクト: cran/MonetDBLite
Symbol findSymbol(Module usermodule, str mod, str fcn) {
	Module m = findModule(usermodule, mod);
	return findSymbolInModule(m, fcn);
}
コード例 #29
0
ファイル: events.c プロジェクト: Elemental-IRCd/anope
void event_message_process(char *eventbuf)
{
    int retVal = 0;
    EvtMessage *current = NULL;
    char source[64];
    char cmd[64];
    char buf[512];              /* Longest legal IRC command line */
    char *s;
    int ac;                     /* Parameters for the command */
    char **av;
    EvtMessage *evm;

    /* zero out the buffers before we do much else */
    *buf = '\0';
    *source = '\0';
    *cmd = '\0';

    strscpy(buf, eventbuf, sizeof(buf));

    doCleanBuffer((char *) buf);

    /* Split the buffer into pieces. */
    if (*buf == ':') {
        s = strpbrk(buf, " ");
        if (!s)
            return;
        *s = 0;
        while (isspace(*++s));
        strscpy(source, buf + 1, sizeof(source));
        memmove(buf, s, strlen(s) + 1);
    } else {
        *source = 0;
    }
    if (!*buf)
        return;
    s = strpbrk(buf, " ");
    if (s) {
        *s = 0;
        while (isspace(*++s));
    } else
        s = buf + strlen(buf);
    strscpy(cmd, buf, sizeof(cmd));
    ac = split_buf(s, &av, 1);

    /* Do something with the message. */
    evm = find_event(cmd);
    if (evm) {
        char *mod_current_module_name_save = mod_current_module_name;
        Module *mod_current_module_save = mod_current_module;
        if (evm->func) {
            mod_current_module_name = evm->mod_name;
            mod_current_module = findModule(evm->mod_name);
            retVal = evm->func(source, ac, av);
            if (retVal == MOD_CONT) {
                current = evm->next;
                while (current && current->func && retVal == MOD_CONT) {
                    mod_current_module_name = current->mod_name;
                    mod_current_module = findModule(current->mod_name);
                    retVal = current->func(source, ac, av);
                    current = current->next;
                }
            }
            mod_current_module_name = mod_current_module_name_save;
            mod_current_module = mod_current_module_save;
        }
    }
    /* Free argument list we created */
    free(av);
}
コード例 #30
0
ファイル: modrepo.c プロジェクト: Zirias/c64_tool_mkd64
static IModule *
createInstanceHere(ModRepo *self, ModEntry *entry)
{
    ModEntry *otherMod;
    const char **otherModId;
    IModule *created;

    if (entry->conflicted)
    {
        fprintf(stderr,
"Error: cannot load module `%s' because an already loaded module conflicts\n"
"       with it.\n", entry->id);
        return 0;
    }

    if (entry->conflicts)
    {
        for (otherModId = entry->conflicts; *otherModId; ++otherModId)
        {
            if (findInstContainer(self, *otherModId))
            {
                fprintf(stderr,
"Error: cannot load module `%s' because it conflicts with already loaded\n"
"       module `%s'.\n", entry->id, *otherModId);
                return 0;
            }
            otherMod = findModule(self, *otherModId);
            if (otherMod)
            {
                otherMod->conflicted = 1;
            }
        }
    }

    if (entry->depends)
    {
        for (otherModId = entry->depends; *otherModId; ++otherModId)
        {
            otherMod = findModule(self, *otherModId);
            if (!otherMod)
            {
                fprintf(stderr,
"Error: cannot load module `%s' because it depends on `%s' which is not\n"
"       available.\n", entry->id, *otherModId);
                return 0;
            }
            if (!findInstContainer(self, *otherModId))
            {
                fprintf(stderr, "Info: loading module `%s' "
                        "because `%s' depends on it.\n",
                        otherMod->id, entry->id);
                if (!createInstanceHere(self, otherMod))
                {
                    fprintf(stderr,
"Error: cannot load module `%s' because its dependency `%s' failed to load.",
                            entry->id, otherMod->id);
                    return 0;
                }
            }
        }
    }

    created = entry->instance();
    if (created)
    {
        appendInstance(self, created);
        self->callback(self->owner, created);
        return created;
    }
    return 0;
}