1 /* config.h - configuration abstraction structure */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2005 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>.
17 typedef struct ConfigTable {
23 unsigned int arg_type;
26 AttributeDescription *ad;
39 Cft_Misc /* backend/overlay defined */
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
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_QUOTE 0x20000000 /* wrap with quotes before parsing */
66 #define ARG_OFFSET 0x40000000
67 #define ARG_MAGIC 0x80000000
69 #define ARG_BAD_CONF 0xdead0000 /* overload return values */
71 /* This is a config entry's e_private data */
72 typedef struct CfEntryInfo {
73 struct CfEntryInfo *ce_parent;
74 struct CfEntryInfo *ce_sibs;
75 struct CfEntryInfo *ce_kids;
85 /* Check if the child is allowed to be LDAPAdd'd to the parent */
86 typedef int (ConfigLDAPadd)(
87 CfEntryInfo *parent, Entry *child, struct config_args_s *ca);
89 /* Let the object create children out of slapd.conf */
90 typedef int (ConfigCfAdd)(
91 Operation *op, SlapReply *rs, Entry *parent, struct config_args_s *ca );
93 typedef struct ConfigOCs {
96 ConfigTable *co_table;
97 ConfigLDAPadd *co_ldadd;
98 ConfigCfAdd *co_cfadd;
100 struct berval *co_name;
103 typedef int (ConfigDriver)(struct config_args_s *c);
105 typedef struct config_args_s {
112 unsigned long lineno;
113 char log[MAXPATHLEN + STRLENOF(": line 18446744073709551615") + 1];
114 char msg[SLAP_TEXT_BUFLEN];
116 int valx; /* multi-valued value index */
117 /* parsed first val for simple cases */
125 struct berval vdn_dn;
126 struct berval vdn_ndn;
129 /* return values for emit mode */
130 BerVarray rvalue_vals;
131 BerVarray rvalue_nvals;
132 #define SLAP_CONFIG_EMIT 0x2000 /* emit instead of set */
133 #define SLAP_CONFIG_ADD 0x4000 /* config file add vs LDAP add */
135 int type; /* ConfigTable.arg_type & ARGS_USERLAND */
138 Entry *ca_entry; /* entry being modified */
139 void *private; /* anything */
140 ConfigDriver *cleanup;
143 /* If lineno is zero, we have an actual LDAP Add request from a client.
144 * Otherwise, we're reading a config file or a config dir.
146 #define CONFIG_ONLINE_ADD(ca) (!((ca)->lineno))
148 #define value_int values.v_int
149 #define value_long values.v_long
150 #define value_ber_t values.v_ber_t
151 #define value_string values.v_string
152 #define value_bv values.v_bv
153 #define value_dn values.v_dn.vdn_dn
154 #define value_ndn values.v_dn.vdn_ndn
156 int config_register_schema(ConfigTable *ct, ConfigOCs *co);
157 int config_del_vals(ConfigTable *cf, ConfigArgs *c);
158 int config_get_vals(ConfigTable *ct, ConfigArgs *c);
159 int config_add_vals(ConfigTable *ct, ConfigArgs *c);
161 void init_config_argv( ConfigArgs *c );
162 int init_config_attrs(ConfigTable *ct);
163 int init_config_ocs( ConfigOCs *ocs );
164 int config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx);
165 int config_parse_add(ConfigTable *ct, ConfigArgs *c);
166 int read_config_file(const char *fname, int depth, ConfigArgs *cf,
169 ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);
170 Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
171 ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra );