[dovecot-cvs] dovecot/src/lib module-dir.c, 1.17, 1.18 module-dir.h, 1.6, 1.7

cras at dovecot.org cras at dovecot.org
Wed Apr 12 17:04:57 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv31579

Modified Files:
	module-dir.c module-dir.h 
Log Message:
Allow giving module names in non-basename form.



Index: module-dir.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- module-dir.c	26 Feb 2006 12:15:50 -0000	1.17
+++ module-dir.c	12 Apr 2006 14:04:55 -0000	1.18
@@ -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 {

Index: module-dir.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- module-dir.h	26 Feb 2006 12:15:50 -0000	1.6
+++ module-dir.h	12 Apr 2006 14:04:55 -0000	1.7
@@ -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



More information about the dovecot-cvs mailing list