void CGMCmdList::run(CPC* pc, const char* arg)
{
    std::string str(arg);
    stokenizer token(str, sep);
    std::vector<std::string> vec;
    vec.assign(token.begin(), token.end());

    if (vec.empty())
        return;

    const char* p = arg;
    char command[512];
    p = AnyOneArg(p, command, true);

    // 존재하는지 검색
    CGMCmd* pGMCmd = find(vec[0]);
    if ( pGMCmd == NULL )
        return;

    // 실행할 수 있는지 검색
    if ( !canRun( pGMCmd, pc ) )
        return;

    GAMELOG << init("GM COMMAND")
            << command << delim << p << delim
            << pc->m_index << delim
            << pc->m_name << delim
            << pc->m_nick << delim
            << end;

    // 실행
    vec.erase(vec.begin());
    pGMCmd->run(pc, p, vec);
}
RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig,
        const QString &mode)
{
    Q_ASSERT(mode == ProjectExplorer::Constants::RUNMODE
             || mode == Debugger::Constants::DEBUGMODE);
    Q_ASSERT(canRun(runConfig, mode));
    MaemoRunConfiguration *rc = qobject_cast<MaemoRunConfiguration *>(runConfig);
    Q_ASSERT(rc);
    if (mode == ProjectExplorer::Constants::RUNMODE)
        return new MaemoRunControl(rc);
    return MaemoDebugSupport::createDebugRunControl(rc);
}
RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig,
                                        Core::Id mode, QString *errorMessage)
{
    Q_ASSERT(canRun(runConfig, mode));
    AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig);
    Q_ASSERT(rc);
    if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
        return new AndroidRunControl(rc);
    if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN)
        return AndroidDebugSupport::createDebugRunControl(rc, errorMessage);
    if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
        return AndroidAnalyzeSupport::createAnalyzeRunControl(rc, mode);
    QTC_CHECK(false); // The other run modes are not supported
    return 0;
}
RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, QString *errorMessage)
{
    Q_ASSERT(canRun(runConfig, mode));

    RemoteLinuxRunConfiguration *rc = qobject_cast<RemoteLinuxRunConfiguration *>(runConfig);
    Q_ASSERT(rc);
    if (mode == ProjectExplorer::NormalRunMode)
        return new RemoteLinuxRunControl(rc);

    DebuggerStartParameters params = LinuxDeviceDebugSupport::startParameters(rc);
    if (mode == ProjectExplorer::DebugRunModeWithBreakOnMain)
        params.breakOnMain = true;
    DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc, errorMessage);
    if (!runControl)
        return 0;
    LinuxDeviceDebugSupport * const debugSupport =
            new LinuxDeviceDebugSupport(rc, runControl->engine());
    connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished()));
    return runControl;
}
void Application::loop(){
	Uint32 MS_PER_UPDATE = 16;
	Uint32 previous_time = SDL_GetTicks();
	Uint32 lag = 0;
	while(canRun()){
	
		Uint32 current_time = SDL_GetTicks();
		Uint32 elapsed_time = current_time - previous_time;
		previous_time = current_time;
		lag += elapsed_time;	
		
		if(lag >= MS_PER_UPDATE){
			handleInput();
			update();
			lag -= MS_PER_UPDATE;
		}
		
		render();
		getInput()->clearDown();
	}
}
Exemple #6
0
bool Launcher::daemonize()
{
	bool result = false;
	string jail_path = ctx_.exec(
		"GET gsmanager:%s:path",
		jail_name_.c_str()
	).string();
	struct stat sts;
	if(stat(jail_path.c_str(), &sts) == 0 && S_ISDIR(sts.st_mode)) {
		clearenv();
		if(chdir(jail_path.c_str()) == -1) {
			perror("No puedo cambiar al directorio");
			fputs(jail_path.c_str(), stderr);
			fputs("\n\n", stderr);
			return false;
		}
		if(chroot(".") != 0) {
			perror("No puedo hacer chroot");
			return false;
		}
		pid_t pid = fork();
		if(pid == 0) {
			if(canRun(ctx_, jail_name_)) {
				setsid(); /* se separa del padre creando un nuevo grupo de procesos y se desvincula de la consola */
				for(int i = getdtablesize(); i >= 0; --i) {
					if(i != ctx_.fd()) close(i); /* cierra todos los descriptores excepto el de la conexión redis */
				}
				int fd = open("/dev/null", O_RDWR); /* abre stdin */
				(void)dup(fd); /* stdout */
				(void)dup(fd); /* stderr */
				processMain();
			}
		}
		result = pid > 0;
	}
	return result;
}
RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig,
                                        RunMode mode, QString *errorMessage)
{
    Q_ASSERT(canRun(runConfig, mode));
    AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig);
    Q_ASSERT(rc);
    switch (mode) {
    case NormalRunMode:
        return new AndroidRunControl(rc);
    case DebugRunMode:
        return AndroidDebugSupport::createDebugRunControl(rc, errorMessage);
    case QmlProfilerRunMode:
        return AndroidAnalyzeSupport::createAnalyzeRunControl(rc, mode);
    case NoRunMode:
    case DebugRunModeWithBreakOnMain:
    case CallgrindRunMode:
    case MemcheckRunMode:
    case MemcheckWithGdbRunMode:
    case ClangStaticAnalyzerMode:
    case PerfProfilerRunMode:
        QTC_CHECK(false); // The other run modes are not supported
    }
    return 0;
}