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