]> git.sur5r.net Git - openldap/blob - servers/slapd/config.h
ITS#3748 do necessary startup when adding databases online
[openldap] / servers / slapd / config.h
1 /* config.h - configuration abstraction structure */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2005 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 typedef struct ConfigTable {
18         char *name;
19         char *what;
20         int min_args;
21         int max_args;
22         int length;
23         unsigned int arg_type;
24         void *arg_item;
25         char *attribute;
26         AttributeDescription *ad;
27         void *notify;
28 } ConfigTable;
29
30 typedef enum {
31         Cft_Abstract = 0,
32         Cft_Global,
33         Cft_Schema,
34         Cft_Backend,
35         Cft_Database,
36         Cft_Overlay,
37         Cft_Include,
38         Cft_Module,
39         Cft_Misc        /* backend/overlay defined */
40 } ConfigType;
41
42 #define ARGS_USERLAND   0x00000fff
43 #define ARGS_TYPES      0x000ff000
44 #define ARGS_POINTER    0x0003f000
45 #define ARGS_NUMERIC    0x0000f000
46 #define ARG_INT         0x00001000
47 #define ARG_LONG        0x00002000
48 #define ARG_BER_LEN_T   0x00004000
49 #define ARG_ON_OFF      0x00008000
50 #define ARG_STRING      0x00010000
51 #define ARG_BERVAL      0x00020000
52 #define ARG_DN          0x00040000
53 #define ARG_IGNORED     0x00080000
54
55 #define ARGS_SYNTAX     0xfff00000
56 #define ARG_PRE_BI      0x00100000
57 #define ARG_PRE_DB      0x00200000
58 #define ARG_DB          0x00400000      /* Only applies to DB */
59 #define ARG_MAY_DB      0x00800000      /* May apply to DB */
60 #define ARG_PAREN       0x01000000
61 #define ARG_NONZERO     0x02000000
62 #define ARG_NO_INSERT   0x04000000      /* no arbitrary inserting */
63 #define ARG_NO_DELETE   0x08000000      /* no runtime deletes */
64 #define ARG_UNIQUE      0x10000000
65 #define ARG_OFFSET      0x40000000
66 #define ARG_MAGIC       0x80000000
67
68 #define ARG_BAD_CONF    0xdead0000      /* overload return values */
69
70 /* This is a config entry's e_private data */
71 typedef struct CfEntryInfo {
72         struct CfEntryInfo *ce_parent;
73         struct CfEntryInfo *ce_sibs;
74         struct CfEntryInfo *ce_kids;
75         Entry *ce_entry;
76         ConfigType ce_type;
77         BackendInfo *ce_bi;
78         BackendDB *ce_be;
79         void *ce_private;
80 } CfEntryInfo;
81
82 struct config_args_s;
83
84 /* Check if the child is allowed to be LDAPAdd'd to the parent */
85 typedef int (ConfigLDAPadd)(
86         CfEntryInfo *parent, Entry *child, struct config_args_s *ca);
87
88 /* Let the object create children out of slapd.conf */
89 typedef int (ConfigCfAdd)(
90         Operation *op, SlapReply *rs, Entry *parent, struct config_args_s *ca );
91
92 typedef struct ConfigOCs {
93         char *co_def;
94         ConfigType co_type;
95         ConfigTable *co_table;
96         ConfigLDAPadd *co_ldadd;
97         ConfigCfAdd *co_cfadd;
98         ObjectClass *co_oc;
99         struct berval *co_name;
100 } ConfigOCs;
101
102 typedef int (ConfigDriver)(struct config_args_s *c);
103
104 typedef struct config_args_s {
105         int argc;
106         char **argv;
107         int argv_size;
108         char *line;
109         char *tline;
110         const char *fname;
111         unsigned long lineno;
112         char log[MAXPATHLEN + STRLENOF(": line 18446744073709551615") + 1];
113         char msg[SLAP_TEXT_BUFLEN];
114         int depth;
115         int valx;       /* multi-valued value index */
116         /* parsed first val for simple cases */
117         union {
118                 int v_int;
119                 long v_long;
120                 ber_len_t v_ber_t;
121                 char *v_string;
122                 struct berval v_bv;
123                 struct {
124                         struct berval vdn_dn;
125                         struct berval vdn_ndn;
126                 } v_dn;
127         } values;
128         /* return values for emit mode */
129         BerVarray rvalue_vals;
130         BerVarray rvalue_nvals;
131 #define SLAP_CONFIG_EMIT        0x2000  /* emit instead of set */
132 #define SLAP_CONFIG_ADD         0x4000  /* config file add vs LDAP add */
133         int op;
134         int type;       /* ConfigTable.arg_type & ARGS_USERLAND */
135         BackendDB *be;
136         BackendInfo *bi;
137         Entry *ca_entry;        /* entry being modified */
138         void *private;  /* anything */
139         ConfigDriver *cleanup;
140 } ConfigArgs;
141
142 /* If lineno is zero, we have an actual LDAP Add request from a client.
143  * Otherwise, we're reading a config file or a config dir.
144  */
145 #define CONFIG_ONLINE_ADD(ca)   (!((ca)->lineno))
146
147 #define value_int values.v_int
148 #define value_long values.v_long
149 #define value_ber_t values.v_ber_t
150 #define value_string values.v_string
151 #define value_bv values.v_bv
152 #define value_dn values.v_dn.vdn_dn
153 #define value_ndn values.v_dn.vdn_ndn
154
155 int config_register_schema(ConfigTable *ct, ConfigOCs *co);
156 int config_get_vals(ConfigTable *ct, ConfigArgs *c);
157 int config_add_vals(ConfigTable *ct, ConfigArgs *c);
158 ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);
159 Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
160         ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra );