]> git.sur5r.net Git - openldap/commitdiff
OS/390 EBCDIC support
authorHoward Chu <hyc@openldap.org>
Thu, 22 Aug 2002 04:39:59 +0000 (04:39 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 22 Aug 2002 04:39:59 +0000 (04:39 +0000)
servers/slapd/back-bdb/dbcache.c
servers/slapd/back-bdb/error.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/proto-bdb.h

index 8ee06503e5f1c9b1dece8c593240dcfa0ce96def..2110554fac0f59461ca97dcd28927e4276d0e68c 100644 (file)
@@ -109,6 +109,9 @@ bdb_db_cache(
        file = ch_malloc( strlen( name ) + sizeof(BDB_SUFFIX) );
        sprintf( file, "%s" BDB_SUFFIX, name );
 
+#ifdef HAVE_EBCDIC
+       __atoe( file );
+#endif
        rc = DB_OPEN( db->bdi_db,
                file, name,
                DB_HASH, bdb->bi_db_opflags | DB_CREATE | DB_THREAD,
index c34b277df1316bdf3b19da4d4c4d09016fbfda2c..79d528a0e0272b53aaab46b5902defd5a097718a 100644 (file)
 
 void bdb_errcall( const char *pfx, char * msg )
 {
+#ifdef HAVE_EBCDIC
+       if ( msg[0] > 0x7f )
+               __etoa( msg );
+#endif
 #ifdef NEW_LOGGING
        LDAP_LOG ( OPERATION, INFO, "bdb(%s): %s\n", pfx, msg, 0 );
 #else
        Debug( LDAP_DEBUG_ANY, "bdb(%s): %s\n", pfx, msg, 0 );
 #endif
 }
+
+#ifdef HAVE_EBCDIC
+
+#undef db_strerror
+
+/* Not re-entrant! */
+char *ebcdic_dberror( int rc )
+{
+       static char msg[1024];
+
+       strcpy( msg, db_strerror( rc ) );
+       __etoa( msg );
+       return msg;
+}
+#endif
index 7c9ce06645f5cf07dac5800138dd97dd3a61f879..978835bd91b895905a271ffc3d9385c663246d25 100644 (file)
@@ -173,6 +173,9 @@ bdb_db_open( BackendDB *be )
        int rc, i;
        struct bdb_info *bdb = (struct bdb_info *) be->be_private;
        u_int32_t flags;
+#ifdef HAVE_EBCDIC
+       char path[MAXPATHLEN];
+#endif
 
 #ifdef NEW_LOGGING
        LDAP_LOG( BACK_BDB, ARGS, 
@@ -284,10 +287,19 @@ bdb_db_open( BackendDB *be )
                bdb->bi_dbenv_home, 0, 0);
 #endif
 
+#ifdef HAVE_EBCDIC
+       strcpy( path, bdb->bi_dbenv_home );
+       __atoe( path );
+       rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
+               path,
+               flags,
+               bdb->bi_dbenv_mode );
+#else
        rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
                bdb->bi_dbenv_home,
                flags,
                bdb->bi_dbenv_mode );
+#endif
        if( rc != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( BACK_BDB, ERR, 
@@ -362,12 +374,23 @@ bdb_db_open( BackendDB *be )
                                BDB_PAGESIZE );
                }
 
+#ifdef HAVE_EBCDIC
+               strcpy( path, bdbi_databases[i].file );
+               __atoe( path );
+               rc = DB_OPEN( db->bdi_db, 
+                       path,
+               /*      bdbi_databases[i].name, */ NULL,
+                       bdbi_databases[i].type,
+                       bdbi_databases[i].flags | flags,
+                       bdb->bi_dbenv_mode );
+#else
                rc = DB_OPEN( db->bdi_db, 
                        bdbi_databases[i].file,
                /*      bdbi_databases[i].name, */ NULL,
                        bdbi_databases[i].type,
                        bdbi_databases[i].flags | flags,
                        bdb->bi_dbenv_mode );
+#endif
 
                if( rc != 0 ) {
 #ifdef NEW_LOGGING
@@ -543,6 +566,17 @@ bdb_initialize(
        {       /* version check */
                int major, minor, patch;
                char *version = db_version( &major, &minor, &patch );
+#ifdef HAVE_EBCDIC
+               char v2[1024];
+
+               /* All our stdio does an ASCII to EBCDIC conversion on
+                * the output. Strings from the BDB library are already
+                * in EBCDIC; we have to go back and forth...
+                */
+               strcpy( v2, version );
+               __etoa( v2 );
+               version = v2;
+#endif
 
                if( major != DB_VERSION_MAJOR ||
                        minor != DB_VERSION_MINOR ||
index 7adf2f0d4747d67e9a6a2768f36cd97a4d389ada..6cef37e39c57fa2b7433f4b9a0ef2ccb2d5b2405 100644 (file)
@@ -343,6 +343,12 @@ int bdb_cache_delete_entry(
 );
 void bdb_cache_release_all( Cache *cache );
 
+#ifdef HAVE_EBCDIC
+char *ebcdic_dberror( int rc );
+
+#define db_strerror(x) ebcdic_dberror(x)
+#endif
+
 LDAP_END_DECL
 
 #endif /* _PROTO_BDB_H */