]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb2/startup.c
Change 'unsigned long len' to ber_len_t in get_filter()
[openldap] / servers / slapd / back-bdb2 / startup.c
index 6f6d73c814ec213fea64ac179588b15c0e466c84..3857ab681248236b7910ffe883fc312bf4a51e18 100644 (file)
@@ -6,8 +6,16 @@
 
 #include <ac/string.h>
 #include <ac/socket.h>
+#include <ac/unistd.h>
 
-#include "ldapconfig.h"
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifdef HAVE_DIRECT_H
+#include <direct.h>
+#endif
+
+#include "ldap_defaults.h"
 #include "slap.h"
 #include "back-bdb2.h"
 
@@ -17,7 +25,7 @@ static void remove_old_locks( char *home );
 
 
 static void
-bdb2i_db_errcall( char *prefix, char *message )
+bdb2i_db_errcall( const char *prefix, char *message )
 {
        Debug( LDAP_DEBUG_ANY, "bdb2_db_errcall(): %s %s", prefix, message, 0 );
 }
@@ -31,17 +39,21 @@ bdb2i_back_startup_internal(
 )
 {
        struct ldbtype  *lty = (struct ldbtype *) bi->bi_private;
-       DB_ENV           *dbEnv = lty->lty_dbenv;
-       int    envFlags = DB_CREATE | DB_THREAD | DB_INIT_LOCK | DB_INIT_MPOOL;
-       int    err      = 0;
-       char   *home;
+       int             envFlags;
+       int             err      = 0;
+       char            *home;
+
+       /*  set the flags for a full-feldged transaction schema  */
+       envFlags = ( DB_CREATE | DB_THREAD | DB_INIT_TXN | DB_INIT_LOG |
+                                       DB_INIT_LOCK | DB_INIT_MPOOL );
 
        /*  make sure, dbhome is an absolute path  */
-       if ( *lty->lty_dbhome != *DEFAULT_DIRSEP ) {
+       if ( *lty->lty_dbhome != *LDAP_DIRSEP ) {
                char   cwd[MAXPATHLEN];
 
                (void) getcwd( cwd, MAXPATHLEN );
-               sprintf( cwd, "%s%s%s", cwd, DEFAULT_DIRSEP, lty->lty_dbhome );
+               sprintf( cwd, "%s" LDAP_DIRSEP "%s",
+                       cwd, lty->lty_dbhome );
                free( lty->lty_dbhome );
                lty->lty_dbhome = ch_strdup( cwd );
 
@@ -49,21 +61,21 @@ bdb2i_back_startup_internal(
        home = lty->lty_dbhome;
 
        /*  general initialization of the environment  */
-       memset( dbEnv, 0, sizeof( DB_ENV ));
-       dbEnv->db_errcall = bdb2i_db_errcall;
-       dbEnv->db_errpfx  = "==>";
+       memset( &bdb2i_dbEnv, 0, sizeof( DB_ENV ));
+       bdb2i_dbEnv.db_errcall = bdb2i_db_errcall;
+       bdb2i_dbEnv.db_errpfx  = "==>";
 
        /*  initialize the lock subsystem  */
-       dbEnv->lk_max     = 0;
+       bdb2i_dbEnv.lk_max     = 0;
 
        /*  remove old locking tables  */
        remove_old_locks( home );
 
        /*  initialize the mpool subsystem  */
-       dbEnv->mp_size   = lty->lty_mpsize;
+       bdb2i_dbEnv.mp_size   = lty->lty_mpsize;
 
        /*  now do the db_appinit  */
-       if ( ( err = db_appinit( home, NULL, dbEnv, envFlags )) ) {
+       if ( ( err = db_appinit( home, NULL, &bdb2i_dbEnv, envFlags )) ) {
                char  error[BUFSIZ];
 
                if ( err < 0 ) sprintf( error, "%ld\n", (long) err );
@@ -86,22 +98,21 @@ bdb2i_back_shutdown_internal(
 )
 {
        struct ldbtype  *lty = (struct ldbtype *) bi->bi_private;
-       DB_ENV           *dbEnv = lty->lty_dbenv;
        int              err;
 
        /*  remove old locking tables  */
-       dbEnv->db_errpfx  = "bdb2i_back_shutdown(): lock_unlink:";
-       if ( ( err = lock_unlink( NULL, 1, dbEnv )) != 0 )
+       bdb2i_dbEnv.db_errpfx  = "bdb2i_back_shutdown(): lock_unlink:";
+       if ( ( err = lock_unlink( NULL, 1, &bdb2i_dbEnv )) != 0 )
                Debug( LDAP_DEBUG_ANY, "bdb2i_back_shutdown(): lock_unlink: %s\n",
                                        strerror( err ), 0, 0);
 
        /*  remove old memory pool  */
-       dbEnv->db_errpfx  = "bdb2i_back_shutdown(): memp_unlink:";
-       if ( ( err = memp_unlink( NULL, 1, dbEnv )) != 0 )
+       bdb2i_dbEnv.db_errpfx  = "bdb2i_back_shutdown(): memp_unlink:";
+       if ( ( err = memp_unlink( NULL, 1, &bdb2i_dbEnv )) != 0 )
                Debug( LDAP_DEBUG_ANY, "bdb2i_back_shutdown(): memp_unlink: %s\n",
                                        strerror( err ), 0, 0);
 
-       (void) db_appexit( dbEnv );
+       (void) db_appexit( &bdb2i_dbEnv );
 
        return( 0 );
 }
@@ -152,11 +163,13 @@ bdb2i_back_db_startup_internal(
 
        /*  if the data directory is not an absolute path, have it relative
         to the current working directory (which should not be configured !)  */
-       if ( *li->li_directory != *DEFAULT_DIRSEP ) {
+       if ( *li->li_directory != *LDAP_DIRSEP ) {
                char   cwd[MAXPATHLEN];
 
                (void) getcwd( cwd, MAXPATHLEN );
-               sprintf( cwd, "%s%s%s", cwd, DEFAULT_DIRSEP, li->li_directory );
+               sprintf( cwd, "%s" LDAP_DIRSEP "%s",
+                       cwd, li->li_directory );
+
                free( li->li_directory );
                li->li_directory = ch_strdup( cwd );
 
@@ -167,7 +180,7 @@ bdb2i_back_db_startup_internal(
                return 1;
 
        /*  now open all DB files  */
-       if ( bdb2i_txn_open_files( li ) != 0 )
+       if ( bdb2i_txn_open_files( be ) != 0 )
                return 1;
 
        return 0;
@@ -224,7 +237,7 @@ remove_old_locks( char *home )
        int     err;
 
        memset( &dbEnv, 0, sizeof( DB_ENV ));
-       dbEnv.db_errcall = stderr;
+       dbEnv.db_errcall = bdb2i_db_errcall;
        dbEnv.db_errpfx  = "remove_old_locks(): db_appinit:";
        dbEnv.lk_max     = 0;