4 int read_config(string conf_file_name, config_t * config) {
5 fstream conf_file(conf_file_name.c_str(), ios::in);
6 char line[MAX_CONFIG_LINE_SIZE];
8 if (!conf_file.is_open()) {
12 while ((conf_file.getline(line, MAX_CONFIG_LINE_SIZE))) {
13 string conf_line = line;
16 int offset, ltrim_index, rtrim_index;
18 if (conf_line[0] == '#') {
22 offset = conf_line.find(":", 0);
23 tag = conf_line.substr(0,offset);
26 istringstream tag_stream(tag, istringstream::in);
33 // basic whitespace trimming, we assume that the config handlers will deal with
34 // tokenizing and further formatting
35 value = conf_line.substr(offset + 1, conf_line.length() - offset);
36 ltrim_index = value.find_first_not_of(" \t");
37 rtrim_index = value.find_last_not_of(" \t");
38 value = value.substr(ltrim_index, (rtrim_index + 1) - ltrim_index);
40 (*config)[tag] = value;