Changeset 808 for trunk/ithildin/lib/module.c
- Timestamp:
- 06/05/07 10:46:00 (5 years ago)
- File:
-
- 1 edited
-
trunk/ithildin/lib/module.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ithildin/lib/module.c
r806 r808 70 70 bool new = false; 71 71 char *s = NULL; 72 char *dname = NULL; 72 73 73 74 if (cep->type == CONF_TYPE_LIST) { … … 97 98 if (clp != NULL) { 98 99 if ((s = conf_find_entry("config", clp, 1)) != NULL) { 99 /* try to access their config file as specified, if it does not 100 * come with a path prefix, we try prepending the conf 101 * directory, then with the full pathname make sure we can load 102 * the conf. if we can't we won't load the module */ 103 m->conffile = malloc(PATH_MAX); 104 if (*s != 's') /* XXX: this will suck come windows support time */ 105 snprintf(m->conffile, PATH_MAX, "%s/%s", me.conf_path, s); 106 else 107 strlcpy(m->conffile, s, PATH_MAX); 108 109 } 110 111 if ((s = conf_find_entry("load", clp, 1)) != NULL && 112 str_conv_bool(s, false)) 113 m->flags |= MODULE_FL_AUTOLOAD; 114 else 100 /* Let the config code sort out the correct path.. */ 101 m->conffile = strdup(s); 102 } 103 104 if ((s = conf_find_entry("load", clp, 1)) != NULL) { 105 if (str_conv_bool(s, false)) 106 m->flags |= MODULE_FL_AUTOLOAD; 107 } else 115 108 m->flags |= MODULE_FL_AUTOLOAD; /* default is to load. */ 116 109 … … 128 121 /* let's also take a stab at guessing their module config file name. 129 122 * We try two things: $confdir/modulename.conf and 130 * $confdir/modulename/modulename.conf. If neither works we do not 131 * make any further efforts. We determine the usability of these 132 * files through the access() call. */ 123 * $confdir/modulename/modulename.conf. For modules with '.'s in 124 * their name we replace the '.'s with path separators and try that 125 * way, using the last portion of the module's name as the name of 126 * the config file. */ 127 s = dname = strdup(m->name); 128 while (*s != '\0') { 129 if (*s == '.') 130 *s = '/'; 131 s++; 132 } 133 133 134 s = malloc(PATH_MAX); 134 snprintf(s, PATH_MAX, "%s/%s.conf", me.conf_path, m->name); 135 /* first try the path without the additional directory layer */ 136 snprintf(s, PATH_MAX, "%s/%s.conf", me.conf_path, dname); 135 137 if (access(s, R_OK) == 0) 136 138 m->conffile = s; 137 139 else { 138 /* don't try the directory method if the module name already 139 * contains slashes (indicating it is subdirectory-ized already) */ 140 if (!strchr(s, '/')) { 141 snprintf(s, PATH_MAX, "%s/%s/%s.conf", me.conf_path, m->name, 142 m->name); 143 if (access(s, R_OK) == 0) 144 m->conffile = s; 145 } 146 } 140 /* Now try the subdirectory method, this is a little weird since 141 * we need to get just the last component of the module's name 142 * (if it has dots in it) */ 143 snprintf(s, PATH_MAX, "%s/%s/%s.conf", me.conf_path, dname, 144 (strchr(m->name, '.') ? strrchr(m->name, '.') + 1 : 145 m->name)); 146 if (access(s, R_OK) == 0) 147 m->conffile = s; 148 } 149 free(dname); 150 if (m->conffile == NULL) 151 free(s); 147 152 } 148 153
Note: See TracChangeset
for help on using the changeset viewer.
