From: Kurt Zeilenga Date: Sun, 25 Oct 1998 02:02:31 +0000 (+0000) Subject: replace with ac version X-Git-Tag: PHP3_TOOL_0_0~22 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a57b7a5bb0cf4fc6dfc9173a078ed84b4fd244c0;p=openldap replace with ac version --- diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index cc358ceefc..d5bd6715bf 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -5,69 +5,29 @@ * os-ip.c -- platform-specific TCP & UDP related code */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif +#include "portable.h" #include #include -#include -#include -#ifdef _WIN32 -#include -#include "msdos.h" -#else /* _WIN32 */ -#include -#include -#include -#include -#include -#include -#include -#endif /* _WIN32 */ -#ifdef _AIX -#include -#endif /* _AIX */ -#ifdef VMS -#include "ucx_select.h" -#endif /* VMS */ +#include +#include +#include +#include +#include -#include "portable.h" -#include "lber.h" -#include "ldap.h" +#ifdef HAVE_IO_H +#include +#endif /* HAVE_IO_H */ -#ifdef LDAP_REFERRALS -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ -#ifdef notyet -#ifdef NEED_FILIO +#if defined( HAVE_SYS_FILIO_H ) #include -#else /* NEED_FILIO */ +#elif defined( HAVE_SYS_IOCTL_H ) #include -#endif /* NEED_FILIO */ -#endif /* notyet */ -#endif /* LDAP_REFERRALS */ - -#ifdef MACOS -#define tcp_close( s ) tcpclose( s ) -#else /* MACOS */ -#ifdef DOS -#ifdef PCNFS -#define tcp_close( s ) close( s ) -#endif /* PCNFS */ -#ifdef NCSA -#define tcp_close( s ) netclose( s ); netshut() -#endif /* NCSA */ -#ifdef WINSOCK -#define tcp_close( s ) closesocket( s ); WSACleanup(); -#endif /* WINSOCK */ -#else /* DOS */ -#define tcp_close( s ) close( s ) -#endif /* DOS */ -#endif /* MACOS */ +#endif +#include "lber.h" +#include "ldap.h" #include "ldap-int.h" int @@ -92,13 +52,17 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, #endif /* notyet */ Debug( LDAP_DEBUG_TRACE, "ldap_connect_to_host: %s:%d\n", - ( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 ); + ( host == NULL ) ? "(by address)" : host, (int) ntohs( (short) port ), 0 ); connected = use_hp = 0; if ( host != NULL && ( address = inet_addr( host )) == -1 ) { if ( (hp = gethostbyname( host )) == NULL ) { +#ifdef HAVE_WINSOCK + errno = WSAGetLastError(); +#else errno = EHOSTUNREACH; /* not exactly right, but... */ +#endif return( -1 ); } use_hp = 1; @@ -131,6 +95,9 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, rc = 0; break; } else { +#ifdef HAVE_WINSOCK + errno = WSAGetLastError(); +#endif #ifdef notyet #ifdef LDAP_REFERRALS #ifdef EAGAIN @@ -151,7 +118,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, perror( (char *)inet_ntoa( sin.sin_addr )); } #endif - close( s ); + tcp_close( s ); if ( !use_hp ) { break; } @@ -172,7 +139,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, #endif /* notyet */ Debug( LDAP_DEBUG_TRACE, "sd %d connected to: %s\n", - s, inet_ntoa( sin.sin_addr ), 0 ); + s, (char *) inet_ntoa( sin.sin_addr ), 0 ); } return( rc ); @@ -186,7 +153,7 @@ ldap_close_connection( Sockbuf *sb ) } -#ifdef KERBEROS +#ifdef HAVE_KERBEROS char * ldap_host_connected_to( Sockbuf *sb ) { @@ -215,7 +182,7 @@ ldap_host_connected_to( Sockbuf *sb ) return( NULL ); } -#endif /* KERBEROS */ +#endif /* HAVE_KERBEROS */ #ifdef LDAP_REFERRALS @@ -236,7 +203,7 @@ ldap_mark_select_write( LDAP *ld, Sockbuf *sb ) sip = (struct selectinfo *)ld->ld_selectinfo; if ( !FD_ISSET( sb->sb_sd, &sip->si_writefds )) { - FD_SET( sb->sb_sd, &sip->si_writefds ); + FD_SET( (u_int) sb->sb_sd, &sip->si_writefds ); } } @@ -249,7 +216,7 @@ ldap_mark_select_read( LDAP *ld, Sockbuf *sb ) sip = (struct selectinfo *)ld->ld_selectinfo; if ( !FD_ISSET( sb->sb_sd, &sip->si_readfds )) { - FD_SET( sb->sb_sd, &sip->si_readfds ); + FD_SET( (u_int) sb->sb_sd, &sip->si_readfds ); } } @@ -261,8 +228,8 @@ ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ) sip = (struct selectinfo *)ld->ld_selectinfo; - FD_CLR( sb->sb_sd, &sip->si_writefds ); - FD_CLR( sb->sb_sd, &sip->si_readfds ); + FD_CLR( (u_int) sb->sb_sd, &sip->si_writefds ); + FD_CLR( (u_int) sb->sb_sd, &sip->si_readfds ); } @@ -319,9 +286,9 @@ do_ldap_select( LDAP *ld, struct timeval *timeout ) Debug( LDAP_DEBUG_TRACE, "do_ldap_select\n", 0, 0, 0 ); if ( tblsize == 0 ) { -#ifdef USE_SYSCONF +#if defined( HAVE_SYSCONF ) tblsize = sysconf( _SC_OPEN_MAX ); -#else /* !USE_SYSCONF */ +#elif defined( HAVE_GETDTABLESIZE ) tblsize = getdtablesize(); #endif /* !USE_SYSCONF */ diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index d4ff0d395c..df3bb6d57c 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -6,119 +6,16 @@ * - DB_DBT_MALLOC ; 1998/03/22, /KSp */ -#include -#include "ldbm.h" - -#ifdef LDBM_USE_GDBM - -#include -#include - -/***************************************************************** - * * - * use gdbm * - * * - *****************************************************************/ - -LDBM -ldbm_open( char *name, int rw, int mode, int dbcachesize ) -{ - LDBM db; - struct stat st; - - if ( (db = gdbm_open( name, 0, rw | GDBM_FAST, mode, 0 )) == NULL ) { - return( NULL ); - } - if ( dbcachesize > 0 && stat( name, &st ) == 0 ) { - dbcachesize = (dbcachesize / st.st_blksize); - gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) ); - } - - return( db ); -} - -void -ldbm_close( LDBM ldbm ) -{ - gdbm_close( ldbm ); -} - -void -ldbm_sync( LDBM ldbm ) -{ - gdbm_sync( ldbm ); -} - -void -ldbm_datum_free( LDBM ldbm, Datum data ) -{ - free( data.dptr ); -} - -Datum -ldbm_datum_dup( LDBM ldbm, Datum data ) -{ - Datum dup; - - if ( data.dsize == 0 ) { - dup.dsize = 0; - dup.dptr = NULL; +#include "portable.h" - return( dup ); - } - dup.dsize = data.dsize; - if ( dup.dptr = (char *) malloc( data.dsize ) ) - memcpy( dup.dptr, data.dptr, data.dsize ); - - return( dup ); -} - -Datum -ldbm_fetch( LDBM ldbm, Datum key ) -{ - return( gdbm_fetch( ldbm, key ) ); -} +#ifdef SLAPD_LDBM -int -ldbm_store( LDBM ldbm, Datum key, Datum data, int flags ) -{ - int rc; - - rc = gdbm_store( ldbm, key, data, flags & ~LDBM_SYNC ); - if ( flags & LDBM_SYNC ) - gdbm_sync( ldbm ); - return( rc ); -} - -int -ldbm_delete( LDBM ldbm, Datum key ) -{ - int rc; - - rc = gdbm_delete( ldbm, key ); - gdbm_sync( ldbm ); - return( rc ); -} - -Datum -ldbm_firstkey( LDBM ldbm ) -{ - return( gdbm_firstkey( ldbm ) ); -} - -Datum -ldbm_nextkey( LDBM ldbm, Datum key ) -{ - return( gdbm_nextkey( ldbm, key ) ); -} +#include +#include +#include -int -ldbm_errno( LDBM ldbm ) -{ - return( (int) gdbm_errno ); -} +#include "ldbm.h" -#else #if defined( LDBM_USE_DBHASH ) || defined( LDBM_USE_DBBTREE ) /***************************************************************** @@ -127,16 +24,13 @@ ldbm_errno( LDBM ldbm ) * * *****************************************************************/ -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 /************************************************* * * * A malloc routine for use with DB_DBT_MALLOC * * * *************************************************/ -#include - - void * ldbm_malloc( size_t size ) { @@ -151,7 +45,7 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize ) { LDBM ret = NULL; -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 DB_INFO dbinfo; memset( &dbinfo, 0, sizeof( dbinfo )); @@ -188,7 +82,7 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize ) void ldbm_close( LDBM ldbm ) { -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 (*ldbm->close)( ldbm, 0 ); #else (*ldbm->close)( ldbm ); @@ -212,7 +106,7 @@ ldbm_datum_dup( LDBM ldbm, Datum data ) { Datum dup; -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 memset( &dup, 0, sizeof( dup )); #endif @@ -235,7 +129,7 @@ ldbm_fetch( LDBM ldbm, Datum key ) Datum data; int rc; -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 memset( &data, 0, sizeof( data )); data.flags = DB_DBT_MALLOC; @@ -259,7 +153,7 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags ) { int rc; -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 rc = (*ldbm->put)( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC ); rc = (-1 ) * rc; #else @@ -275,7 +169,7 @@ ldbm_delete( LDBM ldbm, Datum key ) { int rc; -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 rc = (*ldbm->del)( ldbm, NULL, &key, 0 ); rc = (-1 ) * rc; #else @@ -286,7 +180,7 @@ ldbm_delete( LDBM ldbm, Datum key ) } Datum -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 ldbm_firstkey( LDBM ldbm, DBC **dbch ) #else ldbm_firstkey( LDBM ldbm ) @@ -295,7 +189,7 @@ ldbm_firstkey( LDBM ldbm ) Datum key, data; int rc; -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 DBC *dbci; memset( &key, 0, sizeof( key )); @@ -319,7 +213,7 @@ ldbm_firstkey( LDBM ldbm ) key.dsize = 0; } -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 } #endif @@ -327,7 +221,7 @@ ldbm_firstkey( LDBM ldbm ) } Datum -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 ldbm_nextkey( LDBM ldbm, Datum key, DBC *dbcp ) #else ldbm_nextkey( LDBM ldbm, Datum key ) @@ -336,7 +230,7 @@ ldbm_nextkey( LDBM ldbm, Datum key ) Datum data; int rc; -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 void *oldKey = key.dptr; memset( &data, 0, sizeof( data )); @@ -353,7 +247,7 @@ ldbm_nextkey( LDBM ldbm, Datum key ) key.dptr = NULL; key.dsize = 0; } -#ifdef LDBM_USE_DB2 +#ifdef HAVE_BERKELEY_DB2 if ( oldKey ) free( oldKey ); #endif @@ -366,9 +260,115 @@ ldbm_errno( LDBM ldbm ) return( errno ); } -#else +#elif defined( HAVE_GDBM ) + +#include + +/***************************************************************** + * * + * use gdbm * + * * + *****************************************************************/ + +LDBM +ldbm_open( char *name, int rw, int mode, int dbcachesize ) +{ + LDBM db; + struct stat st; + + if ( (db = gdbm_open( name, 0, rw | GDBM_FAST, mode, 0 )) == NULL ) { + return( NULL ); + } + if ( dbcachesize > 0 && stat( name, &st ) == 0 ) { + dbcachesize = (dbcachesize / st.st_blksize); + gdbm_setopt( db, GDBM_CACHESIZE, &dbcachesize, sizeof(int) ); + } + + return( db ); +} + +void +ldbm_close( LDBM ldbm ) +{ + gdbm_close( ldbm ); +} + +void +ldbm_sync( LDBM ldbm ) +{ + gdbm_sync( ldbm ); +} + +void +ldbm_datum_free( LDBM ldbm, Datum data ) +{ + free( data.dptr ); +} + +Datum +ldbm_datum_dup( LDBM ldbm, Datum data ) +{ + Datum dup; + + if ( data.dsize == 0 ) { + dup.dsize = 0; + dup.dptr = NULL; + + return( dup ); + } + dup.dsize = data.dsize; + if ( dup.dptr = (char *) malloc( data.dsize ) ) + memcpy( dup.dptr, data.dptr, data.dsize ); + + return( dup ); +} + +Datum +ldbm_fetch( LDBM ldbm, Datum key ) +{ + return( gdbm_fetch( ldbm, key ) ); +} + +int +ldbm_store( LDBM ldbm, Datum key, Datum data, int flags ) +{ + int rc; + + rc = gdbm_store( ldbm, key, data, flags & ~LDBM_SYNC ); + if ( flags & LDBM_SYNC ) + gdbm_sync( ldbm ); + return( rc ); +} + +int +ldbm_delete( LDBM ldbm, Datum key ) +{ + int rc; + + rc = gdbm_delete( ldbm, key ); + gdbm_sync( ldbm ); + return( rc ); +} + +Datum +ldbm_firstkey( LDBM ldbm ) +{ + return( gdbm_firstkey( ldbm ) ); +} + +Datum +ldbm_nextkey( LDBM ldbm, Datum key ) +{ + return( gdbm_nextkey( ldbm, key ) ); +} + +int +ldbm_errno( LDBM ldbm ) +{ + return( (int) gdbm_errno ); +} -#ifdef LDBM_USE_NDBM +#elif defined( HAVE_NDBM ) /***************************************************************** * * @@ -457,5 +457,4 @@ ldbm_errno( LDBM ldbm ) } #endif /* ndbm */ -#endif /* db */ -#endif /* gdbm */ +#endif /* ldbm */