Пример #1
0
void run(const char *dir)
{
    {
        Application app_(dir);

        setApplication(&app_);

        Script *script = resMgr->load<Script>("resources/scripts/main.rkt");
        app->setNextScript(script);
        script->release();

        app->mainloop();
    }

    setApplication(nullptr);
}
Пример #2
0
std::string getConfigSectionOption(const ConfigNameList &section, const char *option, const char *defaultValue, const ConfigNameList &app) {
    if (augeas==NULL){
        if(!augeas_init()) {
            return defaultValue;
        }
    }

    // If app has no values, default to section
    ConfigNameList app_(app, section);

    AGO_TRACE() << "Augeas: get " << app_ << " / " << section;
    BOOST_FOREACH(const std::string & a, app_.names()) {
        BOOST_FOREACH(const std::string & s, section.names()) {
            const char *value;
            std::string aug_path = augeasPath(confPathFromApp(a), s, option);

            int ret = aug_get(augeas, aug_path.c_str(), &value);
            if(ret == 1 && value != NULL) {
                std::stringstream result;
                AGO_TRACE() << "Augeas: using config value from " << aug_path << ": " << value;
                result << value;
                return result.str();
            }

            AGO_TRACE() << "Augeas: config value at " << aug_path << " not found (ret=" << ret << ")";
        }
    }

    if(defaultValue) {
        AGO_TRACE() << "Augeas, no match on " << section << " / " << app << ", falling back to default value " << defaultValue;
        return defaultValue;
    }

    // empty
    return std::string();
}