| 204 | } |
| 205 | |
| 206 | void |
| 207 | cf_parse(void) |
| 208 | { |
| 209 | FILE *f = fopen(CONFIG_FILE, "r"); |
| 210 | if (!f) |
| 211 | die("Cannot open %s: %m", CONFIG_FILE); |
| 212 | |
| 213 | char line[MAX_LINE_LEN]; |
| 214 | while (fgets(line, sizeof(line), f)) |
| 215 | { |
| 216 | line_number++; |
| 217 | char *nl = strchr(line, '\n'); |
| 218 | if (!nl) |
| 219 | cf_err("Line not terminated or too long"); |
| 220 | *nl = 0; |
| 221 | |
| 222 | if (!line[0] || line[0] == '#') |
| 223 | continue; |
| 224 | |
| 225 | char *s = line; |
| 226 | while (*s && *s != ' ' && *s != '\t' && *s != '=') |
| 227 | s++; |
| 228 | while (*s == ' ' || *s == '\t') |
| 229 | *s++ = 0; |
| 230 | if (*s != '=') |
| 231 | cf_err("Syntax error, expecting key=value"); |
| 232 | *s++ = 0; |
| 233 | while (*s == ' ' || *s == '\t') |
| 234 | *s++ = 0; |
| 235 | |
| 236 | cf_entry(line, s); |
| 237 | } |
| 238 | |
| 239 | fclose(f); |
| 240 | cf_find_ids(); |
| 241 | cf_check(); |
| 242 | } |
| 243 | |
| 244 | struct cf_per_box * |
| 245 | cf_per_box(int box_id) |