From cd60deb4a98c04e39d427c1d4a228162c942d104 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 22 Aug 2002 04:39:59 +0000 Subject: [PATCH] OS/390 EBCDIC support --- servers/slapd/back-bdb/dbcache.c | 3 +++ servers/slapd/back-bdb/error.c | 19 +++++++++++++++++ servers/slapd/back-bdb/init.c | 34 ++++++++++++++++++++++++++++++ servers/slapd/back-bdb/proto-bdb.h | 6 ++++++ 4 files changed, 62 insertions(+) diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c index 8ee06503e5..2110554fac 100644 --- a/servers/slapd/back-bdb/dbcache.c +++ b/servers/slapd/back-bdb/dbcache.c @@ -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, diff --git a/servers/slapd/back-bdb/error.c b/servers/slapd/back-bdb/error.c index c34b277df1..79d528a0e0 100644 --- a/servers/slapd/back-bdb/error.c +++ b/servers/slapd/back-bdb/error.c @@ -15,9 +15,28 @@ 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 diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 7c9ce06645..978835bd91 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -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 || diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 7adf2f0d47..6cef37e39c 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -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 */ -- 2.39.5