/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2005 The OpenLDAP Foundation.
* Portions Copyright 1997,2002-2003 IBM Corporation.
* All rights reserved.
*
#include <ldap_pvt_thread.h>
#include <slap.h>
#include <slapi.h>
+#include <lutil.h>
/*
* Note: if ltdl.h is not available, slapi should not be compiled
static Slapi_PBlock *
plugin_pblock_new(
int type,
- const char *path,
- const char *initfunc,
int argc,
char *argv[] )
{
Slapi_PluginDesc *pPluginDesc = NULL;
lt_dlhandle hdLoadHandle;
int rc;
+ char **av2 = NULL, **ppPluginArgv;
+ char *path = argv[2];
+ char *initfunc = argv[3];
pPlugin = slapi_pblock_new();
if ( pPlugin == NULL ) {
goto done;
}
- rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGV, (void *)argv );
+ av2 = ldap_charray_dup( argv );
+ if ( !av2 ) {
+ rc = LDAP_NO_MEMORY;
+ goto done;
+ }
+
+ if ( argc > 0 ) {
+ ppPluginArgv = &av2[4];
+ } else {
+ ppPluginArgv = NULL;
+ }
+ rc = slapi_pblock_set( pPlugin, SLAPI_PLUGIN_ARGV, (void *)ppPluginArgv );
+ if ( rc != 0 ) {
+ goto done;
+ }
+
+ rc = slapi_pblock_set( pPlugin, SLAPI_X_CONFIG_ARGV, (void *)av2 );
if ( rc != 0 ) {
goto done;
}
if ( rc != 0 && pPlugin != NULL ) {
slapi_pblock_destroy( pPlugin );
pPlugin = NULL;
+ if ( av2 ) {
+ ldap_charray_free( av2 );
+ }
}
return pPlugin;
{
int iType = -1;
int numPluginArgc = 0;
- char **ppPluginArgv = NULL;
if ( argc < 4 ) {
fprintf( stderr,
}
numPluginArgc = argc - 4;
- if ( numPluginArgc > 0 ) {
- ppPluginArgv = &argv[4];
- } else {
- ppPluginArgv = NULL;
- }
if ( iType == SLAPI_PLUGIN_PREOPERATION ||
iType == SLAPI_PLUGIN_EXTENDEDOP ||
int rc;
Slapi_PBlock *pPlugin;
- pPlugin = plugin_pblock_new( iType, argv[2], argv[3],
- numPluginArgc, ppPluginArgv );
+ pPlugin = plugin_pblock_new( iType, numPluginArgc, argv );
if (pPlugin == NULL) {
return 1;
}
return 0;
}
+void
+slapi_int_plugin_unparse(
+ Backend *be,
+ BerVarray *out
+)
+{
+ Slapi_PBlock *pp;
+ int i, j, rc;
+ char **argv, ibuf[32], *ptr;
+ struct berval idx, bv;
+
+ *out = NULL;
+ idx.bv_val = ibuf;
+ i = 0;
+ for ( pp=be->be_pb; pp; slapi_pblock_get( pp, SLAPI_IBM_PBLOCK, &pp ) ) {
+ slapi_pblock_get( pp, SLAPI_X_CONFIG_ARGV, &argv );
+ idx.bv_len = sprintf( idx.bv_val, "{%d}", i );
+ bv.bv_len = idx.bv_len;
+ for (j=1; argv[j]; j++) {
+ bv.bv_len += strlen(argv[j]);
+ if ( j ) bv.bv_len++;
+ }
+ bv.bv_val = ch_malloc( bv.bv_len + 1 );
+ ptr = lutil_strcopy( bv.bv_val, ibuf );
+ for (j=1; argv[j]; j++) {
+ if ( j ) *ptr++ = ' ';
+ ptr = lutil_strcopy( ptr, argv[j] );
+ }
+ ber_bvarray_add( out, &bv );
+ }
+}
+
int
slapi_int_initialize(void)
{