]> git.sur5r.net Git - openldap/blob - servers/slapd/config.h
implement search timeout when the remote server does not respond in the specified...
[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-2007 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 #ifndef CONFIG_H
18 #define CONFIG_H
19
20 typedef struct ConfigTable {
21         char *name;
22         char *what;
23         int min_args;
24         int max_args;
25         int length;
26         unsigned int arg_type;
27         void *arg_item;
28         char *attribute;
29         AttributeDescription *ad;
30         void *notify;
31 } ConfigTable;
32
33 /* search entries are returned according to this order */
34 typedef enum {
35         Cft_Abstract = 0,
36         Cft_Global,
37         Cft_Include,
38         Cft_Module,
39         Cft_Schema,
40         Cft_Backend,
41         Cft_Database,
42         Cft_Overlay,
43         Cft_Misc        /* backend/overlay defined */
44 } ConfigType;
45
46 #define ARGS_USERLAND   0x00000fff
47
48 /* types are enumerated, not a bitmask */
49 #define ARGS_TYPES      0x0000f000
50 #define ARG_INT         0x00001000
51 #define ARG_LONG        0x00002000
52 #define ARG_BER_LEN_T   0x00003000
53 #define ARG_ON_OFF      0x00004000
54 #define ARG_STRING      0x00005000
55 #define ARG_BERVAL      0x00006000
56 #define ARG_DN          0x00007000
57
58 #define ARGS_SYNTAX     0xffff0000
59 #define ARG_IGNORED     0x00080000
60 #define ARG_PRE_BI      0x00100000
61 #define ARG_PRE_DB      0x00200000
62 #define ARG_DB          0x00400000      /* Only applies to DB */
63 #define ARG_MAY_DB      0x00800000      /* May apply to DB */
64 #define ARG_PAREN       0x01000000
65 #define ARG_NONZERO     0x02000000
66 #define ARG_NO_INSERT   0x04000000      /* no arbitrary inserting */
67 #define ARG_NO_DELETE   0x08000000      /* no runtime deletes */
68 #define ARG_UNIQUE      0x10000000
69 #define ARG_QUOTE       0x20000000      /* wrap with quotes before parsing */
70 #define ARG_OFFSET      0x40000000
71 #define ARG_MAGIC       0x80000000
72
73 #define ARG_BAD_CONF    0xdead0000      /* overload return values */
74
75 /* This is a config entry's e_private data */
76 typedef struct CfEntryInfo {
77         struct CfEntryInfo *ce_parent;
78         struct CfEntryInfo *ce_sibs;
79         struct CfEntryInfo *ce_kids;
80         Entry *ce_entry;
81         ConfigType ce_type;
82         BackendInfo *ce_bi;
83         BackendDB *ce_be;
84         void *ce_private;
85 } CfEntryInfo;
86
87 struct config_args_s;
88
89 /* Check if the child is allowed to be LDAPAdd'd to the parent */
90 typedef int (ConfigLDAPadd)(
91         CfEntryInfo *parent, Entry *child, struct config_args_s *ca);
92
93 /* Let the object create children out of slapd.conf */
94 typedef int (ConfigCfAdd)(
95         Operation *op, SlapReply *rs, Entry *parent, struct config_args_s *ca );
96
97 typedef struct ConfigOCs {
98         char *co_def;
99         ConfigType co_type;
100         ConfigTable *co_table;
101         ConfigLDAPadd *co_ldadd;
102         ConfigCfAdd *co_cfadd;
103         ObjectClass *co_oc;
104         struct berval *co_name;
105 } ConfigOCs;
106
107 typedef int (ConfigDriver)(struct config_args_s *c);
108
109 typedef struct config_args_s {
110         int argc;
111         char **argv;
112         int argv_size;
113         char *line;
114         char *tline;
115         const char *fname;
116         int lineno;
117         char log[MAXPATHLEN + STRLENOF(": line 18446744073709551615") + 1];
118         char msg[SLAP_TEXT_BUFLEN];
119         int depth;
120         int valx;       /* multi-valued value index */
121         /* parsed first val for simple cases */
122         union {
123                 int v_int;
124                 long v_long;
125                 ber_len_t v_ber_t;
126                 char *v_string;
127                 struct berval v_bv;
128                 struct {
129                         struct berval vdn_dn;
130                         struct berval vdn_ndn;
131                 } v_dn;
132         } values;
133         /* return values for emit mode */
134         BerVarray rvalue_vals;
135         BerVarray rvalue_nvals;
136 #define SLAP_CONFIG_EMIT        0x2000  /* emit instead of set */
137 #define SLAP_CONFIG_ADD         0x4000  /* config file add vs LDAP add */
138         int op;
139         int type;       /* ConfigTable.arg_type & ARGS_USERLAND */
140         Operation *ca_op;
141         BackendDB *be;
142         BackendInfo *bi;
143         Entry *ca_entry;        /* entry being modified */
144         void *private;  /* anything */
145         ConfigDriver *cleanup;
146 } ConfigArgs;
147
148 /* If lineno is zero, we have an actual LDAP Add request from a client.
149  * Otherwise, we're reading a config file or a config dir.
150  */
151 #define CONFIG_ONLINE_ADD(ca)   (!((ca)->lineno))
152
153 #define value_int values.v_int
154 #define value_long values.v_long
155 #define value_ber_t values.v_ber_t
156 #define value_string values.v_string
157 #define value_bv values.v_bv
158 #define value_dn values.v_dn.vdn_dn
159 #define value_ndn values.v_dn.vdn_ndn
160
161 int config_register_schema(ConfigTable *ct, ConfigOCs *co);
162 int config_del_vals(ConfigTable *cf, ConfigArgs *c);
163 int config_get_vals(ConfigTable *ct, ConfigArgs *c);
164 int config_add_vals(ConfigTable *ct, ConfigArgs *c);
165
166 void init_config_argv( ConfigArgs *c );
167 int init_config_attrs(ConfigTable *ct);
168 int init_config_ocs( ConfigOCs *ocs );
169 int config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx);
170 int config_parse_add(ConfigTable *ct, ConfigArgs *c, int valx);
171 int read_config_file(const char *fname, int depth, ConfigArgs *cf,
172         ConfigTable *cft );
173
174 ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);
175 Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
176         ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra );
177
178 int config_shadow( ConfigArgs *c, int flag );
179 #define config_slurp_shadow(c)  config_shadow((c), SLAP_DBFLAG_SLURP_SHADOW)
180 #define config_sync_shadow(c)   config_shadow((c), SLAP_DBFLAG_SYNC_SHADOW)
181
182         /* Make sure we don't exceed the bits reserved for userland */
183 #define config_check_userland(last) \
184         assert( ( ( (last) - 1 ) & ARGS_USERLAND ) == ( (last) - 1 ) );
185
186 #define SLAP_X_ORDERED_FMT      "{%d}"
187
188 #endif /* CONFIG_H */