[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r795 - GNUnet/src/conf
From: |
durner |
Subject: |
[GNUnet-SVN] r795 - GNUnet/src/conf |
Date: |
Thu, 19 May 2005 14:16:27 -0700 (PDT) |
Author: durner
Date: 2005-05-19 14:15:30 -0700 (Thu, 19 May 2005)
New Revision: 795
Modified:
GNUnet/src/conf/confdata.c
Log:
Load values from the config files that are specified in the templates.
Modified: GNUnet/src/conf/confdata.c
===================================================================
--- GNUnet/src/conf/confdata.c 2005-05-19 18:38:15 UTC (rev 794)
+++ GNUnet/src/conf/confdata.c 2005-05-19 21:15:30 UTC (rev 795)
@@ -109,19 +109,65 @@
struct expr *e;
int i = 0;
- if (!name) {
- const char **names = conf_confnames;
-
- while ((name = *names++)) {
- name = conf_expand_value(name);
- if (cfg_parse_file((char *) name) == 0) {
- printf("#\n"
- "# using defaults found in %s\n"
- "#\n", name);
- i = 1;
- break;
+ if (! name) {
+ /* Read default config files as defined in the templates */
+ if (! name && file_list) {
+ struct file *f;
+ i = 1;
+
+ /* Go through the list of used template files */
+ for (f = file_list; f; f = f->next) {
+ char *path, *fn, *key;
+ struct symbol *defFile;
+
+ path = f->name;
+ fn = path + strlen(path);
+
+ /* Get filename without path */
+ while(*fn != '/' && *fn != '\\' && fn != path)
+ fn--;
+ if (fn != path)
+ fn++;
+
+ /* Query default config file */
+ key = malloc(strlen(fn) + 16);
+ sprintf(key, "%s_CONF_DEF_DIR", fn);
+ sym = sym_find(key, "Meta");
+ if (sym) {
+ sprintf(key, "%s_CONF_DEF_FILE", fn);
+ defFile = sym_find(key, "Meta");
+ if (defFile) {
+ char *path, *file;
+
+ sym_calc_value_ext(sym, 1);
+ sym_calc_value_ext(defFile, 1);
+ path =
sym_get_string_value(sym);
+ file =
sym_get_string_value(defFile);
+
+ key = realloc(key, strlen(path)
+ strlen(file) + 2);
+ sprintf(key, "%s%c%s", path,
DIR_SEPARATOR, file);
+ cfg_parse_file(key);
+ }
+ }
+ free(key);
}
}
+
+ /* Read global default files (only if necessary) */
+ if (!i) {
+ const char **names = conf_confnames;
+
+ while ((name = *names++)) {
+ name = conf_expand_value(name);
+ if (cfg_parse_file((char *) name) == 0) {
+ printf("#\n"
+ "# using defaults found in %s\n"
+ "#\n", name);
+ i = 1;
+ break;
+ }
+ }
+ }
}
else {
i = 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r795 - GNUnet/src/conf,
durner <=