From: Kurt Zeilenga Date: Sun, 25 Oct 1998 03:13:43 +0000 (+0000) Subject: More files that didn't get merged properly. X-Git-Tag: PHP3_TOOL_0_0~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dd51f860420a21b9d813600709d82a3d86e56e9b;p=openldap More files that didn't get merged properly. --- diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 569621e3eb..a3dfc559bf 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -5,80 +5,39 @@ * request.c - sending of ldap requests; handling of referrals */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include #include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#include -#ifdef PCNFS -#include -#include -#include -#endif /* PCNFS */ -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#else /* DOS */ -#include -#include -#include -#include -#ifdef _AIX -#include -#endif /* _AIX */ -#include "portable.h" -#endif /* DOS */ -#endif /* MACOS */ -#ifdef VMS -#include "ucx_select.h" -#endif +#include +#include +#include +#include +#include + #include "lber.h" #include "ldap.h" #include "ldap-int.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ - - #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) -#ifdef NEEDPROTOS -static LDAPConn *find_connection( LDAP *ld, LDAPServer *srv, int any ); -static void use_connection( LDAP *ld, LDAPConn *lc ); -static void free_servers( LDAPServer *srvlist ); -#else /* NEEDPROTOS */ -static LDAPConn *find_connection(); -static void use_connection(); -static void free_servers(); -#endif /* NEEDPROTOS */ +static LDAPConn *find_connection LDAP_P(( LDAP *ld, LDAPServer *srv, int any )); +static void use_connection LDAP_P(( LDAP *ld, LDAPConn *lc )); +static void free_servers LDAP_P(( LDAPServer *srvlist )); #endif /* LDAP_REFERRALS || LDAP_DNS */ #ifdef LDAP_DNS -#ifdef NEEDPROTOS -static LDAPServer *dn2servers( LDAP *ld, char *dn ); -#else /* NEEDPROTOS */ -static LDAPServer *dn2servers(); -#endif /* NEEDPROTOS */ +static LDAPServer *dn2servers LDAP_P(( LDAP *ld, char *dn )); #endif /* LDAP_DNS */ #ifdef LDAP_REFERRALS -#ifdef NEEDPROTOS -static BerElement *re_encode_request( LDAP *ld, BerElement *origber, - int msgid, char **dnp ); -#else /* NEEDPROTOS */ -static BerElement *re_encode_request(); -#endif /* NEEDPROTOS */ +static BerElement *re_encode_request LDAP_P(( LDAP *ld, BerElement *origber, + int msgid, char **dnp )); #endif /* LDAP_REFERRALS */ diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 34966dc17a..dd6f5dbd44 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -5,86 +5,41 @@ * result.c - wait for an ldap result */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include #include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#ifdef PCNFS -#include -#include -#include -#endif /* PCNFS */ -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#else /* DOS */ -#include -#include -#include -#include -#ifdef _AIX -#include -#endif /* _AIX */ -#endif /* DOS */ -#endif /* MACOS */ -#ifdef VMS -#include "ucx_select.h" -#endif - -#include "portable.h" +#include +#include +#include +#include +#include #include "lber.h" #include "ldap.h" #include "ldap-int.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ -#ifdef NEEDPROTOS -static int ldap_abandoned( LDAP *ld, int msgid ); -static int ldap_mark_abandoned( LDAP *ld, int msgid ); -static int wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, - LDAPMessage **result ); +static int ldap_abandoned LDAP_P(( LDAP *ld, int msgid )); +static int ldap_mark_abandoned LDAP_P(( LDAP *ld, int msgid )); +static int wait4msg LDAP_P(( LDAP *ld, int msgid, int all, struct timeval *timeout, + LDAPMessage **result )); #ifdef LDAP_REFERRALS -static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc, - LDAPMessage **result ); -static int build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ); -static void merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ); +static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc, + LDAPMessage **result )); +static int build_result_ber LDAP_P(( LDAP *ld, BerElement *ber, LDAPRequest *lr )); +static void merge_error_info LDAP_P(( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )); #else /* LDAP_REFERRALS */ -static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, - LDAPMessage **result ); +static int read1msg LDAP_P(( LDAP *ld, int msgid, int all, Sockbuf *sb, + LDAPMessage **result )); #endif /* LDAP_REFERRALS */ -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -static int ldap_select1( LDAP *ld, struct timeval *timeout ); -#endif -#else /* NEEDPROTOS */ -static int ldap_abandoned(); -static int ldap_mark_abandoned(); -static int wait4msg(); -static int read1msg(); -#ifdef LDAP_REFERRALS -static int build_result_ber(); -static void merge_error_info(); -#endif /* LDAP_REFERRALS */ -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -static int ldap_select1(); -#endif -#endif /* NEEDPROTOS */ - -#if !defined( MACOS ) && !defined( DOS ) -extern int errno; +#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_REFERRALS ) +static int ldap_select1 LDAP_P(( LDAP *ld, struct timeval *timeout )); #endif @@ -215,12 +170,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) { rc = ldap_select1( ld, tvp ); -#if !defined( MACOS ) && !defined( DOS ) if ( rc == 0 || ( rc == -1 && (( ld->ld_options & LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) { -#else - if ( rc == -1 || rc == 0 ) { -#endif ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : LDAP_TIMEOUT); return( rc ); @@ -252,7 +203,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, rc = do_ldap_select( ld, tvp ); -#if defined( LDAP_DEBUG ) && !defined( MACOS ) && !defined( DOS ) +#ifdef LDAP_DEBUG if ( rc == -1 ) { Debug( LDAP_DEBUG_TRACE, "do_ldap_select returned -1: errno %d\n", @@ -260,12 +211,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } #endif -#if !defined( MACOS ) && !defined( DOS ) if ( rc == 0 || ( rc == -1 && (( ld->ld_options & LDAP_OPT_RESTART ) == 0 || errno != EINTR ))) { -#else - if ( rc == -1 || rc == 0 ) { -#endif ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN : LDAP_TIMEOUT); return( rc ); @@ -483,11 +430,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); new->lm_msgtype = tag; new->lm_ber = ber_dup( &ber ); -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { ldap_add_result_to_cache( ld, new ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ /* is this the one we're looking for? */ if ( msgid == LDAP_RES_ANY || id == msgid ) { @@ -633,8 +580,8 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) -#if defined( CLDAP ) || !defined( LDAP_REFERRALS ) -#if !defined( MACOS ) && !defined( DOS ) && !defined( _WIN32 ) +#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_REFERRALS ) + static int ldap_select1( LDAP *ld, struct timeval *timeout ) { @@ -642,11 +589,13 @@ ldap_select1( LDAP *ld, struct timeval *timeout ) static int tblsize; if ( tblsize == 0 ) { -#ifdef USE_SYSCONF +#ifdef HAVE_SYSCONF tblsize = sysconf( _SC_OPEN_MAX ); -#else /* !USE_SYSCONF */ +#elif HAVE_GETDTABLESIZE tblsize = getdtablesize(); -#endif /* !USE_SYSCONF */ +#else + tblsize = FD_SETSIZE; +#endif #ifdef FD_SETSIZE if ( tblsize > FD_SETSIZE ) { tblsize = FD_SETSIZE; @@ -659,77 +608,7 @@ ldap_select1( LDAP *ld, struct timeval *timeout ) return( select( tblsize, &readfds, 0, 0, timeout ) ); } -#endif /* !MACOS */ - -#ifdef MACOS -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - return( tcpselect( ld->ld_sb.sb_sd, timeout )); -} -#endif /* MACOS */ - - -#if ( defined( DOS ) && defined( WINSOCK )) || defined( _WIN32 ) -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - fd_set readfds; - int rc; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sb.sb_sd, &readfds ); - - rc = select( 1, &readfds, 0, 0, timeout ); - return( rc == SOCKET_ERROR ? -1 : rc ); -} -#endif /* WINSOCK || _WIN32 */ - - -#ifdef DOS -#ifdef PCNFS -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - fd_set readfds; - int res; - - FD_ZERO( &readfds ); - FD_SET( ld->ld_sb.sb_sd, &readfds ); - - res = select( FD_SETSIZE, &readfds, NULL, NULL, timeout ); - if ( res == -1 && errno == EINTR) { - /* We've been CTRL-C'ed at this point. It'd be nice to - carry on but PC-NFS currently won't let us! */ - printf("\n*** CTRL-C ***\n"); - exit(-1); - } - return( res ); -} -#endif /* PCNFS */ - -#ifdef NCSA -static int -ldap_select1( LDAP *ld, struct timeval *timeout ) -{ - int rc; - clock_t endtime; - - if ( timeout != NULL ) { - endtime = timeout->tv_sec * CLK_TCK + - timeout->tv_usec * CLK_TCK / 1000000 + clock(); - } - - do { - Stask(); - rc = netqlen( ld->ld_sb.sb_sd ); - } while ( rc <= 0 && ( timeout == NULL || clock() < endtime )); - - return( rc > 0 ? 1 : 0 ); -} -#endif /* NCSA */ -#endif /* DOS */ #endif /* !LDAP_REFERRALS */ @@ -827,7 +706,7 @@ ldap_mark_abandoned( LDAP *ld, int msgid ) } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS int cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber ) { @@ -853,4 +732,4 @@ cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber ) return( tag ); } -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ diff --git a/libraries/libldap/sbind.c b/libraries/libldap/sbind.c index 9421b07fee..17347d7cb2 100644 --- a/libraries/libldap/sbind.c +++ b/libraries/libldap/sbind.c @@ -5,21 +5,17 @@ * sbind.c */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include +#include #include "lber.h" #include "ldap.h" @@ -73,11 +69,11 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd ) return( -1 ); } -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { ldap_flush_cache( ld ); } -#endif /* !NO_CACHE */ +#endif /* !LDAP_NOCACHE */ /* send the message */ return( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index a37e26884f..191d346710 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -5,49 +5,31 @@ * search.c */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include -#include #include -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ - -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ - -#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) -#include -#include -#include -#endif +#include +#include +#include +#include #include "lber.h" #include "ldap.h" #include "ldap-int.h" -#ifdef NEEDPROTOS -static char *find_right_paren( char *s ); -static char *put_complex_filter( BerElement *ber, char *str, - unsigned long tag, int not ); -static int put_filter( BerElement *ber, char *str ); -static int put_simple_filter( BerElement *ber, char *str ); -static int put_substring_filter( BerElement *ber, char *type, char *str ); -static int put_filter_list( BerElement *ber, char *str ); -#else -static char *find_right_paren(); -static char *put_complex_filter(); -static int put_filter(); -static int put_simple_filter(); -static int put_substring_filter(); -static int put_filter_list(); -#endif /* NEEDPROTOS */ +static char *find_right_paren LDAP_P(( char *s )); +static char *put_complex_filter LDAP_P(( BerElement *ber, char *str, + unsigned long tag, int not )); +static int put_filter LDAP_P(( BerElement *ber, char *str )); +static int put_simple_filter LDAP_P(( BerElement *ber, char *str )); +static int put_substring_filter LDAP_P(( BerElement *ber, char *type, char *str )); +static int put_filter_list LDAP_P(( BerElement *ber, char *str )); /* * ldap_search - initiate an ldap (and X.500) search operation. Parameters: @@ -79,7 +61,7 @@ ldap_search( LDAP *ld, char *base, int scope, char *filter, return( -1 ); } -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) { if ( ldap_check_cache( ld, LDAP_REQ_SEARCH, ber ) == 0 ) { ber_free( ber, 1 ); @@ -88,7 +70,7 @@ ldap_search( LDAP *ld, char *base, int scope, char *filter, } ldap_add_request_to_cache( ld, LDAP_REQ_SEARCH, ber ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ /* send the message */ return ( ldap_send_initial_request( ld, LDAP_REQ_SEARCH, base, ber )); @@ -135,19 +117,19 @@ ldap_build_search_req( LDAP *ld, char *base, int scope, char *filter, base = ""; } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( ld->ld_sb.sb_naddr > 0 ) { err = ber_printf( ber, "{ist{seeiib", ++ld->ld_msgid, ld->ld_cldapdn, LDAP_REQ_SEARCH, base, scope, ld->ld_deref, ld->ld_sizelimit, ld->ld_timelimit, attrsonly ); } else { -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ err = ber_printf( ber, "{it{seeiib", ++ld->ld_msgid, LDAP_REQ_SEARCH, base, scope, ld->ld_deref, ld->ld_sizelimit, ld->ld_timelimit, attrsonly ); -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS } -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ if ( err == -1 ) { ld->ld_errno = LDAP_ENCODING_ERROR; diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index 44bde3c76f..2ac3c31a81 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -12,35 +12,27 @@ * sort.c: LDAP library entry and value sort routines */ +#include "portable.h" + #include -#include -#include #include -#include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#endif /* DOS */ -#endif /* MACOS */ + +#include +#include +#include #include "lber.h" #include "ldap.h" + struct entrything { char **et_vals; LDAPMessage *et_msg; }; -#ifndef NEEDPROTOS -static int (*et_cmp_fn)(); -static int et_cmp(); -#else /* !NEEDPROTOS */ -static int (*et_cmp_fn)( char *a, char *b ); -static int et_cmp( void *aa, void *bb); -#endif /* !NEEDPROTOS */ +static int (*et_cmp_fn) LDAP_P(( char *a, char *b )); +static int et_cmp LDAP_P(( void *aa, void *bb)); + int ldap_sort_strcasecmp( @@ -87,7 +79,7 @@ ldap_sort_entries( LDAP *ld, LDAPMessage **chain, char *attr, /* NULL => sort by DN */ - int (*cmp)() + int (*cmp) LDAP_P((char *, char *)) ) { int i, count; @@ -121,7 +113,7 @@ ldap_sort_entries( last = e; et_cmp_fn = cmp; - qsort( et, count, sizeof(struct entrything), (void *) et_cmp ); + qsort( et, count, sizeof(struct entrything), et_cmp ); ep = chain; for ( i = 0; i < count; i++ ) { @@ -140,7 +132,7 @@ int ldap_sort_values( LDAP *ld, char **vals, - int (*cmp)() + int (*cmp) LDAP_P((const void *, const void *)) ) { int nel; diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index 293c4d9cd5..34c1eb9250 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -1,33 +1,24 @@ +#include "portable.h" + #include -#include -#include #include -#ifdef MACOS -#ifdef THINK_C -#include -#include -#include -#endif /* THINK_C */ -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#if defined( WINSOCK ) || defined( _WIN32 ) -#include "console.h" -#endif /* WINSOCK */ -#else /* DOS */ -#include -#include -#include +#include +#include +#include +#include +#include + #include + +#ifdef HAVE_SYS_FILE_H #include -#ifndef VMS +#endif +#ifdef HAVE_IO_H +#include +#endif + #include -#include -#endif /* VMS */ -#endif /* DOS */ -#endif /* MACOS */ #include "lber.h" #include "ldap.h" @@ -38,27 +29,16 @@ */ #include "ldap-int.h" -#if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS ) -#define MOD_USE_BVALS -#endif /* !PCNFS && !WINSOCK && !MACOS */ +static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm )); +static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s )); +static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res )); +static void free_list LDAP_P(( char **list )); -#ifdef NEEDPROTOS -static void handle_result( LDAP *ld, LDAPMessage *lm ); -static void print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s ); -static void print_search_entry( LDAP *ld, LDAPMessage *res ); -static void free_list( char **list ); -#else -static void handle_result(); -static void print_ldap_result(); -static void print_search_entry(); -static void free_list(); -#endif /* NEEDPROTOS */ - -#define NOCACHEERRMSG "don't compile with -DNO_CACHE if you desire local caching" +#define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching" char *dnsuffix; -#ifndef WINSOCK +#ifndef HAVE_GETLINE static char * getline( char *line, int len, FILE *fp, char *prompt ) { @@ -71,7 +51,7 @@ getline( char *line, int len, FILE *fp, char *prompt ) return( line ); } -#endif /* WINSOCK */ +#endif static char ** get_list( char *prompt ) @@ -119,7 +99,6 @@ free_list( char **list ) } -#ifdef MOD_USE_BVALS static int file_read( char *path, struct berval *bv ) { @@ -156,7 +135,7 @@ file_read( char *path, struct berval *bv ) eof = feof( fp ); fclose( fp ); - if ( rlen != bv->bv_len ) { + if ( (unsigned long) rlen != bv->bv_len ) { perror( path ); free( bv->bv_val ); return( -1 ); @@ -164,7 +143,6 @@ file_read( char *path, struct berval *bv ) return( bv->bv_len ); } -#endif /* MOD_USE_BVALS */ static LDAPMod ** @@ -174,9 +152,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 ) int num; LDAPMod tmp; LDAPMod **result; -#ifdef MOD_USE_BVALS struct berval **bvals; -#endif /* MOD_USE_BVALS */ num = 0; result = NULL; @@ -195,7 +171,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 ) tmp.mod_type = strdup( buf ); tmp.mod_values = get_list( prompt3 ); -#ifdef MOD_USE_BVALS + if ( tmp.mod_values != NULL ) { int i; @@ -221,7 +197,6 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 ) tmp.mod_bvalues = bvals; tmp.mod_op |= LDAP_MOD_BVALUES; } -#endif /* MOD_USE_BVALS */ if ( result == NULL ) result = (LDAPMod **) malloc( sizeof(LDAPMod *) ); @@ -250,7 +225,7 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, static char dn[256], passwd[256]; if ( !freeit ) { -#ifdef KERBEROS +#ifdef HAVE_KERBEROS getline( dn, sizeof(dn), stdin, "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " ); if (( *authmethodp = atoi( dn )) == 3 ) { @@ -258,9 +233,9 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, } else { *authmethodp |= 0x80; } -#else /* KERBEROS */ +#else /* HAVE_KERBEROS */ *authmethodp = LDAP_AUTH_SIMPLE; -#endif /* KERBEROS */ +#endif /* HAVE_KERBEROS */ getline( dn, sizeof(dn), stdin, "re-bind dn? " ); strcat( dn, dnsuffix ); @@ -281,12 +256,7 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, int -#ifdef WINSOCK -ldapmain( -#else /* WINSOCK */ -main( -#endif /* WINSOCK */ - int argc, char **argv ) +main( int argc, char **argv ) { LDAP *ld = NULL; int i, c, port, cldapflg, errflg, method, id, msgtype; @@ -306,15 +276,6 @@ main( extern char *optarg; extern int optind; -#ifdef MACOS - if (( argv = get_list( "cmd line arg?" )) == NULL ) { - exit( 1 ); - } - for ( argc = 0; argv[ argc ] != NULL; ++argc ) { - ; - } -#endif /* MACOS */ - host = NULL; port = LDAP_PORT; dnsuffix = ""; @@ -323,11 +284,11 @@ main( while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) { switch( c ) { case 'u': -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS cldapflg++; -#else /* CLDAP */ - printf( "Compile with -DCLDAP for UDP support\n" ); -#endif /* CLDAP */ +#else /* LDAP_CONNECTIONLESS */ + printf( "Compile with -DLDAP_CONNECTIONLESS for UDP support\n" ); +#endif /* LDAP_CONNECTIONLESS */ break; case 'd': @@ -353,7 +314,6 @@ main( port = atoi( optarg ); break; -#if !defined(MACOS) && !defined(DOS) case 't': /* copy ber's to given file */ copyfname = strdup( optarg ); copyoptions = LBER_TO_FILE; @@ -363,7 +323,6 @@ main( copyfname = strdup( optarg ); copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY); break; -#endif default: ++errflg; @@ -384,9 +343,9 @@ main( host == NULL ? "(null)" : host, port ); if ( cldapflg ) { -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS ld = cldap_open( host, port ); -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ } else { ld = ldap_open( host, port ); } @@ -396,7 +355,6 @@ main( exit(1); } -#if !defined(MACOS) && !defined(DOS) if ( copyfname != NULL ) { if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT, 0600 )) == -1 ) { @@ -405,7 +363,6 @@ main( } ld->ld_sb.sb_options = copyoptions; } -#endif bound = 0; timeout.tv_sec = 0; @@ -447,13 +404,13 @@ main( break; case 'b': /* asynch bind */ -#ifdef KERBEROS +#ifdef HAVE_KERBEROS getline( line, sizeof(line), stdin, "method (0->simple, 1->krbv41, 2->krbv42)? " ); method = atoi( line ) | 0x80; -#else /* KERBEROS */ +#else /* HAVE_KERBEROS */ method = LDAP_AUTH_SIMPLE; -#endif /* KERBEROS */ +#endif /* HAVE_KERBEROS */ getline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); @@ -473,7 +430,7 @@ main( break; case 'B': /* synch bind */ -#ifdef KERBEROS +#ifdef HAVE_KERBEROS getline( line, sizeof(line), stdin, "method 0->simple 1->krbv41 2->krbv42 3->krb? " ); method = atoi( line ); @@ -481,9 +438,9 @@ main( method = LDAP_AUTH_KRBV4; else method = method | 0x80; -#else /* KERBEROS */ +#else /* HAVE_KERBEROS */ method = LDAP_AUTH_SIMPLE; -#endif /* KERBEROS */ +#endif /* HAVE_KERBEROS */ getline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); @@ -574,10 +531,10 @@ main( break; case 'q': /* quit */ -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( cldapflg ) cldap_close( ld ); -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ #ifdef LDAP_REFERRALS if ( !cldapflg ) #else /* LDAP_REFERRALS */ @@ -643,7 +600,7 @@ main( attrsonly = atoi( line ); if ( cldapflg ) { -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS getline( line, sizeof(line), stdin, "Requestor DN (for logging)? " ); if ( cldap_search_s( ld, dn, scope, filter, types, @@ -655,7 +612,7 @@ main( handle_result( ld, res ); res = NULLMSG; } -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ } else { if (( id = ldap_search( ld, dn, scope, filter, types, attrsonly )) == -1 ) { @@ -756,9 +713,9 @@ main( break; case 'e': /* enable cache */ -#ifdef NO_CACHE +#ifdef LDAP_NOCACHE printf( NOCACHEERRMSG ); -#else /* NO_CACHE */ +#else /* LDAP_NOCACHE */ getline( line, sizeof(line), stdin, "Cache timeout (secs)? " ); i = atoi( line ); getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " ); @@ -767,25 +724,25 @@ main( } else { printf( "ldap_enable_cache failed\n" ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ break; case 'x': /* uncache entry */ -#ifdef NO_CACHE +#ifdef LDAP_NOCACHE printf( NOCACHEERRMSG ); -#else /* NO_CACHE */ +#else /* LDAP_NOCACHE */ getline( line, sizeof(line), stdin, "DN? " ); ldap_uncache_entry( ld, line ); -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ break; case 'X': /* uncache request */ -#ifdef NO_CACHE +#ifdef LDAP_NOCACHE printf( NOCACHEERRMSG ); -#else /* NO_CACHE */ +#else /* LDAP_NOCACHE */ getline( line, sizeof(line), stdin, "request msgid? " ); ldap_uncache_request( ld, atoi( line )); -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ break; case 'o': /* set ldap options */ @@ -840,9 +797,9 @@ main( break; case 'O': /* set cache options */ -#ifdef NO_CACHE +#ifdef LDAP_NOCACHE printf( NOCACHEERRMSG ); -#else /* NO_CACHE */ +#else /* LDAP_NOCACHE */ getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" ); switch( atoi( line )) { case 0: @@ -859,7 +816,7 @@ main( default: printf( "not a valid cache option\n" ); } -#endif /* NO_CACHE */ +#endif /* LDAP_NOCACHE */ break; case '?': /* help */ @@ -963,13 +920,9 @@ print_search_entry( LDAP *ld, LDAPMessage *res ) ufn = ldap_dn2ufn( dn ); printf( "\tUFN: %s\n", ufn ); -#ifdef WINSOCK - ldap_memfree( dn ); - ldap_memfree( ufn ); -#else /* WINSOCK */ + free( dn ); free( ufn ); -#endif /* WINSOCK */ for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL; a = ldap_next_attribute( ld, e, ber ) ) { @@ -982,7 +935,7 @@ print_search_entry( LDAP *ld, LDAPMessage *res ) int j, nonascii; nonascii = 0; - for ( j = 0; j < vals[i]->bv_len; j++ ) + for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ ) if ( !isascii( vals[i]->bv_val[j] ) ) { nonascii = 1; break; @@ -1008,23 +961,3 @@ print_search_entry( LDAP *ld, LDAPMessage *res ) || res->lm_chain != NULLMSG ) print_ldap_result( ld, res, "search" ); } - - -#ifdef WINSOCK -void -ldap_perror( LDAP *ld, char *s ) -{ - char *errs; - - if ( ld == NULL ) { - perror( s ); - return; - } - - errs = ldap_err2string( ld->ld_errno ); - printf( "%s: %s\n", s, errs == NULL ? "unknown error" : errs ); - if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) { - printf( "%s: additional info: %s\n", s, ld->ld_error ); - } -} -#endif /* WINSOCK */ diff --git a/libraries/libldap/tmplout.c b/libraries/libldap/tmplout.c index 4dff3c8536..823b36a30c 100644 --- a/libraries/libldap/tmplout.c +++ b/libraries/libldap/tmplout.c @@ -3,28 +3,19 @@ * 12 April 1994 by Mark C Smith */ +#include "portable.h" + #include -#include -#include -#include #include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include +#include +#include +#include -#ifdef VMS -#include -#endif /* VMS */ +#ifdef HAVE_SYS_FILE_H +#include +#endif #include "lber.h" #include "ldap.h" @@ -32,41 +23,34 @@ #include "ldapconfig.h" -#ifdef NEEDPROTOS -static int do_entry2text( LDAP *ld, char *buf, char *base, LDAPMessage *entry, +static int do_entry2text LDAP_P(( + LDAP *ld, char *buf, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, - unsigned long opts, char *urlprefix ); -static int do_entry2text_search( LDAP *ld, char *dn, char *base, + unsigned long opts, char *urlprefix )); +static int do_entry2text_search LDAP_P(( + LDAP *ld, char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, - int rdncount, unsigned long opts, char *urlprefix ); -static int do_vals2text( LDAP *ld, char *buf, char **vals, char *label, + int rdncount, unsigned long opts, char *urlprefix )); +static int do_vals2text LDAP_P(( + LDAP *ld, char *buf, char **vals, char *label, int labelwidth, unsigned long syntaxid, writeptype writeproc, - void *writeparm, char *eol, int rdncount, char *urlprefix ); -static int max_label_len( struct ldap_disptmpl *tmpl ); -static int output_label( char *buf, char *label, int width, - writeptype writeproc, void *writeparm, char *eol, int html ); -static int output_dn( char *buf, char *dn, int width, int rdncount, - writeptype writeproc, void *writeparm, char *eol, char *urlprefix ); -static void strcat_escaped( char *s1, char *s2 ); -static char *time2text( char *ldtimestr, int dateonly ); -static long gtime( struct tm *tm ); -static int searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, + void *writeparm, char *eol, int rdncount, char *urlprefix )); +static int max_label_len LDAP_P(( struct ldap_disptmpl *tmpl )); +static int output_label LDAP_P(( + char *buf, char *label, int width, + writeptype writeproc, void *writeparm, char *eol, int html )); +static int output_dn LDAP_P(( + char *buf, char *dn, int width, int rdncount, + writeptype writeproc, void *writeparm, char *eol, char *urlprefix )); +static void strcat_escaped LDAP_P(( char *s1, char *s2 )); +static char *time2text LDAP_P(( char *ldtimestr, int dateonly )); +static long gtime LDAP_P(( struct tm *tm )); +static int searchaction LDAP_P(( + LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn, struct ldap_tmplitem *tip, int labelwidth, int rdncount, - writeptype writeproc, void *writeparm, char *eol, char *urlprefix ); -#else /* NEEDPROTOS */ -static int do_entry2text(); -static int do_entry2text_search(); -static int do_vals2text(); -static int max_label_len(); -static int output_label(); -static int output_dn(); -static void strcat_escaped(); -static char *time2text(); -static long gtime(); -static int searchaction(); -#endif /* NEEDPROTOS */ + writeptype writeproc, void *writeparm, char *eol, char *urlprefix )); #define DEF_LABEL_WIDTH 15 #define SEARCH_TIMEOUT_SECS 120 @@ -478,12 +462,12 @@ do_entry2text_search( ocattrs[0] = OCATTRNAME; ocattrs[1] = NULL; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( LDAP_IS_CLDAP( ld )) err = cldap_search_s( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", ocattrs, 0, &ldmp, NULL ); else -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ err = ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", ocattrs, 0, &timeout, &ldmp ); @@ -512,12 +496,12 @@ do_entry2text_search( fetchattrs = ldap_tmplattrs( tmpl, NULL, 1, LDAP_SYN_OPT_DEFER ); } -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( LDAP_IS_CLDAP( ld )) err = cldap_search_s( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", fetchattrs, 0, &ldmp, NULL ); else -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ err = ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "objectClass=*", fetchattrs, 0, &timeout, &ldmp ); @@ -927,11 +911,6 @@ time2text( char *ldtimestr, int dateonly ) /* gtime.c - inverse gmtime */ - -#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS ) -#include -#endif /* !MACOS */ - /* gtime(): the inverse of localtime(). This routine was supplied by Mike Accetta at CMU many years ago. */ @@ -1050,12 +1029,12 @@ searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn, timeout.tv_sec = SEARCH_TIMEOUT_SECS; timeout.tv_usec = 0; -#ifdef CLDAP +#ifdef LDAP_CONNECTIONLESS if ( LDAP_IS_CLDAP( ld )) lderr = cldap_search_s( ld, base, LDAP_SCOPE_SUBTREE, filter, retattrs, 0, &ldmp, NULL ); else -#endif /* CLDAP */ +#endif /* LDAP_CONNECTIONLESS */ lderr = ldap_search_st( ld, base, LDAP_SCOPE_SUBTREE, filter, retattrs, 0, &timeout, &ldmp ); diff --git a/libraries/libldap/tmpltest.c b/libraries/libldap/tmpltest.c index 5a0796b473..5bd25241b4 100644 --- a/libraries/libldap/tmpltest.c +++ b/libraries/libldap/tmpltest.c @@ -1,8 +1,12 @@ +#include "portable.h" + #include #include -#include -#ifdef MACOS +#include +#include + +#ifdef HAVE_CONSOLE_H #include #endif /* MACOS */ @@ -11,13 +15,8 @@ #include "disptmpl.h" #include "srchpref.h" -#ifdef NEEDPROTOS -void dump_tmpl( struct ldap_disptmpl *tmpl ); -void dump_srchpref( struct ldap_searchobj *sp ); -#else /* NEEDPROTOS */ -void dump_tmpl(); -void dump_srchpref(); -#endif /* NEEDPROTOS */ +void dump_tmpl LDAP_P(( struct ldap_disptmpl *tmpl )); +void dump_srchpref LDAP_P(( struct ldap_searchobj *sp )); #define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s ) @@ -28,7 +27,7 @@ main( int argc, char **argv ) struct ldap_searchobj *so, *sop; int err; -#ifdef MACOS +#ifdef HAVE_CONSOLE_H ccommand( &argv ); for ( argc = 0; argv[ argc ] != NULL; ++argc ) { ; diff --git a/libraries/libldap/ufn.c b/libraries/libldap/ufn.c index 0c10e593db..f623c28525 100644 --- a/libraries/libldap/ufn.c +++ b/libraries/libldap/ufn.c @@ -5,53 +5,36 @@ * ufn.c */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include +#include #include #include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include +#include #include "lber.h" #include "ldap.h" #include "ldapconfig.h" -#ifdef NEEDPROTOS -typedef int (*cancelptype)( void *cancelparm ); -#else /* NEEDPROTOS */ -typedef int (*cancelptype)(); -#endif /* NEEDPROTOS */ +typedef int (*cancelptype) LDAP_P(( void *cancelparm )); -#ifdef NEEDPROTOS -static int ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, +static int ldap_ufn_search_ctx LDAP_P(( LDAP *ld, char **ufncomp, int ncomp, char *prefix, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2, - char *tag3 ); -static LDAPMessage *ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b ); -static LDAPMessage *ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, + char *tag3 )); +static LDAPMessage *ldap_msg_merge LDAP_P(( LDAP *ld, LDAPMessage *a, LDAPMessage *b )); +static LDAPMessage *ldap_ufn_expand LDAP_P(( LDAP *ld, cancelptype cancelproc, void *cancelparm, char **dns, char *filter, int scope, - char **attrs, int aonly, int *err ); -LDAPFiltDesc *ldap_ufn_setfilter( LDAP *ld, char *fname ); -#else /* NEEDPROTOS */ -static LDAPMessage *ldap_msg_merge(); -static LDAPMessage *ldap_ufn_expand(); -LDAPFiltDesc *ldap_ufn_setfilter(); -#endif /* NEEDPROTOS */ + char **attrs, int aonly, int *err )); +LDAPFiltDesc *ldap_ufn_setfilter LDAP_P(( LDAP *ld, char *fname )); /* * ldap_ufn_search_ctx - do user friendly searching; provide cancel feature; diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index ac196f3b8d..2fc2727c3d 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -5,28 +5,18 @@ * unbind.c */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include #include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include +#include +#include #include "lber.h" #include "ldap.h" @@ -84,10 +74,10 @@ ldap_ld_free( LDAP *ld, int close ) ldap_msgfree( lm ); } -#ifndef NO_CACHE +#ifndef LDAP_NOCACHE if ( ld->ld_cache != NULL ) ldap_destroy_cache( ld ); -#endif /* !NO_CACHE */ +#endif /* !LDAP_NOCACHE */ if ( ld->ld_error != NULL ) free( ld->ld_error ); if ( ld->ld_matched != NULL ) @@ -115,6 +105,8 @@ ldap_ld_free( LDAP *ld, int close ) free( (char *) ld ); + WSACleanup(); + return( err ); } diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index 54832f21a7..2a3a1708f1 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -1,10 +1,14 @@ /* line64.c - routines for dealing with the slapd line format */ +#include "portable.h" + #include -#include #include -#include -#include + +#include +#include +#include + #include "lber.h" #include "ldap.h" #include "ldif.h" diff --git a/libraries/liblthread/rdwr.c b/libraries/liblthread/rdwr.c index cebe318cdf..137c993435 100644 --- a/libraries/liblthread/rdwr.c +++ b/libraries/liblthread/rdwr.c @@ -17,6 +17,10 @@ * * Library of functions implementing reader/writer locks */ + +#define DISABLE_BRIDGE +#include + #include #include #include diff --git a/libraries/liblthread/stack.c b/libraries/liblthread/stack.c index 8736e25b95..ad16bfd945 100644 --- a/libraries/liblthread/stack.c +++ b/libraries/liblthread/stack.c @@ -1,7 +1,12 @@ /* stack.c - stack handling routines */ +#include "portable.h" + #include -#include + +#include +#include + #include "lber.h" #include "ldap.h" diff --git a/libraries/liblutil/base64.c b/libraries/liblutil/base64.c index 01ead24322..6f4b88fe8d 100644 --- a/libraries/liblutil/base64.c +++ b/libraries/liblutil/base64.c @@ -44,12 +44,17 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ +#include "portable.h" + #include #include -#include -#include -#include +#include + +/* include socket.h to get sys/types.h and/or winsock2.h */ +#include + +#include "lutil.h" #define Assert(Cond) if (!(Cond)) abort()