const char * sphLoadConfig ( const char * sOptConfig, bool bQuiet, CSphConfigParser & cp ) { // fallback to defaults if there was no explicit config specified while ( !sOptConfig ) { #ifdef SYSCONFDIR sOptConfig = SYSCONFDIR "/sphinx.conf"; if ( sphIsReadable(sOptConfig) ) break; #endif sOptConfig = "./sphinx.conf"; if ( sphIsReadable(sOptConfig) ) break; sOptConfig = NULL; break; } if ( !sOptConfig ) sphDie ( "no readable config file (looked in " #ifdef SYSCONFDIR SYSCONFDIR "/sphinx.conf, " #endif "./sphinx.conf)" ); if ( !bQuiet ) fprintf ( stdout, "using config file '%s'...\n", sOptConfig ); // load config if ( !cp.Parse ( sOptConfig ) ) sphDie ( "failed to parse config file '%s'", sOptConfig ); CSphConfig & hConf = cp.m_tConf; if ( !hConf ( "index" ) ) sphDie ( "no indexes found in config file '%s'", sOptConfig ); return sOptConfig; }
int checkParameter(Json::Value& value) { int ret = 0; if (value["merge"].asBool() && value["indexes"].size() != 2) { printf("merge parame error\n --merge mainIndex incIndex\n"); usage(); exit(-2); } if (value["indexes"].size() == 0) { printf("parame error\n default should give a index\n"); usage(); exit(-3); } if (!sphIsReadable(value["config"].asString().c_str())) { sphDie("config file '%s' does not exist or is not readable", value["config"].asString().c_str()); } return ret; }