]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapi/plugin.c
use slapi_pblock_delete_param()
[openldap] / servers / slapd / slapi / plugin.c
index 65dd9094b49ab42f4b2bf033342953de5acdb48e..abdd63d6cdc2f27a2430ed2b329fb55f77795574 100644 (file)
@@ -111,7 +111,7 @@ plugin_pblock_new(
                goto done;
        }
 
-       rc = slapi_int_load_plugin( pPlugin, path, initfunc, TRUE, NULL, &hdLoadHandle );
+       rc = slapi_int_load_plugin( pPlugin, path, initfunc, 1, NULL, &hdLoadHandle );
        if ( rc != 0 ) {
                goto done;
        }
@@ -163,11 +163,11 @@ slapi_int_register_plugin(
        Slapi_PBlock *pSavePB;
        int    rc = LDAP_SUCCESS;
 
-       assert( be != NULL ); /* global plugins are now stored in frontendDB */
+       assert( be != NULL );
 
-       pTmpPB = (Slapi_PBlock *)be->be_pb;
+       pTmpPB = SLAPI_BACKEND_PBLOCK( be );
        if ( pTmpPB == NULL ) {
-               be->be_pb = (void *)pPB;
+               SLAPI_BACKEND_PBLOCK( be ) = pPB;
        } else {
                while ( pTmpPB != NULL && rc == LDAP_SUCCESS ) {
                        pSavePB = pTmpPB;
@@ -217,32 +217,7 @@ slapi_int_get_plugins(
                goto done;
        }
 
-       /*
-        * First, count the plugins associated with a specific
-        * backend.
-        */
-       if ( be != frontendDB ) {
-               pCurrentPB = (Slapi_PBlock *)be->be_pb;
-
-               while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) {
-                       rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr );
-                       if ( rc == LDAP_SUCCESS ) {
-                               if ( FuncPtr != NULL )  {
-                                       numPB++;
-                               }
-                               rc = slapi_pblock_get( pCurrentPB,
-                                       SLAPI_IBM_PBLOCK, &pCurrentPB );
-                       }
-               }
-       }
-       if ( rc != LDAP_SUCCESS ) {
-               goto done;
-       }
-
-       /*
-        * Then, count the global plugins.
-        */
-       pCurrentPB = (Slapi_PBlock *)frontendDB->be_pb;
+       pCurrentPB = SLAPI_BACKEND_PBLOCK( be );
 
        while ( pCurrentPB != NULL && rc == LDAP_SUCCESS ) {
                rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr );
@@ -254,9 +229,6 @@ slapi_int_get_plugins(
                                SLAPI_IBM_PBLOCK, &pCurrentPB );
                }
        }
-       if ( rc != LDAP_SUCCESS ) {
-               goto done;
-       }
 
        if ( numPB == 0 ) {
                *ppFuncPtrs = NULL;
@@ -275,23 +247,7 @@ slapi_int_get_plugins(
                goto done;
        }
 
-       if ( be != frontendDB ) {
-               pCurrentPB = (Slapi_PBlock *)be->be_pb;
-
-               while ( pCurrentPB != NULL && rc == LDAP_SUCCESS )  {
-                       rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr );
-                       if ( rc == LDAP_SUCCESS ) {
-                               if ( FuncPtr != NULL )  {
-                                       *pTmpFuncPtr = FuncPtr;
-                                       pTmpFuncPtr++;
-                               } 
-                               rc = slapi_pblock_get( pCurrentPB,
-                                               SLAPI_IBM_PBLOCK, &pCurrentPB );
-                       }
-               }
-       }
-
-       pCurrentPB = (Slapi_PBlock *)frontendDB->be_pb;
+       pCurrentPB = SLAPI_BACKEND_PBLOCK( be );
 
        while ( pCurrentPB != NULL && rc == LDAP_SUCCESS )  {
                rc = slapi_pblock_get( pCurrentPB, functype, &FuncPtr );
@@ -304,7 +260,9 @@ slapi_int_get_plugins(
                                        SLAPI_IBM_PBLOCK, &pCurrentPB );
                }
        }
-       *pTmpFuncPtr = NULL ;
+
+       *pTmpFuncPtr = NULL;
+
 
 done:
        if ( rc != LDAP_SUCCESS && *ppFuncPtrs != NULL ) {
@@ -618,7 +576,7 @@ slapi_int_load_plugin(
                return LDAP_LOCAL_ERROR;
        }
 
-       if ( doInit == TRUE ) {
+       if ( doInit ) {
                rc = ( *fpInitFunc )( pPlugin );
                if ( rc != LDAP_SUCCESS ) {
                        lt_dlclose( *pLdHandle );
@@ -701,6 +659,14 @@ slapi_int_read_config(
                        fname, lineno );
                return 1;
        }
+
+       /* automatically instantiate overlay if necessary */
+       if ( !overlay_is_inst( be, SLAPI_OVERLAY_NAME ) ) {
+               if ( overlay_config( be, SLAPI_OVERLAY_NAME ) != 0 ) {
+                       fprintf( stderr, "Failed to instantiate SLAPI overlay\n");
+                       return -1;
+               }
+       }
        
        if ( strcasecmp( argv[1], "preoperation" ) == 0 ) {
                iType = SLAPI_PLUGIN_PREOPERATION;
@@ -766,7 +732,7 @@ slapi_int_plugin_unparse(
        idx.bv_val = ibuf;
        i = 0;
 
-       for ( pp = be->be_pb;
+       for ( pp = SLAPI_BACKEND_PBLOCK( be );
              pp != NULL;
              slapi_pblock_get( pp, SLAPI_IBM_PBLOCK, &pp ) )
        {
@@ -813,6 +779,5 @@ slapi_int_initialize(void)
                return -1;
        }
 
-       return 0;
+       return slapi_int_overlay_init();
 }
-