Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


f54d7650c0ec29b01462673213a1c8bb06f99159
[palacios.releases.git] / misc / network_servers / vtl / config.cc
1 #include "config.h"
2
3
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];
7
8   if (!conf_file.is_open()) {
9     return -1;
10   }
11
12   while ((conf_file.getline(line, MAX_CONFIG_LINE_SIZE))) {
13     string conf_line = line;
14     string tag;
15     string value;
16     int offset, ltrim_index, rtrim_index;
17
18     if (conf_line[0] == '#') {
19       continue;
20     }
21
22     offset = conf_line.find(":", 0);
23     tag = conf_line.substr(0,offset);
24
25     // kill white space
26     istringstream tag_stream(tag, istringstream::in);
27     tag_stream >> tag;
28
29     if (tag.empty()) {
30       continue;
31     }
32
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);
39
40     (*config)[tag] = value;
41   }
42   return 0;
43 }