mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-15 03:01:09 +08:00
216049bd12
Separates per backend type from per backend database initialization and startup. Also supports per type / per backend shutdown. New frontend startup/shutdown routines are also provided: slap_init() slap_startup() slap_shutdown() slap_destroy() New frontend->backend startup/shutdown is managed by: backend_init() backend_startup() backend_shutdown backend_destroy backend_init() now calls bi_init() to initial all function pointers for the backend (excepting bi_init() which is now the only hardcoded entry point). New entry points are detailed in slap.h struct backend_info. backend_info is a per database type structure. Besides the new startup/shutdown entry points, the new interface also supports per backend type configuration options. One could have: backend bdb2 (new Berkeley DB 2 backend) bdb2_home /directory database bdb2 ... *** This code is fairly experimental *** *** Much cleanup and testing is still needed *** see slap.h for details on struct backend_db and backend_info.
129 lines
3.2 KiB
C
129 lines
3.2 KiB
C
/* config.c - shell backend configuration file routine */
|
|
|
|
#include "portable.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ac/string.h>
|
|
#include <ac/socket.h>
|
|
|
|
#include "slap.h"
|
|
#include "shell.h"
|
|
|
|
int
|
|
shell_back_db_config(
|
|
BackendDB *be,
|
|
char *fname,
|
|
int lineno,
|
|
int argc,
|
|
char **argv
|
|
)
|
|
{
|
|
struct shellinfo *si = (struct shellinfo *) be->be_private;
|
|
|
|
if ( si == NULL ) {
|
|
fprintf( stderr, "%s: line %d: shell backend info is null!\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
|
|
/* command + args to exec for binds */
|
|
if ( strcasecmp( argv[0], "bind" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"bind <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_bind = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for unbinds */
|
|
} else if ( strcasecmp( argv[0], "unbind" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"unbind <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_unbind = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for searches */
|
|
} else if ( strcasecmp( argv[0], "search" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"search <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_search = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for compares */
|
|
} else if ( strcasecmp( argv[0], "compare" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"compare <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_compare = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for modifies */
|
|
} else if ( strcasecmp( argv[0], "modify" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"modify <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_modify = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for modrdn */
|
|
} else if ( strcasecmp( argv[0], "modrdn" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"modrdn <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_modrdn = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for add */
|
|
} else if ( strcasecmp( argv[0], "add" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"add <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_add = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for delete */
|
|
} else if ( strcasecmp( argv[0], "delete" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"delete <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_delete = charray_dup( &argv[1] );
|
|
|
|
/* command + args to exec for abandon */
|
|
} else if ( strcasecmp( argv[0], "abandon" ) == 0 ) {
|
|
if ( argc < 2 ) {
|
|
fprintf( stderr,
|
|
"%s: line %d: missing executable in \"abandon <executable>\" line\n",
|
|
fname, lineno );
|
|
return( 1 );
|
|
}
|
|
si->si_abandon = charray_dup( &argv[1] );
|
|
|
|
/* anything else */
|
|
} else {
|
|
fprintf( stderr,
|
|
"%s: line %d: unknown directive \"%s\" in shell database definition (ignored)\n",
|
|
fname, lineno, argv[0] );
|
|
}
|
|
|
|
return 0;
|
|
}
|