ConfSection *_add_section(const char *section, ConfLine *cl);
void _dump(int fd);
- int _parse(char *filename, ConfSection **psection);
+ bool _parse(char *filename, ConfSection **psection);
public:
ConfFile(const char *fname) : filename(strdup(fname)), auto_update(false),
post_process_func(NULL) {}
const SectionList& get_section_list() { return sections_list; }
const char *get_filename() { return filename; }
- int parse();
+ bool parse();
int read(const char *section, const char *var, int *val, int def_val);
int read(const char *section, const char *var, unsigned int *val, unsigned int def_val);
int read(const char *section, const char *var, long long *val, long long def_val);
return ret;
}
-void parse_config_file(ConfFile *cf, bool auto_update)
+bool parse_config_file(ConfFile *cf, bool auto_update)
{
int opt_len = sizeof(config_optionsp)/sizeof(config_option);
cf->set_auto_update(false);
cf->set_post_process_func(conf_post_process_val);
- cf->parse();
+ if (!cf->parse())
+ return false;
for (int i=0; i<opt_len; i++) {
config_option *opt = &config_optionsp[i];
conf_read_key(NULL, opt->conf_name, opt->type, opt->val_ptr, opt->val_ptr);
}
+
+ return true;
}
bool is_bool_param(const char *param)
{
DEFINE_CONF_VARS(NULL);
std::vector<const char *> nargs;
+ bool conf_specified = false;
if (!g_conf.id)
g_conf.id = (char *)"";
FOR_EACH_ARG(args) {
if (CONF_ARG_EQ("conf", 'c')) {
CONF_SAFE_SET_ARG_VAL(&g_conf.conf, OPT_STR);
+ conf_specified = true;
} else if (CONF_ARG_EQ("monmap", 'M')) {
CONF_SAFE_SET_ARG_VAL(&g_conf.monmap, OPT_STR);
} else if (CONF_ARG_EQ("bind", 0)) {
cf = new ConfFile(g_conf.conf);
- parse_config_file(cf, true);
+ int ret = parse_config_file(cf, true);
+
+ if (conf_specified && !ret) {
+ cerr << "error reading config file " << g_conf.conf << std::endl;
+ exit(1);
+ }
if (show_config) {
cf->dump();