[dovecot-cvs] dovecot/src/lib-dict .cvsignore, 1.1, 1.2 Makefile.am, 1.5, 1.6 dict-client.c, 1.13, 1.14 dict-client.h, 1.4, 1.5 dict-db.c, 1.1, 1.2 dict-private.h, 1.6, 1.7 dict-sql.c, 1.12, 1.13 dict.c, 1.10, 1.11 dict.h, 1.7, 1.8

tss-movial at dovecot.org tss-movial at dovecot.org
Sun Jul 30 22:27:30 EEST 2006


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

Modified Files:
	.cvsignore Makefile.am dict-client.c dict-client.h dict-db.c 
	dict-private.h dict-sql.c dict.c dict.h 
Log Message:
Berkeley DB dict support is now enabled only when using --with-db configure option.



Index: .cvsignore
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- .cvsignore	10 Dec 2005 18:59:03 -0000	1.1
+++ .cvsignore	30 Jul 2006 19:27:26 -0000	1.2
@@ -6,3 +6,4 @@
 Makefile
 Makefile.in
 so_locations
+dict-drivers-register.c

Index: Makefile.am
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am	30 Jul 2006 18:49:38 -0000	1.5
+++ Makefile.am	30 Jul 2006 19:27:26 -0000	1.6
@@ -1,5 +1,7 @@
 noinst_LIBRARIES = libdict.a
 
+dict_drivers = @dict_drivers@
+
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/lib \
 	-I$(top_srcdir)/src/lib-sql \
@@ -10,11 +12,44 @@
 	dict.c \
 	dict-client.c \
 	dict-db.c \
-	dict-sql.c
+	dict-sql.c \
+	dict-drivers-register.c
 
 noinst_HEADERS = \
 	dict.h \
 	dict-client.h \
 	dict-private.h \
-	dict-db.h \
 	dict-sql.h
+
+dict-drivers-register.c: Makefile
+	rm -f $@
+	echo '/* this file automatically generated by Makefile */' >$@
+	echo '#include "lib.h"' >>$@
+	echo '#include "dict.h"' >>$@
+	echo '#include "dict-sql.h"' >>$@
+	for i in $(dict_drivers) null; do \
+	  if [ "$${i}" != "null" ]; then \
+	        echo "extern struct dict dict_driver_$${i};" >>$@ ; \
+	  fi \
+	done
+	echo 'void dict_drivers_register_all(void) {' >>$@
+	echo 'dict_sql_register();' >>$@
+	for i in $(dict_drivers) null; do \
+	  if [ "$${i}" != "null" ]; then \
+	        echo "dict_driver_register(&dict_driver_$${i});" >>$@ ; \
+	  fi \
+	done
+	echo '}' >>$@
+	echo 'void dict_drivers_unregister_all(void) {' >>$@
+	echo 'dict_sql_unregister();' >>$@
+	for i in $(dict_drivers) null; do \
+	  if [ "$${i}" != "null" ]; then \
+	        echo "dict_driver_unregister(&dict_driver_$${i});" >>$@ ; \
+	  fi \
+	done
+	echo '}' >>$@
+
+DISTFILES = $(DIST_COMMON) $(dist_sources) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+distclean-generic:
+	rm -f Makefile dict-drivers-register.c

Index: dict-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-client.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- dict-client.c	30 Jul 2006 18:49:38 -0000	1.13
+++ dict-client.c	30 Jul 2006 19:27:26 -0000	1.14
@@ -282,7 +282,7 @@
 }
 
 static struct dict *
-client_dict_init(struct dict *dict_class, const char *uri,
+client_dict_init(struct dict *driver, const char *uri,
 		 enum dict_data_type value_type, const char *username)
 {
 	struct client_dict *dict;
@@ -299,7 +299,7 @@
 	pool = pool_alloconly_create("client dict", 1024);
 	dict = p_new(pool, struct client_dict, 1);
 	dict->pool = pool;
-	dict->dict = *dict_class;
+	dict->dict = *driver;
 	dict->value_type = value_type;
 	dict->username = p_strdup(pool, username);
 
@@ -536,7 +536,7 @@
 	t_pop();
 }
 
-static struct dict client_dict = {
+struct dict dict_driver_client = {
 	MEMBER(name) "proxy",
 
 	{
@@ -554,13 +554,3 @@
 		client_dict_atomic_inc
 	}
 };
-
-void dict_client_register(void)
-{
-	dict_class_register(&client_dict);
-}
-
-void dict_client_unregister(void)
-{
-	dict_class_unregister(&client_dict);
-}

Index: dict-client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-client.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dict-client.h	30 Jul 2006 18:49:38 -0000	1.4
+++ dict-client.h	30 Jul 2006 19:27:26 -0000	1.5
@@ -1,6 +1,8 @@
 #ifndef __DICT_CLIENT_H
 #define __DICT_CLIENT_H
 
+#include "dict.h"
+
 #define DEFAULT_DICT_SERVER_SOCKET_PATH PKG_RUNDIR"/dict-server"
 
 #define DICT_CLIENT_PROTOCOL_MAJOR_VERSION 2
@@ -31,10 +33,9 @@
 	DICT_PROTOCOL_REPLY_FAIL = 'F'
 };
 
+extern struct dict dict_driver_client;
+
 const char *dict_client_escape(const char *src);
 const char *dict_client_unescape(const char *src);
 
-void dict_client_register(void);
-void dict_client_unregister(void);
-
 #endif

Index: dict-db.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-db.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dict-db.c	30 Jul 2006 18:49:38 -0000	1.1
+++ dict-db.c	30 Jul 2006 19:27:26 -0000	1.2
@@ -2,8 +2,8 @@
 
 #include "lib.h"
 #include "dict-private.h"
-#include "dict-db.h"
 
+#ifdef BUILD_DB
 #include <stdlib.h>
 #include <db.h>
 
@@ -59,7 +59,7 @@
 		(*ua < *ub ? -1 : 0);
 }
 
-static struct dict *db_dict_init(struct dict *dict_class, const char *uri,
+static struct dict *db_dict_init(struct dict *driver, const char *uri,
 				 enum dict_data_type value_type,
 				 const char *username __attr_unused__)
 {
@@ -72,7 +72,7 @@
 	pool = pool_alloconly_create("db dict", 1024);
 	dict = p_new(pool, struct db_dict, 1);
 	dict->pool = pool;
-	dict->dict = *dict_class;
+	dict->dict = *driver;
 
 	/* prepare the environment */
 	ret = db_env_create(&dict->db_env, 0);
@@ -407,7 +407,7 @@
 	/* FIXME */
 }
 
-static struct dict dict_db_class = {
+struct dict dict_driver_db = {
 	MEMBER(name) "db",
 	{
 		db_dict_init,
@@ -424,13 +424,4 @@
 		db_dict_atomic_inc
 	}
 };
-
-void dict_db_register(void)
-{
-	dict_class_register(&dict_db_class);
-}
-
-void dict_db_unregister(void)
-{
-	dict_class_unregister(&dict_db_class);
-}
+#endif

Index: dict-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-private.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dict-private.h	30 Jul 2006 18:49:38 -0000	1.6
+++ dict-private.h	30 Jul 2006 19:27:26 -0000	1.7
@@ -4,7 +4,7 @@
 #include "dict.h"
 
 struct dict_vfuncs {
-	struct dict *(*init)(struct dict *dict_class, const char *uri,
+	struct dict *(*init)(struct dict *dict_driver, const char *uri,
 			     enum dict_data_type value_type,
 			     const char *username);
 	void (*deinit)(struct dict *dict);

Index: dict-sql.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-sql.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dict-sql.c	30 Jul 2006 18:49:38 -0000	1.12
+++ dict-sql.c	30 Jul 2006 19:27:26 -0000	1.13
@@ -102,7 +102,7 @@
 }
 
 static struct dict *
-sql_dict_init(struct dict *dict_class, const char *uri,
+sql_dict_init(struct dict *driver, const char *uri,
 	      enum dict_data_type value_type __attr_unused__,
 	      const char *username)
 {
@@ -112,7 +112,7 @@
 	pool = pool_alloconly_create("sql dict", 1024);
 	dict = p_new(pool, struct sql_dict, 1);
 	dict->pool = pool;
-	dict->dict = *dict_class;
+	dict->dict = *driver;
 	dict->username = p_strdup(pool, username);
 
 	if (sql_dict_read_config(dict, uri) < 0) {
@@ -121,7 +121,7 @@
 	}
 
 	t_push();
-	dict->db = sql_init(dict_class->name, dict->connect_string);
+	dict->db = sql_init(driver->name, dict->connect_string);
 	t_pop();
 	return &dict->dict;
 }
@@ -440,7 +440,7 @@
 	}
 };
 
-static struct dict *dict_sql_classes;
+static struct dict *dict_sql_drivers;
 
 void dict_sql_register(void)
 {
@@ -449,13 +449,13 @@
 
 	/* @UNSAFE */
 	drivers = array_get(&sql_drivers, &count);
-	dict_sql_classes = i_new(struct dict, count + 1);
+	dict_sql_drivers = i_new(struct dict, count + 1);
 
 	for (i = 0; i < count; i++) {
-		dict_sql_classes[i] = sql_dict;
-		dict_sql_classes[i].name = drivers[i]->name;
+		dict_sql_drivers[i] = sql_dict;
+		dict_sql_drivers[i].name = drivers[i]->name;
 
-		dict_class_register(&dict_sql_classes[i]);
+		dict_driver_register(&dict_sql_drivers[i]);
 	}
 }
 
@@ -463,7 +463,7 @@
 {
 	int i;
 
-	for (i = 0; dict_sql_classes[i].name != NULL; i++)
-		dict_class_unregister(&dict_sql_classes[i]);
-	i_free(dict_sql_classes);
+	for (i = 0; dict_sql_drivers[i].name != NULL; i++)
+		dict_driver_unregister(&dict_sql_drivers[i]);
+	i_free(dict_sql_drivers);
 }

Index: dict.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dict.c	30 Jul 2006 18:49:38 -0000	1.10
+++ dict.c	30 Jul 2006 19:27:26 -0000	1.11
@@ -5,14 +5,14 @@
 #include "dict-sql.h"
 #include "dict-private.h"
 
-static ARRAY_DEFINE(dict_classes, struct dict *);
+static ARRAY_DEFINE(dict_drivers, struct dict *);
 
-static struct dict *dict_class_lookup(const char *name)
+static struct dict *dict_driver_lookup(const char *name)
 {
 	struct dict *const *dicts;
 	unsigned int i, count;
 
-	dicts = array_get(&dict_classes, &count);
+	dicts = array_get(&dict_drivers, &count);
 	for (i = 0; i < count; i++) {
 		if (strcmp(dicts[i]->name, name) == 0)
 			return dicts[i];
@@ -20,35 +20,35 @@
 	return NULL;
 }
 
-void dict_class_register(struct dict *dict_class)
+void dict_driver_register(struct dict *driver)
 {
-	if (!array_is_created(&dict_classes))
-		ARRAY_CREATE(&dict_classes, default_pool, struct dict *, 8);
+	if (!array_is_created(&dict_drivers))
+		ARRAY_CREATE(&dict_drivers, default_pool, struct dict *, 8);
 
-	if (dict_class_lookup(dict_class->name) != NULL) {
-		i_fatal("dict_class_register(%s): Already registered",
-			dict_class->name);
+	if (dict_driver_lookup(driver->name) != NULL) {
+		i_fatal("dict_driver_register(%s): Already registered",
+			driver->name);
 	}
-	array_append(&dict_classes, &dict_class, 1);
+	array_append(&dict_drivers, &driver, 1);
 }
 
-void dict_class_unregister(struct dict *dict_class)
+void dict_driver_unregister(struct dict *driver)
 {
 	struct dict *const *dicts;
 	unsigned int i, count;
 
-	dicts = array_get(&dict_classes, &count);
+	dicts = array_get(&dict_drivers, &count);
 	for (i = 0; i < count; i++) {
-		if (dicts[i] == dict_class) {
-			array_delete(&dict_classes, i, 1);
+		if (dicts[i] == driver) {
+			array_delete(&dict_drivers, i, 1);
 			break;
 		}
 	}
 
 	i_assert(i < count);
 
-	if (array_count(&dict_classes) == 0)
-		array_free(&dict_classes);
+	if (array_count(&dict_drivers) == 0)
+		array_free(&dict_drivers);
 }
 
 struct dict *dict_init(const char *uri, enum dict_data_type value_type,
@@ -65,7 +65,7 @@
 
 	t_push();
 	name = t_strdup_until(uri, p);
-	dict = dict_class_lookup(name);
+	dict = dict_driver_lookup(name);
 	if (dict == NULL) {
 		i_error("Unknown dict module: %s", name);
 		t_pop();

Index: dict.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dict.h	30 Jul 2006 18:49:38 -0000	1.7
+++ dict.h	30 Jul 2006 19:27:26 -0000	1.8
@@ -17,8 +17,11 @@
 	DICT_DATA_TYPE_UINT32
 };
 
-void dict_class_register(struct dict *dict_class);
-void dict_class_unregister(struct dict *dict_class);
+void dict_driver_register(struct dict *driver);
+void dict_driver_unregister(struct dict *driver);
+
+void dict_drivers_register_all(void);
+void dict_drivers_unregister_all(void);
 
 /* Open dictionary with given URI (type:data).
    If URI is invalid, returns NULL. */



More information about the dovecot-cvs mailing list