xref: /netbsd-src/external/ibm-public/postfix/dist/src/global/mail_dict.c (revision fdd524d4ccd2bb0c6f67401e938dabf773eb0372)
1 /*	$NetBSD: mail_dict.c,v 1.1.1.3 2013/01/02 18:58:58 tron Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	mail_dict 3
6 /* SUMMARY
7 /*	register application-specific dictionaries
8 /* SYNOPSIS
9 /*	#include <mail_dict.h>
10 /*
11 /*	void	mail_dict_init()
12 /* DESCRIPTION
13 /*	This module registers dictionary types that depend on higher-level
14 /*	Postfix-specific interfaces and protocols.
15 /* LICENSE
16 /* .ad
17 /* .fi
18 /*	The Secure Mailer license must be distributed with this software.
19 /* AUTHOR(S)
20 /*	Wietse Venema
21 /*	IBM T.J. Watson Research
22 /*	P.O. Box 704
23 /*	Yorktown Heights, NY 10598, USA
24 /*--*/
25 
26 /* System library. */
27 
28 #include <sys_defs.h>
29 
30 /* Utility library. */
31 
32 #include <dict.h>
33 #include <msg.h>
34 
35 /* Global library. */
36 
37 #include <dict_proxy.h>
38 #include <dict_ldap.h>
39 #include <dict_mysql.h>
40 #include <dict_pgsql.h>
41 #include <dict_sqlite.h>
42 #include <dict_memcache.h>
43 #include <mail_dict.h>
44 
45 typedef struct {
46     char   *type;
47     struct DICT *(*open) (const char *, int, int);
48 } DICT_OPEN_INFO;
49 
50 static const DICT_OPEN_INFO dict_open_info[] = {
51     DICT_TYPE_PROXY, dict_proxy_open,
52 #ifdef HAS_LDAP
53     DICT_TYPE_LDAP, dict_ldap_open,
54 #endif
55 #ifdef HAS_MYSQL
56     DICT_TYPE_MYSQL, dict_mysql_open,
57 #endif
58 #ifdef HAS_PGSQL
59     DICT_TYPE_PGSQL, dict_pgsql_open,
60 #endif
61 #ifdef HAS_SQLITE
62     DICT_TYPE_SQLITE, dict_sqlite_open,
63 #endif
64     DICT_TYPE_MEMCACHE, dict_memcache_open,
65     0,
66 };
67 
68 /* mail_dict_init - dictionaries that depend on Postfix-specific interfaces */
69 
70 void    mail_dict_init(void)
71 {
72     const DICT_OPEN_INFO *dp;
73 
74     for (dp = dict_open_info; dp->type; dp++)
75 	dict_open_register(dp->type, dp->open);
76 }
77 
78 #ifdef TEST
79  /*
80   * Proof-of-concept test program.
81   */
82 
83 #include <mail_proto.h>
84 #include <mail_params.h>
85 
86 int     main(int argc, char **argv)
87 {
88     var_queue_dir = DEF_QUEUE_DIR;
89     var_proxymap_service = DEF_PROXYMAP_SERVICE;
90     var_proxywrite_service = DEF_PROXYWRITE_SERVICE;
91     var_ipc_timeout = 3600;
92     mail_dict_init();
93     dict_test(argc, argv);
94     return (0);
95 }
96 
97 #endif
98