]> the.earth.li Git - onak.git/blob - onak-conf.h
6d7500aab096fc08fb86c02b2fdbe193d97c543d
[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, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __ONAK_CONF_H_
21 #define __ONAK_CONF_H_
22
23 #include <stdbool.h>
24
25 #include "ll.h"
26
27 /**
28  * @brief Backend database configuration.
29  *
30  */
31 struct onak_db_config {
32         /** Name, as used to refer to individual backend instances */
33         char *name;
34         /** Backend type [e.g. db4, pg, fs, file] */
35         char *type;
36         /** Location information; directory for file backed, DB name for DBs */
37         char *location;
38         /** Database backend hostname, if appropriate */
39         char *hostname;
40         /** Database backend username, if appropriate */
41         char *username;
42         /** Database backend password, if appropriate */
43         char *password;
44 };
45
46 /**
47  * @brief Runtime configuration for onak.
48  *
49  * This structure holds various runtime configuration options for onak. It
50  * will eventually be populated from the config file.
51  */
52 struct onak_config {
53         /*
54          * Generic options.
55          */
56         /** The maximum number of keys a query should return. */
57         int maxkeys;
58         /** Our email address that servers sync with. */
59         char *thissite;
60         /** The email address of the server admin. */
61         char *adminemail;
62         /** The mta to invoke to send sync mails. */
63         char *mta;
64         /** List of email address for sites we sync with via email */
65         struct ll *syncsites;
66         /** A linked list of sites we sync with. */
67         char *logfile;
68
69         /** Set if we're using keyd as the backend. */
70         bool use_keyd;
71         /** The path to the directory the keyd socket lives in. */
72         char *sock_dir;
73
74         /** List of backend configurations */
75         struct ll *backends;
76
77         /* The default backend to use */
78         struct onak_db_config *backend;
79
80         /*
81          * Options for the dynamic backend.
82          */
83         /** Name of the DB backend we're using */
84         char *db_backend;
85         /** Directory where backend .so files can be found */
86         char *backends_dir;
87
88         /** Pointer to the initialisation function for our loaded DB backend */
89         struct onak_dbctx *(*dbinit)(struct onak_db_config *, bool);
90
91         /** Should we verify signature hashes match? */
92         bool check_sighash;
93
94         /*
95          * Options used by the email handling script.
96          * None of the C code uses this information, but we should be able
97          * to parse it.
98          */
99         /** Location of the onak binary, so the mail script can find it. */
100         char *bin_dir;
101         /** Where incoming mail gets queue, one file per mail. */
102         char *mail_dir;
103 };
104
105 /**
106  * @brief The variable containing our runtime config.
107  */
108 extern struct onak_config config;
109
110 /**
111  * @brief read the onak config.
112  * @param configfile the config file to read.
113  *
114  * Read in our config file. If config file is NULL read in the compile
115  * time default.
116  */
117 void readconfig(const char *configfile);
118
119 /**
120  * @brief write the onak config.
121  * @param configfile the config file to write to.
122  *
123  * Write out the config file. If config file is NULL write it to STDOUT.
124  */
125 void writeconfig(const char *configfile);
126
127 /**
128  * @brief clean up the config when we're shutting down.
129  */
130 void cleanupconfig(void);
131
132
133 /**
134  * @brief Find a specified backend configuration by name.
135  */
136 struct onak_db_config *find_db_backend_config(struct ll *backends, char *name);
137
138 #endif /* __ONAK_CONF_H_ */