ProxyWidget *DockContainer::loadModule(ConfigModule *module) { QApplication::setOverrideCursor(waitCursor); ProxyWidget *widget = _modulew->load(module); if(widget) { _module = module; connect(_module, SIGNAL(childClosed()), SLOT(removeModule())); connect(_module, SIGNAL(changed(ConfigModule *)), SIGNAL(changedModule(ConfigModule *))); connect(widget, SIGNAL(quickHelpChanged()), SLOT(quickHelpChanged())); raiseWidget(_modulew); emit newModule(widget->caption(), module->docPath(), widget->quickHelp()); } else { raiseWidget(_basew); emit newModule(_basew->caption(), "", ""); } QApplication::restoreOverrideCursor(); return widget; }
void DockContainer::removeModule() { raiseWidget(_basew); deleteModule(); if(_basew) emit newModule(_basew->caption(), "", ""); else emit newModule("", "", ""); }
/* * Forking is a relatively cheap way to create a new client. The new * client record shares the IO descriptors. To avoid interference, we * limit children to only produce output by closing the input-side. * * If the father itself is a temporary client, let the new child depend * on the grandfather. */ Client MCforkClient(Client father) { Client son = NULL; if (father == NULL) return NULL; if (father->father != NULL) father = father->father; if ((son = MCinitClient(father->user, father->fdin, father->fdout))) { son->fdin = NULL; son->fdout = father->fdout; son->bak = NULL; son->yycur = 0; son->father = father; son->scenario = father->scenario; if (son->prompt) GDKfree(son->prompt); son->prompt = GDKstrdup(father->prompt); son->promptlength = strlen(father->prompt); /* reuse the scopes wherever possible */ if (son->nspace == 0) son->nspace = newModule(NULL, putName("child", 5)); son->nspace->outer = father->nspace->outer; } return son; }
/* * The MonetDB server uses a startup script to boot the system. * This script is an ordinary MAL program, but will mostly * consist of include statements to load modules of general interest. * The startup script is run as user Admin. */ int malBootstrap(void) { Client c; str msg, bootfile = "mal_init", s; c = MCinitClient((oid) 0, 0, 0); assert(c != NULL); c->nspace = newModule(NULL, putName("user", 4)); initLibraries(); if ( (msg = defaultScenario(c)) ) { GDKfree(msg); GDKerror("Failed to initialise default scenario"); return 0; } MSinitClientPrg(c, "user", "main"); (void) MCinitClientThread(c); s = malInclude(c, bootfile, 0); if (s != NULL) { mnstr_printf(GDKout, "!%s\n", s); GDKfree(s); return 0; } pushEndInstruction(c->curprg->def); chkProgram(c->fdout, c->nspace, c->curprg->def); if (c->curprg->def->errors) showErrors(c); s = MALengine(c); if (s) GDKfree(s); return 1; }
/* * HandleLibLoad - process library loaded */ void HandleLibLoad( int type, HANDLE hmod ) { static MODULEENTRY me; if( MyModuleFindHandle( &me, hmod ) ) { newModule( hmod, me.szExePath, type ); } } /* HandleLibLoad */
void DockContainer::setBaseWidget(QWidget *widget) { removeWidget( _basew ); delete _basew; _basew = 0; if (!widget) return; _basew = widget; addWidget( _basew ); raiseWidget( _basew ); emit newModule(widget->caption(), "", ""); }
/** * Open a file and set it as the current listened file. */ void MainWindow::setCurrentFile(QString file) { this->closeCurrentFile(); disconnect(&this->model, SIGNAL(newLogEntries(int)), 0, 0); this->currentFile = new QFile(this->currentDir.absolutePath() + '/' + file); if (currentFile->exists() && this->currentFile->open(QIODevice::ReadOnly)) { this->model.setDataSource(this->currentFile); this->refreshFilters(); // New messages can be logged after the file is loaded, thus some new severities/modules/threads can appear. connect(&this->model, SIGNAL(newSeverity(QString)), this->severities, SLOT(addItem(const QString&))); connect(&this->model, SIGNAL(newModule(QString)), this->modules, SLOT(addItem(const QString&))); connect(&this->model, SIGNAL(newThread(QString)), this->threads, SLOT(addItem(const QString&))); this->ui->tblLog->scrollToBottom(); connect(&this->model, SIGNAL(newLogEntries(int)), this, SLOT(newLogEntries(int))); }
/** * Determine all loaded modules as well as the process module itself for the given process id. */ NaviError LinuxSystem::fillModules(pid_t pid, ModulesMap& modules) { std::string filename = "/proc/" + zylib::zycon::toString(pid) + "/maps"; msglog->log(LOG_ALL, "Trying to read the modules map from file %s", filename.c_str()); std::ifstream file(filename.c_str()); if (!file) { msglog->log(LOG_ALWAYS, "Error: Couldn't read modules map file"); return NaviErrors::COULDNT_READ_MEMORY; } std::vector < std::string > lines; std::string line; while (std::getline(file, line)) { msglog->log(LOG_ALL, "Successfully read line %s from modules map file", line.c_str()); lines.push_back(line); } // 08048000-08053000 r-xp 00000000 08:01 282412 /usr/bin/kdeinit // 08053000-08054000 r--p 0000a000 08:01 282412 /usr/bin/kdeinit // 08054000-08055000 rw-p 0000b000 08:01 282412 /usr/bin/kdeinit // 09f73000-0a016000 rw-p 09f73000 00:00 0 [heap] // b6638000-b6672000 rw-p b6672000 00:00 0 // b66bb000-b66d9000 r-xp 00000000 08:01 352021 /usr/lib/kde3/plugins/styles/plastik.so // b66d9000-b66da000 r--p 0001d000 08:01 352021 /usr/lib/kde3/plugins/styles/plastik.so // b66da000-b66db000 rw-p 0001e000 08:01 352021 /usr/lib/kde3/plugins/styles/plastik.so // b66db000-b66e1000 r--s 00000000 08:01 396230 /var/cache/fontconfig/945677eb7aeaf62f1d50efc3fb3ec7d8-x86.cache-2 // b66e1000-b66e4000 r--s 00000000 08:01 396239 /var/cache/fontconfig/e383d7ea5fbe662a33d9b44caf393297-x86.cache-2 // b66e4000-b66e5000 r--s 00000000 08:01 396225 /var/cache/fontconfig/4c73fe0c47614734b17d736dbde7580a-x86.cache-2 // b66e5000-b66e8000 r--s 00000000 08:01 396231 /var/cache/fontconfig/a755afe4a08bf5b97852ceb7400b47bc-x86.cache-2 // b66e8000-b66ef000 r--s 00000000 08:01 396608 /var/cache/fontconfig/6d41288fd70b0be22e8c3a91e032eec0-x86.cache-2 // b66ef000-b66f7000 r--s 00000000 08:01 396240 /var/cache/fontconfig/e3de0de479f42330eadf588a55fb5bf4-x86.cache-2 // b66f7000-b6702000 r--s 00000000 08:01 396220 /var/cache/fontconfig/0f34bcd4b6ee430af32735b75db7f02b-x86.cache-2 // b6702000-b6709000 r--s 00000000 08:01 396234 /var/cache/fontconfig/d52a8644073d54c13679302ca1180695-x86.cache-2 std::string lastName = ""; CPUADDRESS start = 0; CPUADDRESS end = 0; for (std::vector<std::string>::iterator Iter = lines.begin(); Iter != lines.end(); ++Iter) { std::string line = *Iter; size_t position = line.find("/"); if (position != std::string::npos) { // OK, we found a line with a name; now we gotta figure out if we found a new module // or just with a new section in the same module. std::string name = line.substr(position); // TODO: Only works in 32bit platforms std::string startString = Iter->substr(0, 8); std::string endString = Iter->substr(9, 8); if (name != lastName) { // We found a new module, so we can take the information from the previous // module and add the previous module to the list of modules. if (lastName != "") { Module newModule(getModuleName(lastName), lastName, start, end - start); modules.insert(std::make_pair(lastName, newModule)); } lastName = name; start = zylib::zycon::parseHexString < CPUADDRESS > (startString); end = zylib::zycon::parseHexString < CPUADDRESS > (endString); } else { // The module in the current line is the same module we already processed // in the previous line. Only the end information has to be updated in this // case. end = zylib::zycon::parseHexString < CPUADDRESS > (endString); } } else if (lastName != "") { // We found a line without a name and the previous module has // a valid name => Add the previous module to the list of modules. Module newModule(getModuleName(lastName), lastName, start, end - start); modules.insert(std::make_pair(lastName, newModule)); lastName = ""; } } if (lastName != "") { // Add the last module in the list. Module newModule(getModuleName(lastName), lastName, start, end - start); modules.insert(std::make_pair(lastName, newModule)); } return NaviErrors::SUCCESS; }
static rpmRC processPolicies(rpmSpec spec, Package pkg, int test) { const char *path = NULL; char *name = NULL; char *types = NULL; uint32_t flags = 0; poptContext optCon = NULL; rpmRC rc = RPMRC_FAIL; struct poptOption optionsTable[] = { {"name", 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL}, {"types", 't', POPT_ARG_STRING, &types, 't', NULL, NULL}, {"base", 'b', POPT_ARGFLAG_OR, &flags, RPMPOL_FLAG_BASE, NULL, NULL}, POPT_TABLEEND }; if (!spec || !pkg) { goto exit; } for (ARGV_const_t pol = pkg->policyList; *pol != NULL; pol++) { ModuleRec mod; const char *line = *pol; const char **argv = NULL; int argc = 0; int err; if ((err = poptParseArgvString(line, &argc, &argv))) { rpmlog(RPMLOG_ERR, _("Error parsing %s: %s\n"), line, poptStrerror(err)); goto exit; } if (!rstreq(argv[0], "%semodule")) { rpmlog(RPMLOG_ERR, _("Expecting %%semodule tag: %s\n"), line); goto exit; } optCon = poptGetContext(NULL, argc, argv, optionsTable, 0); while (poptGetNextOpt(optCon) > 0) { } path = poptGetArg(optCon); if (!path) { rpmlog(RPMLOG_ERR, _("Missing module path in line: %s\n"), line); goto exit; } if (poptPeekArg(optCon)) { rpmlog(RPMLOG_ERR, _("Too many arguments in line: %s\n"), line); goto exit; } mod = newModule(path, name, types, flags); if (!mod) { goto exit; } if (writeModuleToHeader(mod, pkg) != RPMRC_OK) { freeModule(mod); goto exit; } freeModule(mod); } rc = RPMRC_OK; exit: return rc; }
void DockContainer::quickHelpChanged() { if(_module && _module->module()) emit newModule(_module->module()->caption(), _module->docPath(), _module->module()->quickHelp()); }
void Interpreter::loadModuleRecursive (const string &moduleName) { debug ("Interpreter::loadModuleRecursive " "(moduleName = " << moduleName << ")"); if (moduleIsLoadedInternal (moduleName)) { debug ("\talready loaded"); return; } // // Using the module search path, locate the file that contains the // source code for the module. Open the file. // string fileName = findModule (moduleName); ifstream file (fileName.c_str()); if (!file) { THROW_ERRNO ("Cannot load CTL module \"" << moduleName << "\". " "Opening file \"" << fileName << "\" for reading " "failed (%T)."); } debug ("\tloading from file \"" << fileName << "\""); Module *module = 0; LContext *lcontext = 0; try { // // Create a Module, an Lcontext and a Parser // module = newModule (moduleName, fileName); _data->moduleSet.addModule (module); lcontext = newLContext (file, module, _data->symtab); Parser parser (*lcontext, *this); // // Parse the source code and generate executable code // for the module // debug ("\tparsing input"); SyntaxNodePtr syntaxTree = parser.parseInput (); if (syntaxTree && lcontext->numErrors() == 0) { debug ("\tgenerating code"); syntaxTree->generateCode (*lcontext); } if (lcontext->numErrors() > 0) { lcontext->printDeclaredErrors(); THROW (LoadModuleExc, "Failed to load CTL module \"" << moduleName << "\"."); } // // Run the module's initialization code // debug ("\trunning module initialization code"); module->runInitCode(); // // Cleanup: the LContext and the module's local symbols // are no longer needed, but we keep the global symbols. // debug ("\tcleanup"); delete lcontext; _data->symtab.deleteAllLocalSymbols (module); } catch (...) { // // Something went wrong while loading the module, clean up // delete lcontext; _data->symtab.deleteAllSymbols (module); _data->moduleSet.removeModule (moduleName); throw; } }
void MSscheduleClient(str command, str challenge, bstream *fin, stream *fout) { char *user = command, *algo = NULL, *passwd = NULL, *lang = NULL; char *database = NULL, *s, *dbname; Client c; /* decode BIG/LIT:user:{cypher}passwordchal:lang:database: line */ /* byte order */ s = strchr(user, ':'); if (s) { *s = 0; mnstr_set_byteorder(fin->s, strcmp(user, "BIG") == 0); user = s + 1; } else { mnstr_printf(fout, "!incomplete challenge '%s'\n", user); exit_streams(fin, fout); GDKfree(command); return; } /* passwd */ s = strchr(user, ':'); if (s) { *s = 0; passwd = s + 1; /* decode algorithm, i.e. {plain}mypasswordchallenge */ if (*passwd != '{') { mnstr_printf(fout, "!invalid password entry\n"); exit_streams(fin, fout); GDKfree(command); return; } algo = passwd + 1; s = strchr(algo, '}'); if (!s) { mnstr_printf(fout, "!invalid password entry\n"); exit_streams(fin, fout); GDKfree(command); return; } *s = 0; passwd = s + 1; } else { mnstr_printf(fout, "!incomplete challenge '%s'\n", user); exit_streams(fin, fout); GDKfree(command); return; } /* lang */ s = strchr(passwd, ':'); if (s) { *s = 0; lang = s + 1; } else { mnstr_printf(fout, "!incomplete challenge, missing language\n"); exit_streams(fin, fout); GDKfree(command); return; } /* database */ s = strchr(lang, ':'); if (s) { *s = 0; database = s + 1; /* we can have stuff following, make it void */ s = strchr(database, ':'); if (s) *s = 0; } dbname = GDKgetenv("gdk_dbname"); if (database != NULL && database[0] != '\0' && strcmp(database, dbname) != 0) { mnstr_printf(fout, "!request for database '%s', " "but this is database '%s', " "did you mean to connect to monetdbd instead?\n", database, dbname); /* flush the error to the client, and abort further execution */ exit_streams(fin, fout); GDKfree(command); return; } else { str err; oid uid; sabdb *stats = NULL; Client root = &mal_clients[0]; /* access control: verify the credentials supplied by the user, * no need to check for database stuff, because that is done per * database itself (one gets a redirect) */ err = AUTHcheckCredentials(&uid, root, &user, &passwd, &challenge, &algo); if (err != MAL_SUCCEED) { mnstr_printf(fout, "!%s\n", err); exit_streams(fin, fout); GDKfree(err); GDKfree(command); return; } err = SABAOTHgetMyStatus(&stats); if (err != MAL_SUCCEED) { /* this is kind of awful, but we need to get rid of this * message */ fprintf(stderr, "!SABAOTHgetMyStatus: %s\n", err); if (err != M5OutOfMemory) GDKfree(err); mnstr_printf(fout, "!internal server error, " "please try again later\n"); exit_streams(fin, fout); GDKfree(command); return; } if (stats->locked == 1) { if (uid == 0) { mnstr_printf(fout, "#server is running in " "maintenance mode\n"); } else { mnstr_printf(fout, "!server is running in " "maintenance mode, please try again later\n"); exit_streams(fin, fout); SABAOTHfreeStatus(&stats); GDKfree(command); return; } } SABAOTHfreeStatus(&stats); c = MCinitClient(uid, fin, fout); if (c == NULL) { if ( MCshutdowninprogress()) mnstr_printf(fout, "!system shutdown in progress, please try again later\n"); else mnstr_printf(fout, "!maximum concurrent client limit reached " "(%d), please try again later\n", MAL_MAXCLIENTS); exit_streams(fin, fout); GDKfree(command); return; } /* move this back !! */ if (c->nspace == 0) { c->nspace = newModule(NULL, putName("user", 4)); c->nspace->outer = mal_clients[0].nspace->outer; } if ((s = setScenario(c, lang)) != NULL) { mnstr_printf(c->fdout, "!%s\n", s); mnstr_flush(c->fdout); GDKfree(s); c->mode = FINISHCLIENT; } if (!GDKgetenv_isyes(mal_enableflag) && (strncasecmp("sql", lang, 3) != 0 && uid != 0)) { mnstr_printf(fout, "!only the 'monetdb' user can use non-sql languages. " "run mserver5 with --set %s=yes to change this.\n", mal_enableflag); exit_streams(fin, fout); GDKfree(command); return; } } MSinitClientPrg(c, "user", "main"); GDKfree(command); /* NOTE ABOUT STARTING NEW THREADS * At this point we have conducted experiments (Jun 2012) with * reusing threads. The implementation used was a lockless array of * semaphores to wake up threads to do work. Experimentation on * Linux, Solaris and Darwin showed no significant improvements, in * most cases no improvements at all. Hence the following * conclusion: thread reuse doesn't save up on the costs of just * forking new threads. Since the latter means no difficulties of * properly maintaining a pool of threads and picking the workers * out of them, it is favourable just to start new threads on * demand. */ /* fork a new thread to handle this client */ mnstr_settimeout(c->fdin->s, 50, GDKexiting); MSserveClient(c); }
int register_module( std::vector<ModuleReg> & modules, ModuleMap & functions, std::vector<ModuleFunction> & timedfunctions, const char * moduleName ) { /* open the module with the name moduleName */ /* load the module (if possible) */ void * handle = NULL; char * error = NULL; if ( moduleName == NULL ){ syslog( LOG_ERR, "Unable to load Module, no module name given" ); return 0; } handle = dlopen( moduleName, RTLD_LAZY ); if ( handle == NULL ){ syslog( LOG_ERR, "Unable to load Module %s : %s", moduleName, dlerror() ); return 0; } error = dlerror(); /* clear any possible error handler */ /* now call the register_module function */ int ( *registerFunction )( std::vector<CommandFunctionPair> & ); registerFunction = ( int (*)( std::vector<CommandFunctionPair> &) ) dlsym( handle, "load" ); if ( (error = dlerror()) != NULL) { syslog( LOG_ERR, "Unable to load Module %s : Module lacks load method.", moduleName ); return 0; } ModuleReg newModule( moduleName, handle ); modules.push_back( newModule ); std::vector<CommandFunctionPair> pairs; (*registerFunction)( pairs ); for ( std::vector<CommandFunctionPair>::iterator funcref = pairs.begin(); funcref != pairs.end(); funcref++ ){ /* create the appropriate structure to place this information in */ ModuleFunction newFunction( funcref->function, handle, funcref->timeout, funcref->user_id, funcref->group_id, funcref->version, funcref->owner, funcref->logging); if ( newFunction.timeout != -1 ){ syslog( LOG_INFO, " Registering timed function : %s:%d", funcref->command.c_str(), newFunction.timeout ); timedfunctions.push_back( newFunction ); continue; } syslog( LOG_INFO, " Registering command : %s", funcref->command.c_str() ); if ( newFunction.version == 0 ){ syslog( LOG_ERR, "Unable to determine action for command \"%s\", skipping definition", funcref->command.c_str() ); continue; } if ( functions[ funcref->command ].version >= newFunction.version ){ syslog( LOG_WARNING, " Command \"%s\" already exists and is of later version \"%d\" (thisver:%d)", funcref->command.c_str(), functions[ funcref->command ].version, newFunction.version ); continue; } else if ( functions[ funcref->command ].version < newFunction.version && functions[ funcref->command ].version > 0 ){ syslog( LOG_WARNING, " Command \"%s\" is already defined but of an earlier version (%d), using this one instead (thisver:%d)", funcref->command.c_str(), functions[ funcref->command ].version, newFunction.version ); } functions[ funcref->command ] = newFunction; } return 1; }