/*! Main view's constructor, full of important stuff. Sets all global properties, sizing policy, connects important signals and slots, reads config file(s). */ CcfMain::CcfMain(CcfCommandLineParser *cmd, QWindow *parent) : QQuickView(parent), CcfError(), mCmdLnParser(cmd) { qmlRegisterType<CcfQmlBaseRosterMenu>("QmlBase", 0, 1, "BaseRosterMenu"); qmlRegisterType<CcfQmlBaseScenario>("QmlBase", 0, 1, "BaseScenario"); qmlRegisterType<CcfQmlBaseMap>("QmlBase", 0, 1, "Map"); qmlRegisterType<CcfQmlBaseUnit>("QmlBase", 0, 1, "BaseUnit"); qmlRegisterType<CcfQmlBaseSoldier>("QmlBase", 0, 1, "Soldier"); mLogger = new CcfLogger(this, mCmdLnParser->isDebug()); mGlobal = new CcfGlobal(this); mGameManager = new CcfGameManager(this); mEngineHelpers = new CcfEngineHelpers(this); initConfiguration(); rootContext()->setContextProperty("Global", mGlobal); rootContext()->setContextProperty("Config", mConfiguration); rootContext()->setContextProperty("GameManager", mGameManager); rootContext()->setContextProperty("EngineHelpers", mEngineHelpers); rootContext()->setContextProperty("Logger", mLogger); QString pwd = qApp->applicationDirPath() + "/"; rootContext()->setContextProperty("PWD", pwd); setResizeMode(QQuickView::SizeRootObjectToView); // connect(this, SIGNAL(sceneResized(QSize)), configuration, SLOT(windowResized(QSize))); connect(mConfiguration, SIGNAL(sizeModifiedInGame(int,int)), this, SLOT(forceViewportResize(int,int))); connect(engine(), SIGNAL(quit()), this, SLOT(quit())); connect(mConfiguration, SIGNAL(maximise()), this, SLOT(showMaximized())); connect(mConfiguration, SIGNAL(demaximise()), this, SLOT(showNormal())); connect(mGlobal, SIGNAL(disableQrc(QObject*)), this, SLOT(disableQrc(QObject*))); }
bool G2DConfiguration::checkForGLExtension(const char* searchName) { if (!s_inited) initConfiguration(); return s_glExtensionsString.find(String::format("%s ", searchName), true) >= 0; }
void initSubsystems(int argc, const char *argv[]) { initFilesystem(argc, argv); initScripting(); init_c_interface(); initConfiguration(argc, argv); initGame(); initVideo(); initAudio(); initInput(); }
int MatchingApplication::match() { try{ addOptions(); processArguments(); initConfiguration(); // Cleaning if(w_) delete w_; if(g1_) delete g1_; if(g2_) delete g2_; if(gl1_) delete gl1_; if(gl2_) delete gl2_; w_ = 0; g1_ = g2_ = 0; gl1_ = gl2_ = 0; // Check number of arguments QStringList args = positionalArguments(); if(args.size() != 2) Exception(QString("You must provide exactly two %1 (%2 given)").arg(isMultiMatching_?"directories":"graphs").arg(args.size())); // Loading weights and graphs w_ = new Weights(cfg_->substitution, cfg_->creation); if(isMultiMatching_) { gl1_ = new GraphList(QDir(args.at(0)), cfg_->ext); gl2_ = (args.at(0).compare(args.at(1)) == 0)? gl1_ : new GraphList(QDir(args.at(1)), cfg_->ext); } else { g1_ = new Graph(args.at(0)); g2_ = new Graph(args.at(1)); } initMatrix(); QThreadPool::globalInstance()->setMaxThreadCount(cfg_->parallelInstances); // Running the matching(s) if(isMultiMatching_) { for(auto i : *gl1_) for(auto j : *gl2_) if((gl1_ != gl2_) || (j->getIndex() > i->getIndex())) queue_.enqueue(qMakePair(i,j)); } else { queue_.enqueue(qMakePair(g1_, g2_)); } populate(); return exec(); } catch(std::exception &e) { error(e); } return EXIT_FAILURE; }
int main( int argc, char *argv[] ) { // init random number generator // ::srand( time(0) ); QApplication app(argc, argv); // Load singular instance of configuration manager // - to ensure access to stored configuration values we need // to set application name and organization name first... QCoreApplication::setApplicationName(PROGNAME); QCoreApplication::setOrganizationName(PROGNAME); QCoreApplication::setOrganizationDomain(PROGORGADOMAIN); ConfigManager & conf = ConfigManager::getInstance(); initLogger( conf ); initConfiguration( conf ); // Set text codec of translations to UTF-8 QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8")); const QString & localeConf = conf.getStringValue("main.language"); QString locale; if ( localeConf.isNull() || localeConf.isEmpty() || localeConf.compare("auto", Qt::CaseInsensitive ) == 0 ) { // if there is no configuration or configuration value is 'auto': lookup system locale locale = QLocale::system().name(); // this gives a string in form: "language_country" -> we need only "language"! // Note: Qt is missing a useful method to get the language code without country code! (probably I didn't see...) int underscoreIdx = locale.indexOf('_'); if ( underscoreIdx > 0 ) locale = locale.left( underscoreIdx ); } else locale = localeConf; QTranslator translator; if ( translator.load( QString("USBhubConnect_") + locale, QString("i18n") ) ) app.installTranslator(&translator); else printf("Cannot load translation files for locale: %s\n", locale.toUtf8().data() ); // Load main window - and core application mainFrame mf; mf.show(); // quit window event QObject::connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()) ); QObject::connect( qApp, SIGNAL(aboutToQuit()), &mf, SLOT(cleanUpAllStuff()) ); // Start event processing and wait for exit int res = app.exec(); return res; }
/** @brief The main top level init * * The main init function to be called from main.c before entering the main * loop. This function is simply a delegator to the finer grained special * purpose init functions. * * @author Fred Cooke */ void init(){ ATOMIC_START(); /* Disable ALL interrupts while we configure the board ready for use */ initPLL(); /* Set up the PLL and use it */ initIO(); /* TODO make this config dependent. Set up all the pins and modules to be in low power harmless states */ initAllPagedRAM(); /* Copy table and config blocks of data from flash to the paged ram blocks for fast data lookup */ initAllPagedAddresses(); /* Save the paged memory addresses to variables such that we can access them from another paged block with no warnings */ initVariables(); /* Initialise the rest of the running variables etc */ initFlash(); /* TODO, finalise this */ initECTTimer(); /* TODO move this to inside config in an organised way. Set up the timer module and its various aspects */ initPITTimer(); /* TODO ditto... */ initSCIStuff(); /* Setup the sci module(s) that we will use. */ initConfiguration(); /* TODO Set user/feature/config up here! */ initInterrupts(); /* still last, reset timers, enable interrupts here TODO move this to inside config in an organised way. Set up the rest of the individual interrupts */ ATOMIC_END(); /* Re-enable any configured interrupts */ }
MarkdownEditAreaWidget::MarkdownEditAreaWidget( MdCharmForm *mainForm, const QString &filePath, const QUrl &baseUrl ) : EditAreaWidget( filePath, AllowSaveAs | AllowSelectAll | AllowExportToHtml | AllowExportToODT | AllowExportToPdf | AllowPrint | AllowPreview | AllowFind | AllowSplit ), mainForm( mainForm ) { inited = false; // lastRevision = -2; this->baseUrl = baseUrl; em.setEditorType( EditorModel::MARKDOWN ); initGui(); initContent( filePath ); initConfiguration(); initPreviewerMatter(); initSignalsAndSlots(); }
void TopWin::writeConfiguration(ToplevelType t, int level, MusECore::Xml& xml) { if (!initInited) { printf ("WARNING: TopWin::writeConfiguration() called although the config hasn't been\n" " initalized! writing default configuration\n"); initConfiguration(); } xml.tag(level++, "topwin"); xml.intTag(level, "width", _widthInit[t]); xml.intTag(level, "height", _heightInit[t]); xml.strTag(level, "nonshared_toolbars", _toolbarNonsharedInit[t].toHex().data()); xml.strTag(level, "shared_toolbars", _toolbarSharedInit[t].toHex().data()); xml.intTag(level, "shares_when_free", _sharesWhenFree[t]); xml.intTag(level, "shares_when_subwin", _sharesWhenSubwin[t]); xml.intTag(level, "default_subwin", _defaultSubwin[t]); xml.etag(level, "topwin"); }
/** @brief The main top level init * * The main init function to be called from main.c before entering the main * loop. This function is simply a delegator to the finer grained special * purpose init functions. */ void init(){ ATOMIC_START(); /* Disable ALL interrupts while we configure the board ready for use */ initPLL(); /* Set up the PLL and use it */ initGPIO(); initPWM(); initADC(); initAllPagedRAM(); /* Copy table and config blocks of data from flash to the paged RAM blocks for fast data lookup */ initVariables(); /* Initialise the rest of the running variables etc */ initFlash(); /* TODO, finalise this */ initECTTimer(); /* TODO move this to inside config in an organised way. Set up the timer module and its various aspects */ // initPITTimer(); /* TODO ditto... */ initSCIStuff(); /* Setup the sci module(s) that we will use. */ initConfiguration(); /* TODO Set user/feature/config up here! */ #ifdef XGATE initXgate(); /* Fred is a legend, for good reason as of now */ #endif initInterrupts(); /* still last, reset timers, enable interrupts here TODO move this to inside config in an organised way. Set up the rest of the individual interrupts */ ATOMIC_END(); /* Re-enable any configured interrupts */ }
void TopWin::readConfiguration(ToplevelType t, MusECore::Xml& xml) { if (initInited==false) initConfiguration(); for (;;) { MusECore::Xml::Token token = xml.parse(); if (token == MusECore::Xml::Error || token == MusECore::Xml::End) break; const QString& tag = xml.s1(); switch (token) { case MusECore::Xml::TagStart: if (tag == "width") _widthInit[t] = xml.parseInt(); else if (tag == "height") _heightInit[t] = xml.parseInt(); else if (tag == "nonshared_toolbars") _toolbarNonsharedInit[t] = QByteArray::fromHex(xml.parse1().toAscii()); else if (tag == "shared_toolbars") _toolbarSharedInit[t] = QByteArray::fromHex(xml.parse1().toAscii()); else if (tag == "shares_when_free") _sharesWhenFree[t] = xml.parseInt(); else if (tag == "shares_when_subwin") _sharesWhenSubwin[t] = xml.parseInt(); else if (tag == "default_subwin") _defaultSubwin[t] = xml.parseInt(); else xml.unknown("TopWin"); break; case MusECore::Xml::TagEnd: if (tag == "topwin") return; default: break; } } }
int initAll() { initConfiguration(); // cout << "Use webcam? (Y/N)" <<endl; // // char cc = fgetc(stdin); if( !initCapture(true,cam_id)) //!initCapture(cc == 'Y' || cc == 'y',cam_id) ) return 0; if( !initFaceDet((OPENCV_ROOT + "/data/haarcascades/haarcascade_frontalface_default.xml").c_str())) { cerr << "failed initFaceDet with" << OPENCV_ROOT << "/data/haarcascades/haarcascade_frontalface_default.xml" << endl; return 0; } // Startup message tells user how to begin and how to exit printf( "\n********************************************\n" "To exit, click inside the video display,\n" "then press the ESC key\n\n" "Press <ENTER> to begin" "\n********************************************\n" ); fgetc(stdin); // Create the display window cvNamedWindow( DISPLAY_WINDOW, 1 ); // Initialize tracker captureVideoFrame(); if( !createTracker(pfd_pVideoFrameCopy) ) return 0; // Set Camshift parameters setVmin(60); setSmin(50); FdInit(); return 1; }
TopWin::TopWin(ToplevelType t, QWidget* parent, const char* name, Qt::WindowFlags f) : QMainWindow(parent, f) { _initalizing = true; _isDeleting = false; if (initInited==false) initConfiguration(); _type=t; setObjectName(QString(name)); //setDockNestingEnabled(true); // Allow multiple rows. Tim. setIconSize(ICON_SIZE); subwinAction=new QAction(tr("As subwindow"), this); subwinAction->setCheckable(true); connect(subwinAction, SIGNAL(toggled(bool)), SLOT(setIsMdiWin(bool))); shareAction=new QAction(tr("Shares tools and menu"), this); shareAction->setCheckable(true); connect(shareAction, SIGNAL(toggled(bool)), SLOT(shareToolsAndMenu(bool))); fullscreenAction=new QAction(tr("Fullscreen"), this); fullscreenAction->setCheckable(true); fullscreenAction->setChecked(false); fullscreenAction->setShortcut(shortcuts[SHRT_FULLSCREEN].key); connect(fullscreenAction, SIGNAL(toggled(bool)), SLOT(setFullscreen(bool))); mdisubwin=NULL; if (!MusEGlobal::unityWorkaround) _sharesToolsAndMenu=_defaultSubwin[_type] ? _sharesWhenSubwin[_type] : _sharesWhenFree[_type]; else _sharesToolsAndMenu=false; if (_defaultSubwin[_type] && !MusEGlobal::unityWorkaround) { setIsMdiWin(true); _savedToolbarState=_toolbarNonsharedInit[_type]; } if (_sharesToolsAndMenu) menuBar()->hide(); subwinAction->setChecked(isMdiWin()); shareAction->setChecked(_sharesToolsAndMenu); if (MusEGlobal::unityWorkaround) { shareAction->setEnabled(false); subwinAction->setEnabled(false); } fullscreenAction->setEnabled(!isMdiWin()); if (mdisubwin) mdisubwin->resize(_widthInit[_type], _heightInit[_type]); else resize(_widthInit[_type], _heightInit[_type]); QToolBar* undo_tools=addToolBar(tr("Undo/Redo tools")); undo_tools->setObjectName("Undo/Redo tools"); undo_tools->addActions(MusEGlobal::undoRedo->actions()); QToolBar* panic_toolbar = addToolBar(tr("Panic")); panic_toolbar->setObjectName("panic"); panic_toolbar->addAction(MusEGlobal::panicAction); QToolBar* metronome_toolbar = addToolBar(tr("Metronome")); metronome_toolbar->setObjectName("metronome"); metronome_toolbar->addAction(MusEGlobal::metronomeAction); QToolBar* transport_toolbar = addToolBar(tr("Transport")); transport_toolbar->setObjectName("transport"); transport_toolbar->addActions(MusEGlobal::transportAction->actions()); QToolBar* songpos_tb; songpos_tb = addToolBar(tr("Song Position")); songpos_tb->setObjectName("Song Position"); songpos_tb->addWidget(new MusEGui::SongPosToolbarWidget(songpos_tb)); songpos_tb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); songpos_tb->setContextMenuPolicy(Qt::PreventContextMenu); QToolBar* tempo_tb; tempo_tb = addToolBar(tr("Tempo")); tempo_tb->setObjectName("Tempo"); MusEGui::TempoToolbarWidget* tw = new MusEGui::TempoToolbarWidget(tempo_tb); tempo_tb->addWidget(tw); QToolBar* sig_tb; sig_tb = addToolBar(tr("Signature")); sig_tb->setObjectName("Signature"); MusEGui::SigToolbarWidget* sw = new MusEGui::SigToolbarWidget(tempo_tb); sig_tb->addWidget(sw); connect(tw, SIGNAL(returnPressed()), SLOT(focusCanvas())); connect(tw, SIGNAL(escapePressed()), SLOT(focusCanvas())); connect(sw, SIGNAL(returnPressed()), SLOT(focusCanvas())); connect(sw, SIGNAL(escapePressed()), SLOT(focusCanvas())); }
Client::Client(const Options &options): mOptions(options), mGame(0), mCurrentDialog(0), mQuitDialog(0), mDesktop(0), mSetupButton(0), mState(STATE_CHOOSE_SERVER), mOldState(STATE_START), mStateAfterOkDialog(mState), mIcon(0), mLogicCounterId(0), mSecondsCounterId(0), mLimitFps(false) { assert(!mInstance); mInstance = this; logger = new Logger; // Set default values for configuration files branding.setDefaultValues(getBrandingDefaults()); paths.setDefaultValues(getPathsDefaults()); config.setDefaultValues(getConfigDefaults()); // Load branding information if (!options.brandingPath.empty()) { branding.init(options.brandingPath); } initRootDir(); initHomeDir(); initConfiguration(); chatLogger = new ChatLogger; if (options.chatLogDir.empty()) chatLogger->setLogDir(mLocalDataDir + std::string("/logs/")); else chatLogger->setLogDir(options.chatLogDir); // Configure logger logger->setLogFile(mLocalDataDir + std::string("/mana.log")); logger->setLogToStandardOut(config.getBoolValue("logToStandardOut")); // Log the mana version logger->log("Mana %s", FULL_VERSION); initScreenshotDir(); // Initialize SDL logger->log("Initializing SDL..."); if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { logger->error(strprintf("Could not initialize SDL: %s", SDL_GetError())); } atexit(SDL_Quit); SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_WM_SetCaption(branding.getValue("appName", "Mana").c_str(), NULL); ResourceManager *resman = ResourceManager::getInstance(); if (!resman->setWriteDir(mLocalDataDir)) { logger->error(strprintf("%s couldn't be set as home directory! " "Exiting.", mLocalDataDir.c_str())); } Image::SDLsetEnableAlphaCache(config.getValue("alphaCache", true)); #if defined __APPLE__ CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); char path[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { fprintf(stderr, "Can't find Resources directory\n"); } CFRelease(resourcesURL); strncat(path, "/data", PATH_MAX - 1); resman->addToSearchPath(path, false); mPackageDir = path; #else resman->addToSearchPath(PKG_DATADIR "data", false); mPackageDir = PKG_DATADIR "data"; #endif resman->addToSearchPath("data", false); // Add branding/data to PhysFS search path if (!options.brandingPath.empty()) { std::string path = options.brandingPath; // Strip blah.mana from the path #ifdef _WIN32 int loc1 = path.find_last_of('/'); int loc2 = path.find_last_of('\\'); int loc = std::max(loc1, loc2); #else int loc = path.find_last_of('/'); #endif if (loc > 0) resman->addToSearchPath(path.substr(0, loc + 1) + "data", false); } // Add the main data directories to our PhysicsFS search path if (!options.dataPath.empty()) resman->addToSearchPath(options.dataPath, false); // Add the local data directory to PhysicsFS search path resman->addToSearchPath(mLocalDataDir, false); std::string iconFile = branding.getValue("appIcon", "icons/mana"); #ifdef _WIN32 iconFile += ".ico"; #else iconFile += ".png"; #endif iconFile = resman->getPath(iconFile); logger->log("Loading icon from file: %s", iconFile.c_str()); #ifdef _WIN32 static SDL_SysWMinfo pInfo; SDL_GetWMInfo(&pInfo); // Attempt to load icon from .ico file HICON icon = (HICON) LoadImage(NULL, iconFile.c_str(), IMAGE_ICON, 64, 64, LR_LOADFROMFILE); // If it's failing, we load the default resource file. if (!icon) icon = LoadIcon(GetModuleHandle(NULL), "A"); if (icon) SetClassLong(pInfo.window, GCL_HICON, (LONG) icon); #else mIcon = IMG_Load(iconFile.c_str()); if (mIcon) { SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); SDL_WM_SetIcon(mIcon, NULL); } #endif bool useOpenGL = !mOptions.noOpenGL && (config.getValue("opengl", 1) == 1); // Set up the transparency option for low CPU when not using OpenGL. if (!useOpenGL && (config.getValue("disableTransparency", 0) == 1)) Image::SDLdisableTransparency(); #ifdef USE_OPENGL // Setup image loading for the right image format Image::setLoadAsOpenGL(useOpenGL); // Create the graphics context graphics = useOpenGL ? new OpenGLGraphics : new Graphics; #else // Create the graphics context graphics = new Graphics; #endif const int width = config.getIntValue("screenwidth"); const int height = config.getIntValue("screenheight"); const int bpp = 0; const bool fullscreen = config.getBoolValue("screen"); const bool hwaccel = config.getBoolValue("hwaccel"); // Try to set the desired video mode if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { logger->error(strprintf("Couldn't set %dx%dx%d video mode: %s", width, height, bpp, SDL_GetError())); } // Initialize for drawing graphics->_beginDraw(); Theme::prepareThemePath(); // Initialize the item and emote shortcuts. itemShortcut = new ItemShortcut; emoteShortcut = new EmoteShortcut; gui = new Gui(graphics); // Initialize sound engine try { if (config.getBoolValue("sound")) sound.init(); sound.setSfxVolume(config.getIntValue("sfxVolume")); sound.setNotificationsVolume(config.getIntValue("notificationsVolume")); sound.setMusicVolume(config.getIntValue("musicVolume")); } catch (const char *err) { mState = STATE_ERROR; errorMessage = err; logger->log("Warning: %s", err); } // Initialize keyboard keyboard.init(); // Initialise player relations player_relations.init(); userPalette = new UserPalette; setupWindow = new Setup; sound.playMusic(branding.getStringValue("loginMusic")); // Initialize default server mCurrentServer.hostname = options.serverName; mCurrentServer.port = options.serverPort; loginData.username = options.username; loginData.password = options.password; loginData.remember = config.getBoolValue("remember"); loginData.registerLogin = false; if (mCurrentServer.hostname.empty()) mCurrentServer.hostname = branding.getValue("defaultServer","").c_str(); if (mCurrentServer.port == 0) { mCurrentServer.port = (short) branding.getValue("defaultPort", DEFAULT_PORT); mCurrentServer.type = ServerInfo::parseType( branding.getValue("defaultServerType", "tmwathena")); } if (chatLogger) chatLogger->setServerName(mCurrentServer.hostname); if (loginData.username.empty() && loginData.remember) loginData.username = config.getStringValue("username"); if (mState != STATE_ERROR) mState = STATE_CHOOSE_SERVER; // Initialize logic and seconds counters tick_time = 0; mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, NULL); mSecondsCounterId = SDL_AddTimer(1000, nextSecond, NULL); // Initialize frame limiting SDL_initFramerate(&mFpsManager); listen(Event::ConfigChannel); //TODO: fix having to fake a option changed event Event fakeevent(Event::ConfigOptionChanged); fakeevent.setString("option", "fpslimit"); event(Event::ConfigChannel, fakeevent); // Initialize PlayerInfo PlayerInfo::init(); }
/* if don't have any envorin variable at all */ int main(int argc, char **argv, char **envp) #endif #endif { rlim_t memlock_limit = -2; int error = 0, max_mem_lock = 0, memory_safe = 0, ptrace_safe = 0; #ifdef TEST_OPTION int testrun = 0; #endif char* binaryname; savetermios(); TRACE(99, "main()", NULL); #ifndef HAVE_EXTERN_ENVIRON #ifndef MANUAL_EXTERN_ENVIRON /* since in solaris environ does not exist, we manually pass it along */ environ = envp; #endif #endif if (initSecurity(&max_mem_lock, &memory_safe, &ptrace_safe, &memlock_limit)) { exit(1); } /* we initialize gettext */ setlocale(LC_ALL, ""); #ifdef TEST_OPTION bindtextdomain(PACKAGE_NAME, "./po/"); #else bindtextdomain(PACKAGE_NAME, LOCALEDIR); #endif textdomain(PACKAGE_NAME); #ifndef LIBXML_TREE_ENABLED fprintf(stderr, _("Tree support not compiled in to libxml2 %s\n"), LIBXML_DOTTED_VERSION); exit(1); #endif /* * This function installs "sighandler" to handle the SIGINT and returns a * pointer to the previously installed handler for this signal (which is * the default handler SIG_DFL initially). If we try to install another * handler to handle SIGINT at some other time... Then the new handler * replaces this current one and returns a pointer to this handler. */ signal(SIGINT, sighandler); signal(SIGTERM, sighandler); /* the SIGWINCH handler is set in userInterface() */ initConfiguration(); runtime -> memlock_limit = memlock_limit; runtime -> max_mem_lock = max_mem_lock; runtime -> memory_safe = memory_safe; runtime -> ptrace_safe = ptrace_safe; initKeys(); initPatternparser(); initXML(); initXMLInterface(); if (getOptions(argc, argv)) { fprintf(stderr, _("Try `%s --help' for more information.\n"), argv[0]); error = 1; } if (!error && config -> help) { showHelp(); } else if (!error && config -> version) { showVersion(); } else if (!error) { getDefaultOptions(); if (readResources()) return 1; if (config -> dbfilecmd) { /* the --file option must overwrite the resource file */ runtime -> dbfile = resolveFilelink(config -> dbfilecmd); } else { /* we use the resource file configuration or the compiletime * default */ runtime -> dbfile = resolveFilelink(config -> dbfilerc); } } /* we switch to read-only mode on request */ if (config -> readonly) { runtime -> readonly = 1; } /* in case our basename is cpmv, we switch to read-only mode */ binaryname = basename(argv[0]); if (!strcmp(binaryname, "cpmv")) { runtime -> readonly = 1; } initGPG(); if (!error && config -> security) { checkSecurity(0); } #ifdef TEST_OPTION if (!error && config -> testrun && !strncmp(config -> testrun, "compress", 8)) { testCompress(); testrun = 1; } if (!error && config -> testrun && !strcmp(config -> testrun, "environment")) { testEnvironment(); testrun = 1; } if (!error && config -> testrun && ( !strcmp(config -> testrun, "backup") || !strcmp(config -> testrun, "garbage") || !strcmp(config -> testrun, "searchpattern"))) { testrun = 1; } #endif if (config -> configtest && !error) { fprintf(stderr, _("configuration ok.\n")); } if (config -> environtmentlist && !error) { listEnvironment(); } if (!error && !config -> configtest && !config -> environtmentlist && !config -> help && !config -> security && !config -> version) { #ifdef TEST_OPTION if (checkSecurity(1) != MAX_SECURITY_LEVEL && !config -> testrun) #else if (checkSecurity(1) != MAX_SECURITY_LEVEL) #endif { checkSecurity(0); printf("\n%s %s\n%s\n", _("Maximum security level not reached."), _("Your database will be less protected while CPM is running."), _("Are you sure you want to continue?"), _("Press CTRL+C to stop now or ENTER to continue.")); fgetc(stdin); } if (runtime -> guimode) { /* we run in interactive mode */ userInterface(); } else { /* we run in CLI mode */ error = cliInterface(); #ifdef TEST_OPTION if (error == 2) { /* for testruns, we must modify the stuff a little */ error = 0; testrun = 1; } #endif } } freeGPG(); freeXMLInterface(); freeUTF8Interface(); freeXML(); freePatternparser(); freeKeys(); freeConfiguration(); if (memCheck()) { /* we validate our memory consumption */ fprintf(stderr, _("error: memory leak detected.\n")); if (memCheck() > 0) { fprintf(stderr, _("%ld byte of memory were not freed.\n"), memCheck()); } else { fprintf(stderr, _("%ld byte of memory were freed without being allocated.\n"), memCheck()); } fprintf(stderr, _("Please send a report about this problem to Harry Brueckner <*****@*****.**>.\n")); error = 1; } #ifdef TEST_OPTION if (testrun) { return 0; } else { return error; } #else return error; #endif }