+ if(condition->db_key != ID_TIME_INTERVAL) {
+ regfree(&condition->db_value_regexp);
+ }
+}
+
+const char *eat_space(const char *s) {
+ while(*s == ' ' || *s == '\t') { s++; }
+ return s;
+}
+
+void read_rc_file(const char *rc_filename) {
+ char raw_line[BUFFER_SIZE];
+ char command[TOKEN_BUFFER_SIZE], tmp_token[TOKEN_BUFFER_SIZE];
+
+ FILE *rc_file;
+ int line_number;
+ const char *s;
+ char *t;
+
+ rc_file = fopen(rc_filename, "r");
+
+ if(rc_file) {
+ line_number = 1;
+ while(fgets(raw_line, BUFFER_SIZE, rc_file)) {
+ t = raw_line;
+ while(*t) { if(*t == '\n') { *t = '\0'; }; t++; }
+
+ s = raw_line;
+ s = eat_space(s);
+
+ if(*s && *s != '#') {
+ s = parse_token(command, TOKEN_BUFFER_SIZE, ' ', s);
+
+ if(strcmp(command, "alias") == 0) {
+ struct alias_node *a = safe_malloc(sizeof(struct alias_node));
+ a->next = global_alias_list;
+ global_alias_list = a;
+ if(s) {
+ s = eat_space(s);
+ s = parse_token(tmp_token, TOKEN_BUFFER_SIZE, '=', s);
+ a->alias = strdup(tmp_token);
+ if(s) {
+ s = eat_space(s);
+ a->value = strdup(s);
+ } else {
+ fprintf(stderr, "%s:%d syntax error, missing alias value.\n",
+ rc_filename,
+ line_number);
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ fprintf(stderr, "%s:%d syntax error, missing alias key.\n",
+ rc_filename,
+ line_number);
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ fprintf(stderr, "%s:%d syntax error, unknown command '%s'.\n",
+ rc_filename,
+ line_number,
+ command);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ line_number++;
+ }
+ fclose(rc_file);