Commit dd51f860 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

More files that didn't get merged properly.

parent eb16d5d8
......@@ -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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef MACOS
#include <time.h>
#include "macos.h"
#else /* MACOS */
#if defined( DOS ) || defined( _WIN32 )
#include "msdos.h"
#include <time.h>
#ifdef PCNFS
#include <tklib.h>
#include <tk_errno.h>
#include <bios.h>
#endif /* PCNFS */
#ifdef NCSA
#include "externs.h"
#endif /* NCSA */
#else /* DOS */
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#ifdef _AIX
#include <sys/select.h>
#endif /* _AIX */
#include "portable.h"
#endif /* DOS */
#endif /* MACOS */
#ifdef VMS
#include "ucx_select.h"
#endif
#include <ac/errno.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include "lber.h"
#include "ldap.h"
#include "ldap-int.h"
#ifdef USE_SYSCONF
#include <unistd.h>
#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 */
......
......@@ -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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef MACOS
#include <time.h>
#include "macos.h"
#else /* MACOS */
#if defined( DOS ) || defined( _WIN32 )
#include <time.h>
#include "msdos.h"
#ifdef PCNFS
#include <tklib.h>
#include <tk_errno.h>
#include <bios.h>
#endif /* PCNFS */
#ifdef NCSA
#include "externs.h"
#endif /* NCSA */
#else /* DOS */
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/errno.h>
#ifdef _AIX
#include <sys/select.h>
#endif /* _AIX */
#endif /* DOS */
#endif /* MACOS */
#ifdef VMS
#include "ucx_select.h"
#endif
#include "portable.h"
#include <ac/errno.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include "lber.h"
#include "ldap.h"
#include "ldap-int.h"
#ifdef USE_SYSCONF
#include <unistd.h>
#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 */
......@@ -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 <stdio.h>
#include <string.h>
#ifdef MACOS
#include "macos.h"
#endif /* MACOS */
#if !defined( MACOS ) && !defined( DOS )
#include <sys/types.h>
#include <sys/socket.h>
#endif
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#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 ));
......
......@@ -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 <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#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 <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#endif
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#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;
......
......@@ -12,35 +12,27 @@
* sort.c: LDAP library entry and value sort routines
*/
#include "portable.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#ifdef MACOS
#include "macos.h"
#else /* MACOS */
#ifdef DOS
#include <malloc.h>
#include "msdos.h"
#endif /* DOS */
#endif /* MACOS */
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
#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;
......
#include "portable.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#ifdef MACOS
#ifdef THINK_C
#include <console.h>
#include <unix.h>
#include <fcntl.h>
#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 <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#ifndef VMS
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#endif /* VMS */
#endif /* DOS */
#endif /* MACOS */