From 13bd786abf3248e39428a8edac67c27772cb8dc0 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 20 Oct 1998 04:13:34 +0000 Subject: [PATCH] VC++ Port: round 1 --- libraries/libavl/avl.c | 1 - libraries/libavl/libavl.dsp | 86 ++++++++ libraries/libavl/libavl.dsw | 29 +++ libraries/liblber/bprint.c | 4 +- libraries/liblber/decode.c | 32 +-- libraries/liblber/encode.c | 36 ++-- libraries/liblber/io.c | 28 +-- libraries/liblber/liblber.dsp | 98 +++++++++ libraries/liblber/liblber.dsw | 29 +++ libraries/libldap/abandon.c | 33 +-- libraries/libldap/add.c | 24 +-- libraries/libldap/addentry.c | 19 +- libraries/libldap/bind.c | 20 +- libraries/libldap/cache.c | 27 +-- libraries/libldap/charset.c | 39 +--- libraries/libldap/cldap.c | 19 +- libraries/libldap/compare.c | 21 +- libraries/libldap/delete.c | 21 +- libraries/libldap/disptmpl.c | 51 ++--- libraries/libldap/dsparse.c | 37 ++-- libraries/libldap/error.c | 111 +++++----- libraries/libldap/free.c | 20 +- libraries/libldap/friendly.c | 21 +- libraries/libldap/getattr.c | 21 +- libraries/libldap/getdn.c | 21 +- libraries/libldap/getdxbyname.c | 46 ++-- libraries/libldap/getentry.c | 19 +- libraries/libldap/getfilter.c | 36 ++-- libraries/libldap/getvalues.c | 19 +- libraries/libldap/kbind.c | 44 ++-- libraries/libldap/ldap-int.h | 145 ++++--------- libraries/libldap/libldap.dsp | 218 +++++++++++++++++++ libraries/libldap/libldap.dsw | 29 +++ libraries/libldap/modify.c | 17 +- libraries/libldap/modrdn.c | 17 +- libraries/libldap/open.c | 43 ++-- libraries/libldap/os-ip.c | 80 ++----- libraries/libldap/request.c | 166 +++++++-------- libraries/libldap/result.c | 133 +++++------- libraries/libldap/sbind.c | 17 +- libraries/libldap/search.c | 48 ++--- libraries/libldap/sort.c | 31 ++- libraries/libldap/srchpref.c | 44 ++-- libraries/libldap/ufn.c | 52 ++--- libraries/libldap/unbind.c | 36 ++-- libraries/libldap/url.c | 21 +- libraries/libldbm/libldbm.dsp | 82 +++++++ libraries/libldbm/libldbm.dsw | 29 +++ libraries/libldif/libldif.dsp | 82 +++++++ libraries/libldif/libldif.dsw | 29 +++ libraries/libldif/line64.c | 9 +- libraries/liblthread/liblthread.dsp | 90 ++++++++ libraries/liblthread/liblthread.dsw | 29 +++ libraries/liblutil/base64.c | 319 ++++++++++++++++++++++++++++ libraries/liblutil/liblutil.dsp | 102 +++++++++ libraries/liblutil/liblutil.dsw | 29 +++ libraries/liblutil/md5.c | 3 + libraries/liblutil/sha1.c | 30 ++- 58 files changed, 1880 insertions(+), 1062 deletions(-) create mode 100644 libraries/libavl/libavl.dsp create mode 100644 libraries/libavl/libavl.dsw create mode 100644 libraries/liblber/liblber.dsp create mode 100644 libraries/liblber/liblber.dsw create mode 100644 libraries/libldap/libldap.dsp create mode 100644 libraries/libldap/libldap.dsw create mode 100644 libraries/libldbm/libldbm.dsp create mode 100644 libraries/libldbm/libldbm.dsw create mode 100644 libraries/libldif/libldif.dsp create mode 100644 libraries/libldif/libldif.dsw create mode 100644 libraries/liblthread/liblthread.dsp create mode 100644 libraries/liblthread/liblthread.dsw create mode 100644 libraries/liblutil/base64.c create mode 100644 libraries/liblutil/liblutil.dsp create mode 100644 libraries/liblutil/liblutil.dsw diff --git a/libraries/libavl/avl.c b/libraries/libavl/avl.c index f90cd3366a..30938263d1 100644 --- a/libraries/libavl/avl.c +++ b/libraries/libavl/avl.c @@ -11,7 +11,6 @@ * is provided ``as is'' without express or implied warranty. */ -#define DISABLE_BRIDGE #include "portable.h" #ifndef lint diff --git a/libraries/libavl/libavl.dsp b/libraries/libavl/libavl.dsp new file mode 100644 index 0000000000..384cfaca53 --- /dev/null +++ b/libraries/libavl/libavl.dsp @@ -0,0 +1,86 @@ +# Microsoft Developer Studio Project File - Name="libavl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libavl - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libavl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libavl.mak" CFG="libavl - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libavl - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libavl - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "libavl - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libavl - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\libavl.lib" + +!ENDIF + +# Begin Target + +# Name "libavl - Win32 Release" +# Name "libavl - Win32 Debug" +# Begin Source File + +SOURCE=.\avl.c +# End Source File +# Begin Source File + +SOURCE=..\..\include\avl.h +# End Source File +# End Target +# End Project diff --git a/libraries/libavl/libavl.dsw b/libraries/libavl/libavl.dsw new file mode 100644 index 0000000000..a3ea4fd280 --- /dev/null +++ b/libraries/libavl/libavl.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "libavl"=.\libavl.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index 78af185d2b..1dbc833b99 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -1,11 +1,11 @@ -#define LDAP_BRIDGE /* disable LDAP_BRIDGE code */ #include "portable.h" #if defined( LDAP_DEBUG ) && defined( LDAP_LIBUI ) #include -#include #include + +#include #endif /* LDAP_DEBUG && LDAP_LIBUI */ #include "lber.h" diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 1803d93b66..26bf40c54b 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -11,7 +11,6 @@ * is provided ``as is'' without express or implied warranty. */ -#define DISABLE_BRIDGE /* disable LDAP_BRIDGE code */ #include "portable.h" #include @@ -24,21 +23,8 @@ #endif #include - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ - #include -#include -#include - -#ifdef PCNFS -#include -#endif /* PCNFS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ +#include #include "lber.h" @@ -126,7 +112,7 @@ ber_skip_tag( BerElement *ber, unsigned long *len ) if ( ber_read( ber, (char *) &netlen + diff, noctets ) != noctets ) return( LBER_DEFAULT ); - *len = LBER_NTOHL( netlen ); + *len = NTOHL( netlen ); } else { *len = lc; } @@ -175,10 +161,10 @@ ber_getnint( BerElement *ber, long *num, int len ) sign = (0x80 & *(p+diff) ); if ( sign && len < sizeof(long) ) { for ( i = 0; i < diff; i++ ) { - *(p+i) = 0xff; + *(p+i) = (char) 0xff; } } - *num = LBER_NTOHL( netnum ); + *num = NTOHL( netnum ); return( len ); } @@ -191,7 +177,7 @@ ber_get_int( BerElement *ber, long *num ) if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) return( LBER_DEFAULT ); - if ( ber_getnint( ber, num, (int)len ) != len ) + if ( (unsigned long) ber_getnint( ber, num, (int)len ) != len ) return( LBER_DEFAULT ); else return( tag ); @@ -210,7 +196,7 @@ ber_get_stringb( BerElement *ber, char *buf, unsigned long *len ) if ( datalen > (*len - 1) ) return( LBER_DEFAULT ); - if ( ber_read( ber, buf, datalen ) != datalen ) + if ( (unsigned long) ber_read( ber, buf, datalen ) != datalen ) return( LBER_DEFAULT ); buf[datalen] = '\0'; @@ -249,7 +235,7 @@ ber_get_stringa( BerElement *ber, char **buf ) if ( (*buf = (char *) malloc( (size_t)datalen + 1 )) == NULL ) return( LBER_DEFAULT ); - if ( ber_read( ber, *buf, datalen ) != datalen ) + if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) return( LBER_DEFAULT ); (*buf)[datalen] = '\0'; @@ -282,7 +268,7 @@ ber_get_stringal( BerElement *ber, struct berval **bv ) if ( ((*bv)->bv_val = (char *) malloc( (size_t)len + 1 )) == NULL ) return( LBER_DEFAULT ); - if ( ber_read( ber, (*bv)->bv_val, len ) != len ) + if ( (unsigned long) ber_read( ber, (*bv)->bv_val, len ) != len ) return( LBER_DEFAULT ); ((*bv)->bv_val)[len] = '\0'; (*bv)->bv_len = len; @@ -319,7 +305,7 @@ ber_get_bitstringa( BerElement *ber, char **buf, unsigned long *blen ) if ( ber_read( ber, (char *)&unusedbits, 1 ) != 1 ) return( LBER_DEFAULT ); - if ( ber_read( ber, *buf, datalen ) != datalen ) + if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) return( LBER_DEFAULT ); *blen = datalen * 8 - unusedbits; diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index 26f09fcd6e..4933b2ff62 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -11,7 +11,6 @@ * is provided ``as is'' without express or implied warranty. */ -#define DISABLE_BRIDGE #include "portable.h" #include @@ -24,21 +23,8 @@ #include #endif -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ - #include -#include -#include - -#ifdef PCNFS -#include -#endif /* PCNFS */ - -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ +#include #include "lber.h" @@ -79,7 +65,7 @@ ber_put_tag( BerElement *ber, unsigned long tag, int nosos ) taglen = ber_calc_taglen( tag ); - ntag = LBER_HTONL( tag ); + ntag = HTONL( tag ); return( ber_write( ber, ((char *) &ntag) + sizeof(long) - taglen, taglen, nosos ) ); @@ -125,7 +111,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) */ if ( len <= 127 ) { - netlen = LBER_HTONL( len ); + netlen = HTONL( len ); return( ber_write( ber, (char *) &netlen + sizeof(long) - 1, 1, nosos ) ); } @@ -152,7 +138,7 @@ ber_put_len( BerElement *ber, unsigned long len, int nosos ) return( -1 ); /* write the length itself */ - netlen = LBER_HTONL( len ); + netlen = HTONL( len ); if ( ber_write( ber, (char *) &netlen + (sizeof(long) - i), i, nosos ) != i ) return( -1 ); @@ -203,7 +189,7 @@ ber_put_int_or_enum( BerElement *ber, long num, unsigned long tag ) if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 ) return( -1 ); i++; - netnum = LBER_HTONL( num ); + netnum = HTONL( num ); if ( ber_write( ber, (char *) &netnum + (sizeof(long) - i), i, 0 ) != i ) return( -1 ); @@ -259,7 +245,7 @@ ber_put_ostring( BerElement *ber, char *str, unsigned long len, #endif /* STR_TRANSLATION */ if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 || - ber_write( ber, str, len, 0 ) != len ) { + (unsigned long) ber_write( ber, str, len, 0 ) != len ) { rc = -1; } else { /* return length of tag + length + contents */ @@ -295,7 +281,7 @@ ber_put_bitstring( BerElement *ber, char *str, return( -1 ); len = ( blen + 7 ) / 8; - unusedbits = len * 8 - blen; + unusedbits = (unsigned char) ((len * 8) - blen); if ( (lenlen = ber_put_len( ber, len + 1, 0 )) == -1 ) return( -1 ); @@ -411,7 +397,7 @@ ber_put_seqorset( BerElement *ber ) */ len = (*sos)->sos_clen; - netlen = LBER_HTONL( len ); + netlen = HTONL( len ); if ( sizeof(long) > 4 && len > 0xFFFFFFFFL ) return( -1 ); @@ -460,12 +446,14 @@ ber_put_seqorset( BerElement *ber ) /* the tag */ taglen = ber_calc_taglen( (*sos)->sos_tag ); - ntag = LBER_HTONL( (*sos)->sos_tag ); + ntag = HTONL( (*sos)->sos_tag ); SAFEMEMCPY( (*sos)->sos_first, (char *) &ntag + sizeof(long) - taglen, taglen ); if ( ber->ber_options & LBER_USE_DER ) { - ltag = (lenlen == 1) ? len : 0x80 + (lenlen - 1); + ltag = (lenlen == 1) + ? (unsigned char) len + : 0x80 + (lenlen - 1); } /* one byte of length length */ diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index 92c85a90ff..282d25fb45 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -11,7 +11,6 @@ * is provided ``as is'' without express or implied warranty. */ -#define DISABLE_BRIDGE #include "portable.h" #include @@ -21,26 +20,13 @@ #include #include -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS || _WIN32 */ - -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ #include #include -#include -#include -#ifdef PCNFS -#include -#endif /* PCNFS */ -#endif /* MACOS */ +#include -#ifdef _WIN32 -#include +#ifdef HAVE_IO_H #include -#endif /* _WIN32 */ +#endif #include "lber.h" @@ -320,8 +306,8 @@ ber_flush( Sockbuf *sb, BerElement *ber, int freeit ) return( -1 ); /* fake error if write was not atomic */ if (rc < towrite) { -#if !defined( MACOS ) && !defined( DOS ) - errno = EMSGSIZE; +#if defined( WSAEMSGSIZE ) + errno = WSAEMSGSIZE; #endif return( -1 ); } @@ -538,7 +524,7 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) noctets ) { return( LBER_DEFAULT ); } - *len = LBER_NTOHL( netlen ); + *len = NTOHL( netlen ); } else { *len = lc; } @@ -557,7 +543,7 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber ) #endif /* DOS && !_WIN32 */ if ( ( sb->sb_options & LBER_MAX_INCOMING_SIZE ) && - *len > sb->sb_max_incoming ) { + *len > (unsigned long) sb->sb_max_incoming ) { return( LBER_DEFAULT ); } diff --git a/libraries/liblber/liblber.dsp b/libraries/liblber/liblber.dsp new file mode 100644 index 0000000000..eb47093cc0 --- /dev/null +++ b/libraries/liblber/liblber.dsp @@ -0,0 +1,98 @@ +# Microsoft Developer Studio Project File - Name="liblber" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=liblber - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "liblber.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "liblber.mak" CFG="liblber - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "liblber - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "liblber - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "liblber - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "liblber - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\liblber.lib" + +!ENDIF + +# Begin Target + +# Name "liblber - Win32 Release" +# Name "liblber - Win32 Debug" +# Begin Source File + +SOURCE=.\bprint.c +# End Source File +# Begin Source File + +SOURCE=.\decode.c +# End Source File +# Begin Source File + +SOURCE=.\encode.c +# End Source File +# Begin Source File + +SOURCE=.\io.c +# End Source File +# Begin Source File + +SOURCE=..\..\include\lber.h +# End Source File +# End Target +# End Project diff --git a/libraries/liblber/liblber.dsw b/libraries/liblber/liblber.dsw new file mode 100644 index 0000000000..a3ac447307 --- /dev/null +++ b/libraries/liblber/liblber.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "liblber"=.\liblber.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/libldap/abandon.c b/libraries/libldap/abandon.c index 18324260bd..a5e93798c1 100644 --- a/libraries/libldap/abandon.c +++ b/libraries/libldap/abandon.c @@ -5,37 +5,24 @@ * abandon.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 - -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif - -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#endif /* DOS */ - -#ifdef MACOS #include -#include "macos.h" -#endif /* MACOS */ + +#include +#include #include "lber.h" #include "ldap.h" #include "ldap-int.h" -#ifdef NEEDPROTOS -static int do_abandon( LDAP *ld, int origid, int msgid ); -#else /* NEEDPROTOS */ -static int do_abandon(); -#endif /* NEEDPROTOS */ +static int do_abandon LDAP_P(( LDAP *ld, int origid, int msgid )); + /* * ldap_abandon - perform an ldap (and X.500) abandon operation. Parameters: * @@ -107,7 +94,7 @@ do_abandon( LDAP *ld, int origid, int msgid ) err = 0; if ( sendabandon ) { /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { err = -1; ld->ld_errno = LDAP_NO_MEMORY; } else { @@ -151,10 +138,10 @@ do_abandon( LDAP *ld, int origid, int msgid ) #ifdef LDAP_REFERRALS if ( lr != NULL ) { if ( sendabandon ) { - free_connection( ld, lr->lr_conn, 0, 1 ); + ldap_free_connection( ld, lr->lr_conn, 0, 1 ); } if ( origid == msgid ) { - free_request( ld, lr ); + ldap_free_request( ld, lr ); } } #endif /* LDAP_REFERRALS */ diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index b79cd09b9d..901658bef3 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -5,26 +5,16 @@ * add.c */ -#ifndef lint +#include "portable.h" + +#ifndef lint static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ - -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#endif /* DOS */ -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif /* !MACOS && !DOS */ +#include +#include #include "lber.h" #include "ldap.h" @@ -69,7 +59,7 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs ) Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -103,7 +93,7 @@ ldap_add( LDAP *ld, char *dn, LDAPMod **attrs ) } /* send the message */ - return( send_initial_request( ld, LDAP_REQ_ADD, dn, ber )); + return( ldap_send_initial_request( ld, LDAP_REQ_ADD, dn, ber )); } int diff --git a/libraries/libldap/addentry.c b/libraries/libldap/addentry.c index a0fc4174e6..ff8e5635ca 100644 --- a/libraries/libldap/addentry.c +++ b/libraries/libldap/addentry.c @@ -5,25 +5,18 @@ * addentry.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 -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include + +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/bind.c b/libraries/libldap/bind.c index 0a0487349e..050d72a596 100644 --- a/libraries/libldap/bind.c +++ b/libraries/libldap/bind.c @@ -5,27 +5,17 @@ * bind.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 -#ifdef MACOS #include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include "msdos.h" -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ + +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/cache.c b/libraries/libldap/cache.c index 0cc3b48a07..f851f6bb09 100644 --- a/libraries/libldap/cache.c +++ b/libraries/libldap/cache.c @@ -5,7 +5,6 @@ * cache.c - local caching support for LDAP */ -#define DISABLE_BRIDGE #include "portable.h" #ifndef NO_CACHE @@ -15,27 +14,11 @@ static char copyright[] = "@(#) Copyright (c) 1993 The Regents of the University #endif #include -#include #include -#ifdef MACOS -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#ifdef NCSA -#include "externs.h" -#endif /* NCSA */ -#ifdef WINSOCK -#include -#endif /* WINSOCK */ -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include +#include +#include #include "lber.h" #include "ldap.h" @@ -518,7 +501,9 @@ request_cmp( BerElement *req1, BerElement *req2 ) /* * check remaining length and bytes if necessary */ - if (( len = r1.ber_end - r1.ber_ptr ) != r2.ber_end - r2.ber_ptr ) { + if (( len = r1.ber_end - r1.ber_ptr ) != + (unsigned long) (r2.ber_end - r2.ber_ptr) ) + { return( -1 ); /* different lengths */ } return( memcmp( r1.ber_ptr, r2.ber_ptr, (size_t)len )); diff --git a/libraries/libldap/charset.c b/libraries/libldap/charset.c index d5b74006f5..6c821c81c5 100644 --- a/libraries/libldap/charset.c +++ b/libraries/libldap/charset.c @@ -5,13 +5,7 @@ * charset.c */ -#if defined( DOS ) || defined( _WIN32 ) -/* - * This MUST precede "#ifdef STR_TRANSLATION" - * because STR_TRANSLATION and friends are defined in msdos.h. - */ -#include "msdos.h" -#endif /* DOS */ +#include "portable.h" #ifdef STR_TRANSLATION @@ -20,19 +14,15 @@ static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of #endif #include -#include - -#ifdef MACOS #include -#include "macos.h" -#endif /* MACOS */ -#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) && !defined(VMS) -#include -#include -#include +#include +#include + +#ifdef HAVE_SYS_PARAM_H #include #endif + #include "lber.h" #include "ldap.h" #include "ldap-int.h" @@ -159,7 +149,7 @@ ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp, #include #include -#include +#include /* Character set used: ISO 8859-1, ISO 8859-2, ISO 8859-3, ... */ /* #define ISO_8859 1 */ @@ -171,17 +161,10 @@ ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp, typedef unsigned char Byte; typedef struct { Byte a, b; } Couple; -#ifdef NEEDPROTOS -static Byte *c_to_hh( Byte *o, Byte c ); -static Byte *c_to_cc( Byte *o, Couple *cc, Byte c ); -static int hh_to_c( Byte *h ); -static Byte *cc_to_t61( Byte *o, Byte *s ); -#else /* NEEDPROTOS */ -static Byte *c_to_hh(); -static Byte *c_to_cc(); -static int hh_to_c(); -static Byte *cc_to_t61(); -#endif /* NEEDPROTOS */ +static Byte *c_to_hh LDAP_P(( Byte *o, Byte c )); +static Byte *c_to_cc LDAP_P(( Byte *o, Couple *cc, Byte c )); +static int hh_to_c LDAP_P(( Byte *h )); +static Byte *cc_to_t61 LDAP_P(( Byte *o, Byte *s )); /* Character choosed as base in diacritics alone: NO-BREAK SPACE. diff --git a/libraries/libldap/cldap.c b/libraries/libldap/cldap.c index 8639ee2550..c037927de8 100644 --- a/libraries/libldap/cldap.c +++ b/libraries/libldap/cldap.c @@ -5,7 +5,6 @@ * cldap.c - synchronous, retrying interface to the cldap protocol */ -#define DISABLE_BRIDGE #include "portable.h" #ifdef CLDAP @@ -15,22 +14,12 @@ static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the Universi #endif #include -#include -#include #include -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ -#ifdef DOS -#include "msdos.h" -#endif /* DOS */ - -#include -#include -#include -#include -#include + +#include +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/compare.c b/libraries/libldap/compare.c index 74388f1cea..2e2e243b96 100644 --- a/libraries/libldap/compare.c +++ b/libraries/libldap/compare.c @@ -5,21 +5,16 @@ * compare.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 - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include #include "lber.h" #include "ldap.h" @@ -52,7 +47,7 @@ ldap_compare( LDAP *ld, char *dn, char *attr, char *value ) Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -65,17 +60,17 @@ ldap_compare( LDAP *ld, char *dn, char *attr, char *value ) #ifndef NO_CACHE if ( ld->ld_cache != NULL ) { - if ( check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) { + if ( ldap_check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) { ber_free( ber, 1 ); ld->ld_errno = LDAP_SUCCESS; return( ld->ld_msgid ); } - add_request_to_cache( ld, LDAP_REQ_COMPARE, ber ); + ldap_add_request_to_cache( ld, LDAP_REQ_COMPARE, ber ); } #endif /* NO_CACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber )); } int diff --git a/libraries/libldap/delete.c b/libraries/libldap/delete.c index 47e240ea6a..a6ebfecd50 100644 --- a/libraries/libldap/delete.c +++ b/libraries/libldap/delete.c @@ -5,25 +5,16 @@ * delete.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 - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ - -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include #include "lber.h" #include "ldap.h" @@ -51,7 +42,7 @@ ldap_delete( LDAP *ld, char *dn ) Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -63,7 +54,7 @@ ldap_delete( LDAP *ld, char *dn ) } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_DELETE, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_DELETE, dn, ber )); } diff --git a/libraries/libldap/disptmpl.c b/libraries/libldap/disptmpl.c index be418309e9..291316dcb6 100644 --- a/libraries/libldap/disptmpl.c +++ b/libraries/libldap/disptmpl.c @@ -13,41 +13,30 @@ * 7 March 1994 by Mark C Smith */ +#include "portable.h" + #include -#include -#include #include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include +#include + +#include +#include + +#ifdef HAVE_SYS_FILE_H #include -#ifndef VMS -#include -#endif /* VMS */ -#endif /* DOS */ -#endif /* MACOS */ +#endif + +#include #include "lber.h" #include "ldap.h" #include "disptmpl.h" -#ifndef NEEDPROTOS -static void free_disptmpl(); -static int read_next_tmpl(); -int next_line_tokens(); -void free_strarray(); -#else /* !NEEDPROTOS */ -static void free_disptmpl( struct ldap_disptmpl *tmpl ); -static int read_next_tmpl( char **bufp, long *blenp, - struct ldap_disptmpl **tmplp, int dtversion ); -int next_line_tokens( char **bufp, long *blenp, char ***toksp ); -void free_strarray( char **sap ); -#endif /* !NEEDPROTOS */ +static void free_disptmpl LDAP_P(( struct ldap_disptmpl *tmpl )); +static int read_next_tmpl LDAP_P(( char **bufp, long *blenp, + struct ldap_disptmpl **tmplp, int dtversion )); +int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp )); +void free_strarray LDAP_P(( char **sap )); static char *tmploptions[] = { "addable", "modrdn", @@ -152,7 +141,7 @@ int ldap_init_templates_buf( char *buf, long buflen, struct ldap_disptmpl **tmpllistp ) { - int rc, version; + int rc=-1, version; char **toks; struct ldap_disptmpl *prevtmpl, *tmpl; @@ -457,9 +446,9 @@ read_next_tmpl( char **bufp, long *blenp, struct ldap_disptmpl **tmplp, int i, j, tokcnt, samerow, adsource; char **toks, *itemopts; struct ldap_disptmpl *tmpl; - struct ldap_oclist *ocp, *prevocp; - struct ldap_adddeflist *adp, *prevadp; - struct ldap_tmplitem *rowp, *ip, *previp; + struct ldap_oclist *ocp, *prevocp = NULL; + struct ldap_adddeflist *adp, *prevadp = NULL; + struct ldap_tmplitem *rowp = NULL, *ip, *previp = NULL; *tmplp = NULL; diff --git a/libraries/libldap/dsparse.c b/libraries/libldap/dsparse.c index 1771d7283e..6fc1e6e296 100644 --- a/libraries/libldap/dsparse.c +++ b/libraries/libldap/dsparse.c @@ -15,37 +15,26 @@ * 7 March 1994 by Mark C Smith */ +#include "portable.h" + #include -#include -#include -#ifdef MACOS #include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include +#include + +#include +#include + +#ifdef HAVE_SYS_FILE_H #include -#include -#endif /* DOS */ -#endif /* MACOS */ +#endif #include "lber.h" #include "ldap.h" -#ifndef NEEDPROTOS -int next_line_tokens(); -void free_strarray(); -static int next_line(); -static char *next_token(); -#else /* !NEEDPROTOS */ -int next_line_tokens( char **bufp, long *blenp, char ***toksp ); -void free_strarray( char **sap ); -static int next_line( char **bufp, long *blenp, char **linep ); -static char *next_token( char ** sp ); -#endif /* !NEEDPROTOS */ +int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp )); +void free_strarray LDAP_P(( char **sap )); +static int next_line LDAP_P(( char **bufp, long *blenp, char **linep )); +static char *next_token LDAP_P(( char ** sp )); diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index b59563ef88..9827bfc5f2 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -1,16 +1,11 @@ +#include "portable.h" + #include -#include -#ifdef MACOS #include -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ + +#include +#include + #include "lber.h" #include "ldap.h" @@ -20,53 +15,53 @@ struct ldaperror { }; static struct ldaperror ldap_errlist[] = { - LDAP_SUCCESS, "Success", - LDAP_OPERATIONS_ERROR, "Operations error", - LDAP_PROTOCOL_ERROR, "Protocol error", - LDAP_TIMELIMIT_EXCEEDED, "Timelimit exceeded", - LDAP_SIZELIMIT_EXCEEDED, "Sizelimit exceeded", - LDAP_COMPARE_FALSE, "Compare false", - LDAP_COMPARE_TRUE, "Compare true", - LDAP_STRONG_AUTH_NOT_SUPPORTED, "Strong authentication not supported", - LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required", - LDAP_PARTIAL_RESULTS, "Partial results and referral received", - LDAP_NO_SUCH_ATTRIBUTE, "No such attribute", - LDAP_UNDEFINED_TYPE, "Undefined attribute type", - LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching", - LDAP_CONSTRAINT_VIOLATION, "Constraint violation", - LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists", - LDAP_INVALID_SYNTAX, "Invalid syntax", - LDAP_NO_SUCH_OBJECT, "No such object", - LDAP_ALIAS_PROBLEM, "Alias problem", - LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax", - LDAP_IS_LEAF, "Object is a leaf", - LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem", - LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication", - LDAP_INVALID_CREDENTIALS, "Invalid credentials", - LDAP_INSUFFICIENT_ACCESS, "Insufficient access", - LDAP_BUSY, "DSA is busy", - LDAP_UNAVAILABLE, "DSA is unavailable", - LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform", - LDAP_LOOP_DETECT, "Loop detected", - LDAP_NAMING_VIOLATION, "Naming violation", - LDAP_OBJECT_CLASS_VIOLATION, "Object class violation", - LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf", - LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN", - LDAP_ALREADY_EXISTS, "Already exists", - LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class", - LDAP_RESULTS_TOO_LARGE, "Results too large", - LDAP_OTHER, "Unknown error", - LDAP_SERVER_DOWN, "Can't contact LDAP server", - LDAP_LOCAL_ERROR, "Local error", - LDAP_ENCODING_ERROR, "Encoding error", - LDAP_DECODING_ERROR, "Decoding error", - LDAP_TIMEOUT, "Timed out", - LDAP_AUTH_UNKNOWN, "Unknown authentication method", - LDAP_FILTER_ERROR, "Bad search filter", - LDAP_USER_CANCELLED, "User cancelled operation", - LDAP_PARAM_ERROR, "Bad parameter to an ldap routine", - LDAP_NO_MEMORY, "Out of memory", - -1, 0 + {LDAP_SUCCESS, "Success" }, + {LDAP_OPERATIONS_ERROR, "Operations error" }, + {LDAP_PROTOCOL_ERROR, "Protocol error" }, + {LDAP_TIMELIMIT_EXCEEDED, "Timelimit exceeded" }, + {LDAP_SIZELIMIT_EXCEEDED, "Sizelimit exceeded" }, + {LDAP_COMPARE_FALSE, "Compare false" }, + {LDAP_COMPARE_TRUE, "Compare true" }, + {LDAP_STRONG_AUTH_NOT_SUPPORTED, "Strong authentication not supported" }, + {LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required" }, + {LDAP_PARTIAL_RESULTS, "Partial results and referral received" }, + {LDAP_NO_SUCH_ATTRIBUTE, "No such attribute" }, + {LDAP_UNDEFINED_TYPE, "Undefined attribute type" }, + {LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching" }, + {LDAP_CONSTRAINT_VIOLATION, "Constraint violation" }, + {LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists" }, + {LDAP_INVALID_SYNTAX, "Invalid syntax" }, + {LDAP_NO_SUCH_OBJECT, "No such object" }, + {LDAP_ALIAS_PROBLEM, "Alias problem" }, + {LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax" }, + {LDAP_IS_LEAF, "Object is a leaf" }, + {LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem" }, + {LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication" }, + {LDAP_INVALID_CREDENTIALS, "Invalid credentials" }, + {LDAP_INSUFFICIENT_ACCESS, "Insufficient access" }, + {LDAP_BUSY, "DSA is busy" }, + {LDAP_UNAVAILABLE, "DSA is unavailable" }, + {LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform" }, + {LDAP_LOOP_DETECT, "Loop detected" }, + {LDAP_NAMING_VIOLATION, "Naming violation" }, + {LDAP_OBJECT_CLASS_VIOLATION, "Object class violation" }, + {LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf" }, + {LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN" }, + {LDAP_ALREADY_EXISTS, "Already exists" }, + {LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class" }, + {LDAP_RESULTS_TOO_LARGE, "Results too large" }, + {LDAP_OTHER, "Unknown error" }, + {LDAP_SERVER_DOWN, "Can't contact LDAP server" }, + {LDAP_LOCAL_ERROR, "Local error" }, + {LDAP_ENCODING_ERROR, "Encoding error" }, + {LDAP_DECODING_ERROR, "Decoding error" }, + {LDAP_TIMEOUT, "Timed out" }, + {LDAP_AUTH_UNKNOWN, "Unknown authentication method" }, + {LDAP_FILTER_ERROR, "Bad search filter" }, + {LDAP_USER_CANCELLED, "User cancelled operation" }, + {LDAP_PARAM_ERROR, "Bad parameter to an ldap routine" }, + {LDAP_NO_MEMORY, "Out of memory" }, + {-1, 0 } }; char * diff --git a/libraries/libldap/free.c b/libraries/libldap/free.c index d7a13228e6..adf1d7b3c9 100644 --- a/libraries/libldap/free.c +++ b/libraries/libldap/free.c @@ -6,26 +6,18 @@ * link in lots of extra code when not using certain features */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1994 The Regents of the University of Michigan.\nAll rights reserved.\n"; #endif - #include -#include -#include -#ifdef MACOS #include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include + +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/friendly.c b/libraries/libldap/friendly.c index 5d77f0be1c..1bf6c44033 100644 --- a/libraries/libldap/friendly.c +++ b/libraries/libldap/friendly.c @@ -5,28 +5,19 @@ * friendly.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 -#ifdef MACOS #include -#include "macos.h" -#endif /* MACOS */ - -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#endif /* DOS */ +#include -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#include -#endif +#include +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/getattr.c b/libraries/libldap/getattr.c index 50caa774c5..24f6d08509 100644 --- a/libraries/libldap/getattr.c +++ b/libraries/libldap/getattr.c @@ -5,25 +5,18 @@ * getattr.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 -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include + +#include +#include #include "lber.h" #include "ldap.h" @@ -36,7 +29,7 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber ) Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 ); - if ( (*ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( NULL ); } diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index bacc1a601c..5467b82c3e 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -5,29 +5,18 @@ * getdn.c */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif -#define DISABLE_BRIDGE -#include "portable.h" - #include -#include -#include #include +#include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/getdxbyname.c b/libraries/libldap/getdxbyname.c index 50683f6c37..97548e218c 100644 --- a/libraries/libldap/getdxbyname.c +++ b/libraries/libldap/getdxbyname.c @@ -1,43 +1,25 @@ +#include "portable.h" + #ifdef LDAP_DNS /* * Copyright (c) 1995 Regents of the University of Michigan. * All rights reserved. * - * getdxbyname - retrieve DX records from the DNS (from TXT records for now) + * ldap_getdxbyname - retrieve DX records from the DNS (from TXT records for now) */ + #include -#include +#include #include -#ifdef MACOS -#include -#include "macos.h" -#endif /* MACOS */ - -#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) -#include -#include -#include -#include -#include -#include -#include -#include -#endif +#include +#include + #include "lber.h" #include "ldap.h" #include "ldap-int.h" -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ - - -#ifdef NEEDPROTOS -static char ** decode_answer( unsigned char *answer, int len ); -#else /* NEEDPROTOS */ -static char **decode_answer(); -#endif /* NEEDPROTOS */ +static char ** decode_answer LDAP_P(( unsigned char *answer, int len )); extern int h_errno; extern char *h_errlist[]; @@ -47,17 +29,17 @@ extern char *h_errlist[]; /* - * getdxbyname - lookup DNS DX records for domain and return an ordered + * ldap_getdxbyname - lookup DNS DX records for domain and return an ordered * array. */ char ** -getdxbyname( char *domain ) +ldap_getdxbyname( char *domain ) { unsigned char buf[ PACKETSZ ]; char **dxs; int rc; - Debug( LDAP_DEBUG_TRACE, "getdxbyname( %s )\n", domain, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_getdxbyname( %s )\n", domain, 0, 0 ); memset( buf, 0, sizeof( buf )); @@ -91,9 +73,11 @@ decode_answer( unsigned char *answer, int len ) int dx_pref[ MAX_TO_SORT ]; #ifdef LDAP_DEBUG +#ifdef notdef if ( ldap_debug & LDAP_DEBUG_PACKETS ) { -/* __p_query( answer ); /* */ + __p_query( answer ); } +#endif #endif /* LDAP_DEBUG */ dxs = NULL; diff --git a/libraries/libldap/getentry.c b/libraries/libldap/getentry.c index f3f896e7b8..f4f523ea3d 100644 --- a/libraries/libldap/getentry.c +++ b/libraries/libldap/getentry.c @@ -5,25 +5,18 @@ * getentry.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 -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include + +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/getfilter.c b/libraries/libldap/getfilter.c index 58eccc7670..5f9bffbe47 100644 --- a/libraries/libldap/getfilter.c +++ b/libraries/libldap/getfilter.c @@ -5,7 +5,6 @@ * getfilter.c -- optional add-on to libldap */ -#define DISABLE_BRIDGE #include "portable.h" #ifndef lint @@ -14,26 +13,17 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of #include #include -#include #include + +#include +#include +#include +#include + #include -#include - -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include +#ifdef HAVE_SYS_FILE_H #include -#include -#ifndef VMS -#include -#endif /* VMS */ -#endif /* DOS */ -#endif /* MACOS */ +#endif #include "lber.h" #include "ldap.h" @@ -131,7 +121,7 @@ ldap_init_getfilter_buf( char *buf, long buflen ) nextflp->lfl_tag = strdup( tag ); nextflp->lfl_pattern = tok[ 0 ]; if ( (rc = regcomp( &re, nextflp->lfl_pattern, 0 )) != 0 ) { -#ifndef NO_USERINTERFACE +#ifdef LDAP_LIBUI char error[512]; regerror(rc, &re, error, sizeof(error)); ldap_getfilter_free( lfdp ); @@ -140,7 +130,7 @@ ldap_init_getfilter_buf( char *buf, long buflen ) #if !defined( MACOS ) && !defined( DOS ) errno = EINVAL; #endif -#endif /* NO_USERINTERFACE */ +#endif /* LDAP_LIBUI */ free_strarray( tok ); return( NULL ); } @@ -402,14 +392,16 @@ ldap_build_filter( char *filtbuf, unsigned long buflen, char *pattern, *f++ = *p; } - if ( f - filtbuf > buflen ) { + if ( (unsigned long) (f - filtbuf) > buflen ) { /* sanity check */ --f; break; } } - if ( suffix != NULL && ( f - filtbuf ) < buflen ) { + if ( suffix != NULL && ( + (unsigned long) ( f - filtbuf ) < buflen ) ) + { strcpy( f, suffix ); } else { *f = '\0'; diff --git a/libraries/libldap/getvalues.c b/libraries/libldap/getvalues.c index 55102be8ab..41efe9adf4 100644 --- a/libraries/libldap/getvalues.c +++ b/libraries/libldap/getvalues.c @@ -5,25 +5,18 @@ * getvalues.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 -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#else /* DOS */ -#include -#include -#endif /* DOS */ -#endif /* MACOS */ +#include + +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldap/kbind.c b/libraries/libldap/kbind.c index ce4a8a7f6d..e900cc881f 100644 --- a/libraries/libldap/kbind.c +++ b/libraries/libldap/kbind.c @@ -5,6 +5,8 @@ * kbind.c */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif @@ -12,23 +14,11 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of #ifdef KERBEROS #include -#include - -#ifdef MACOS #include -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include "msdos.h" -#endif /* DOS */ -#include -#include -#if !defined(DOS) && !defined( _WIN32 ) -#include -#endif /* !DOS && !_WIN32 */ -#include -#include -#endif /* MACOS */ + +#include +#include +#include #include "lber.h" #include "ldap.h" @@ -52,7 +42,7 @@ ldap_kerberos_bind1( LDAP *ld, char *dn ) BerElement *ber; char *cred; int rc, credlen; - char *get_kerberosv4_credentials(); + char *ldap_get_kerberosv4_credentials(); #ifdef STR_TRANSLATION int str_translation_on; #endif /* STR_TRANSLATION */ @@ -75,13 +65,13 @@ ldap_kerberos_bind1( LDAP *ld, char *dn ) if ( dn == NULL ) dn = ""; - if ( (cred = get_kerberosv4_credentials( ld, dn, "ldapserver", + if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "ldapserver", &credlen )) == NULL ) { return( -1 ); /* ld_errno should already be set */ } /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { free( cred ); return( -1 ); } @@ -119,7 +109,7 @@ ldap_kerberos_bind1( LDAP *ld, char *dn ) #endif /* !NO_CACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } int @@ -159,7 +149,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) BerElement *ber; char *cred; int rc, credlen; - char *get_kerberosv4_credentials(); + char *ldap_get_kerberosv4_credentials(); #ifdef STR_TRANSLATION int str_translation_on; #endif /* STR_TRANSLATION */ @@ -169,13 +159,13 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) if ( dn == NULL ) dn = ""; - if ( (cred = get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen )) + if ( (cred = ldap_get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen )) == NULL ) { return( -1 ); /* ld_errno should already be set */ } /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { free( cred ); return( -1 ); } @@ -207,7 +197,7 @@ ldap_kerberos_bind2( LDAP *ld, char *dn ) } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } /* synchronous bind to DSA using kerberos */ @@ -249,19 +239,19 @@ ldap_kerberos_bind_s( LDAP *ld, char *dn ) #ifndef AUTHMAN /* - * get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. + * ldap_get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap. * The dn of the entry to which to bind is supplied. It's assumed the * user already has a tgt. */ char * -get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) +ldap_get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) { KTEXT_ST ktxt; int err; char realm[REALM_SZ], *cred, *krbinstance; - Debug( LDAP_DEBUG_TRACE, "get_kerberosv4_credentials\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_get_kerberosv4_credentials\n", 0, 0, 0 ); if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) { #ifndef NO_USERINTERFACE diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 10adbe91ff..45d1eaf7ae 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -26,28 +26,18 @@ /* * in cache.c */ -#ifdef NEEDPROTOS -void add_request_to_cache( LDAP *ld, unsigned long msgtype, - BerElement *request ); -void add_result_to_cache( LDAP *ld, LDAPMessage *result ); -int check_cache( LDAP *ld, unsigned long msgtype, BerElement *request ); -#else /* NEEDPROTOS */ -void add_request_to_cache(); -void add_result_to_cache(); -int check_cache(); -#endif /* NEEDPROTOS */ +void ldap_add_request_to_cache LDAP_P(( LDAP *ld, unsigned long msgtype, + BerElement *request )); +void ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result )); +int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request )); #ifdef KERBEROS /* * in kerberos.c */ -#ifdef NEEDPROTOS -char *get_kerberosv4_credentials( LDAP *ld, char *who, char *service, - int *len ); -#else /* NEEDPROTOS */ -char *get_kerberosv4_credentials(); -#endif /* NEEDPROTOS */ +char *ldap_get_kerberosv4_credentials LDAP_P(( LDAP *ld, char *who, char *service, + int *len )); #endif /* KERBEROS */ @@ -55,135 +45,92 @@ char *get_kerberosv4_credentials(); /* * in open.c */ -#ifdef NEEDPROTOS int open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport, char **krbinstancep, int async ); -#else /* NEEDPROTOS */ -int open_ldap_connection(); -#endif /* NEEDPROTOS */ /* * in os-ip.c */ -#ifdef NEEDPROTOS -int connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port, +int ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, int port, int async ); -void close_connection( Sockbuf *sb ); -#else /* NEEDPROTOS */ -int connect_to_host(); -void close_connection(); -#endif /* NEEDPROTOS */ +void ldap_close_connection( Sockbuf *sb ); #ifdef KERBEROS -#ifdef NEEDPROTOS -char *host_connected_to( Sockbuf *sb ); -#else /* NEEDPROTOS */ -char *host_connected_to(); -#endif /* NEEDPROTOS */ +char *ldap_host_connected_to( Sockbuf *sb ); #endif /* KERBEROS */ #ifdef LDAP_REFERRALS -#ifdef NEEDPROTOS int do_ldap_select( LDAP *ld, struct timeval *timeout ); -void *new_select_info( void ); -void free_select_info( void *sip ); -void mark_select_write( LDAP *ld, Sockbuf *sb ); -void mark_select_read( LDAP *ld, Sockbuf *sb ); -void mark_select_clear( LDAP *ld, Sockbuf *sb ); -int is_read_ready( LDAP *ld, Sockbuf *sb ); -int is_write_ready( LDAP *ld, Sockbuf *sb ); -#else /* NEEDPROTOS */ -int do_ldap_select(); -void *new_select_info(); -void free_select_info(); -void mark_select_write(); -void mark_select_read(); -void mark_select_clear(); -int is_read_ready(); -int is_write_ready(); -#endif /* NEEDPROTOS */ +void *ldap_new_select_info( void ); +void ldap_free_select_info( void *sip ); +void ldap_mark_select_write( LDAP *ld, Sockbuf *sb ); +void ldap_mark_select_read( LDAP *ld, Sockbuf *sb ); +void ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ); +int ldap_is_read_ready( LDAP *ld, Sockbuf *sb ); +int ldap_is_write_ready( LDAP *ld, Sockbuf *sb ); #endif /* LDAP_REFERRALS */ /* * in request.c */ -#ifdef NEEDPROTOS -int send_initial_request( LDAP *ld, unsigned long msgtype, +int ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, BerElement *ber ); -BerElement *alloc_ber_with_options( LDAP *ld ); -void set_ber_options( LDAP *ld, BerElement *ber ); -#else /* NEEDPROTOS */ -int send_initial_request(); -BerElement *alloc_ber_with_options(); -void set_ber_options(); -#endif /* NEEDPROTOS */ +BerElement *ldap_alloc_ber_with_options( LDAP *ld ); +void ldap_set_ber_options( LDAP *ld, BerElement *ber ); #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) -#ifdef NEEDPROTOS -int send_server_request( LDAP *ld, BerElement *ber, int msgid, +int ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind ); -LDAPConn *new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, +LDAPConn *ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind ); -LDAPRequest *find_request_by_msgid( LDAP *ld, int msgid ); -void free_request( LDAP *ld, LDAPRequest *lr ); -void free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ); -void dump_connection( LDAP *ld, LDAPConn *lconns, int all ); -void dump_requests_and_responses( LDAP *ld ); -#else /* NEEDPROTOS */ -int send_server_request(); -LDAPConn *new_connection(); -LDAPRequest *find_request_by_msgid(); -void free_request(); -void free_connection(); -void dump_connection(); -void dump_requests_and_responses(); -#endif /* NEEDPROTOS */ +LDAPRequest *ldap_find_request_by_msgid( LDAP *ld, int msgid ); +void ldap_free_request( LDAP *ld, LDAPRequest *lr ); +void ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ); +void ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all ); +void ldap_dump_requests_and_responses( LDAP *ld ); #endif /* LDAP_REFERRALS || LDAP_DNS */ #ifdef LDAP_REFERRALS -#ifdef NEEDPROTOS -int chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ); -int append_referral( LDAP *ld, char **referralsp, char *s ); -#else /* NEEDPROTOS */ -int chase_referrals(); -int append_referral(); -#endif /* NEEDPROTOS */ +int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ); +int ldap_append_referral( LDAP *ld, char **referralsp, char *s ); #endif /* LDAP_REFERRALS */ /* * in search.c */ -#ifdef NEEDPROTOS BerElement *ldap_build_search_req( LDAP *ld, char *base, int scope, char *filter, char **attrs, int attrsonly ); -#else /* NEEDPROTOS */ -BerElement *ldap_build_search_req(); -#endif /* NEEDPROTOS */ /* * in unbind.c */ -#ifdef NEEDPROTOS int ldap_ld_free( LDAP *ld, int close ); -int send_unbind( LDAP *ld, Sockbuf *sb ); -#else /* NEEDPROTOS */ -int ldap_ld_free(); -int send_unbind(); -#endif /* NEEDPROTOS */ - +int ldap_send_unbind( LDAP *ld, Sockbuf *sb ); #ifdef LDAP_DNS /* * in getdxbyname.c */ -#ifdef NEEDPROTOS -char **getdxbyname( char *domain ); -#else /* NEEDPROTOS */ -char **getdxbyname(); -#endif /* NEEDPROTOS */ +char **ldap_getdxbyname( char *domain ); #endif /* LDAP_DNS */ + +#if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET ) +/* + * in charset.c + * + * added-in this stuff so that libldap.a would build, i.e. refs to + * these routines from open.c would resolve. + * hodges@stanford.edu 5-Feb-96 + */ +#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET +extern +int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input ); +extern +int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input ); +#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */ +#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */ diff --git a/libraries/libldap/libldap.dsp b/libraries/libldap/libldap.dsp new file mode 100644 index 0000000000..367008fde8 --- /dev/null +++ b/libraries/libldap/libldap.dsp @@ -0,0 +1,218 @@ +# Microsoft Developer Studio Project File - Name="libldap" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libldap - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libldap.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libldap.mak" CFG="libldap - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libldap - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libldap - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "libldap - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libldap - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\libldap.lib" + +!ENDIF + +# Begin Target + +# Name "libldap - Win32 Release" +# Name "libldap - Win32 Debug" +# Begin Source File + +SOURCE=.\abandon.c +# End Source File +# Begin Source File + +SOURCE=.\add.c +# End Source File +# Begin Source File + +SOURCE=.\addentry.c +# End Source File +# Begin Source File + +SOURCE=.\bind.c +# End Source File +# Begin Source File + +SOURCE=.\cache.c +# End Source File +# Begin Source File + +SOURCE=.\charset.c +# End Source File +# Begin Source File + +SOURCE=.\cldap.c +# End Source File +# Begin Source File + +SOURCE=.\compare.c +# End Source File +# Begin Source File + +SOURCE=.\delete.c +# End Source File +# Begin Source File + +SOURCE=.\disptmpl.c +# End Source File +# Begin Source File + +SOURCE=.\dsparse.c +# End Source File +# Begin Source File + +SOURCE=.\error.c +# End Source File +# Begin Source File + +SOURCE=.\free.c +# End Source File +# Begin Source File + +SOURCE=.\friendly.c +# End Source File +# Begin Source File + +SOURCE=.\getattr.c +# End Source File +# Begin Source File + +SOURCE=.\getdn.c +# End Source File +# Begin Source File + +SOURCE=.\getdxbyname.c +# End Source File +# Begin Source File + +SOURCE=.\getentry.c +# End Source File +# Begin Source File + +SOURCE=.\getfilter.c +# End Source File +# Begin Source File + +SOURCE=.\getvalues.c +# End Source File +# Begin Source File + +SOURCE=.\kbind.c +# End Source File +# Begin Source File + +SOURCE=".\ldap-int.h" +# End Source File +# Begin Source File + +SOURCE=.\modify.c +# End Source File +# Begin Source File + +SOURCE=.\modrdn.c +# End Source File +# Begin Source File + +SOURCE=.\open.c +# End Source File +# Begin Source File + +SOURCE=".\os-ip.c" +# End Source File +# Begin Source File + +SOURCE=.\request.c +# End Source File +# Begin Source File + +SOURCE=.\result.c +# End Source File +# Begin Source File + +SOURCE=.\sbind.c +# End Source File +# Begin Source File + +SOURCE=.\search.c +# End Source File +# Begin Source File + +SOURCE=.\sort.c +# End Source File +# Begin Source File + +SOURCE=.\srchpref.c +# End Source File +# Begin Source File + +SOURCE=.\ufn.c +# End Source File +# Begin Source File + +SOURCE=.\unbind.c +# End Source File +# Begin Source File + +SOURCE=.\url.c +# End Source File +# End Target +# End Project diff --git a/libraries/libldap/libldap.dsw b/libraries/libldap/libldap.dsw new file mode 100644 index 0000000000..067d25e554 --- /dev/null +++ b/libraries/libldap/libldap.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "libldap"=.\libldap.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/libldap/modify.c b/libraries/libldap/modify.c index 316dde787f..1766f8a26b 100644 --- a/libraries/libldap/modify.c +++ b/libraries/libldap/modify.c @@ -5,21 +5,16 @@ * modify.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 - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include #include "lber.h" #include "ldap.h" @@ -69,7 +64,7 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods ) Debug( LDAP_DEBUG_TRACE, "ldap_modify\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -105,7 +100,7 @@ ldap_modify( LDAP *ld, char *dn, LDAPMod **mods ) } /* send the message */ - return( send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber )); + return( ldap_send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber )); } int diff --git a/libraries/libldap/modrdn.c b/libraries/libldap/modrdn.c index f4624a919a..491fc97add 100644 --- a/libraries/libldap/modrdn.c +++ b/libraries/libldap/modrdn.c @@ -5,21 +5,16 @@ * modrdn.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 - -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ -#if !defined( MACOS ) && !defined( DOS ) -#include -#include -#endif +#include +#include #include "lber.h" #include "ldap.h" @@ -53,7 +48,7 @@ ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn ) Debug( LDAP_DEBUG_TRACE, "ldap_modrdn\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -65,7 +60,7 @@ ldap_modrdn2( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn ) } /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber )); } int diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index 22cd98e377..30b48bafb5 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -5,32 +5,22 @@ * open.c */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include - -#ifdef MACOS #include -#include "macos.h" -#endif /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#include -#endif /* DOS */ +#include +#include -#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) -#include -#include -#include -#ifndef VMS +#ifdef HAVE_SYS_PARAM_H #include #endif -#include -#endif + #include "lber.h" #include "ldap.h" #include "ldap-int.h" @@ -81,7 +71,7 @@ ldap_open( char *host, int port ) } srv->lsrv_port = ld->ld_defport; - if (( ld->ld_defconn = new_connection( ld, &srv, 1,1,0 )) == NULL ) { + if (( ld->ld_defconn = ldap_new_connection( ld, &srv, 1,1,0 )) == NULL ) { if ( ld->ld_defhost != NULL ) free( srv->lsrv_host ); free( (char *)srv ); ldap_ld_free( ld, 0 ); @@ -126,7 +116,7 @@ ldap_init( char *defhost, int defport ) } #ifdef LDAP_REFERRALS - if (( ld->ld_selectinfo = new_select_info()) == NULL ) { + if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) { free( (char*)ld ); return( NULL ); } @@ -136,7 +126,7 @@ ldap_init( char *defhost, int defport ) if ( defhost != NULL && ( ld->ld_defhost = strdup( defhost )) == NULL ) { #ifdef LDAP_REFERRALS - free_select_info( ld->ld_selectinfo ); + ldap_free_select_info( ld->ld_selectinfo ); #endif /* LDAP_REFERRALS */ free( (char*)ld ); return( NULL ); @@ -148,6 +138,10 @@ ldap_init( char *defhost, int defport ) ld->ld_lberoptions = LBER_USE_DER; ld->ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT; +#ifdef LDAP_REFERRALS + ld->ld_options |= LDAP_OPT_REFERRALS; +#endif /* LDAP_REFERRALS */ + #if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET ) ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS; #if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET @@ -163,13 +157,14 @@ int open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport, char **krbinstancep, int async ) { - int rc, port; + int rc = -1; + int port; char *p, *q, *r; char *curhost, hostname[ 2*MAXHOSTNAMELEN ]; Debug( LDAP_DEBUG_TRACE, "open_ldap_connection\n", 0, 0, 0 ); - defport = htons( defport ); + defport = htons( (short) defport ); if ( host != NULL ) { for ( p = host; p != NULL && *p != '\0'; p = q ) { @@ -197,13 +192,13 @@ open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport, port = defport; } - if (( rc = connect_to_host( sb, curhost, 0L, + if (( rc = ldap_connect_to_host( sb, curhost, 0L, port, async )) != -1 ) { break; } } } else { - rc = connect_to_host( sb, NULL, htonl( INADDR_LOOPBACK ), + rc = ldap_connect_to_host( sb, NULL, htonl( INADDR_LOOPBACK ), defport, async ); } @@ -213,7 +208,7 @@ open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport, if ( krbinstancep != NULL ) { #ifdef KERBEROS - if (( *krbinstancep = host_connected_to( sb )) != NULL && + if (( *krbinstancep = ldap_host_connected_to( sb )) != NULL && ( p = strchr( *krbinstancep, '.' )) != NULL ) { *p = '\0'; } diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 63fc1373ad..b1c8d64c9b 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -5,72 +5,28 @@ * os-ip.c -- platform-specific TCP & UDP related code */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n"; -#endif - -#define DISABLE_BRIDGE #include "portable.h" #include #include + +#include +#include #include -#include +#include -#ifdef _WIN32 +#ifdef HAVE_IO_H #include -#include "msdos.h" -#else /* _WIN32 */ -#include -#include -#include -#include -#include -#include -#include -#endif /* _WIN32 */ -#ifdef _AIX -#include -#endif /* _AIX */ -#ifdef VMS -#include "ucx_select.h" -#endif /* VMS */ - -#include "portable.h" -#include "lber.h" -#include "ldap.h" +#endif /* HAVE_IO_H */ -#ifdef LDAP_REFERRALS -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ -#ifdef notyet -#ifdef NEED_FILIO +#if defined( HAVE_SYS_FILIO_H ) #include -#else /* NEED_FILIO */ +#elif defined( HAVE_SYS_IOCTL_H ) #include -#endif /* NEED_FILIO */ -#endif /* notyet */ -#endif /* LDAP_REFERRALS */ - -#ifdef MACOS -#define tcp_close( s ) tcpclose( s ) -#else /* MACOS */ -#ifdef DOS -#ifdef PCNFS -#define tcp_close( s ) close( s ) -#endif /* PCNFS */ -#ifdef NCSA -#define tcp_close( s ) netclose( s ); netshut() -#endif /* NCSA */ -#ifdef WINSOCK -#define tcp_close( s ) closesocket( s ); WSACleanup(); -#endif /* WINSOCK */ -#else /* DOS */ -#define tcp_close( s ) close( s ) -#endif /* DOS */ -#endif /* MACOS */ +#endif +#include "lber.h" +#include "ldap.h" #include "ldap-int.h" int @@ -95,7 +51,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, #endif /* notyet */ Debug( LDAP_DEBUG_TRACE, "ldap_connect_to_host: %s:%d\n", - ( host == NULL ) ? "(by address)" : host, ntohs( port ), 0 ); + ( host == NULL ) ? "(by address)" : host, (int) ntohs( (short) port ), 0 ); connected = use_hp = 0; @@ -239,7 +195,7 @@ ldap_mark_select_write( LDAP *ld, Sockbuf *sb ) sip = (struct selectinfo *)ld->ld_selectinfo; if ( !FD_ISSET( sb->sb_sd, &sip->si_writefds )) { - FD_SET( sb->sb_sd, &sip->si_writefds ); + FD_SET( (u_int) sb->sb_sd, &sip->si_writefds ); } } @@ -252,7 +208,7 @@ ldap_mark_select_read( LDAP *ld, Sockbuf *sb ) sip = (struct selectinfo *)ld->ld_selectinfo; if ( !FD_ISSET( sb->sb_sd, &sip->si_readfds )) { - FD_SET( sb->sb_sd, &sip->si_readfds ); + FD_SET( (u_int) sb->sb_sd, &sip->si_readfds ); } } @@ -264,8 +220,8 @@ ldap_mark_select_clear( LDAP *ld, Sockbuf *sb ) sip = (struct selectinfo *)ld->ld_selectinfo; - FD_CLR( sb->sb_sd, &sip->si_writefds ); - FD_CLR( sb->sb_sd, &sip->si_readfds ); + FD_CLR( (u_int) sb->sb_sd, &sip->si_writefds ); + FD_CLR( (u_int) sb->sb_sd, &sip->si_readfds ); } @@ -322,9 +278,9 @@ do_ldap_select( LDAP *ld, struct timeval *timeout ) Debug( LDAP_DEBUG_TRACE, "do_ldap_select\n", 0, 0, 0 ); if ( tblsize == 0 ) { -#ifdef USE_SYSCONF +#if defined( HAVE_SYSCONF ) tblsize = sysconf( _SC_OPEN_MAX ); -#else /* !USE_SYSCONF */ +#elif defined( HAVE_GETDTABLESIZE ) tblsize = getdtablesize(); #endif /* !USE_SYSCONF */ diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index b8b50eac7b..da782a8e72 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -5,85 +5,44 @@ * 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 -#ifdef MACOS #include -#include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#include -#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 */ +#tatic 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 */ BerElement * -alloc_ber_with_options( LDAP *ld ) +ldap_alloc_ber_with_options( LDAP *ld ) { BerElement *ber; @@ -91,7 +50,7 @@ alloc_ber_with_options( LDAP *ld ) ld->ld_errno = LDAP_NO_MEMORY; #ifdef STR_TRANSLATION } else { - set_ber_options( ld, ber ); + ldap_set_ber_options( ld, ber ); #endif /* STR_TRANSLATION */ } @@ -100,7 +59,7 @@ alloc_ber_with_options( LDAP *ld ) void -set_ber_options( LDAP *ld, BerElement *ber ) +ldap_set_ber_options( LDAP *ld, BerElement *ber ) { ber->ber_options = ld->ld_lberoptions; #ifdef STR_TRANSLATION @@ -114,14 +73,14 @@ set_ber_options( LDAP *ld, BerElement *ber ) int -send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, +ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, BerElement *ber ) { #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) LDAPServer *servers; #endif /* LDAP_REFERRALS || LDAP_DNS */ - Debug( LDAP_DEBUG_TRACE, "send_initial_request\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 ); #if !defined( LDAP_REFERRALS ) && !defined( LDAP_DNS ) if ( ber_flush( &ld->ld_sb, ber, 1 ) != 0 ) { @@ -165,7 +124,7 @@ send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, } #endif /* LDAP_DNS */ - return( send_server_request( ld, ber, ld->ld_msgid, NULL, servers, + return( ldap_send_server_request( ld, ber, ld->ld_msgid, NULL, servers, NULL, 0 )); #endif /* !LDAP_REFERRALS && !LDAP_DNS */ } @@ -174,13 +133,15 @@ send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) int -send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest +ldap_send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind ) { LDAPRequest *lr; + int incparent; - Debug( LDAP_DEBUG_TRACE, "send_server_request\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_send_server_request\n", 0, 0, 0 ); + incparent = 0; ld->ld_errno = LDAP_SUCCESS; /* optimistic */ if ( lc == NULL ) { @@ -189,7 +150,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest } else { if (( lc = find_connection( ld, srvlist, 1 )) == NULL ) { - lc = new_connection( ld, &srvlist, 0, 1, bind ); + if ( bind && (parentreq != NULL) ) { + /* Remember the bind in the parent */ + incparent = 1; + ++parentreq->lr_outrefcnt; + } + lc = ldap_new_connection( ld, &srvlist, 0, 1, bind ); } free_servers( srvlist ); } @@ -200,6 +166,10 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest if ( ld->ld_errno == LDAP_SUCCESS ) { ld->ld_errno = LDAP_SERVER_DOWN; } + if ( incparent ) { + /* Forget about the bind */ + --parentreq->lr_outrefcnt; + } return( -1 ); } @@ -207,8 +177,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest if (( lr = (LDAPRequest *)calloc( 1, sizeof( LDAPRequest ))) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; - free_connection( ld, lc, 0, 0 ); + ldap_free_connection( ld, lc, 0, 0 ); ber_free( ber, 1 ); + if ( incparent ) { + /* Forget about the bind */ + --parentreq->lr_outrefcnt; + } return( -1 ); } lr->lr_msgid = msgid; @@ -217,7 +191,10 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest lr->lr_ber = ber; lr->lr_conn = lc; if ( parentreq != NULL ) { /* sub-request */ - ++parentreq->lr_outrefcnt; + if ( !incparent ) { + /* Increment if we didn't do it before the bind */ + ++parentreq->lr_outrefcnt; + } lr->lr_origid = parentreq->lr_origid; lr->lr_parentcnt = parentreq->lr_parentcnt + 1; lr->lr_parent = parentreq; @@ -240,12 +217,12 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest if ( errno == EWOULDBLOCK ) { /* need to continue write later */ lr->lr_status = LDAP_REQST_WRITING; - mark_select_write( ld, lc->lconn_sb ); + ldap_mark_select_write( ld, lc->lconn_sb ); } else { #else /* notyet */ ld->ld_errno = LDAP_SERVER_DOWN; - free_request( ld, lr ); - free_connection( ld, lc, 0, 0 ); + ldap_free_request( ld, lr ); + ldap_free_connection( ld, lc, 0, 0 ); return( -1 ); #endif /* notyet */ #ifdef notyet @@ -258,7 +235,7 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest } /* sent -- waiting for a response */ - mark_select_read( ld, lc->lconn_sb ); + ldap_mark_select_read( ld, lc->lconn_sb ); } ld->ld_errno = LDAP_SUCCESS; @@ -267,7 +244,7 @@ send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest LDAPConn * -new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, +ldap_new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, int connect, int bind ) { LDAPConn *lc; @@ -367,7 +344,7 @@ new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb, } if ( err != 0 ) { - free_connection( ld, lc, 1, 0 ); + ldap_free_connection( ld, lc, 1, 0 ); lc = NULL; } } @@ -414,19 +391,19 @@ use_connection( LDAP *ld, LDAPConn *lc ) void -free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) +ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) { LDAPConn *tmplc, *prevlc; - Debug( LDAP_DEBUG_TRACE, "free_connection\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_free_connection\n", 0, 0, 0 ); if ( force || --lc->lconn_refcnt <= 0 ) { if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) { - mark_select_clear( ld, lc->lconn_sb ); + ldap_mark_select_clear( ld, lc->lconn_sb ); if ( unbind ) { - send_unbind( ld, lc->lconn_sb ); + ldap_send_unbind( ld, lc->lconn_sb ); } - close_connection( lc->lconn_sb ); + ldap_close_connection( lc->lconn_sb ); if ( lc->lconn_sb->sb_ber.ber_buf != NULL ) { free( lc->lconn_sb->sb_ber.ber_buf ); } @@ -442,6 +419,7 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) } break; } + prevlc = tmplc; } free_servers( lc->lconn_server ); if ( lc->lconn_krbinstance != NULL ) { @@ -451,11 +429,11 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) free( (char *)lc->lconn_sb ); } free( lc ); - Debug( LDAP_DEBUG_TRACE, "free_connection: actually freed\n", + Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: actually freed\n", 0, 0, 0 ); } else { lc->lconn_lastused = time( 0 ); - Debug( LDAP_DEBUG_TRACE, "free_connection: refcnt %d\n", + Debug( LDAP_DEBUG_TRACE, "ldap_free_connection: refcnt %d\n", lc->lconn_refcnt, 0, 0 ); } } @@ -463,7 +441,7 @@ free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) #ifdef LDAP_DEBUG void -dump_connection( LDAP *ld, LDAPConn *lconns, int all ) +ldap_dump_connection( LDAP *ld, LDAPConn *lconns, int all ) { LDAPConn *lc; @@ -490,7 +468,7 @@ dump_connection( LDAP *ld, LDAPConn *lconns, int all ) void -dump_requests_and_responses( LDAP *ld ) +ldap_dump_requests_and_responses( LDAP *ld ) { LDAPRequest *lr; LDAPMessage *lm, *l; @@ -531,11 +509,11 @@ dump_requests_and_responses( LDAP *ld ) void -free_request( LDAP *ld, LDAPRequest *lr ) +ldap_free_request( LDAP *ld, LDAPRequest *lr ) { LDAPRequest *tmplr, *nextlr; - Debug( LDAP_DEBUG_TRACE, "free_request (origid %d, msgid %d)\n", + Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n", lr->lr_origid, lr->lr_msgid, 0 ); if ( lr->lr_parent != NULL ) { @@ -544,7 +522,7 @@ free_request( LDAP *ld, LDAPRequest *lr ) /* free all referrals (child requests) */ for ( tmplr = lr->lr_refnext; tmplr != NULL; tmplr = nextlr ) { nextlr = tmplr->lr_refnext; - free_request( ld, tmplr ); + ldap_free_request( ld, tmplr ); } } @@ -599,7 +577,7 @@ free_servers( LDAPServer *srvlist ) * XXX merging of errors in this routine needs to be improved */ int -chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) +ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) { int rc, count, len, newdn; #ifdef LDAP_DNS @@ -610,7 +588,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) LDAPServer *srv; BerElement *ber; - Debug( LDAP_DEBUG_TRACE, "chase_referrals\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_chase_referrals\n", 0, 0, 0 ); ld->ld_errno = LDAP_SUCCESS; /* optimistic */ *hadrefp = 0; @@ -681,7 +659,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) } else { Debug( LDAP_DEBUG_TRACE, "ignoring unknown referral <%s>\n", ref, 0, 0 ); - rc = append_referral( ld, &unfollowed, ref ); + rc = ldap_append_referral( ld, &unfollowed, ref ); *hadrefp = 1; continue; } @@ -728,14 +706,14 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) } #endif /* LDAP_DNS */ - if ( srv != NULL && send_server_request( ld, ber, ld->ld_msgid, + if ( srv != NULL && ldap_send_server_request( ld, ber, ld->ld_msgid, lr, srv, NULL, 1 ) >= 0 ) { ++count; } else { Debug( LDAP_DEBUG_ANY, "Unable to chase referral (%s)\n", ldap_err2string( ld->ld_errno ), 0, 0 ); - rc = append_referral( ld, &unfollowed, ref ); + rc = ldap_append_referral( ld, &unfollowed, ref ); } if ( !newdn && refdn != NULL ) { @@ -751,7 +729,7 @@ chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp ) int -append_referral( LDAP *ld, char **referralsp, char *s ) +ldap_append_referral( LDAP *ld, char **referralsp, char *s ) { int first; @@ -810,7 +788,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp ) return( NULL ); } - if (( ber = alloc_ber_with_options( ld )) == NULLBER ) { + if (( ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( NULL ); } @@ -866,7 +844,7 @@ re_encode_request( LDAP *ld, BerElement *origber, int msgid, char **dnp ) LDAPRequest * -find_request_by_msgid( LDAP *ld, int msgid ) +ldap_find_request_by_msgid( LDAP *ld, int msgid ) { LDAPRequest *lr; @@ -895,7 +873,7 @@ dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */ domain = dn; } - if (( dxs = getdxbyname( domain )) == NULL ) { + if (( dxs = ldap_getdxbyname( domain )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( NULL ); } diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 3f8408df18..7dafad5e8b 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -5,83 +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 -#ifdef MACOS #include -#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 */ -#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 */ - -#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; +static int ldap_select1 LDAP_P(( LDAP *ld, struct timeval *timeout )); #endif @@ -181,7 +139,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, { int rc; struct timeval tv, *tvp; - long start_time, tmp_time; + time_t start_time = 0; + time_t tmp_time; #ifdef LDAP_REFERRALS LDAPConn *lc, *nextlc; #endif /* LDAP_REFERRALS */ @@ -201,7 +160,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, } else { tv = *timeout; tvp = &tv; - start_time = (long)time( NULL ); + start_time = time( NULL ); } rc = -2; @@ -231,8 +190,8 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, #else /* !LDAP_REFERRALS */ #ifdef LDAP_DEBUG if ( ldap_debug & LDAP_DEBUG_TRACE ) { - dump_connection( ld, ld->ld_conns, 1 ); - dump_requests_and_responses( ld ); + ldap_dump_connection( ld, ld->ld_conns, 1 ); + ldap_dump_requests_and_responses( ld ); } #endif /* LDAP_DEBUG */ for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { @@ -276,7 +235,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, nextlc = lc->lconn_next; if ( lc->lconn_status == LDAP_CONNST_CONNECTED && - is_read_ready( ld, + ldap_is_read_ready( ld, lc->lconn_sb )) { rc = read1msg( ld, msgid, all, lc->lconn_sb, lc, result ); @@ -287,7 +246,7 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, #endif /* !LDAP_REFERRALS */ if ( rc == -2 && tvp != NULL ) { - tmp_time = (long)time( NULL ); + tmp_time = time( NULL ); if (( tv.tv_sec -= ( tmp_time - start_time )) <= 0 ) { rc = 0; /* timed out */ ld->ld_errno = LDAP_TIMEOUT; @@ -326,7 +285,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 ); ber_init( &ber, 0 ); - set_ber_options( ld, &ber ); + ldap_set_ber_options( ld, &ber ); /* get the next message */ if ( (tag = ber_get_next( sb, &len, &ber )) @@ -349,7 +308,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, } #ifdef LDAP_REFERRALS - if (( lr = find_request_by_msgid( ld, id )) == NULL ) { + if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) { Debug( LDAP_DEBUG_ANY, "no request for response with msgid %ld (tossing)\n", id, 0, 0 ); @@ -384,7 +343,7 @@ read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, != LBER_ERROR ) { if ( lderr != LDAP_SUCCESS ) { /* referrals are in error string */ - refer_cnt = chase_referrals( ld, lr, + refer_cnt = ldap_chase_referrals( ld, lr, &lr->lr_res_error, &hadref ); } @@ -455,11 +414,11 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); } } - free_request( ld, lr ); + ldap_free_request( ld, lr ); } if ( lc != NULL ) { - free_connection( ld, lc, 0, 1 ); + ldap_free_connection( ld, lc, 0, 1 ); } } } @@ -481,7 +440,7 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); #ifndef NO_CACHE if ( ld->ld_cache != NULL ) { - add_result_to_cache( ld, new ); + ldap_add_result_to_cache( ld, new ); } #endif /* NO_CACHE */ @@ -542,7 +501,18 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); prev->lm_next = l->lm_next; *result = l; ld->ld_errno = LDAP_SUCCESS; +#ifdef LDAP_WORLD_P16 + /* + * XXX questionable fix; see text for [P16] on + * http://www.critical-angle.com/ldapworld/patch/ + * + * inclusion of this patch causes searchs to hang on + * multiple platforms + */ + return( l->lm_msgtype ); +#else /* LDAP_WORLD_P16 */ return( tag ); +#endif /* !LDAP_WORLD_P16 */ } return( -2 ); /* continue looking */ @@ -557,7 +527,7 @@ build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr ) long along; ber_init( ber, 0 ); - set_ber_options( ld, ber ); + ldap_set_ber_options( ld, ber ); if ( ber_printf( ber, "{it{ess}}", lr->lr_msgid, (long)lr->lr_res_msgtype, lr->lr_res_errno, lr->lr_res_matched ? lr->lr_res_matched : "", @@ -587,7 +557,7 @@ merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr ) if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) { parentr->lr_res_errno = lr->lr_res_errno; if ( lr->lr_res_error != NULL ) { - (void)append_referral( ld, &parentr->lr_res_error, + (void)ldap_append_referral( ld, &parentr->lr_res_error, lr->lr_res_error ); } } else if ( lr->lr_res_errno != LDAP_SUCCESS && @@ -629,9 +599,14 @@ ldap_select1( LDAP *ld, struct timeval *timeout ) if ( tblsize == 0 ) { #ifdef USE_SYSCONF tblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ +#else /* !USE_SYSCONF */ tblsize = getdtablesize(); -#endif /* USE_SYSCONF */ +#endif /* !USE_SYSCONF */ +#ifdef FD_SETSIZE + if ( tblsize > FD_SETSIZE ) { + tblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE */ } FD_ZERO( &readfds ); diff --git a/libraries/libldap/sbind.c b/libraries/libldap/sbind.c index 656c722f15..e8a5b2731f 100644 --- a/libraries/libldap/sbind.c +++ b/libraries/libldap/sbind.c @@ -5,21 +5,16 @@ * 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 "lber.h" #include "ldap.h" @@ -61,7 +56,7 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd ) passwd = ""; /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( -1 ); } @@ -80,7 +75,7 @@ ldap_simple_bind( LDAP *ld, char *dn, char *passwd ) #endif /* !NO_CACHE */ /* send the message */ - return( send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); + return( ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber )); } /* diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index 2b73ddd07e..3b53fc93ee 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -5,48 +5,30 @@ * 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 - -#ifdef MACOS #include -#include "macos.h" -#endif /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#endif /* DOS */ +#include +#include -#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) -#include -#include -#include -#endif #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: @@ -80,17 +62,17 @@ ldap_search( LDAP *ld, char *base, int scope, char *filter, #ifndef NO_CACHE if ( ld->ld_cache != NULL ) { - if ( check_cache( ld, LDAP_REQ_SEARCH, ber ) == 0 ) { + if ( ldap_check_cache( ld, LDAP_REQ_SEARCH, ber ) == 0 ) { ber_free( ber, 1 ); ld->ld_errno = LDAP_SUCCESS; return( ld->ld_msgid ); } - add_request_to_cache( ld, LDAP_REQ_SEARCH, ber ); + ldap_add_request_to_cache( ld, LDAP_REQ_SEARCH, ber ); } #endif /* NO_CACHE */ /* send the message */ - return ( send_initial_request( ld, LDAP_REQ_SEARCH, base, ber )); + return ( ldap_send_initial_request( ld, LDAP_REQ_SEARCH, base, ber )); } @@ -126,7 +108,7 @@ ldap_build_search_req( LDAP *ld, char *base, int scope, char *filter, */ /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( NULLBER ); } diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index ee5d549c89..fbf1dd4be3 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -12,34 +12,27 @@ * sort.c: LDAP library entry and value sort routines */ +#include "portable.h" + #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( @@ -139,7 +132,7 @@ int ldap_sort_values( LDAP *ld, char **vals, - int (*cmp)() + int (*cmp) LDAP_P((const void *, const void *)) ) { int nel; @@ -147,7 +140,7 @@ ldap_sort_values( for ( nel = 0; vals[nel] != NULL; nel++ ) ; /* NULL */ - qsort( vals, nel, sizeof(char *), cmp ); + qsort( vals, nel, sizeof(char *), (void *) cmp ); return( 0 ); } diff --git a/libraries/libldap/srchpref.c b/libraries/libldap/srchpref.c index 88c094ce76..8e6fd26e30 100644 --- a/libraries/libldap/srchpref.c +++ b/libraries/libldap/srchpref.c @@ -13,41 +13,29 @@ * 17 May 1994 by Gordon Good */ +#include "portable.h" + #include -#include -#include #include -#ifdef MACOS -#include "macos.h" -#else /* MACOS */ -#ifdef DOS -#include -#include "msdos.h" -#else /* DOS */ -#include +#include + +#include +#include +#include + +#ifdef HAVE_SYS_FILE_H #include -#ifndef VMS -#include -#endif /* VMS */ -#endif /* DOS */ -#endif /* MACOS */ +#endif #include "lber.h" #include "ldap.h" #include "srchpref.h" -#ifndef NEEDPROTOS -int next_line_tokens(); -void free_strarray(); -static void free_searchobj(); -static int read_next_searchobj(); -#else /* !NEEDPROTOS */ -int next_line_tokens( char **bufp, long *blenp, char ***toksp ); -void free_strarray( char **sap ); -static void free_searchobj( struct ldap_searchobj *so ); -static int read_next_searchobj( char **bufp, long *blenp, - struct ldap_searchobj **sop, int soversion ); -#endif /* !NEEDPROTOS */ +int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp )); +void free_strarray LDAP_P(( char **sap )); +static void free_searchobj LDAP_P(( struct ldap_searchobj *so )); +static int read_next_searchobj LDAP_P(( char **bufp, long *blenp, + struct ldap_searchobj **sop, int soversion )); static char *sobjoptions[] = { @@ -110,7 +98,7 @@ int ldap_init_searchprefs_buf( char *buf, long buflen, struct ldap_searchobj **solistp ) { - int rc, version; + int rc = -1, version; char **toks; struct ldap_searchobj *prevso, *so; diff --git a/libraries/libldap/ufn.c b/libraries/libldap/ufn.c index 9596adf131..f87af4d87a 100644 --- a/libraries/libldap/ufn.c +++ b/libraries/libldap/ufn.c @@ -5,51 +5,35 @@ * 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 - -#ifdef MACOS #include -#include "macos.h" -#else /* MACOS */ -#if defined( DOS ) || defined( _WIN32 ) -#include "msdos.h" -#else /* DOS */ -#include -#include -#include -#endif /* DOS */ -#endif /* MACOS */ + +#include #include "lber.h" #include "ldap.h" -#ifdef NEEDPROTOS -typedef int (*cancelptype)( void *cancelparm ); -#else /* NEEDPROTOS */ -typedef int (*cancelptype)(); -#endif /* NEEDPROTOS */ +#include "ldapconfig.h" + +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; @@ -83,9 +67,9 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2, char *tag3 ) { - char *dn, *ftag; - char **dns; - int max, i, err, scope, phase, tries; + char *dn, *ftag = NULL; + char **dns = NULL; + int max, i, err, scope = 0, phase, tries; LDAPFiltInfo *fi; LDAPMessage *tmpcand; LDAPMessage *candidates; @@ -240,7 +224,7 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, { char **ufncomp, **prefixcomp; char *pbuf; - int ncomp, pcomp, i, err; + int ncomp, pcomp, i, err = 0; /* initialize the getfilter stuff if it's not already */ if ( ld->ld_filtd == NULL && ldap_ufn_setfilter( ld, FILTERFILE ) diff --git a/libraries/libldap/unbind.c b/libraries/libldap/unbind.c index e7b5c401e6..a555d46f72 100644 --- a/libraries/libldap/unbind.c +++ b/libraries/libldap/unbind.c @@ -5,27 +5,17 @@ * 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 -#ifdef MACOS #include -#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 "lber.h" #include "ldap.h" @@ -55,17 +45,17 @@ ldap_ld_free( LDAP *ld, int close ) /* free LDAP structure and outstanding requests/responses */ for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) { nextlr = lr->lr_next; - free_request( ld, lr ); + ldap_free_request( ld, lr ); } /* free and unbind from all open connections */ while ( ld->ld_conns != NULL ) { - free_connection( ld, ld->ld_conns, 1, close ); + ldap_free_connection( ld, ld->ld_conns, 1, close ); } #else /* LDAP_REFERRALS */ if ( close ) { - err = send_unbind( ld, &ld->ld_sb ); - close_connection( &ld->ld_sb ); + err = ldap_send_unbind( ld, &ld->ld_sb ); + ldap_close_connection( &ld->ld_sb ); } #endif /* LDAP_REFERRALS */ } else { @@ -106,7 +96,7 @@ ldap_ld_free( LDAP *ld, int close ) #ifdef LDAP_REFERRALS if ( ld->ld_selectinfo != NULL ) - free_select_info( ld->ld_selectinfo ); + ldap_free_select_info( ld->ld_selectinfo ); #endif /* LDAP_REFERRALS */ if ( ld->ld_defhost != NULL ) @@ -125,14 +115,14 @@ ldap_unbind_s( LDAP *ld ) int -send_unbind( LDAP *ld, Sockbuf *sb ) +ldap_send_unbind( LDAP *ld, Sockbuf *sb ) { BerElement *ber; - Debug( LDAP_DEBUG_TRACE, "send_unbind\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_send_unbind\n", 0, 0, 0 ); /* create a message to send */ - if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) { + if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) { return( ld->ld_errno ); } diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index adf62b805f..f15e64b2cf 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -17,29 +17,18 @@ * We also tolerate URLs that look like: and */ +#include "portable.h" + #ifndef lint static char copyright[] = "@(#) Copyright (c) 1996 Regents of the University of Michigan.\nAll rights reserved.\n"; #endif #include -#include -#include #include +#include -#ifdef MACOS -#include "macos.h" -#endif /* MACOS */ - -#if defined( DOS ) || defined( _WIN32 ) -#include -#include "msdos.h" -#endif /* DOS || _WIN32 */ - -#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) -#include -#include -#include -#endif /* !MACOS && !DOS && !_WIN32 */ +#include +#include #include "lber.h" #include "ldap.h" diff --git a/libraries/libldbm/libldbm.dsp b/libraries/libldbm/libldbm.dsp new file mode 100644 index 0000000000..8e91550d61 --- /dev/null +++ b/libraries/libldbm/libldbm.dsp @@ -0,0 +1,82 @@ +# Microsoft Developer Studio Project File - Name="libldbm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libldbm - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libldbm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libldbm.mak" CFG="libldbm - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libldbm - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libldbm - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "libldbm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libldbm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\libldbm.lib" + +!ENDIF + +# Begin Target + +# Name "libldbm - Win32 Release" +# Name "libldbm - Win32 Debug" +# Begin Source File + +SOURCE=.\ldbm.c +# End Source File +# End Target +# End Project diff --git a/libraries/libldbm/libldbm.dsw b/libraries/libldbm/libldbm.dsw new file mode 100644 index 0000000000..82412f233e --- /dev/null +++ b/libraries/libldbm/libldbm.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "libldbm"=.\libldbm.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/libldif/libldif.dsp b/libraries/libldif/libldif.dsp new file mode 100644 index 0000000000..e9fb0c2b97 --- /dev/null +++ b/libraries/libldif/libldif.dsp @@ -0,0 +1,82 @@ +# Microsoft Developer Studio Project File - Name="libldif" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=libldif - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libldif.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libldif.mak" CFG="libldif - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libldif - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "libldif - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "libldif - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "libldif - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\libldif.lib" + +!ENDIF + +# Begin Target + +# Name "libldif - Win32 Release" +# Name "libldif - Win32 Debug" +# Begin Source File + +SOURCE=.\line64.c +# End Source File +# End Target +# End Project diff --git a/libraries/libldif/libldif.dsw b/libraries/libldif/libldif.dsw new file mode 100644 index 0000000000..d692d5b4fd --- /dev/null +++ b/libraries/libldif/libldif.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "libldif"=.\libldif.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/libldif/line64.c b/libraries/libldif/line64.c index 54832f21a7..9ca7594148 100644 --- a/libraries/libldif/line64.c +++ b/libraries/libldif/line64.c @@ -1,10 +1,13 @@ /* line64.c - routines for dealing with the slapd line format */ +#include "portable.h" + #include -#include #include -#include -#include + +#include +#include + #include "lber.h" #include "ldap.h" #include "ldif.h" diff --git a/libraries/liblthread/liblthread.dsp b/libraries/liblthread/liblthread.dsp new file mode 100644 index 0000000000..8a5f3445b0 --- /dev/null +++ b/libraries/liblthread/liblthread.dsp @@ -0,0 +1,90 @@ +# Microsoft Developer Studio Project File - Name="liblthread" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=liblthread - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "liblthread.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "liblthread.mak" CFG="liblthread - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "liblthread - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "liblthread - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "liblthread - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "liblthread - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\liblthread.lib" + +!ENDIF + +# Begin Target + +# Name "liblthread - Win32 Release" +# Name "liblthread - Win32 Debug" +# Begin Source File + +SOURCE=.\rdwr.c +# End Source File +# Begin Source File + +SOURCE=.\stack.c +# End Source File +# Begin Source File + +SOURCE=.\thread.c +# End Source File +# End Target +# End Project diff --git a/libraries/liblthread/liblthread.dsw b/libraries/liblthread/liblthread.dsw new file mode 100644 index 0000000000..ee14c84283 --- /dev/null +++ b/libraries/liblthread/liblthread.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "liblthread"=.\liblthread.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/liblutil/base64.c b/libraries/liblutil/base64.c new file mode 100644 index 0000000000..6f4b88fe8d --- /dev/null +++ b/libraries/liblutil/base64.c @@ -0,0 +1,319 @@ +/* + * Modified by Kurt D. Zeilenga for inclusion into OpenLDAP + */ + +/* + * Copyright (c) 1996, 1998 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Portions Copyright (c) 1995 by International Business Machines, Inc. + * + * International Business Machines, Inc. (hereinafter called IBM) grants + * permission under its copyrights to use, copy, modify, and distribute this + * Software with or without fee, provided that the above copyright notice and + * all paragraphs of this notice appear in all copies, and that the name of IBM + * not be used in connection with the marketing of any product incorporating + * the Software or modifications thereof, without specific, written prior + * permission. + * + * To the extent it has a right to do so, IBM grants an immunity from suit + * under its patents, if any, for the use, sale or manufacture of products to + * the extent that such products are used for performing Domain Name System + * dynamic updates in TCP/IP networks by means of the Software. No immunity is + * granted for any product per se or for any other function of any product. + * + * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, + * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN + * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include "portable.h" + +#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() + +static const char Base64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char Pad64 = '='; + +/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) + The following encoding technique is taken from RFC 1521 by Borenstein + and Freed. It is reproduced here in a slightly edited form for + convenience. + + A 65-character subset of US-ASCII is used, enabling 6 bits to be + represented per printable character. (The extra 65th character, "=", + is used to signify a special processing function.) + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8-bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + + Each 6-bit group is used as an index into an array of 64 printable + characters. The character referenced by the index is placed in the + output string. + + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a quantity. When fewer than 24 input + bits are available in an input group, zero bits are added (on the + right) to form an integral number of 6-bit groups. Padding at the + end of the data is performed using the '=' character. + + Since all base64 input is an integral number of octets, only the + ------------------------------------------------- + following cases can arise: + + (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded + output will be an integral multiple of 4 characters + with no "=" padding, + (2) the final quantum of encoding input is exactly 8 bits; + here, the final unit of encoded output will be two + characters followed by two "=" padding characters, or + (3) the final quantum of encoding input is exactly 16 bits; + here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + +int +b64_ntop( + u_char const *src, + size_t srclength, + char *target, + size_t targsize) +{ + size_t datalength = 0; + u_char input[3]; + u_char output[4]; + size_t i; + + while (2 < srclength) { + input[0] = *src++; + input[1] = *src++; + input[2] = *src++; + srclength -= 3; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + output[3] = input[2] & 0x3f; + Assert(output[0] < 64); + Assert(output[1] < 64); + Assert(output[2] < 64); + Assert(output[3] < 64); + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + target[datalength++] = Base64[output[2]]; + target[datalength++] = Base64[output[3]]; + } + + /* Now we worry about padding. */ + if (0 != srclength) { + /* Get what's left. */ + input[0] = input[1] = input[2] = '\0'; + for (i = 0; i < srclength; i++) + input[i] = *src++; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + Assert(output[0] < 64); + Assert(output[1] < 64); + Assert(output[2] < 64); + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + if (srclength == 1) + target[datalength++] = Pad64; + else + target[datalength++] = Base64[output[2]]; + target[datalength++] = Pad64; + } + if (datalength >= targsize) + return (-1); + target[datalength] = '\0'; /* Returned value doesn't count \0. */ + return (datalength); +} + +/* skips all whitespace anywhere. + converts characters, four at a time, starting at (or after) + src from base - 64 numbers into three 8 bit bytes in the target area. + it returns the number of data bytes stored at the target, or -1 on error. + */ + +int +b64_pton( + char const *src, + u_char *target, + size_t targsize) +{ + int tarindex, state, ch; + char *pos; + + state = 0; + tarindex = 0; + + while ((ch = *src++) != '\0') { + if (isspace(ch)) /* Skip whitespace anywhere. */ + continue; + + if (ch == Pad64) + break; + + pos = strchr(Base64, ch); + if (pos == 0) /* A non-base64 character. */ + return (-1); + + switch (state) { + case 0: + if (target) { + if ((size_t)tarindex >= targsize) + return (-1); + target[tarindex] = (pos - Base64) << 2; + } + state = 1; + break; + case 1: + if (target) { + if ((size_t)tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 4; + target[tarindex+1] = ((pos - Base64) & 0x0f) + << 4 ; + } + tarindex++; + state = 2; + break; + case 2: + if (target) { + if ((size_t)tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 2; + target[tarindex+1] = ((pos - Base64) & 0x03) + << 6; + } + tarindex++; + state = 3; + break; + case 3: + if (target) { + if ((size_t)tarindex >= targsize) + return (-1); + target[tarindex] |= (pos - Base64); + } + tarindex++; + state = 0; + break; + default: + abort(); + } + } + + /* + * We are done decoding Base-64 chars. Let's see if we ended + * on a byte boundary, and/or with erroneous trailing characters. + */ + + if (ch == Pad64) { /* We got a pad char. */ + ch = *src++; /* Skip it, get next. */ + switch (state) { + case 0: /* Invalid = in first position */ + case 1: /* Invalid = in second position */ + return (-1); + + case 2: /* Valid, means one byte of info */ + /* Skip any number of spaces. */ + for ((void)NULL; ch != '\0'; ch = *src++) + if (!isspace(ch)) + break; + /* Make sure there is another trailing = sign. */ + if (ch != Pad64) + return (-1); + ch = *src++; /* Skip the = */ + /* Fall through to "single trailing =" case. */ + /* FALLTHROUGH */ + + case 3: /* Valid, means two bytes of info */ + /* + * We know this char is an =. Is there anything but + * whitespace after it? + */ + for ((void)NULL; ch != '\0'; ch = *src++) + if (!isspace(ch)) + return (-1); + + /* + * Now make sure for cases 2 and 3 that the "extra" + * bits that slopped past the last full byte were + * zeros. If we don't check them, they become a + * subliminal channel. + */ + if (target && target[tarindex] != 0) + return (-1); + } + } else { + /* + * We ended by seeing the end of the string. Make sure we + * have no partial bytes lying around. + */ + if (state != 0) + return (-1); + } + + return (tarindex); +} diff --git a/libraries/liblutil/liblutil.dsp b/libraries/liblutil/liblutil.dsp new file mode 100644 index 0000000000..9ee414604c --- /dev/null +++ b/libraries/liblutil/liblutil.dsp @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="liblutil" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=liblutil - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "liblutil.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "liblutil.mak" CFG="liblutil - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "liblutil - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "liblutil - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe + +!IF "$(CFG)" == "liblutil - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "liblutil - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\Debug\liblutil.lib" + +!ENDIF + +# Begin Target + +# Name "liblutil - Win32 Release" +# Name "liblutil - Win32 Debug" +# Begin Source File + +SOURCE=.\base64.c +# End Source File +# Begin Source File + +SOURCE=..\..\include\lutil.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\lutil_md5.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\lutil_sha1.h +# End Source File +# Begin Source File + +SOURCE=.\md5.c +# End Source File +# Begin Source File + +SOURCE=.\sha1.c +# End Source File +# End Target +# End Project diff --git a/libraries/liblutil/liblutil.dsw b/libraries/liblutil/liblutil.dsw new file mode 100644 index 0000000000..2aaef3b026 --- /dev/null +++ b/libraries/liblutil/liblutil.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "liblutil"=.\liblutil.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/libraries/liblutil/md5.c b/libraries/liblutil/md5.c index 46857666ec..122495cf3e 100644 --- a/libraries/liblutil/md5.c +++ b/libraries/liblutil/md5.c @@ -33,6 +33,9 @@ #include +/* include socket.h to get sys/types.h and/or winsock2.h */ +#include + #include /* Little-endian byte-swapping routines. Note that these do not diff --git a/libraries/liblutil/sha1.c b/libraries/liblutil/sha1.c index 5f08be0b0b..a6153f1f8a 100644 --- a/libraries/liblutil/sha1.c +++ b/libraries/liblutil/sha1.c @@ -16,11 +16,15 @@ */ -#define DISABLE_BRIDGE #include "portable.h" +#include + +/* include socket.h to get sys/types.h and/or winsock2.h */ +#include +#if defined(HAVE_SYS_PARAM_H) #include -#include +#endif #include "lutil_sha1.h" @@ -197,13 +201,27 @@ void ldap_SHA1Final(digest, context) static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.1 1997/07/12 20:06:03 millert Exp $"; #endif /* LIBC_SCCS and not lint */ -#include #include -#include +#include + +#include +#include + +#ifdef HAVE_SYS_FILE_H #include -#include +#endif +#ifdef HAVE_SYS_UIO_H #include -#include +#endif + +#ifdef HAVE_IO_H +#include +#endif + +#ifdef HAVE_FCNTL_H +#include +#endif + /* ARGSUSED */ char * -- 2.39.5