#define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
#endif
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 64
+#endif
+
#ifdef MACOS
#define tcp_close( s ) tcpclose( s )
#else /* MACOS */
#include <ac/string.h>
#include <ac/socket.h>
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
#include <console.h>
#endif /* MACOS */
Sockbuf sb;
extern char *optarg;
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
#endif /* MACOS */
#include <ac/socket.h>
#include <ac/string.h>
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
#include <console.h>
-#endif /* MACOS */
+#endif /* HAVE_CONSOLE_H */
#include "lber.h"
sb.sb_sd = 1;
sb.sb_ber.ber_buf = NULL;
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
#define DEF_CLDAP_TIMEOUT 3
#define DEF_CLDAP_TRIES 4
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
-#endif
-
struct cldap_retinfo {
int cri_maxtries;
char buf[BUFSIZ];
if ( map == NULL ) {
-#if !defined( MACOS ) && !defined( DOS )
errno = EINVAL;
-#endif
return( uname );
}
ldap_getfilter_free( lfdp );
fprintf( stderr, "bad regular expresssion %s, %s\n",
nextflp->lfl_pattern, error );
-#if !defined( MACOS ) && !defined( DOS )
errno = EINVAL;
-#endif
#endif /* LDAP_LIBUI */
free_strarray( tok );
return( NULL );
} else {
free_strarray( tok );
ldap_getfilter_free( lfdp );
-#if !defined( MACOS ) && !defined( DOS )
errno = EINVAL;
-#endif
return( NULL );
}
free( tok[ 2 ] );
default:
free_strarray( tok );
ldap_getfilter_free( lfdp );
-#if !defined( MACOS ) && !defined( DOS )
errno = EINVAL;
-#endif
return( NULL );
}
}
int ldap_debug;
#endif
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK ((unsigned long) 0x7f000001)
-#endif
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif
-
/*
* ldap_open - initialize and connect to an ldap server. A magic cookie to
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 );
#if defined( LDAP_CONNECTIONLESS ) || !defined( LDAP_REFERRALS )
-#if !defined( MACOS ) && !defined( DOS ) && !defined( _WIN32 )
+
static int
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 */
*/
#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 ));
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 )
{
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 *) );
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 = "";
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;
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;
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 ) ) {
|| 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 */
/* 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.
*/
#include <ac/socket.h>
#include <ac/time.h>
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
#include <console.h>
#endif /* MACOS */
struct ldap_searchobj *so, *sop;
int err;
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
ccommand( &argv );
for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
;
}
/* acquire the lock */
-#ifdef USE_LOCKF
- while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) {
-#else
+#ifdef HAVE_FLOCK
while ( flock( fileno( *lfp ), LOCK_EX ) != 0 ) {
+#else
+ while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 ) {
#endif
; /* NULL */
}
/* open the log file */
if ( (fp = fopen( fname, type )) == NULL ) {
Debug( LDAP_DEBUG_ANY, "could not open \"%s\"\n", fname, 0, 0 );
-#ifdef USE_LOCKF
- lockf( fileno( *lfp ), F_ULOCK, 0 );
-#else
+#ifdef HAVE_FLOCK
flock( fileno( *lfp ), LOCK_UN );
+#else
+ lockf( fileno( *lfp ), F_ULOCK, 0 );
#endif
return( NULL );
}
}
/* acquire the lock */
-#ifdef HAVE_LOCKF
- while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 )
-#else
+#ifdef HAVE_FLOCK
while ( flock( fileno( *lfp ), LOCK_EX ) != 0 )
+#else
+ while ( lockf( fileno( *lfp ), F_LOCK, 0 ) != 0 )
#endif
{
; /* NULL */
if ( (fp = fopen( fname, type )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"Error: could not open \"%s\"\n", fname, 0, 0 );
-#ifdef HAVE_LOCKF
- lockf( fileno( *lfp ), F_ULOCK, 0 );
-#else
+#ifdef HAVE_FLOCK
flock( fileno( *lfp ), LOCK_UN );
+#else
+ lockf( fileno( *lfp ), F_ULOCK, 0 );
#endif
return( NULL );
}
)
{
/* unlock */
-#ifdef HAVE_LOCKF
- lockf( fileno( lfp ), F_ULOCK, 0 );
-#else
+#ifdef HAVE_FLOCK
flock( fileno( lfp ), LOCK_UN );
+#else
+ lockf( fileno( lfp ), F_ULOCK, 0 );
#endif
fclose( lfp );