* Returns 0 if file loaded OK, * -1 if file was not loaded * Does not print error messages. * Returns pointer to table in memory in *table. */
| 379 | * Returns pointer to table in memory in *table. |
| 380 | */ |
| 381 | int |
| 382 | loadConfigFile( char *configFile, char **table, INTN allocTable) |
| 383 | { |
| 384 | char *configPtr = bootArgs->configEnd; |
| 385 | INTN fd, count; |
| 386 | |
| 387 | /* Read config file into memory */ |
| 388 | if ((fd = open(configFile, 0)) >= 0) |
| 389 | { |
| 390 | if (allocTable) { |
| 391 | configPtr = malloc(file_size(fd)+2); |
| 392 | } else { |
| 393 | if ((configPtr - bootArgs->config) > CONFIG_SIZE) { |
| 394 | error("No room in memory for config file %s\n",configFile); |
| 395 | close(fd); |
| 396 | return -1; |
| 397 | } |
| 398 | localPrintf("Reading config: %s\n",configFile); |
| 399 | } |
| 400 | if (table) *table = configPtr; |
| 401 | count = read(fd, configPtr, IO_CONFIG_DATA_SIZE); |
| 402 | close(fd); |
| 403 | |
| 404 | configPtr += count; |
| 405 | *configPtr++ = 0; |
| 406 | *configPtr = 0; |
| 407 | if (!allocTable) |
| 408 | bootArgs->configEnd = configPtr; |
| 409 | |
| 410 | return 0; |
| 411 | } else { |
| 412 | return -1; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | /* Returns 0 if requested config files were loaded, |
| 417 | * 1 if default files were loaded, |
no test coverage detected