]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backend.c
Added connection initialisation and destruction notification. Now backends can regist...
[openldap] / servers / slapd / backend.c
index 1bf064541b0f93008f8ce393ffd7c8ad1a1ba1ba..eb0e3a31942b9e06296647f33b20e7f0958c0154 100644 (file)
 #include <sys/stat.h>
 
 #include "slap.h"
+#include "lutil.h"
 
+#ifdef SLAPD_LDAP
+#include "back-ldap/external.h"
+#endif
 #ifdef SLAPD_LDBM
 #include "back-ldbm/external.h"
 #endif
 #ifdef SLAPD_SHELL
 #include "back-shell/external.h"
 #endif
+#ifdef SLAPD_TCL
+#include "back-tcl/external.h"
+#endif
 
 static BackendInfo binfo[] = {
+#ifdef SLAPD_LDAP
+       {"ldap",        ldap_back_initialize},
+#endif
 #ifdef SLAPD_LDBM
        {"ldbm",        ldbm_back_initialize},
 #endif
@@ -43,6 +53,9 @@ static BackendInfo binfo[] = {
 #endif
 #ifdef SLAPD_SHELL
        {"shell",       shell_back_initialize},
+#endif
+#ifdef SLAPD_TCL
+       {"tcl",         tcl_back_initialize},
 #endif
        {NULL}
 };
@@ -346,7 +359,7 @@ be_db_close( void )
        int     i;
 
        for ( i = 0; i < nbackends; i++ ) {
-               if ( backends[i].bd_info->bi_db_close != NULL ) {
+               if ( backends[i].bd_info->bi_db_close ) {
                        (*backends[i].bd_info->bi_db_close)( &backends[i] );
                }
        }
@@ -359,16 +372,16 @@ select_backend( char * dn )
 
        dnlen = strlen( dn );
        for ( i = 0; i < nbackends; i++ ) {
-               for ( j = 0; backends[i].be_suffix != NULL &&
-                   backends[i].be_suffix[j] != NULL; j++ )
+               for ( j = 0; backends[i].be_nsuffix != NULL &&
+                   backends[i].be_nsuffix[j] != NULL; j++ )
                {
-                       len = strlen( backends[i].be_suffix[j] );
+                       len = strlen( backends[i].be_nsuffix[j] );
 
                        if ( len > dnlen ) {
                                continue;
                        }
 
-                       if ( strcmp( backends[i].be_suffix[j],
+                       if ( strcmp( backends[i].be_nsuffix[j],
                            dn + (dnlen - len) ) == 0 ) {
                                return( &backends[i] );
                        }
@@ -420,8 +433,8 @@ be_issuffix(
 {
        int     i;
 
-       for ( i = 0; be->be_suffix != NULL && be->be_suffix[i] != NULL; i++ ) {
-               if ( strcmp( be->be_suffix[i], suffix ) == 0 ) {
+       for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i] != NULL; i++ ) {
+               if ( strcmp( be->be_nsuffix[i], suffix ) == 0 ) {
                        return( 1 );
                }
        }
@@ -446,8 +459,6 @@ be_isroot( Backend *be, char *ndn )
 char *
 be_root_dn( Backend *be )
 {
-       int rc;
-
        if ( be->be_root_dn == NULL ) {
                return( "" );
        }
@@ -477,6 +488,19 @@ be_isroot_pw( Backend *be, char *ndn, struct berval *cred )
        return result == 0;
 }
 
+int
+be_entry_release_rw( Backend *be, Entry *e, int rw )
+{
+       if ( be->be_release ) {
+               /* free and release entry from backend */
+               return be->be_release( be, e, rw );
+       } else {
+               /* free entry */
+               entry_free( e );
+               return 0;
+       }
+}
+
 int
 backend_unbind(
        Connection   *conn,
@@ -486,7 +510,7 @@ backend_unbind(
        int     i;
 
        for ( i = 0; i < nbackends; i++ ) {
-               if ( backends[i].be_unbind != NULL ) {
+               if ( backends[i].be_unbind ) {
                        (*backends[i].be_unbind)( &backends[i], conn, op );
                }
        }
@@ -494,6 +518,38 @@ backend_unbind(
        return 0;
 }
 
+int
+backend_connection_init(
+       Connection   *conn
+)
+{
+       int     i;
+
+       for ( i = 0; i < nbackends; i++ ) {
+               if ( backends[i].be_connection_init ) {
+                       (*backends[i].be_connection_init)( &backends[i], conn);
+               }
+       }
+
+       return 0;
+}
+
+int
+backend_connection_destroy(
+       Connection   *conn
+)
+{
+       int     i;
+
+       for ( i = 0; i < nbackends; i++ ) {
+               if ( backends[i].be_connection_destroy ) {
+                       (*backends[i].be_connection_destroy)( &backends[i], conn);
+               }
+       }
+
+       return 0;
+}
+
 #ifdef SLAPD_ACLGROUPS
 int 
 backend_group(