static s32 readFromArgs(s32 argc, const char* argv[], ocrConfig_t * ocrConfig) { // Override any env variable with command line option s32 cur = 1; s32 userArgs = argc; char * ocrOptPrefix = "-ocr:"; s32 ocrOptPrefixLg = strlen(ocrOptPrefix); while(cur < argc) { const char * arg = argv[cur]; if (strncmp(ocrOptPrefix, arg, ocrOptPrefixLg) == 0) { // This is an OCR option const char * ocrArg = arg+ocrOptPrefixLg; if (strcmp("cfg", ocrArg) == 0) { checkNextArgExists(cur, argc, "cfg"); setIniFile(ocrConfig, argv[cur+1]); argv[cur] = NULL; argv[cur+1] = NULL; cur++; // skip param userArgs-=2; } else if (strcmp("version", ocrArg) == 0) { printVersion(); exit(0); break; } else if (strcmp("help", ocrArg) == 0) { printHelp(); exit(0); break; } } cur++; } return userArgs; }
static void readFromEnv(ocrConfig_t * ocrConfig) { // Go over OCR options description and check // if some of the env variables are set. struct options *p; for (p = ocrOptionDesc; p->flag; ++p) { char * opt = getenv(p->env_flag); // If variable defined and has value if ((opt != NULL) && (strcmp(opt, "") != 0)) { switch (p->option) { case OPT_CONFIG: setIniFile(ocrConfig, opt); break; } } } }
void CMemoryIniFile::setIniFile( const char *szIniFileName ) { setIniFile( std::string(szIniFileName) ); }