* 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 */
* 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
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 );
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",
}
#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 );
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 ) {
-#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 )
{
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;
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 */
}
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
int
cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber )
{
return( tag );
}
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
* 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"
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 ));
* 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:
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 );
}
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 ));
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;
* 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(
LDAP *ld,
LDAPMessage **chain,
char *attr, /* NULL => sort by DN */
- int (*cmp)()
+ int (*cmp) LDAP_P((char *, char *))
)
{
int i, count;
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++ ) {
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 */
#include "lber.h"
#include "ldap.h"
*/
#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 )
{
return( line );
}
-#endif /* WINSOCK */
+#endif
static char **
get_list( char *prompt )
}
-#ifdef MOD_USE_BVALS
static int
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 );
return( bv->bv_len );
}
-#endif /* MOD_USE_BVALS */
static LDAPMod **
int num;
LDAPMod tmp;
LDAPMod **result;
-#ifdef MOD_USE_BVALS
struct berval **bvals;
-#endif /* MOD_USE_BVALS */
num = 0;
result = NULL;
tmp.mod_type = strdup( buf );
tmp.mod_values = get_list( prompt3 );
-#ifdef MOD_USE_BVALS
+
if ( tmp.mod_values != NULL ) {
int i;
tmp.mod_bvalues = bvals;
tmp.mod_op |= LDAP_MOD_BVALUES;
}
-#endif /* MOD_USE_BVALS */
if ( result == NULL )
result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
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 ) {
} 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 );
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;
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 = "";
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':
port = atoi( optarg );
break;
-#if !defined(MACOS) && !defined(DOS)
case 't': /* copy ber's to given file */
copyfname = strdup( optarg );
copyoptions = LBER_TO_FILE;
copyfname = strdup( optarg );
copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
break;
-#endif
default:
++errflg;
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 );
}
exit(1);
}
-#if !defined(MACOS) && !defined(DOS)
if ( copyfname != NULL ) {
if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
0600 )) == -1 ) {
}
ld->ld_sb.sb_options = copyoptions;
}
-#endif
bound = 0;
timeout.tv_sec = 0;
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 );
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 );
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 );
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 */
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,
handle_result( ld, res );
res = NULLMSG;
}
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
} else {
if (( id = ldap_search( ld, dn, scope, filter,
types, attrsonly )) == -1 ) {
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)? " );
} 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 */
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:
default:
printf( "not a valid cache option\n" );
}
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
break;
case '?': /* help */
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 ) ) {
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;
|| 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 */
* 12 April 1994 by Mark C Smith
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <time.h>
#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#endif /* DOS */
-#endif /* MACOS */
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/time.h>
-#ifdef VMS
-#include <sys/socket.h>
-#endif /* VMS */
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
#include "lber.h"
#include "ldap.h"
#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
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 );
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 );
/* gtime.c - inverse gmtime */
-
-#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS )
-#include <sys/time.h>
-#endif /* !MACOS */
-
/* gtime(): the inverse of localtime().
This routine was supplied by Mike Accetta at CMU many years ago.
*/
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 );
+#include "portable.h"
+
#include <stdio.h>
#include <stdlib.h>
-#include <sys/types.h>
-#ifdef MACOS
+#include <ac/socket.h>
+#include <ac/time.h>
+
+#ifdef HAVE_CONSOLE_H
#include <console.h>
#endif /* MACOS */
#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 )
struct ldap_searchobj *so, *sop;
int err;
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
ccommand( &argv );
for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
;
* 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 <stdio.h>
-#include <string.h>
+#include <ac/string.h>
#include <ctype.h>
#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
+#include <ac/socket.h>
+#include <ac/time.h>
#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;
* 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 <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#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 <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
#include "lber.h"
#include "ldap.h"
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 )
free( (char *) ld );
+ WSACleanup();
+
return( err );
}
/* line64.c - routines for dealing with the slapd line format */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/time.h>
+
#include "lber.h"
#include "ldap.h"
#include "ldif.h"
*
* Library of functions implementing reader/writer locks
*/
+
+#define DISABLE_BRIDGE
+#include <portable.h>
+
#include <stdlib.h>
#include <lthread.h>
#include <lthread_rdwr.h>
/* stack.c - stack handling routines */
+#include "portable.h"
+
#include <stdio.h>
-#include <time.h>
+
+#include <ac/time.h>
+#include <ac/socket.h>
+
#include "lber.h"
#include "ldap.h"
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
+#include "portable.h"
+
#include <stdlib.h>
#include <stddef.h>
-#include <string.h>
-#include <sys/types.h>
-#include <lutil.h>
+#include <ac/string.h>
+
+/* include socket.h to get sys/types.h and/or winsock2.h */
+#include <ac/socket.h>
+
+#include "lutil.h"
#define Assert(Cond) if (!(Cond)) abort()