Add minimal config support

This commit is contained in:
Kurt Zeilenga 2000-09-25 21:10:21 +00:00
parent c3ab074c00
commit e50c9b1588
5 changed files with 94 additions and 3 deletions

View file

@ -1,9 +1,9 @@
# $OpenLDAP$
SRCS = init.c tools.c \
SRCS = init.c tools.c config.c \
add.c compare.c delete.c search.c \
dn2entry.lo dn2id.c error.c id2entry.c idl.c nextid.c
OBJS = init.lo tools.lo \
OBJS = init.lo tools.lo config.lo \
add.lo compare.lo delete.lo search.lo \
dn2entry.lo dn2id.lo error.lo id2entry.lo idl.lo nextid.lo

View file

@ -139,6 +139,10 @@ SOURCE=.\compare.c
# End Source File
# Begin Source File
SOURCE=.\config.c
# End Source File
# Begin Source File
SOURCE=.\delete.c
# End Source File
# Begin Source File

View file

@ -0,0 +1,83 @@
/* config.c - ldbm backend configuration file routine */
/* $OpenLDAP$ */
/*
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include "back-bdb.h"
int
bdb_db_config(
Backend *be,
const char *fname,
int lineno,
int argc,
char **argv )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
if ( bdb == NULL ) {
fprintf( stderr, "%s: line %d: "
"bdb database info is null!\n",
fname, lineno );
return 1;
}
/* directory is the DB_HOME */
if ( strcasecmp( argv[0], "directory" ) == 0 ) {
if ( argc < 2 ) {
fprintf( stderr, "%s: line %d: "
"missing dir in \"directory <dir>\" line\n",
fname, lineno );
return 1;
}
if ( bdb->bi_dbenv_home ) {
free( bdb->bi_dbenv_home );
}
bdb->bi_dbenv_home = ch_strdup( argv[1] );
/* mode with which to create new database files */
} else if ( strcasecmp( argv[0], "mode" ) == 0 ) {
if ( argc < 2 ) {
fprintf( stderr, "%s: line %d: "
"missing mode in \"mode <mode>\" line\n",
fname, lineno );
return 1;
}
bdb->bi_dbenv_mode = strtol( argv[1], NULL, 0 );
#if 0
/* attribute to index */
} else if ( strcasecmp( argv[0], "index" ) == 0 ) {
int rc;
if ( argc < 2 ) {
fprintf( stderr, "%s: line %d: "
"missing attr in \"index <attr> [pres,eq,approx,sub]\" line\n",
fname, lineno );
return 1;
} else if ( argc > 3 ) {
fprintf( stderr, "%s: line %d: "
"extra junk after \"index <attr> [pres,eq,approx,sub]\" "
"line (ignored)\n",
fname, lineno );
}
rc = attr_index_config( li, fname, lineno, argc - 1, &argv[1] );
if( rc != LDAP_SUCCESS ) return 1;
#endif
/* anything else */
} else {
fprintf( stderr, "%s: line %d: "
"unknown directive \"%s\" in bdb database definition (ignored)\n",
fname, lineno, argv[0] );
}
return 0;
}

View file

@ -11,6 +11,10 @@ LDAP_BEGIN_DECL
extern int bdb_initialize LDAP_P(( BackendInfo *bi ));
extern int bdb_db_config LDAP_P(( BackendDB *bd,
const char *fname, int lineno,
int argc, char **argv ));
extern int bdb_add LDAP_P(( BackendDB *bd,
Connection *conn, Operation *op, Entry *e ));

View file

@ -269,7 +269,7 @@ bdb_initialize(
bi->bi_destroy = bdb_destroy;
bi->bi_db_init = bdb_db_init;
bi->bi_db_config = 0;
bi->bi_db_config = bdb_db_config;
bi->bi_db_open = bdb_db_open;
bi->bi_db_close = bdb_db_close;
bi->bi_db_destroy = bdb_db_destroy;