-/* Returns 0 if requested config files were loaded,
- * 1 if default files were loaded,
- * -1 if no files were loaded.
- * Prints error message if files cannot be loaded.
- */
-
-int
-loadConfigDir(
- const char *bundleName, // bundle directory name (e.g. "System")
- BOOL useDefault, // use Default.table instead of instance tables
- const char **table, // returns pointer to config table
- BOOL allocTable // malloc the table and return in *table
-)
-{
- char *buf;
- int i, max, ret;
- const char *device_dir = usrDevices();
-
- buf = malloc(256);
- ret = 0;
-
- // load up to 99 instance tables
- if (allocTable)
- max = 1;
- else
- max = 99;
- for (i=0; i < max; i++) {
- sprintf(buf, "%s/%s.config/Instance%d.table",
- device_dir,
- bundleName, i);
- if (useDefault || (loadConfigFile(buf, table, allocTable) != 0)) {
- if (i == 0) {
- // couldn't load first instance table;
- // try the default table
- sprintf(buf, "%s/%s.config/%s",
- device_dir,
- bundleName,
- IO_DEFAULT_TABLE_FILENAME);
- if (loadConfigFile(buf, table, allocTable) == 0) {
- ret = 1;
- } else {
- if (!allocTable) {
- error("Config file \"%s\" not found\n", buf);
- sleep(1); // let the message be seen!
- }
- ret = -1;
- }
- }
- // we must be done.
- break;
- }
- }
- free(buf);
- return ret;
-}
-
-
-#define USR_SYSTEM_CONFIG \
- USR_DEVICES "/System.config"
-#define USR_SYSTEM_DEFAULT_FILE \
- USR_SYSTEM_CONFIG "/Default.table"
-#define ARCH_SYSTEM_CONFIG \
- ARCH_DEVICES "/System.config"
-#define ARCH_SYSTEM_DEFAULT_FILE \
- ARCH_SYSTEM_CONFIG "/Default.table"
-#define SYSTEM_CONFIG "System"