1 /* config.h - configuration abstraction structure */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2009 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
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>.
24 typedef struct ConfigTable {
30 unsigned int arg_type;
32 const char *attribute;
33 AttributeDescription *ad;
37 /* search entries are returned according to this order */
46 Cft_Misc /* backend/overlay defined */
49 #define ARGS_USERLAND 0x00000fff
51 /* types are enumerated, not a bitmask */
52 #define ARGS_TYPES 0x0000f000
53 #define ARG_INT 0x00001000
54 #define ARG_LONG 0x00002000
55 #define ARG_BER_LEN_T 0x00003000
56 #define ARG_ON_OFF 0x00004000
57 #define ARG_STRING 0x00005000
58 #define ARG_BERVAL 0x00006000
59 #define ARG_DN 0x00007000
60 #define ARG_UINT 0x00008000
61 #define ARG_ATDESC 0x00009000
62 #define ARG_ULONG 0x0000a000
64 #define ARGS_SYNTAX 0xffff0000
65 #define ARG_IGNORED 0x00080000
66 #define ARG_PRE_BI 0x00100000
67 #define ARG_PRE_DB 0x00200000
68 #define ARG_DB 0x00400000 /* Only applies to DB */
69 #define ARG_MAY_DB 0x00800000 /* May apply to DB */
70 #define ARG_PAREN 0x01000000
71 #define ARG_NONZERO 0x02000000
72 #define ARG_NO_INSERT 0x04000000 /* no arbitrary inserting */
73 #define ARG_NO_DELETE 0x08000000 /* no runtime deletes */
74 #define ARG_UNIQUE 0x10000000
75 #define ARG_QUOTE 0x20000000 /* wrap with quotes before parsing */
76 #define ARG_OFFSET 0x40000000
77 #define ARG_MAGIC 0x80000000
79 #define ARG_BAD_CONF 0xdead0000 /* overload return values */
81 /* This is a config entry's e_private data */
82 typedef struct CfEntryInfo {
83 struct CfEntryInfo *ce_parent;
84 struct CfEntryInfo *ce_sibs;
85 struct CfEntryInfo *ce_kids;
95 /* Check if the child is allowed to be LDAPAdd'd to the parent */
96 typedef int (ConfigLDAPadd)(
97 CfEntryInfo *parent, Entry *child, struct config_args_s *ca);
99 /* Let the object create children out of slapd.conf */
100 typedef int (ConfigCfAdd)(
101 Operation *op, SlapReply *rs, Entry *parent, struct config_args_s *ca );
103 typedef struct ConfigOCs {
106 ConfigTable *co_table;
107 ConfigLDAPadd *co_ldadd;
108 ConfigCfAdd *co_cfadd;
110 struct berval *co_name;
113 typedef int (ConfigDriver)(struct config_args_s *c);
115 struct config_reply_s {
117 char msg[SLAP_TEXT_BUFLEN];
120 typedef struct config_args_s {
128 char log[MAXPATHLEN + STRLENOF(": line ") + LDAP_PVT_INTTYPE_CHARS(unsigned long)];
129 #define cr_msg reply.msg
132 int valx; /* multi-valued value index */
133 /* parsed first val for simple cases */
138 unsigned long v_ulong;
143 struct berval vdn_dn;
144 struct berval vdn_ndn;
146 AttributeDescription *v_ad;
148 /* return values for emit mode */
149 BerVarray rvalue_vals;
150 BerVarray rvalue_nvals;
151 #define SLAP_CONFIG_EMIT 0x2000 /* emit instead of set */
152 #define SLAP_CONFIG_ADD 0x4000 /* config file add vs LDAP add */
154 int type; /* ConfigTable.arg_type & ARGS_USERLAND */
158 Entry *ca_entry; /* entry being modified */
159 void *ca_private; /* anything */
160 ConfigDriver *cleanup;
161 ConfigType table; /* which config table did we come from */
164 /* If lineno is zero, we have an actual LDAP Add request from a client.
165 * Otherwise, we're reading a config file or a config dir.
167 #define CONFIG_ONLINE_ADD(ca) (!((ca)->lineno))
169 #define value_int values.v_int
170 #define value_uint values.v_uint
171 #define value_long values.v_long
172 #define value_ulong values.v_ulong
173 #define value_ber_t values.v_ber_t
174 #define value_string values.v_string
175 #define value_bv values.v_bv
176 #define value_dn values.v_dn.vdn_dn
177 #define value_ndn values.v_dn.vdn_ndn
178 #define value_ad values.v_ad
180 int config_fp_parse_line(ConfigArgs *c);
182 int config_register_schema(ConfigTable *ct, ConfigOCs *co);
183 int config_del_vals(ConfigTable *cf, ConfigArgs *c);
184 int config_get_vals(ConfigTable *ct, ConfigArgs *c);
185 int config_add_vals(ConfigTable *ct, ConfigArgs *c);
187 void init_config_argv( ConfigArgs *c );
188 int init_config_attrs(ConfigTable *ct);
189 int init_config_ocs( ConfigOCs *ocs );
190 int config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx);
191 int config_parse_add(ConfigTable *ct, ConfigArgs *c, int valx);
192 int read_config_file(const char *fname, int depth, ConfigArgs *cf,
195 ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);
196 Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
197 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra );
199 Listener *config_check_my_url(const char *url, LDAPURLDesc *lud);
200 int config_shadow( ConfigArgs *c, slap_mask_t flag );
201 #define config_slurp_shadow(c) config_shadow((c), SLAP_DBFLAG_SLURP_SHADOW)
202 #define config_sync_shadow(c) config_shadow((c), SLAP_DBFLAG_SYNC_SHADOW)
204 /* Make sure we don't exceed the bits reserved for userland */
205 #define config_check_userland(last) \
206 assert( ( ( (last) - 1 ) & ARGS_USERLAND ) == ( (last) - 1 ) );
208 #define SLAP_X_ORDERED_FMT "{%d}"
210 LDAP_SLAPD_V (slap_verbmasks *) slap_ldap_response_code;
211 extern int slap_ldap_response_code_register( struct berval *bv, int err );
213 LDAP_SLAPD_V (ConfigTable) olcDatabaseDummy[];
217 #endif /* CONFIG_H */