ERMsg COGRBaseOption::ParseOption(int argc, char* argv[])
	{
		ERMsg msg;
		// Must process GDAL_SKIP before GDALAllRegister(), but we can't call 
		// GDALGeneralCmdLineProcessor before it needs the drivers to be registered 
		// for the --format or --formats options 
		for (int i = 1; i < argc; i++)
		{
			if (IsEqual(argv[i], "--config") && i + 2 < argc && IsEqual(argv[i + 1], "GDAL_SKIP"))
			{
				CPLSetConfigOption(argv[i + 1], argv[i + 2]);

				i += 2;
			}
		}

		// -------------------------------------------------------------------- 
		//      Register standard GDAL drivers, and process generic GDAL        
		//      command options.                                                
		// -------------------------------------------------------------------- 
		OGRRegisterAll();
		argc = OGRGeneralCmdLineProcessor(argc, &argv, 0);
		if (argc < 1)
			exit(-argc);

		// -------------------------------------------------------------------- 
		//      Parse arguments.                                                
		// -------------------------------------------------------------------- 
		for (int i = 1; i < argc; i++)
		{
			msg += ProcessOption(i, argc, argv);
		}

		if (m_bVersion)
		{
			string error = Format("%s was compiled against GDAL %s and is running against GDAL %s\n",
				argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));

			msg.ajoute(error);
			//return msg;
		}

		if (m_bNeedHelp)
		{
			msg.ajoute(GetUsage());
			msg.ajoute(GetHelp());
			//return msg;
		}


		return msg;
	}
Ejemplo n.º 2
0
static void ProcessFiles( char **argv )
/*************************************/
{
    char *  item;

    while( *argv != NULL ) {
        item = *argv;
        if( *item == '-' || *item == '/' ) {
            ProcessOption( &argv );
        } else {
            put( "Processing file '" );
            put( item );
            put( "'\n" );
            ProcFile( item );
            argv++;
        }
    }
}
Ejemplo n.º 3
0
FCITX_EXPORT_API
boolean FcitxInstanceRun(int argc, char* argv[], int fd)
{
    FcitxInstance* instance = fcitx_utils_new(FcitxInstance);

    do {
        if (!ProcessOption(instance, argc, argv))
            break;

        instance->fd = fd;

        RunInstance(instance);
    } while(0);
    boolean result = instance->loadingFatalError;
//    free(instance);

    return result;
}
Ejemplo n.º 4
0
int DoSetups()
{
	UBYTE *setbuffer, *s, *t, *u /*, c */;
	int errors = 0;
	setbuffer = LoadInputFile((UBYTE *)setupfilename,SETUPFILE);
	if ( setbuffer ) {
/*
		The contents of the file are now in setbuffer.
		Each line is commentary or a single command.
		The buffer is terminated with a zero.
*/
		s = setbuffer;
		while ( *s ) {
			if ( *s == ' ' || *s == '\t' || *s == '*' || *s == '#' || *s == '\n' ) {
				while ( *s && *s != '\n' ) s++;
			}
			else if ( tolower(*s) < 'a' || tolower(*s) > 'z' ) {
				t = s;
				while ( *s && *s != '\n' ) s++;
/*
				c = *s; *s = 0;
				Error1("Setup file: Illegal statement: ",t);
				errors++; *s = c;
*/
			}
			else {
				t = s; /* name of the option */
				while ( tolower(*s) >= 'a' && tolower(*s) <= 'z' ) s++;
				*s++ = 0;
				while ( *s == ' ' || *s == '\t' ) s++;
				u = s; /* 'value' of the option */
				while ( *s && *s != '\n' && *s != '\r' ) s++;
				if ( *s ) *s++ = 0;
				errors += ProcessOption(t,u,0);
			}
			while ( *s == '\n' || *s == '\r' ) s++;
		}
		M_free(setbuffer,"setup file buffer");
	}
	if ( errors ) return(1);
	else return(0);
}
Ejemplo n.º 5
0
void CD3DRenderer::WorkLoop()
{
    m_fpsManage.InitTime();
    while(::WaitForSingleObject(m_hStopEvent, m_fpsManage.WaitTime()) == WAIT_TIMEOUT)
    {
        switch(m_UIState)
        {
        case UIState::MENU:
            ProcessMenu();
            break;
        case UIState::PLAY:
            ProcessPlay();
            break;
        case UIState::OPTION:
            ProcessOption();
            break;
        default:
            break;
        }
    }
}
Ejemplo n.º 6
0
FCITX_EXPORT_API
FcitxInstance* FcitxInstanceCreatePause(sem_t *sem, int argc, char* argv[], int fd)
{
    if (!sem) {
        return NULL;
    }

    FcitxInstance* instance = fcitx_utils_new(FcitxInstance);

    if (!ProcessOption(instance, argc, argv))
        goto create_error_exit_1;

    instance->sem = sem;
    instance->fd = fd;

    if (sem_init(&instance->startUpSem, 0, 0) != 0) {
        goto create_error_exit_1;
    }

    if (sem_init(&instance->notifySem, 0, 0) != 0) {
        goto create_error_exit_2;
    }

    if (pthread_create(&instance->pid, NULL, RunInstance, instance) != 0) {
        goto create_error_exit_3;
    }

    sem_wait(&instance->notifySem);

    return instance;

create_error_exit_3:
    sem_destroy(&instance->notifySem);
create_error_exit_2:
    sem_destroy(&instance->startUpSem);
create_error_exit_1:
    free(instance);
    return NULL;
}
ProgramOption::ProgramOption(int argc, char **argv) {
    InitDefaultValues();

    fopt = new FileOperation();


    int ret = ParseArgument(argc, argv, fopt);
    if (ret != 0) {
        std::cerr << "Chyba programoptiondi" << std::endl;
        this->finish = ret;
    }
    else{

    }


    ProcessOption(fopt);



    delete fopt;
}
Ejemplo n.º 8
0
FCITX_EXPORT_API
FcitxInstance* FcitxInstanceCreateWithFD(sem_t *sem, int argc, char* argv[], int fd)
{
    FcitxInstance* instance = fcitx_utils_malloc0(sizeof(FcitxInstance));
    FcitxAddonsInit(&instance->addons);
    FcitxInstanceInitIM(instance);
    FcitxFrontendsInit(&instance->frontends);
    InitFcitxModules(&instance->modules);
    InitFcitxModules(&instance->eventmodules);
    utarray_init(&instance->uistats, &stat_icd);
    utarray_init(&instance->uicompstats, &compstat_icd);
    utarray_init(&instance->uimenus, &menup_icd);
    utarray_init(&instance->timeout, &timeout_icd);
    utarray_init(&instance->icdata, &icdata_icd);
    instance->input = FcitxInputStateCreate();
    instance->sem = sem;
    instance->config = fcitx_utils_malloc0(sizeof(FcitxGlobalConfig));
    instance->profile = fcitx_utils_malloc0(sizeof(FcitxProfile));
    instance->globalIMName = strdup("");
    if (fd > 0) {
        fcntl(fd, F_SETFL, O_NONBLOCK);
        instance->fd = fd;
    }

    if (!FcitxGlobalConfigLoad(instance->config))
        goto error_exit;

    FcitxCandidateWordSetPageSize(instance->input->candList, instance->config->iMaxCandWord);

    if (!ProcessOption(instance, argc, argv))
        goto error_exit;

    instance->timeStart = time(NULL);
    instance->globalState = instance->config->defaultIMState;
    instance->totaltime = 0;

    FcitxInitThread(instance);
    if (!FcitxProfileLoad(instance->profile, instance))
        goto error_exit;
    if (FcitxAddonGetConfigDesc() == NULL)
        goto error_exit;
    if (GetIMConfigDesc() == NULL)
        goto error_exit;

    FcitxAddonsLoad(&instance->addons);
    FcitxInstanceFillAddonOwner(instance, NULL);
    FcitxInstanceResolveAddonDependency(instance);
    FcitxInstanceInitBuiltInHotkey(instance);
    FcitxInstanceInitBuiltContext(instance);
    FcitxModuleLoad(instance);
    if (instance->loadingFatalError)
        return instance;
    if (!FcitxInstanceLoadAllIM(instance)) {
        FcitxInstanceEnd(instance);
        return instance;
    }

    FcitxInstanceInitIMMenu(instance);
    FcitxUIRegisterMenu(instance, &instance->imMenu);
    FcitxUIRegisterStatus(instance, instance, "remind",
                           instance->profile->bUseRemind ? _("Use remind") :  _("No remind"),
                          _("Toggle Remind"), ToggleRemindState, GetRemindEnabled);
    FcitxUISetStatusVisable(instance, "remind",  false);

    FcitxUILoad(instance);

    instance->iIMIndex = FcitxInstanceGetIMIndexByName(instance, instance->profile->imName);

    FcitxInstanceSwitchIMByIndex(instance, instance->iIMIndex);

    if (!FcitxInstanceLoadFrontend(instance)) {
        FcitxInstanceEnd(instance);
        return instance;
    }

    /* make in order to use block X, query is not good here */
    pthread_create(&instance->pid, NULL, RunInstance, instance);

    return instance;

error_exit:
    FcitxInstanceEnd(instance);
    return instance;

}
Ejemplo n.º 9
0
static int ProcOptions( char *str, int *level )
/*********************************************/
{
    char *save[MAX_NESTING];
    char *buffers[MAX_NESTING];

    if( str != NULL ) {
        for( ;; ) {
            while( *str == ' ' || *str == '\t' )
                ++str;
            if( *str == '@' && *level < MAX_NESTING ) {
                save[(*level)++] = CollectEnvOrFileName( str + 1 );
                buffers[*level] = NULL;
                str = getenv( ParamBuf );
                if( str == NULL ) {
                    str = ReadIndirectFile();
                    buffers[*level] = str;
                }
                if( str != NULL )
                    continue;
                str = save[--(*level)];
            }
            if( *str == '\0' ) {
                if( *level == 0 )
                    break;
                if( buffers[*level] != NULL ) {
                    AsmFree( buffers[*level] );
                    buffers[*level] = NULL;
                }
                str = save[--(*level)];
                continue;
            }
            if( *str == '-'  ||  *str == SwitchChar ) {
                str = ProcessOption(str+1, str);
            } else {  /* collect  file name */
                char *beg, *p;
                int len;

                beg = str;
                if( *str == '"' ) {
                    for( ;; ) {
                        ++str;
                        if( *str == '"' ) {
                            ++str;
                            break;
                        }
                        if( *str == '\0' )
                            break;
                        if( *str == '\\' ) {
                            ++str;
                        }
                    }
                } else {
                    for( ;; ) {
                        if( *str == '\0' )
                            break;
                        if( *str == ' ' )
                            break;
                        if( *str == '\t' )
                            break;
#if !defined(__UNIX__)
                        if( *str == SwitchChar )
                            break;
#endif
                        ++str;
                    }
                }
                len = str-beg;
                p = (char *) AsmAlloc( len + 1 );
                memcpy( p, beg, len );
                p[ len ] = '\0';
                StripQuotes( p );
                get_fname( p, ASM );
                AsmFree(p);
            }
        }
    }
    return( 0 );
}
Ejemplo n.º 10
0
static void DoOneOption( char *opt )
/**********************************/
// process a single option
{
    ProcessOption( opt );
}
Ejemplo n.º 11
0
FCITX_EXPORT_API
FcitxInstance* FcitxInstanceCreate(sem_t *sem, int argc, char* argv[])
{
    FcitxInstance* instance = fcitx_utils_malloc0(sizeof(FcitxInstance));
    FcitxAddonsInit(&instance->addons);
    FcitxInstanceInitIM(instance);
    FcitxFrontendsInit(&instance->frontends);
    InitFcitxModules(&instance->eventmodules);
    utarray_init(&instance->uistats, &stat_icd);
    utarray_init(&instance->uimenus, &menup_icd);
    instance->input = FcitxInputStateCreate();
    instance->sem = sem;
    instance->config = fcitx_utils_malloc0(sizeof(FcitxGlobalConfig));
    instance->profile = fcitx_utils_malloc0(sizeof(FcitxProfile));

    if (!FcitxGlobalConfigLoad(instance->config))
        goto error_exit;

    FcitxCandidateWordSetPageSize(instance->input->candList, instance->config->iMaxCandWord);

    if (!ProcessOption(instance, argc, argv))
        goto error_exit;

    instance->timeStart = time(NULL);
    instance->globalState = instance->config->defaultIMState;
    instance->totaltime = 0;

    FcitxInitThread(instance);
    if (!FcitxProfileLoad(instance->profile, instance))
        goto error_exit;
    if (FcitxAddonGetConfigDesc() == NULL)
        goto error_exit;
    if (GetIMConfigDesc() == NULL)
        goto error_exit;

    FcitxAddonsLoad(&instance->addons);

    /* FIXME: a walkaround for not have instance in function FcitxModuleInvokeFunction */
    FcitxAddon* addon;
    for (addon = (FcitxAddon *) utarray_front(&instance->addons);
            addon != NULL;
            addon = (FcitxAddon *) utarray_next(&instance->addons, addon)) {
        addon->owner = instance;
    }
    FcitxInstanceResolveAddonDependency(instance);
    FcitxInstanceInitBuiltInHotkey(instance);
    FcitxInstanceInitBuiltContext(instance);
    FcitxModuleLoad(instance);
    if (!FcitxInstanceLoadAllIM(instance)) {
        FcitxInstanceEnd(instance);
        return instance;
    }

    FcitxInstanceInitIMMenu(instance);
    FcitxUIRegisterMenu(instance, &instance->imMenu);
    FcitxUIRegisterStatus(instance, instance, "remind", _("Remind"), _("Remind"), ToggleRemindState, GetRemindEnabled);

    FcitxUILoad(instance);

    instance->iIMIndex = FcitxInstanceGetIMIndexByName(instance, instance->profile->imName);

    FcitxInstanceSwitchIM(instance, instance->iIMIndex);
    instance->lastIMIndex = instance->iIMIndex;

    if (!FcitxInstanceLoadFrontend(instance)) {
        FcitxInstanceEnd(instance);
        return instance;
    }

    if (instance->config->bFirstRun) {
        instance->config->bFirstRun = false;
        FcitxGlobalConfigSave(instance->config);

        const char *imname = "fcitx";
        char *strTemp;
        asprintf(&strTemp, "@im=%s", imname);

        if ((getenv("XMODIFIERS") != NULL && CHECK_ENV("XMODIFIERS", strTemp, true)) ||
                (CHECK_ENV("GTK_IM_MODULE", "xim", false) && CHECK_ENV("GTK_IM_MODULE", "fcitx", false))
                || (CHECK_ENV("QT_IM_MODULE", "xim", false) && CHECK_ENV("QT_IM_MODULE", "fcitx", false))) {
            char *msg[12];
            msg[0] = _("Please check your environment varibles.");
            msg[1] = _("You can use tools provided by your distribution.");
            msg[2] = _("Or You may need to set environment varibles below to make fcitx work correctly.");
            msg[3] = "export XMODIFIERS=\"@im=fcitx\"";
            msg[4] = "export QT_IM_MODULE=xim";
            msg[5] = "export GTK_IM_MODULE=xim";
            msg[6] = _("Or (Depends on you install im module or not)");
            msg[7] = "export XMODIFIERS=\"@im=fcitx\"";
            msg[8] = "export QT_IM_MODULE=fcitx";
            msg[9] = "export GTK_IM_MODULE=fcitx";
            msg[10] = _("If you use login manager like gdm or kdm, put those lines in your ~/.xprofile.");
            msg[11] = _("If you use ~/.xinitrc and startx, put those lines in ~/.xinitrc.");

            FcitxUIDisplayMessage(instance, _("Setting Hint"), msg, 12);
        }

        free(strTemp);
    }
    /* make in order to use block X, query is not good here */
    pthread_create(&instance->pid, NULL, RunInstance, instance);

    return instance;

error_exit:
    FcitxInstanceEnd(instance);
    return instance;

}