void ConfFile::dump()
{
+#if 0
std::list<struct conf_line *>::iterator iter, end;
struct conf_line *cl;
char line[MAX_LINE];
printf("line=%s\n", line);
}
}
+#endif
+ ConfMap *cur_map;
+ ConfMap::iterator map_iter, map_end;
+ SectionMap::iterator sec_iter, sec_end;
+
+ sec_end = sections.end();
+
+ for (sec_iter = sections.begin(); sec_iter != sec_end; ++sec_iter) {
+ cur_map = sec_iter->second;
+ map_end = cur_map->end();
+
+ for (map_iter = cur_map->begin(); map_iter != map_end; ++map_iter) {
+
+ }
+ }
+
}
int ConfFile::parse()
return 0;
}
+int ConfFile::read_str_alloc(char *section, char *var, char **val, char *def_val)
+{
+ struct conf_line *cl;
+
+ cl = _find_var(section, var);
+ if (!cl || !cl->val)
+ goto notfound;
+
+ *val = strdup(cl->val);
+
+ return 1;
+notfound:
+ *val = strdup(def_val);
+ return 0;
+}
+
void parse_test(char *line)
{
struct conf_line cl;
#include "osd/osd_types.h"
+#include "common/ConfUtils.h"
+
int buffer::list::read_file(const char *fn)
{
struct stat st;
cf.parse();
#define CF_READ(section, type, field, inout) \
- cf.read_#type(section, ##field, &inout, inout)
+ cf.read_##type((char *)section, (char *)#field, &inout, inout)
+
+#define CF_READ_STR(section, type, field, inout) \
+ cf.read_##type((char *)section, (char *)#field, (char **)&inout, (char *)inout)
CF_READ("global", int, num_mon, g_conf.num_mon);
CF_READ("global", int, num_mon, g_conf.num_mds);
CF_READ("global", bool, file_logs, g_conf.file_logs);
CF_READ("global", bool, log, g_conf.log);
CF_READ("global", int, log_interval, g_conf.log_interval);
- CF_READ("global", str, log_name, g_conf.log_name);
+ CF_READ_STR("global", str_alloc, log_name, g_conf.log_name);
CF_READ("global", bool, log_messages, g_conf.log_messages);
CF_READ("global", bool, log_pins, g_conf.log_pins);
- CF_READ("global", bool, dout_dir, g_conf.dout_dir);
- CF_READ("global", bool, dout_sym_dir, g_conf.dout_sym_dir);
+ CF_READ_STR("global", str_alloc, dout_dir, g_conf.dout_dir);
+ CF_READ_STR("global", str_alloc, dout_sym_dir, g_conf.dout_sym_dir);
}
void parse_config_options(std::vector<const char*>& args, bool open)