Commit ee59484f authored by Howard Chu's avatar Howard Chu
Browse files

Restructured to allow miscellaneous Adds under database/overlay objects

parent 2aefbcfd
......@@ -38,7 +38,7 @@
static ObjectClass *bdb_oc;
static ConfigDriver bdb_cf_oc, bdb_cf_gen;
static ConfigDriver bdb_cf_gen;
enum {
BDB_CHKPT = 1,
......@@ -52,8 +52,6 @@ enum {
};
static ConfigTable bdbcfg[] = {
{ "", "", 0, 0, 0, ARG_MAGIC,
bdb_cf_oc, NULL, NULL, NULL },
{ "directory", "dir", 2, 2, 0, ARG_STRING|ARG_MAGIC|BDB_DIRECTORY,
bdb_cf_gen, "( OLcfgDbAt:0.1 NAME 'olcDbDirectory' "
"DESC 'Directory for database content' "
......@@ -132,7 +130,7 @@ static ConfigOCs bdbocs[] = {
"olcDbNoSync $ olcDbDirtyRead $ olcDbIDLcacheSize $ "
"olcDbIndex $ olcDbLinearIndex $ olcDbLockDetect $ "
"olcDbMode $ olcDbSearchStack $ olcDbShmKey ) )",
Cft_Database, &bdb_oc },
Cft_Database, &bdb_oc, bdbcfg },
{ NULL, 0, NULL }
};
......@@ -617,10 +615,9 @@ bdb_cf_gen(ConfigArgs *c)
int bdb_back_init_cf( BackendInfo *bi )
{
int rc;
bi->bi_cf_table = bdbcfg;
bi->bi_cf_ocs = bdbocs;
rc = config_register_schema( bdbcfg, bdbocs );
if ( rc ) return rc;
bdbcfg[0].ad = slap_schema.si_ad_objectClass;
return 0;
}
......@@ -71,7 +71,7 @@ bdb_db_init( BackendDB *be )
ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
be->be_private = bdb;
be->be_cf_table = be->bd_info->bi_cf_table;
be->be_cf_ocs = be->bd_info->bi_cf_ocs;
return 0;
}
......
......@@ -63,11 +63,7 @@ struct ldif_info {
static ObjectClass *ldif_oc;
static ConfigDriver ldif_cf;
static ConfigTable ldifcfg[] = {
{ "", "", 0, 0, 0, ARG_MAGIC,
ldif_cf, NULL, NULL, NULL },
{ "directory", "dir", 2, 2, 0, ARG_BERVAL|ARG_OFFSET,
(void *)offsetof(struct ldif_info, li_base_path),
"( OLcfgDbAt:0.1 NAME 'olcDbDirectory' "
......@@ -84,20 +80,10 @@ static ConfigOCs ldifocs[] = {
"DESC 'LDIF backend configuration' "
"SUP olcDatabaseConfig "
"MUST ( olcDbDirectory ) )", Cft_Database,
&ldif_oc },
&ldif_oc, ldifcfg },
{ NULL, 0, NULL }
};
static int
ldif_cf( ConfigArgs *c )
{
if ( c->op == SLAP_CONFIG_EMIT ) {
value_add_one( &c->rvalue_vals, &ldif_oc->soc_cname );
return 0;
}
return 1;
}
static void
dn2path(struct berval * dn, struct berval * rootdn, struct berval * base_path,
struct berval *res)
......@@ -1169,7 +1155,7 @@ ldif_back_db_init( BackendDB *be )
ni = ch_calloc( 1, sizeof(struct ldif_info) );
be->be_private = ni;
be->be_cf_table = be->bd_info->bi_cf_table;
be->be_cf_ocs = ldifocs;
ldap_pvt_thread_mutex_init(&ni->li_mutex);
return 0;
}
......@@ -1214,8 +1200,6 @@ ldif_back_initialize(
bi->bi_controls = controls;
bi->bi_cf_table = ldifcfg;
bi->bi_open = 0;
bi->bi_close = 0;
bi->bi_config = 0;
......@@ -1259,6 +1243,5 @@ ldif_back_initialize(
rc = config_register_schema( ldifcfg, ldifocs );
if ( rc ) return rc;
ldifcfg[0].ad = slap_schema.si_ad_objectClass;
return 0;
}
This diff is collapsed.
......@@ -78,7 +78,8 @@ static int fp_parse_line(ConfigArgs *c);
static char *strtok_quote(char *line, char *sep, char **quote_ptr);
int read_config_file(const char *fname, int depth, ConfigArgs *cf);
int read_config_file(const char *fname, int depth, ConfigArgs *cf,
ConfigTable *cft );
ConfigArgs *
new_config_args( BackendDB *be, const char *fname, int lineno, int argc, char **argv )
......@@ -445,26 +446,26 @@ int
init_config_ocs( ConfigOCs *ocs ) {
int i;
for (i=0;ocs[i].def;i++) {
for (i=0;ocs[i].co_def;i++) {
LDAPObjectClass *oc;
int code;
const char *err;
oc = ldap_str2objectclass( ocs[i].def, &code, &err,
oc = ldap_str2objectclass( ocs[i].co_def, &code, &err,
LDAP_SCHEMA_ALLOW_ALL );
if ( !oc ) {
fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
ocs[i].def, ldap_scherr2str(code), err );
ocs[i].co_def, ldap_scherr2str(code), err );
return code;
}
code = oc_add(oc,0,NULL,&err);
if ( code && code != SLAP_SCHERR_CLASS_DUP ) {
fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n",
ocs[i].def, scherr2str(code), err );
ocs[i].co_def, scherr2str(code), err );
return code;
}
if ( ocs[i].oc ) {
*ocs[i].oc = oc_find(oc->oc_names[0]);
if ( ocs[i].co_oc ) {
*ocs[i].co_oc = oc_find(oc->oc_names[0]);
}
ldap_memfree(oc);
}
......@@ -513,7 +514,7 @@ config_parse_add(ConfigTable *ct, ConfigArgs *c)
}
int
read_config_file(const char *fname, int depth, ConfigArgs *cf)
read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
{
FILE *fp;
ConfigTable *ct;
......@@ -582,7 +583,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf)
c->op = SLAP_CONFIG_ADD;
ct = config_find_keyword( config_back_cf_table, c );
ct = config_find_keyword( cft, c );
if ( ct ) {
rc = config_add_vals( ct, c );
if ( !rc ) continue;
......@@ -601,8 +602,8 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf)
} else if ( c->bi ) {
rc = SLAP_CONF_UNKNOWN;
if ( c->bi->bi_cf_table ) {
ct = config_find_keyword( c->bi->bi_cf_table, c );
if ( c->bi->bi_cf_ocs->co_table ) {
ct = config_find_keyword( c->bi->bi_cf_ocs->co_table, c );
if ( ct ) {
rc = config_add_vals( ct, c );
}
......@@ -629,8 +630,8 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf)
} else if ( c->be ) {
rc = SLAP_CONF_UNKNOWN;
if ( c->be->be_cf_table ) {
ct = config_find_keyword( c->be->be_cf_table, c );
if ( c->be->be_cf_ocs ) {
ct = config_find_keyword( c->be->be_cf_ocs->co_table, c );
if ( ct ) {
rc = config_add_vals( ct, c );
}
......@@ -1155,7 +1156,7 @@ int config_generic_wrapper( Backend *be, const char *fname, int lineno,
sprintf( c.log, "%s: line %lu", fname, lineno );
rc = SLAP_CONF_UNKNOWN;
ct = config_find_keyword( be->be_cf_table, &c );
ct = config_find_keyword( be->be_cf_ocs->co_table, &c );
if ( ct )
rc = config_add_vals( ct, &c );
return rc;
......
......@@ -35,7 +35,8 @@ typedef enum {
Cft_Database,
Cft_Overlay,
Cft_Include,
Cft_Module
Cft_Module,
Cft_Misc /* backend/overlay defined */
} ConfigType;
#define ARGS_USERLAND 0x00000fff
......@@ -66,16 +67,38 @@ typedef enum {
#define ARG_BAD_CONF 0xdead0000 /* overload return values */
extern ConfigTable config_back_cf_table[];
/* This is a config entry's e_private data */
typedef struct CfEntryInfo {
struct CfEntryInfo *ce_parent;
struct CfEntryInfo *ce_sibs;
struct CfEntryInfo *ce_kids;
Entry *ce_entry;
ConfigType ce_type;
BackendInfo *ce_bi;
BackendDB *ce_be;
void *ce_private;
} CfEntryInfo;
struct config_args_s;
/* Check if the child is allowed to be LDAPAdd'd to the parent */
typedef int (ConfigLDAPadd)(
CfEntryInfo *parent, Entry *child, struct config_args_s *ca);
/* Let the object create children out of slapd.conf */
typedef int (ConfigCfAdd)(
Operation *op, SlapReply *rs, Entry *parent, struct config_args_s *ca );
typedef struct ConfigOCs {
char *def;
ConfigType cft;
ObjectClass **oc;
char *co_def;
ConfigType co_type;
ObjectClass **co_oc;
ConfigTable *co_table;
ConfigLDAPadd *co_ldadd;
ConfigCfAdd *co_cfadd;
struct berval *co_name;
} ConfigOCs;
struct config_args_s;
typedef int (ConfigDriver)(struct config_args_s *c);
typedef struct config_args_s {
......@@ -111,6 +134,7 @@ typedef struct config_args_s {
int type; /* ConfigTable.arg_type & ARGS_USERLAND */
BackendDB *be;
BackendInfo *bi;
Entry *ca_entry; /* entry being modified */
void *private; /* anything */
ConfigDriver *cleanup;
} ConfigArgs;
......@@ -127,3 +151,5 @@ int config_register_schema(ConfigTable *ct, ConfigOCs *co);
int config_get_vals(ConfigTable *ct, ConfigArgs *c);
int config_add_vals(ConfigTable *ct, ConfigArgs *c);
ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);
Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra );
......@@ -1605,6 +1605,8 @@ LDAP_TAILQ_HEAD( be_pcl, slap_csn_entry );
#define SLAP_MAX_CIDS 32 /* Maximum number of supported controls */
#endif
struct ConfigOCs; /* config.h */
struct slap_backend_db {
BackendInfo *bd_info; /* pointer to shared backend info */
......@@ -1775,7 +1777,7 @@ struct slap_backend_db {
struct syncinfo_s *be_syncinfo; /* For syncrepl */
void *be_pb; /* Netscape plugin */
struct ConfigTable *be_cf_table;
struct ConfigOCs *be_cf_ocs;
void *be_private; /* anything the backend database needs */
LDAP_STAILQ_ENTRY(slap_backend_db) be_next;
......@@ -1989,8 +1991,6 @@ typedef int (BI_tool_id2entry_get) LDAP_P(( BackendDB *be, ID id, Entry **e ));
typedef ID (BI_tool_entry_modify) LDAP_P(( BackendDB *be, Entry *e,
struct berval *text ));
struct ConfigTable; /* config.h */
struct slap_backend_info {
char *bi_type; /* type of backend */
......@@ -2118,7 +2118,7 @@ struct slap_backend_info {
char bi_ctrls[SLAP_MAX_CIDS + 1];
unsigned int bi_nDB; /* number of databases of this type */
struct ConfigTable *bi_cf_table;
struct ConfigOCs *bi_cf_ocs;
void *bi_private; /* anything the backend type needs */
LDAP_STAILQ_ENTRY(slap_backend_info) bi_next ;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment