]> git.sur5r.net Git - openldap/blob - servers/slapd/config.h
30b2d199e80c112efd4ffc717dd78f0b4fa5a754
[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 } ConfigType;
40
41 #define ARGS_USERLAND   0x00000fff
42 #define ARGS_TYPES      0x000ff000
43 #define ARGS_POINTER    0x0003f000
44 #define ARGS_NUMERIC    0x0000f000
45 #define ARG_INT         0x00001000
46 #define ARG_LONG        0x00002000
47 #define ARG_BER_LEN_T   0x00004000
48 #define ARG_ON_OFF      0x00008000
49 #define ARG_STRING      0x00010000
50 #define ARG_BERVAL      0x00020000
51 #define ARG_DN          0x00040000
52 #define ARG_IGNORED     0x00080000
53
54 #define ARGS_SYNTAX     0xfff00000
55 #define ARG_PRE_BI      0x00100000
56 #define ARG_PRE_DB      0x00200000
57 #define ARG_DB          0x00400000      /* Only applies to DB */
58 #define ARG_MAY_DB      0x00800000      /* May apply to DB */
59 #define ARG_PAREN       0x01000000
60 #define ARG_NONZERO     0x02000000
61 #define ARG_NO_INSERT   0x04000000      /* no arbitrary inserting */
62 #define ARG_NO_DELETE   0x08000000      /* no runtime deletes */
63 #define ARG_UNIQUE      0x10000000
64 #define ARG_OFFSET      0x40000000
65 #define ARG_MAGIC       0x80000000
66
67 #define ARG_BAD_CONF    0xdead0000      /* overload return values */
68 #define ARG_UNKNOWN     0xc0de0000
69
70 extern ConfigTable config_back_cf_table[];
71
72 typedef struct ConfigOCs {
73         char *def;
74         ConfigType cft;
75         ObjectClass **oc;
76 #if 0
77         BI_op_add *add;         /* optional, add-specific processing */
78         BI_op_delete *del;      /* mandatory, delete implementation */
79         BI_op_modify *mod;      /* optional, mod-specific */
80         BI_op_modrdn *ren;      /* optional, modrdn... */
81 #endif
82 } ConfigOCs;
83
84 struct config_args_s;
85
86 typedef int (ConfigDriver)(struct config_args_s *c);
87
88 typedef struct config_args_s {
89         int argc;
90         char **argv;
91         int argv_size;
92         char *line;
93         char *tline;
94         const char *fname;
95         unsigned long lineno;
96         char log[MAXPATHLEN + STRLENOF(": line 18446744073709551615") + 1];
97         int depth;
98         int valx;       /* multi-valued value index */
99         /* parsed first val for simple cases */
100         union {
101                 int v_int;
102                 long v_long;
103                 ber_len_t v_ber_t;
104                 char *v_string;
105                 struct berval v_bv;
106                 struct {
107                         struct berval vdn_dn;
108                         struct berval vdn_ndn;
109                 } v_dn;
110         } values;
111         /* return values for emit mode */
112         BerVarray rvalue_vals;
113         BerVarray rvalue_nvals;
114 #define SLAP_CONFIG_EMIT        0x2000  /* emit instead of set */
115 #define SLAP_CONFIG_ADD         0x4000  /* config file add vs LDAP add */
116         int op;
117         int type;       /* ConfigTable.arg_type & ARGS_USERLAND */
118         BackendDB *be;
119         BackendInfo *bi;
120         void *private;  /* anything */
121         ConfigDriver *cleanup;
122 } ConfigArgs;
123
124 #define value_int values.v_int
125 #define value_long values.v_long
126 #define value_ber_t values.v_ber_t
127 #define value_string values.v_string
128 #define value_bv values.v_bv
129 #define value_dn values.v_dn.vdn_dn
130 #define value_ndn values.v_dn.vdn_ndn
131
132 int config_register_schema(ConfigTable *ct, ConfigOCs *co);
133 int config_get_vals(ConfigTable *ct, ConfigArgs *c);
134 int config_add_vals(ConfigTable *ct, ConfigArgs *c);
135 ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);