Ejemplo n.º 1
0
char const *findTempl(char const *shell, char const *Type)  // 005, 007
{
    static char const *name;
    static char        block[1024+1];
    static TstrBuf     templ;
    
    FILE *fp = NULL;
    
    if ((NULL != (name = findConfig(shell))) && (fp = fopen(name, "r")))
    {
        int buffLen = 0;
        int len;
        while (0 < (len = fread(block, 1, sizeof(block)-1, fp)))
        {
             block[len] = '\0';
             templ.cat(block, buffLen);
             buffLen += len;
        }
        
        fclose(fp);
        
        return ((char const *)templ);
    }
    
    return (NULL);
}
Ejemplo n.º 2
0
signed char SWMgr::Load() {
	signed char ret = 0;

	if (!config) {	// If we weren't passed a config object at construction, find a config file
		if (!configPath) {	// If we weren't passed a config path at construction...
			SWLog::getSystemLog()->logDebug("LOOKING UP MODULE CONFIGURATION...");
			SWConfig *externalSysConf = sysConfig;	// if we have a sysConf before findConfig, then we were provided one from an external source.
			findConfig(&configType, &prefixPath, &configPath, &augPaths, &sysConfig);
			if (!externalSysConf) mysysconfig = sysConfig;	// remind us to delete our own sysConfig in d-tor
			SWLog::getSystemLog()->logDebug("LOOKING UP MODULE CONFIGURATION COMPLETE.");
		}
		if (configPath) {
			if (configType)
				loadConfigDir(configPath);
			else	config = myconfig = new SWConfig(configPath);
		}
	}

	if (config) {
		SectionMap::iterator Sectloop, Sectend;
		ConfigEntMap::iterator Entryloop, Entryend;

		DeleteMods();

		for (Sectloop = config->Sections.lower_bound("Globals"), Sectend = config->Sections.upper_bound("Globals"); Sectloop != Sectend; Sectloop++) {		// scan thru all 'Globals' sections
			for (Entryloop = (*Sectloop).second.lower_bound("AutoInstall"), Entryend = (*Sectloop).second.upper_bound("AutoInstall"); Entryloop != Entryend; Entryloop++)	// scan thru all AutoInstall entries
				InstallScan((*Entryloop).second.c_str());		// Scan AutoInstall entry directory for new modules and install
		}		
		if (configType) {	// force reload on config object because we may have installed new modules
			delete myconfig;
			config = myconfig = 0;
			loadConfigDir(configPath);
		}
		else	config->Load();

		CreateMods(mgrModeMultiMod);

		for (std::list<SWBuf>::iterator pathIt = augPaths.begin(); pathIt != augPaths.end(); pathIt++) {
			augmentModules(pathIt->c_str(), mgrModeMultiMod);
		}
		if (augmentHome) {
			// augment config with ~/.sword/mods.d if it exists ---------------------
			SWBuf homeDir = getHomeDir();
			if (homeDir.length() && configType != 2) { // 2 = user only
				SWBuf path = homeDir;
				path += ".sword/";
				augmentModules(path.c_str(), mgrModeMultiMod);
				path = homeDir;
				path += "sword/";
				augmentModules(path.c_str(), mgrModeMultiMod);
			}
		}
// -------------------------------------------------------------------------
		if (!Modules.size()) // config exists, but no modules
			ret = 1;

	}
	else {
		SWLog::getSystemLog()->logError("SWMgr: Can't find 'mods.conf' or 'mods.d'.  Try setting:\n\tSWORD_PATH=<directory containing mods.conf>\n\tOr see the README file for a full description of setup options (%s)", (configPath) ? configPath : "<configPath is null>");
		ret = -1;
	}

	return ret;
}
Ejemplo n.º 3
0
psi::psi() {
    root = decoded.createElement("psi");
    decoded.appendChild(root);
    findConfig();
}
Ejemplo n.º 4
0
    void EGLRuntime::initializeEGL(OpenGLESVersion requestedAPIVersion)
    {
        Platform* platform = Platform::getInstance();

        EGLBoolean success = EGL_FALSE;

#if defined(_WIN32)
        /* Win32 */
        display = eglGetDisplay(platform->deviceContext);
#elif defined(__arm__)
        /* Linux on ARM */
        display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
#else
        /* Desktop Linux */
        platform->display = XOpenDisplay(NULL);
        display = eglGetDisplay(platform->display);
#endif

        if(display == EGL_NO_DISPLAY)
        {
            EGLint error = eglGetError();
            LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
            LOGE("No EGL Display available at %s:%i\n", __FILE__, __LINE__);
            exit(1);
        }

        /* Initialize EGL. */
        success = eglInitialize(display, NULL, NULL);
        if(success != EGL_TRUE)
        {
            EGLint error = eglGetError();
            LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
            LOGE("Failed to initialize EGL at %s:%i\n", __FILE__, __LINE__);
            exit(1);
        }

        /* Depending on app-requested EGL attributes, tweak the attributes we pass to EGL. */
        if(requestedAPIVersion == OPENGLES1)
        {
            configAttributes[15] = EGL_OPENGL_ES_BIT;
            contextAttributes[1] = 1;
        }
        else if(requestedAPIVersion == OPENGLES2)
        {
            configAttributes[15] = EGL_OPENGL_ES2_BIT;
            contextAttributes[1] = 2;
        }
        /*
         * Despite the fact an OpenGL ES 3.0 config is required, we request configs using the OpenGL_ES2_BIT.
         * At the time of writing there is no OpenGL_ES3_BIT, and so platforms return
         * OpenGL ES 3.0 configs with the OpenGL_ES2_BIT set.
         * We request a context with EGL_CONTEXT_CLIENT_VERSION of 3 (OpenGL ES 3.0) which will ensure that
         * OpenGL ES 3.0 features are supported.
         */
        else if (requestedAPIVersion == OPENGLES3)
        {
            configAttributes[15] = EGL_OPENGL_ES2_BIT;
            contextAttributes[1] = 3;
        }

        /*
         * Find a matching config and store it in our static variable.
         * On ARM devices perform a strict match to ensure we get the best performance.
         * On desktop devices perform a loose match to ensure greatest compatability.
         */
#if defined(__arm__)
        config = findConfig(true);
#else
        config = findConfig(false);
#endif

#if defined(__linux__) && !defined(__arm__)
        ((DesktopLinuxPlatform*)(platform))->createX11Window();
#endif

        /* Create a surface. */
        surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)(platform->window), windowAttributes);
        if(surface == EGL_NO_SURFACE)
        {
            EGLint error = eglGetError();
            LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
            LOGE("Failed to create EGL surface at %s:%i\n", __FILE__, __LINE__);
            exit(1);
        }

        /* Unconditionally bind to OpenGL ES API as we exit this function, since it's the default. */
        eglBindAPI(EGL_OPENGL_ES_API);

        context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttributes);
        if(context == EGL_NO_CONTEXT)
        {
            EGLint error = eglGetError();
            LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
            LOGE("Failed to create EGL context at %s:%i\n", __FILE__, __LINE__);
            exit(1);
        }
    }
Ejemplo n.º 5
0
saje::saje()
{
    root = decoded.createElement("saje");
    decoded.appendChild(root);
    findConfig();
}
Ejemplo n.º 6
0
MAIN(http, int argc, char **argv, char **envp)
{
    Mpr     *mpr;
    cchar   *argp;
    char    *logSpec, *traceSpec;
    int     argind;

    logSpec = 0;
    traceSpec = 0;

    if ((mpr = mprCreate(argc, argv, MPR_USER_EVENTS_THREAD)) == NULL) {
        exit(1);
    }
    if ((app = mprAllocObj(App, manageApp)) == NULL) {
        exit(2);
    }
    mprAddRoot(app);
    mprAddStandardSignals();

    if (httpCreate(HTTP_CLIENT_SIDE | HTTP_SERVER_SIDE) < 0) {
        exit(2);
    }
    app->mpr = mpr;
    app->home = mprGetCurrentPath();
    argc = mpr->argc;
    argv = (char**) mpr->argv;

    for (argind = 1; argind < argc; argind++) {
        argp = argv[argind];
        if (*argp != '-') {
            break;
        }
        if (smatch(argp, "--config") || smatch(argp, "--conf")) {
            if (argind >= argc) {
                usageError();
            }
            app->configFile = sclone(argv[++argind]);

        } else if (smatch(argp, "--debugger") || smatch(argp, "-D")) {
            mprSetDebugMode(1);

        } else if (smatch(argp, "--log") || smatch(argp, "-l")) {
            if (argind >= argc) {
                usageError();
            }
            logSpec = argv[++argind];

        } else if (smatch(argp, "--name") || smatch(argp, "-n")) {
            if (argind >= argc) {
                usageError();
            }
            mprSetAppName(argv[++argind], 0, 0);

        } else if (smatch(argp, "--show") || smatch(argp, "-s")) {
            app->show = 1;

        } else if (smatch(argp, "--trace") || smatch(argp, "-t")) {
            if (argind >= argc) {
                usageError();
            }
            traceSpec = argv[++argind];

        } else if (smatch(argp, "--verbose") || smatch(argp, "-v")) {
            if (!logSpec) {
                logSpec = sfmt("stderr:2");
            }
            if (!traceSpec) {
                traceSpec = sfmt("stderr:2");
            }

        } else if (smatch(argp, "--version") || smatch(argp, "-V")) {
            mprPrintf("%s\n", ME_VERSION);
            exit(0);

        } else if (*argp == '-' && isdigit((uchar) argp[1])) {
            if (!logSpec) {
                logSpec = sfmt("stderr:%d", (int) stoi(&argp[1]));
            }
            if (!traceSpec) {
                traceSpec = sfmt("stderr:%d", (int) stoi(&argp[1]));
            }

        } else if (smatch(argp, "-?") || scontains(argp, "-help")) {
            usageError();
            exit(3);

        } else if (*argp == '-') {
            mprLog("error http", 0, "Unknown switch \"%s\"", argp);
            usageError();
            exit(4);
        }
    }
    if (logSpec) {
        mprStartLogging(logSpec, MPR_LOG_CMDLINE);
    }
    if (traceSpec) {
        httpStartTracing(traceSpec);
    }
    if (mprStart() < 0) {
        mprLog("error http", 0, "Cannot start MPR");
        mprDestroy();
        return MPR_ERR_CANT_INITIALIZE;
    }
    if (argc == argind && !app->configFile) {
        if (findConfig() < 0) {
            exit(5);
        }
    }
    if (createEndpoints(argc - argind, &argv[argind]) < 0) {
        return MPR_ERR_CANT_INITIALIZE;
    }
    if (httpStartEndpoints() < 0) {
        mprLog("error http", 0, "Cannot start HTTP service, exiting.");
        exit(6);
    }
    if (app->show) {
        httpLogRoutes(0, 0);
    }
    mprServiceEvents(-1, 0);

    mprLog("info http", 1, "Stopping http-server ...");
    mprDestroy();
    return mprGetExitStatus();
}