Back to index

openldap  2.4.31
config.h
Go to the documentation of this file.
00001 /* config.h - configuration abstraction structure */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #ifndef CONFIG_H
00018 #define CONFIG_H
00019 
00020 #include<ac/string.h>
00021 
00022 LDAP_BEGIN_DECL
00023 
00024 typedef struct ConfigTable {
00025        const char *name;
00026        const char *what;
00027        int min_args;
00028        int max_args;
00029        int length;
00030        unsigned int arg_type;
00031        void *arg_item;
00032        const char *attribute;
00033        AttributeDescription *ad;
00034        void *notify;
00035 } ConfigTable;
00036 
00037 /* search entries are returned according to this order */
00038 typedef enum {
00039        Cft_Abstract = 0,
00040        Cft_Global,
00041        Cft_Module,
00042        Cft_Schema,
00043        Cft_Backend,
00044        Cft_Database,
00045        Cft_Overlay,
00046        Cft_Misc      /* backend/overlay defined */
00047 } ConfigType;
00048 
00049 #define ARGS_USERLAND       0x00000fff
00050 
00051 /* types are enumerated, not a bitmask */
00052 #define ARGS_TYPES   0x0000f000
00053 #define ARG_INT             0x00001000
00054 #define ARG_LONG     0x00002000
00055 #define ARG_BER_LEN_T       0x00003000
00056 #define ARG_ON_OFF   0x00004000
00057 #define ARG_STRING   0x00005000
00058 #define ARG_BERVAL   0x00006000
00059 #define ARG_DN              0x00007000
00060 #define ARG_UINT     0x00008000
00061 #define ARG_ATDESC   0x00009000
00062 #define ARG_ULONG    0x0000a000
00063 
00064 #define ARGS_SYNTAX  0xffff0000
00065 #define ARG_IGNORED  0x00080000
00066 #define ARG_PRE_BI   0x00100000
00067 #define ARG_PRE_DB   0x00200000
00068 #define ARG_DB              0x00400000    /* Only applies to DB */
00069 #define ARG_MAY_DB   0x00800000    /* May apply to DB */
00070 #define ARG_PAREN    0x01000000
00071 #define ARG_NONZERO  0x02000000
00072 #define       ARG_NO_INSERT 0x04000000    /* no arbitrary inserting */
00073 #define       ARG_NO_DELETE 0x08000000    /* no runtime deletes */
00074 #define ARG_UNIQUE   0x10000000
00075 #define       ARG_QUOTE     0x20000000    /* wrap with quotes before parsing */
00076 #define ARG_OFFSET   0x40000000
00077 #define ARG_MAGIC    0x80000000
00078 
00079 #define ARG_BAD_CONF 0xdead0000    /* overload return values */
00080 
00081 /* This is a config entry's e_private data */
00082 typedef struct CfEntryInfo {
00083        struct CfEntryInfo *ce_parent;
00084        struct CfEntryInfo *ce_sibs;
00085        struct CfEntryInfo *ce_kids;
00086        Entry *ce_entry;
00087        ConfigType ce_type;
00088        BackendInfo *ce_bi;
00089        BackendDB *ce_be;
00090        void *ce_private;
00091 } CfEntryInfo;
00092 
00093 struct config_args_s;
00094 
00095 /* Check if the child is allowed to be LDAPAdd'd to the parent */
00096 typedef int (ConfigLDAPadd)(
00097        CfEntryInfo *parent, Entry *child, struct config_args_s *ca);
00098 
00099 /* Let the object create children out of slapd.conf */
00100 typedef int (ConfigCfAdd)(
00101        Operation *op, SlapReply *rs, Entry *parent, struct config_args_s *ca );
00102 
00103 #ifdef SLAP_CONFIG_DELETE
00104 /* Called when deleting a Cft_Misc Child object from cn=config */
00105 typedef int (ConfigLDAPdel)(
00106        CfEntryInfo *ce, Operation *op );
00107 #endif
00108 
00109 typedef struct ConfigOCs {
00110        const char *co_def;
00111        ConfigType co_type;
00112        ConfigTable *co_table;
00113        ConfigLDAPadd *co_ldadd;
00114        ConfigCfAdd *co_cfadd;
00115 #ifdef SLAP_CONFIG_DELETE
00116        ConfigLDAPdel *co_lddel;
00117 #endif
00118        ObjectClass *co_oc;
00119        struct berval *co_name;
00120 } ConfigOCs;
00121 
00122 typedef int (ConfigDriver)(struct config_args_s *c);
00123 
00124 struct config_reply_s {
00125        int err;
00126        char msg[SLAP_TEXT_BUFLEN];
00127 };
00128 
00129 typedef struct config_args_s {
00130        int argc;
00131        char **argv;
00132        int argv_size;
00133        char *line;
00134        char *tline;
00135        const char *fname;
00136        int lineno;
00137        char log[MAXPATHLEN + STRLENOF(": line ") + LDAP_PVT_INTTYPE_CHARS(unsigned long)];
00138 #define cr_msg reply.msg
00139        ConfigReply reply;
00140        int depth;
00141        int valx;     /* multi-valued value index */
00142        /* parsed first val for simple cases */
00143        union {
00144               int v_int;
00145               unsigned v_uint;
00146               long v_long;
00147               unsigned long v_ulong;
00148               ber_len_t v_ber_t;
00149               char *v_string;
00150               struct berval v_bv;
00151               struct {
00152                      struct berval vdn_dn;
00153                      struct berval vdn_ndn;
00154               } v_dn;
00155               AttributeDescription *v_ad;
00156        } values;
00157        /* return values for emit mode */
00158        BerVarray rvalue_vals;
00159        BerVarray rvalue_nvals;
00160 #define       SLAP_CONFIG_EMIT     0x2000 /* emit instead of set */
00161 #define SLAP_CONFIG_ADD            0x4000 /* config file add vs LDAP add */
00162        int op;
00163        int type;     /* ConfigTable.arg_type & ARGS_USERLAND */
00164        Operation *ca_op;
00165        BackendDB *be;
00166        BackendInfo *bi;
00167        Entry *ca_entry;     /* entry being modified */
00168        void *ca_private;    /* anything */
00169        ConfigDriver *cleanup;
00170        ConfigType table;    /* which config table did we come from */
00171 } ConfigArgs;
00172 
00173 /* If lineno is zero, we have an actual LDAP Add request from a client.
00174  * Otherwise, we're reading a config file or a config dir.
00175  */
00176 #define CONFIG_ONLINE_ADD(ca)      (!((ca)->lineno))
00177 
00178 #define value_int values.v_int
00179 #define value_uint values.v_uint
00180 #define value_long values.v_long
00181 #define value_ulong values.v_ulong
00182 #define value_ber_t values.v_ber_t
00183 #define value_string values.v_string
00184 #define value_bv values.v_bv
00185 #define value_dn values.v_dn.vdn_dn
00186 #define value_ndn values.v_dn.vdn_ndn
00187 #define value_ad values.v_ad
00188 
00189 int config_fp_parse_line(ConfigArgs *c);
00190 
00191 int config_register_schema(ConfigTable *ct, ConfigOCs *co);
00192 int config_del_vals(ConfigTable *cf, ConfigArgs *c);
00193 int config_get_vals(ConfigTable *ct, ConfigArgs *c);
00194 int config_add_vals(ConfigTable *ct, ConfigArgs *c);
00195 
00196 void init_config_argv( ConfigArgs *c );
00197 int init_config_attrs(ConfigTable *ct);
00198 int init_config_ocs( ConfigOCs *ocs );
00199 int config_parse_vals(ConfigTable *ct, ConfigArgs *c, int valx);
00200 int config_parse_add(ConfigTable *ct, ConfigArgs *c, int valx);
00201 int read_config_file(const char *fname, int depth, ConfigArgs *cf,
00202        ConfigTable *cft );
00203 
00204 ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);
00205 Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
00206        ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra );
00207 
00208 Listener *config_check_my_url(const char *url, LDAPURLDesc *lud);
00209 int config_shadow( ConfigArgs *c, slap_mask_t flag );
00210 #define       config_slurp_shadow(c)      config_shadow((c), SLAP_DBFLAG_SLURP_SHADOW)
00211 #define       config_sync_shadow(c)       config_shadow((c), SLAP_DBFLAG_SYNC_SHADOW)
00212 
00213        /* Make sure we don't exceed the bits reserved for userland */
00214 #define       config_check_userland(last) \
00215        assert( ( ( (last) - 1 ) & ARGS_USERLAND ) == ( (last) - 1 ) );
00216 
00217 #define       SLAP_X_ORDERED_FMT   "{%d}"
00218 
00219 LDAP_SLAPD_V (slap_verbmasks *) slap_ldap_response_code;
00220 extern int slap_ldap_response_code_register( struct berval *bv, int err );
00221 
00222 LDAP_SLAPD_V (ConfigTable) olcDatabaseDummy[];
00223 
00224 LDAP_END_DECL
00225 
00226 #endif /* CONFIG_H */