Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4167:32dd28f96dce HEAD
Allow giving module names in non-basename form.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 12 Apr 2006 17:04:55 +0300 |
parents | cda5c90cae57 |
children | 3f27bf7832a2 |
files | src/lib/module-dir.c src/lib/module-dir.h |
diffstat | 2 files changed, 37 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/module-dir.c Wed Apr 12 14:44:53 2006 +0300 +++ b/src/lib/module-dir.c Wed Apr 12 17:04:55 2006 +0300 @@ -37,6 +37,28 @@ return ret; } +const char *module_file_get_name(const char *fname) +{ + const char *p; + + /* [lib][nn_]name(.so) */ + if (strncmp(fname, "lib", 3) == 0) + fname += 3; + + for (p = fname; *p != '\0'; p++) { + if (*p < '0' || *p > '9') + break; + } + if (*p == '_') + fname = p + 1; + + p = strstr(fname, ".so"); + if (p == NULL) + return fname; + + return t_strdup_until(fname, p); +} + static void *get_symbol(struct module *module, const char *symbol, bool quiet) { if (quiet) @@ -174,28 +196,22 @@ qsort(names_p, count, sizeof(const char *), module_name_cmp); t_push(); - module_names_arr = module_names == NULL ? NULL : - t_strsplit_spaces(module_names, ", "); + if (module_names == NULL) + module_names_arr = NULL; + else { + module_names_arr = t_strsplit_spaces(module_names, ", "); + /* allow giving the module names also in non-base form. + conver them in here. */ + for (i = 0; module_names_arr[i] != NULL; i++) { + module_names_arr[i] = + module_file_get_name(module_names_arr[i]); + } + } for (i = 0; i < count; i++) { const char *name = names_p[i]; - /* [lib][nn_]name(.so) */ - stripped_name = name; - if (strncmp(stripped_name, "lib", 3) == 0) - stripped_name += 3; - - for (p = stripped_name; *p != '\0'; p++) { - if (*p < '0' || *p > '9') - break; - } - if (*p == '_') - stripped_name = p + 1; - - p = strstr(stripped_name, ".so"); - i_assert(p != NULL); - t_push(); - stripped_name = t_strdup_until(stripped_name, p); + stripped_name = module_file_get_name(name); if (!module_want_load(module_names_arr, stripped_name)) module = NULL; else {
--- a/src/lib/module-dir.h Wed Apr 12 14:44:53 2006 +0300 +++ b/src/lib/module-dir.h Wed Apr 12 17:04:55 2006 +0300 @@ -22,4 +22,7 @@ void *module_get_symbol(struct module *module, const char *symbol); +/* Returns module's base name from the filename. */ +const char *module_file_get_name(const char *fname); + #endif