]> the.earth.li Git - onak.git/blob - onak-conf.h
Add stacked backend
[onak.git] / onak-conf.h
1 /**
2  * @file onak-conf.h
3  * @brief Routines related to runtime config.
4  *
5  * Copyright 2002 Jonathan McDowell <noodles@earth.li>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 51
18  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef __ONAK_CONF_H_
22 #define __ONAK_CONF_H_
23
24 #include "keydb.h"
25
26 /**
27  * @brief Backend database configuration.
28  *
29  */
30 struct onak_db_config {
31         /** Name, as used to refer to individual backend instances */
32         char *name;
33         /** Backend type [e.g. db4, pg, fs, file] */
34         char *type;
35         /** Location information; directory for file backed, DB name for DBs */
36         char *location;
37         /** Database backend hostname, if appropriate */
38         char *hostname;
39         /** Database backend username, if appropriate */
40         char *username;
41         /** Database backend password, if appropriate */
42         char *password;
43 };
44
45 /**
46  * @brief Runtime configuration for onak.
47  *
48  * This structure holds various runtime configuration options for onak. It
49  * will eventually be populated from the config file.
50  */
51 struct onak_config {
52         /*
53          * Generic options.
54          */
55         /** The maximum number of keys a query should return. */
56         int maxkeys;
57         /** Our email address that servers sync with. */
58         char *thissite;
59         /** The email address of the server admin. */
60         char *adminemail;
61         /** The mta to invoke to send sync mails. */
62         char *mta;
63         /** List of email address for sites we sync with via email */
64         struct ll *syncsites;
65         /** A linked list of sites we sync with. */
66         char *logfile;
67
68         /** Set if we're using keyd as the backend. */
69         bool use_keyd;
70         /** The path to the directory the keyd socket lives in. */
71         char *sock_dir;
72
73         /** List of backend configurations */
74         struct ll *backends;
75
76         /* The default backend to use */
77         struct onak_db_config *backend;
78
79         /*
80          * Options for the dynamic backend.
81          */
82         /** Name of the DB backend we're using */
83         char *db_backend;
84         /** Directory where backend .so files can be found */
85         char *backends_dir;
86
87         /** Pointer to the initialisation function for our loaded DB backend */
88         struct onak_dbctx *(*dbinit)(struct onak_db_config *, bool);
89
90         /** Should we verify signature hashes match? */
91         bool check_sighash;
92
93         /*
94          * Options used by the email handling script.
95          * None of the C code uses this information, but we should be able
96          * to parse it.
97          */
98         /** Location of the onak binary, so the mail script can find it. */
99         char *bin_dir;
100         /** Where incoming mail gets queue, one file per mail. */
101         char *mail_dir;
102 };
103
104 /**
105  * @brief The variable containing our runtime config.
106  */
107 extern struct onak_config config;
108
109 /**
110  * @brief read the onak config.
111  * @param configfile the config file to read.
112  *
113  * Read in our config file. If config file is NULL read in the compile
114  * time default.
115  */
116 void readconfig(const char *configfile);
117
118 /**
119  * @brief write the onak config.
120  * @param configfile the config file to write to.
121  *
122  * Write out the config file. If config file is NULL write it to STDOUT.
123  */
124 void writeconfig(const char *configfile);
125
126 /**
127  * @brief clean up the config when we're shutting down.
128  */
129 void cleanupconfig(void);
130
131
132 /**
133  * @brief Find a specified backend configuration by name.
134  */
135 struct onak_db_config *find_db_backend_config(struct ll *backends, char *name);
136
137 #endif /* __ONAK_CONF_H_ */