| 420 | */ |
| 421 | |
| 422 | int |
| 423 | loadConfigDir( |
| 424 | char *bundleName, // bundle directory name (e.g. "System.config") |
| 425 | INTN useDefault, // use Default.table instead of instance tables |
| 426 | char **table, // returns pointer to config table |
| 427 | INTN allocTable // malloc the table and return in *table |
| 428 | ) |
| 429 | { |
| 430 | char *buf; |
| 431 | INTN i, ret; |
| 432 | |
| 433 | buf = malloc(256); |
| 434 | ret = 0; |
| 435 | |
| 436 | // load up to 99 instance tables |
| 437 | for (i=0; i < 99; i++) { |
| 438 | sprintf(buf, "%s%s.config/Instance%d.table", IO_CONFIG_DIR, |
| 439 | bundleName, i); |
| 440 | if (useDefault || (loadConfigFile(buf, table, allocTable) != 0)) { |
| 441 | if (i == 0) { |
| 442 | // couldn't load first instance table; |
| 443 | // try the default table |
| 444 | sprintf(buf, "%s%s.config/%s", IO_CONFIG_DIR, bundleName, |
| 445 | IO_DEFAULT_TABLE_FILENAME); |
| 446 | if (loadConfigFile(buf, table, allocTable) == 0) { |
| 447 | ret = 1; |
| 448 | } else { |
| 449 | if (!allocTable) |
| 450 | error("Config file \"%s\" not found\n", buf); |
| 451 | ret = -1; |
| 452 | } |
| 453 | } |
| 454 | // we must be done. |
| 455 | break; |
| 456 | } |
| 457 | } |
| 458 | free(buf); |
| 459 | return ret; |
| 460 | } |
| 461 | |
| 462 | |
| 463 | #define SYSTEM_DEFAULT_FILE \ |
no test coverage detected