[dovecot-cvs] dovecot/src/lib-settings settings.c, 1.16, 1.17 settings.h, 1.4, 1.5

tss at dovecot.org tss at dovecot.org
Fri Dec 15 16:55:44 UTC 2006


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

Modified Files:
	settings.c settings.h 
Log Message:
Added context parameter type safety checks for most callback APIs.



Index: settings.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-settings/settings.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- settings.c	18 Nov 2006 13:41:40 -0000	1.16
+++ settings.c	15 Dec 2006 16:55:42 -0000	1.17
@@ -8,6 +8,8 @@
 #include <stdio.h>
 #include <fcntl.h>
 
+settings_section_callback_t *null_settings_section_callback = NULL;
+
 static const char *get_bool(const char *value, bool *result)
 {
 	if (strcasecmp(value, "yes") == 0)
@@ -59,6 +61,7 @@
 
 #define IS_WHITE(c) ((c) == ' ' || (c) == '\t')
 
+#undef settings_read
 bool settings_read(const char *path, const char *section,
 		   settings_callback_t *callback,
 		   settings_section_callback_t *sect_callback, void *context)

Index: settings.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-settings/settings.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- settings.h	13 Jan 2006 20:26:20 -0000	1.4
+++ settings.h	15 Dec 2006 16:55:42 -0000	1.5
@@ -21,6 +21,8 @@
 typedef bool settings_section_callback_t(const char *type, const char *name,
 					 void *context, const char **errormsg);
 
+extern settings_section_callback_t *null_settings_section_callback;
+
 const char *
 parse_setting_from_defs(pool_t pool, struct setting_def *defs, void *base,
 			const char *key, const char *value);
@@ -28,5 +30,12 @@
 bool settings_read(const char *path, const char *section,
 		   settings_callback_t *callback,
 		   settings_section_callback_t *sect_callback, void *context);
+#ifdef CONTEXT_TYPE_SAFETY
+#  define settings_read(path, section, callback, sect_callback, context) \
+	({(void)(1 ? 0 : callback(0, 0, context)); \
+	  (void)(1 ? 0 : sect_callback(0, 0, context, 0)); \
+	  settings_read(path, section, (settings_callback_t *)callback, \
+		(settings_section_callback_t *)sect_callback, context); })
+#endif
 
 #endif



More information about the dovecot-cvs mailing list