1/*	$NetBSD: mail_dict.c,v 1.3 2023/12/23 20:30:43 christos 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/*
16/*	This also initializes the support for run-time loading of
17/*	lookup tables, if applicable.
18/*
19/*	The latter requires basic parameter initialization
20/*	by either mail_conf_read() or mail_params_init().
21/* LICENSE
22/* .ad
23/* .fi
24/*	The Secure Mailer license must be distributed with this software.
25/* AUTHOR(S)
26/*	Wietse Venema
27/*	IBM T.J. Watson Research
28/*	P.O. Box 704
29/*	Yorktown Heights, NY 10598, USA
30/*
31/*	Wietse Venema
32/*	Google, Inc.
33/*	111 8th Avenue
34/*	New York, NY 10011, USA
35/*--*/
36
37/* System library. */
38
39#include <sys_defs.h>
40
41/* Utility library. */
42
43#include <dict.h>
44#include <msg.h>
45#include <mymalloc.h>
46#include <stringops.h>
47#include <dynamicmaps.h>
48
49/* Global library. */
50
51#include <dict_proxy.h>
52#include <dict_ldap.h>
53#include <dict_mysql.h>
54#include <dict_pgsql.h>
55#include <dict_sqlite.h>
56#include <dict_memcache.h>
57#include <mail_dict.h>
58#include <mail_params.h>
59#include <mail_dict.h>
60
61static const DICT_OPEN_INFO dict_open_info[] = {
62    DICT_TYPE_PROXY, dict_proxy_open, mkmap_proxy_open,
63#ifndef USE_DYNAMIC_MAPS
64#ifdef HAS_LDAP
65    DICT_TYPE_LDAP, dict_ldap_open, 0,
66#endif
67#ifdef HAS_MYSQL
68    DICT_TYPE_MYSQL, dict_mysql_open, 0,
69#endif
70#ifdef HAS_PGSQL
71    DICT_TYPE_PGSQL, dict_pgsql_open, 0,
72#endif
73#ifdef HAS_SQLITE
74    DICT_TYPE_SQLITE, dict_sqlite_open, 0,
75#endif
76#endif					/* !USE_DYNAMIC_MAPS */
77    DICT_TYPE_MEMCACHE, dict_memcache_open, 0,
78    0,
79};
80
81/* mail_dict_init - dictionaries that depend on Postfix-specific interfaces */
82
83void    mail_dict_init(void)
84{
85    const DICT_OPEN_INFO *dp;
86
87#ifdef USE_DYNAMIC_MAPS
88    char   *path;
89
90    path = concatenate(var_meta_dir, "/", "dynamicmaps.cf",
91#ifdef SHLIB_VERSION
92		       ".", SHLIB_VERSION,
93#endif
94		       (char *) 0);
95    dymap_init(path, var_shlib_dir);
96    myfree(path);
97#endif
98
99    for (dp = dict_open_info; dp->type; dp++)
100	dict_open_register(dp);
101}
102
103#ifdef TEST
104
105 /*
106  * Proof-of-concept test program.
107  */
108
109#include <mail_proto.h>
110#include <mail_params.h>
111
112int     main(int argc, char **argv)
113{
114    var_queue_dir = DEF_QUEUE_DIR;
115    var_proxymap_service = DEF_PROXYMAP_SERVICE;
116    var_proxywrite_service = DEF_PROXYWRITE_SERVICE;
117    var_ipc_timeout = 3600;
118    mail_dict_init();
119    dict_test(argc, argv);
120    return (0);
121}
122
123#endif
124