Index: acinclude.m4
===================================================================
RCS file: /cvsroot/curl/curl/acinclude.m4,v
retrieving revision 1.124
diff -u -r1.124 acinclude.m4
--- acinclude.m4	30 Jul 2007 22:53:18 -0000	1.124
+++ acinclude.m4	7 Aug 2007 13:28:09 -0000
@@ -1830,81 +1830,6 @@
 
 ]) dnl end of AC_DEFUN()
 
-
-dnl Determine the name of the library to pass to dlopen() based on the name
-dnl that would normally be given to AC_CHECK_LIB.  The preprocessor symbol
-dnl given is set to the quoted library file name. 
-dnl The standard dynamic library file name is first generated, based on the
-dnl current system type, then a search is performed for that file on the
-dnl standard dynamic library path.  If it is a symbolic link, the destination
-dnl of the link is used as the file name, after stripping off any minor
-dnl version numbers. If a library file can't be found, a guess is made.
-dnl This macro assumes AC_PROG_LIBTOOL has been called and requires perl
-dnl to be available in the PATH, or $PERL to be set to its location.
-dnl
-dnl CURL_DLLIB_NAME(VARIABLE, library_name)
-dnl e.g. CURL_DLLIB_NAME(LDAP_NAME, ldap) on a Linux system might result
-dnl in LDAP_NAME holding the string "libldap.so.2".
-
-AC_DEFUN([CURL_DLLIB_NAME],
-[
-AC_MSG_CHECKING([name of dynamic library $2])
-dnl The shared library extension variable name changes from version to
-dnl version of libtool.  Try a few names then just set one statically.
-test -z "$shared_ext" && eval shared_ext=\"$shrext_cmds\"
-test -z "$shared_ext" && shared_ext="$std_shrext"
-test -z "$shared_ext" && shared_ext="$shrext"
-test -z "$shared_ext" && shared_ext=".so"
-
-dnl Create the library link name of the correct form for this platform
-LIBNAME_LINK_SPEC=`echo "$library_names_spec" | $SED 's/^.* //'`
-DLGUESSLIB=`name=$2 eval echo "$libname_spec"`
-DLGUESSFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$LIBNAME_LINK_SPEC"`
-dnl Last resort in case libtool knows nothing about shared libs on this platform
-test -z "$DLGUESSFILE" && DLGUESSFILE="$DLGUESSLIB$shared_ext"
-
-dnl Synthesize a likely dynamic library name in case we can't find an actual one
-SO_NAME_SPEC="$soname_spec"
-dnl soname_spec undefined when identical to the 1st entry in library_names_spec
-test -z "$SO_NAME_SPEC" && SO_NAME_SPEC=`echo "$library_names_spec" | $SED 's/ .*$//'`
-DLGUESSSOFILE=`libname="$DLGUESSLIB" release="" major="" versuffix="" eval echo "$SO_NAME_SPEC"`
-dnl Last resort in case libtool knows nothing about shared libs on this platform
-test -z "$DLGUESSSOFILE" && DLGUESSSOFILE="$DLGUESSFILE"
-
-if test "$cross_compiling" = yes; then
-  dnl Can't look at filesystem when cross-compiling
-  AC_DEFINE_UNQUOTED($1, "$DLGUESSSOFILE", [$2 dynamic library file])
-  AC_MSG_RESULT([$DLGUESSSOFILE (guess while cross-compiling)])
-else
-
-  DLFOUNDFILE=""
-  if test "$sys_lib_dlsearch_path_spec" ; then
-    dnl Search for the link library name and see what it points to.
-    for direc in $sys_lib_dlsearch_path_spec ; do
-      DLTRYFILE="$direc/$DLGUESSFILE"
-      dnl Find where the symbolic link for this name points
-      changequote(<<, >>)dnl
-      <<
-      DLFOUNDFILE=`${PERL:-perl} -e 'use File::Basename; (basename(readlink($ARGV[0])) =~ /^(.*[^\d]\.\d+)[\d\.]*$/ && print ${1}) || exit 1;' "$DLTRYFILE" 2>&5`
-      >>
-      changequote([, ])dnl
-      if test "$?" -eq "0"; then
-        dnl Found the file link
-        break
-      fi
-    done
-  fi
-
-  if test -z "$DLFOUNDFILE" ; then
-    dnl Couldn't find a link library, so guess at a name.
-    DLFOUNDFILE="$DLGUESSSOFILE"
-  fi
-
-  AC_DEFINE_UNQUOTED($1, "$DLFOUNDFILE", [$2 dynamic library file])
-  AC_MSG_RESULT($DLFOUNDFILE)
-fi
-])
-
 # This is only a temporary fix. This macro is here to replace the broken one
 # delivered by the automake project (including the 1.9.6 release). As soon as
 # they ship a working version we SHOULD remove this work-around.
Index: configure.ac
===================================================================
RCS file: /cvsroot/curl/curl/configure.ac,v
retrieving revision 1.245
diff -u -r1.245 configure.ac
--- configure.ac	12 Jun 2007 21:39:21 -0000	1.245
+++ configure.ac	7 Aug 2007 16:35:08 -0000
@@ -500,58 +500,66 @@
        AC_MSG_RESULT(no)
 )
 
-dnl dl lib?
-AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
-
 dnl **********************************************************************
-dnl Check for the name of dynamic OpenLDAP libraries
+dnl Check for LDAP
 dnl **********************************************************************
 
 LDAPLIBNAME=""
 AC_ARG_WITH(ldap-lib,
-AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of dynamic ldap lib file]),
+AC_HELP_STRING([--with-ldap-lib=libname],[Specify name of ldap lib file]),
  [LDAPLIBNAME="$withval"])
 
 LBERLIBNAME=""
 AC_ARG_WITH(lber-lib,
-AC_HELP_STRING([--with-lber-lib=libname],[Specify name of dynamic lber lib file]),
+AC_HELP_STRING([--with-lber-lib=libname],[Specify name of lber lib file]),
  [LBERLIBNAME="$withval"])
 
 if test x$CURL_DISABLE_LDAP != x1 ; then
 
   if test -z "$LDAPLIBNAME" ; then
     case $host in
-      *-*-cygwin | *-*-mingw* | *-*-pw32*)
+      *-*-cygwin* | *-*-mingw* | *-*-pw32*)
         dnl Windows uses a single and unique OpenLDAP DLL name
-        LDAPLIBNAME="wldap32.dll"
+        LDAPLIBNAME="wldap32"
         LBERLIBNAME="no"
         ;;
     esac
   fi
 
   if test "$LDAPLIBNAME" ; then
-    AC_DEFINE_UNQUOTED(DL_LDAP_FILE, "$LDAPLIBNAME")
-    AC_MSG_CHECKING([name of dynamic library ldap])
-    AC_MSG_RESULT($LDAPLIBNAME)
+    AC_CHECK_LIB("$LDAPLIBNAME", ldap_init,, [
+      AC_MSG_ERROR(["$LDAPLIBNAME" is not an LDAP library])
+      CURL_DISABLE_LDAP=1])
   else
     dnl Try to find the right ldap library name for this system
-    CURL_DLLIB_NAME(DL_LDAP_FILE, ldap)
+    AC_SEARCH_LIBS(ldap_init, [ldap],, [
+      AC_MSG_ERROR([Cannot find LDAP library!])
+      CURL_DISABLE_LDAP=1])
   fi
+fi
+
+if test x$CURL_DISABLE_LDAP != x1 ; then
 
   if test "$LBERLIBNAME" ; then
-    dnl If name is "no" then don't define this variable at all
+    dnl If name is "no" then don't define this library at all
     dnl (it's only needed if libldap.so's dependencies are broken).
     if test "$LBERLIBNAME" != "no" ; then 
-      AC_DEFINE_UNQUOTED(DL_LBER_FILE, "$LBERLIBNAME")
+      AC_CHECK_LIB("$LBERLIBNAME", ber_free,, [
+        AC_MSG_ERROR(["$LBERLIBNAME" is not an LBER library])
+        CURL_DISABLE_LDAP=1])
     fi
-    AC_MSG_CHECKING([name of dynamic library lber])
-    AC_MSG_RESULT($LBERLIBNAME)
   else
     dnl Try to find the right lber library name for this system
-    CURL_DLLIB_NAME(DL_LBER_FILE, lber)
+    AC_SEARCH_LIBS(ber_free, [lber],, [
+      AC_MSG_ERROR([Cannot find a library defining ber_free()])
+      CURL_DISABLE_LDAP=1])
   fi
 fi
 
+if test x$CURL_DISABLE_LDAP != x1 ; then
+  AC_CHECK_FUNCS([ldap_url_parse])
+fi
+
 dnl **********************************************************************
 dnl Check for the presence of the winmm library.
 dnl **********************************************************************
@@ -1716,7 +1724,6 @@
         termio.h \
         sgtty.h \
         fcntl.h \
-        dlfcn.h \
         alloca.h \
         time.h \
         io.h \
@@ -1858,7 +1865,6 @@
                 strlcat \
                 getpwuid \
                 geteuid \
-                dlopen \
                 utime \
                 sigsetjmp \
                 basename \
Index: ares/Makefile.netware
===================================================================
RCS file: /cvsroot/curl/curl/ares/Makefile.netware,v
retrieving revision 1.35
diff -u -r1.35 Makefile.netware
--- ares/Makefile.netware	20 Jul 2007 21:50:53 -0000	1.35
+++ ares/Makefile.netware	7 Aug 2007 13:25:44 -0000
@@ -306,8 +306,6 @@
 	@echo $(DL)#define strcasecmp stricmp$(DL) >> $@
 else
 	@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
-	@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
-	@echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
 	@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
 	@echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
 	@echo $(DL)#define HAVE_INET_PTON 1$(DL) >> $@
Index: ares/configure.ac
===================================================================
RCS file: /cvsroot/curl/curl/ares/configure.ac,v
retrieving revision 1.71
diff -u -r1.71 configure.ac
--- ares/configure.ac	26 Jul 2007 21:56:47 -0000	1.71
+++ ares/configure.ac	7 Aug 2007 13:28:40 -0000
@@ -221,9 +221,6 @@
 dnl socket lib?
 AC_CHECK_FUNC(connect, , [ AC_CHECK_LIB(socket, connect) ])
 
-dnl dl lib?
-AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
-
 AC_MSG_CHECKING([whether to use libgcc])
 AC_ARG_ENABLE(libgcc,
 AC_HELP_STRING([--enable-libgcc],[use libgcc when linking]),
Index: docs/examples/Makefile.example
===================================================================
RCS file: /cvsroot/curl/curl/docs/examples/Makefile.example,v
retrieving revision 1.3
diff -u -r1.3 Makefile.example
--- docs/examples/Makefile.example	14 Aug 2002 23:01:14 -0000	1.3
+++ docs/examples/Makefile.example	7 Aug 2007 13:30:31 -0000
@@ -29,9 +29,8 @@
 # We need -lcurl for the curl stuff
 # We need -lsocket and -lnsl when on Solaris
 # We need -lssl and -lcrypto when using libcurl with SSL support
-# We need -ldl for dlopen() if that is in libdl
 # We need -lpthread for the pthread example
-LIBS = -lcurl -lsocket -lnsl -lssl -lcrypto -dl
+LIBS = -lcurl -lsocket -lnsl -lssl -lcrypto
 
 # Link the target with all objects and libraries
 $(TARGET) : $(OBJS)
Index: hiper/Makefile
===================================================================
RCS file: /cvsroot/curl/curl/hiper/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- hiper/Makefile	24 Apr 2006 22:40:20 -0000	1.5
+++ hiper/Makefile	7 Aug 2007 13:32:39 -0000
@@ -3,7 +3,7 @@
 # During dev at least, we use a static libcurl.
 #
 
-LDFLAGS = -lcrypt -lidn -lssl -lcrypto -ldl -lz -lresolv -L../ares/.libs \
+LDFLAGS = -lcrypt -lidn -lssl -lcrypto -lz -lresolv -L../ares/.libs \
  -lcares
 LIBCURL = -L../lib/.libs/ -lcurl
 CFLAGS = -I../include -g
Index: lib/Makefile.netware
===================================================================
RCS file: /cvsroot/curl/curl/lib/Makefile.netware,v
retrieving revision 1.61
diff -u -r1.61 Makefile.netware
--- lib/Makefile.netware	4 Aug 2007 23:35:23 -0000	1.61
+++ lib/Makefile.netware	7 Aug 2007 13:26:01 -0000
@@ -370,8 +370,6 @@
 	@echo $(DL)#define DL_LDAP_FILE "ldapsdk.nlm"$(DL) >> $@
 else
 	@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
-	@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
-	@echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
 	@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
 	@echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
 	@echo $(DL)#define HAVE_INET_PTON 1$(DL) >> $@
Index: lib/config-riscos.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/config-riscos.h,v
retrieving revision 1.12
diff -u -r1.12 config-riscos.h
--- lib/config-riscos.h	24 Nov 2006 16:38:59 -0000	1.12
+++ lib/config-riscos.h	7 Aug 2007 13:32:56 -0000
@@ -74,12 +74,6 @@
 /* Define if you have the <des.h> header file. */
 #undef HAVE_DES_H
 
-/* Define if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define if you have the `dlopen' function. */
-#undef HAVE_DLOPEN
-
 /* Define if you have the <err.h> header file. */
 #undef HAVE_ERR_H
 
@@ -146,9 +140,6 @@
 /* Define if you have the `crypto' library (-lcrypto). */
 #undef HAVE_LIBCRYPTO
 
-/* Define if you have the `dl' library (-ldl). */
-#undef HAVE_LIBDL
-
 /* Define if you have the `nsl' library (-lnsl). */
 #undef HAVE_LIBNSL
 
Index: lib/config-tpf.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/config-tpf.h,v
retrieving revision 1.9
diff -u -r1.9 config-tpf.h
--- lib/config-tpf.h	20 Mar 2007 16:30:14 -0000	1.9
+++ lib/config-tpf.h	7 Aug 2007 13:33:06 -0000
@@ -104,12 +104,6 @@
 /* disabled non-blocking sockets */
 /* #undef HAVE_DISABLED_NONBLOCKING */
 
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the `dlopen' function. */
-#define HAVE_DLOPEN 1
-
 /* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */
 /* #undef HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
 #define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1
@@ -244,9 +238,6 @@
 /* Define to 1 if you have the <krb.h> header file. */
 /* #undef HAVE_KRB_H */
 
-/* Define to 1 if you have the `dl' library (-ldl). */
-#define HAVE_LIBDL 1
-
 /* Define to 1 if you have the <libgen.h> header file. */
 /* #undef HAVE_LIBGEN_H 1 */
 
Index: lib/config-win32.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/config-win32.h,v
retrieving revision 1.47
diff -u -r1.47 config-win32.h
--- lib/config-win32.h	7 Aug 2007 17:40:56 -0000	1.47
+++ lib/config-win32.h	7 Aug 2007 19:15:14 -0000
@@ -18,9 +18,6 @@
 /* Define if you have the <crypto.h> header file.  */
 /* #define HAVE_CRYPTO_H 1 */
 
-/* Define if you have the <dlfcn.h> header file.  */
-/* #define HAVE_DLFCN_H 1 */
-
 /* Define if you have the <err.h> header file.  */
 /* #define HAVE_ERR_H 1 */
 
Index: lib/config-win32ce.h
===================================================================
RCS file: /cvsroot/curl/curl/lib/config-win32ce.h,v
retrieving revision 1.18
diff -u -r1.18 config-win32ce.h
--- lib/config-win32ce.h	20 Mar 2007 16:30:14 -0000	1.18
+++ lib/config-win32ce.h	7 Aug 2007 13:20:02 -0000
@@ -18,9 +18,6 @@
 /* Define if you have the <crypto.h> header file.  */
 /* #define HAVE_CRYPTO_H 1 */
 
-/* Define if you have the <dlfcn.h> header file.  */
-/* #define HAVE_DLFCN_H 1 */
-
 /* Define if you have the <err.h> header file.  */
 /* #define HAVE_ERR_H 1 */
 
Index: lib/ldap.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/ldap.c,v
retrieving revision 1.69
diff -u -r1.69 ldap.c
--- lib/ldap.c	12 Mar 2007 05:09:25 -0000	1.69
+++ lib/ldap.c	7 Aug 2007 19:05:01 -0000
@@ -35,18 +35,72 @@
 #endif
 #include <errno.h>
 
+/***********************************************************************
+ */
+
+struct bv {
+  unsigned long bv_len;
+  char  *bv_val;
+};
+
+typedef struct ldap_url_desc {
+    struct ldap_url_desc *lud_next;
+    char   *lud_scheme;
+    char   *lud_host;
+    int     lud_port;
+    char   *lud_dn;
+    char  **lud_attrs;
+    int     lud_scope;
+    char   *lud_filter;
+    char  **lud_exts;
+    int     lud_crit_exts;
+} LDAPURLDesc;
+
+/***********************************************************************
+ */
+
 #if defined(WIN32)
 # include <winldap.h>
+#else
+# if !defined(HAVE_LDAP_URL_PARSE)
+/* Probably using winldap on cygwin/mingw32/... */
+#  include <windows.h>
+#  include <winldap.h>
+#  undef WIN32
+#  undef _WIN32
+#  undef __WIN32__
+# else
+/* We need to define the prototypes in a portable way without header files,
+   because definitions are generally incompatible among different ldap
+   implementations. However, using generic 'void'-based prototypes seems OK. */
+#define LDAPMessage     void
+#define BerElement      void
+#define BerValue        void
+extern int           ldap_url_parse(char *, LDAPURLDesc **);
+extern void          ldap_free_urldesc(void *);
+extern void *        ldap_init(char *, int);
+extern int           ldap_simple_bind_s(void *, char *, char *);
+extern int           ldap_unbind_s(void *);
+extern int           ldap_search_s(void *, char *, int, char *, char **,
+                                   int, LDAPMessage **);
+extern LDAPMessage * ldap_first_entry(void *, LDAPMessage *);
+extern LDAPMessage * ldap_next_entry(void *, LDAPMessage *);
+extern char *        ldap_err2string(int);
+extern char *        ldap_get_dn(void *, LDAPMessage *);
+extern char *        ldap_first_attribute(void *, LDAPMessage *, BerElement **);
+extern char *        ldap_next_attribute(void *, LDAPMessage *, BerElement *);
+extern BerValue **   ldap_get_values_len(void *, LDAPMessage *, const char *);
+extern void          ldap_value_free_len(BerValue **);
+extern void          ldap_memfree(void *);
+extern void          ber_free(BerElement *, int);
+extern int           ldap_set_option(void *, int, void *);
+# endif
 #endif
 
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
 
-#ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
-#endif
-
 #include "urldata.h"
 #include <curl/curl.h>
 #include "sendf.h"
@@ -63,14 +117,6 @@
 
 #include "memdebug.h"
 
-/* WLdap32.dll functions are *not* stdcall. Must call these via __cdecl
- * pointers in case libcurl was compiled as fastcall (cl -Gr). Watcom
- * uses fastcall by default.
- */
-#if !defined(WIN32) && !defined(__cdecl)
-#define __cdecl
-#endif
-
 #ifndef LDAP_SIZELIMIT_EXCEEDED
 #define LDAP_SIZELIMIT_EXCEEDED 4
 #endif
@@ -84,153 +130,7 @@
 #define LDAP_OPT_PROTOCOL_VERSION 0x0011
 #endif
 
-#define DLOPEN_MODE   RTLD_LAZY  /*! assume all dlopen() implementations have
-                                   this */
-
-#if defined(RTLD_LAZY_GLOBAL)    /* It turns out some systems use this: */
-# undef  DLOPEN_MODE
-# define DLOPEN_MODE  RTLD_LAZY_GLOBAL
-#elif defined(RTLD_GLOBAL)
-# undef  DLOPEN_MODE
-# define DLOPEN_MODE  (RTLD_LAZY | RTLD_GLOBAL)
-#endif
-
-#define DYNA_GET_FUNCTION(type, fnc) do { \
-          (fnc) = (type)DynaGetFunction(#fnc); \
-          if ((fnc) == NULL) \
-             return CURLE_FUNCTION_NOT_FOUND; \
-        } while (0)
-
-/*! CygWin etc. configure could set these, but we don't want it.
- * Must use WLdap32.dll code.
- */
-#if defined(WIN32)
-#undef HAVE_DLOPEN
-#undef HAVE_LIBDL
-#endif
-
-/*
- * We use this ZERO_NULL to avoid picky compiler warnings,
- * when assigning a NULL pointer to a function pointer var.
- */
-
-#define ZERO_NULL 0
-
-typedef void * (*dynafunc)(void *input);
-
-/***********************************************************************
- */
-#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL) || defined(WIN32)
-static void *libldap = NULL;
-#if defined(DL_LBER_FILE)
-static void *liblber = NULL;
-#endif
-#endif
-
-struct bv {
-  unsigned long bv_len;
-  char  *bv_val;
-};
-
-static int DynaOpen(const char **mod_name)
-{
-#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
-  if (libldap == NULL) {
-    /*
-     * libldap.so can normally resolve its dependency on liblber.so
-     * automatically, but in broken installation it does not so
-     * handle it here by opening liblber.so as global.
-     */
-#ifdef DL_LBER_FILE
-    *mod_name = DL_LBER_FILE;
-    liblber = dlopen(*mod_name, DLOPEN_MODE);
-    if (!liblber)
-      return 0;
-#endif
-
-    /* Assume loading libldap.so will fail if loading of liblber.so failed
-     */
-    *mod_name = DL_LDAP_FILE;
-    libldap = dlopen(*mod_name, RTLD_LAZY);
-  }
-  return (libldap != NULL);
-
-#elif defined(WIN32)
-  *mod_name = DL_LDAP_FILE;
-  if (!libldap)
-    libldap = (void*)LoadLibrary(*mod_name);
-  return (libldap != NULL);
-
-#else
-  *mod_name = "";
-  return (0);
-#endif
-}
-
-static void DynaClose(void)
-{
-#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
-  if (libldap) {
-    dlclose(libldap);
-    libldap=NULL;
-  }
-#ifdef DL_LBER_FILE
-  if (liblber) {
-    dlclose(liblber);
-    liblber=NULL;
-  }
-#endif
-#elif defined(WIN32)
-  if (libldap) {
-    FreeLibrary ((HMODULE)libldap);
-    libldap = NULL;
-  }
-#endif
-}
-
-static dynafunc DynaGetFunction(const char *name)
-{
-  dynafunc func = (dynafunc)ZERO_NULL;
-
-#if defined(HAVE_DLOPEN) || defined(HAVE_LIBDL)
-  if (libldap) {
-    /* This typecast magic below was brought by Joe Halpin. In ISO C, you
-     * cannot typecast a data pointer to a function pointer, but that's
-     * exactly what we need to do here to avoid compiler warnings on picky
-     * compilers! */
-    *(void**) (&func) = dlsym(libldap, name);
-  }
-#ifdef DL_LBER_FILE
-  if (!func && liblber) {
-    *(void**) (&func) = dlsym(liblber, name);
-  }
-#endif
-#elif defined(WIN32)
-  if (libldap) {
-    func = (dynafunc)GetProcAddress((HINSTANCE)libldap, name);
-  }
-#else
-  (void) name;
-#endif
-  return func;
-}
-
-/***********************************************************************
- */
-typedef struct ldap_url_desc {
-    struct ldap_url_desc *lud_next;
-    char   *lud_scheme;
-    char   *lud_host;
-    int     lud_port;
-    char   *lud_dn;
-    char  **lud_attrs;
-    int     lud_scope;
-    char   *lud_filter;
-    char  **lud_exts;
-    int     lud_crit_exts;
-} LDAPURLDesc;
-
-#ifdef WIN32
+#if defined(WIN32) || !defined(HAVE_LDAP_URL_PARSE)
 static int  _ldap_url_parse (const struct connectdata *conn,
                              LDAPURLDesc **ludp);
 static void _ldap_free_urldesc (LDAPURLDesc *ludp);
@@ -254,32 +154,11 @@
 {
   CURLcode status = CURLE_OK;
   int rc = 0;
-#ifndef WIN32
-  int    (*ldap_url_parse)(char *, LDAPURLDesc **);
-  void   (*ldap_free_urldesc)(void *);
-#endif
-  void  *(__cdecl *ldap_init)(char *, int);
-  int    (__cdecl *ldap_simple_bind_s)(void *, char *, char *);
-  int    (__cdecl *ldap_unbind_s)(void *);
-  int    (__cdecl *ldap_search_s)(void *, char *, int, char *, char **,
-                                  int, void **);
-  void  *(__cdecl *ldap_first_entry)(void *, void *);
-  void  *(__cdecl *ldap_next_entry)(void *, void *);
-  char  *(__cdecl *ldap_err2string)(int);
-  char  *(__cdecl *ldap_get_dn)(void *, void *);
-  char  *(__cdecl *ldap_first_attribute)(void *, void *, void **);
-  char  *(__cdecl *ldap_next_attribute)(void *, void *, void *);
-  void **(__cdecl *ldap_get_values_len)(void *, void *, const char *);
-  void   (__cdecl *ldap_value_free_len)(void **);
-  void   (__cdecl *ldap_memfree)(void *);
-  void   (__cdecl *ber_free)(void *, int);
-  int    (__cdecl *ldap_set_option)(void *, int, void *);
-
   void *server;
   LDAPURLDesc *ludp = NULL;
   const char *mod_name;
-  void *result;
-  void *entryIterator;     /*! type should be 'LDAPMessage *' */
+  LDAPMessage *result;
+  LDAPMessage *entryIterator;
   int num = 0;
   struct SessionHandle *data=conn->data;
   int ldap_proto;
@@ -289,40 +168,7 @@
   *done = TRUE; /* unconditionally */
   infof(data, "LDAP local: %s\n", data->change.url);
 
-  if (!DynaOpen(&mod_name)) {
-    failf(data, "The %s LDAP library/libraries couldn't be opened", mod_name);
-    return CURLE_LIBRARY_NOT_FOUND;
-  }
-
-  /* The types are needed because ANSI C distinguishes between
-   * pointer-to-object (data) and pointer-to-function.
-   */
-  DYNA_GET_FUNCTION(void *(__cdecl *)(char *, int), ldap_init);
-  DYNA_GET_FUNCTION(int (__cdecl *)(void *, char *, char *),
-                    ldap_simple_bind_s);
-  DYNA_GET_FUNCTION(int (__cdecl *)(void *), ldap_unbind_s);
-#ifndef WIN32
-  DYNA_GET_FUNCTION(int (*)(char *, LDAPURLDesc **), ldap_url_parse);
-  DYNA_GET_FUNCTION(void (*)(void *), ldap_free_urldesc);
-#endif
-  DYNA_GET_FUNCTION(int (__cdecl *)(void *, char *, int, char *, char **, int,
-                                    void **), ldap_search_s);
-  DYNA_GET_FUNCTION(void *(__cdecl *)(void *, void *), ldap_first_entry);
-  DYNA_GET_FUNCTION(void *(__cdecl *)(void *, void *), ldap_next_entry);
-  DYNA_GET_FUNCTION(char *(__cdecl *)(int), ldap_err2string);
-  DYNA_GET_FUNCTION(char *(__cdecl *)(void *, void *), ldap_get_dn);
-  DYNA_GET_FUNCTION(char *(__cdecl *)(void *, void *, void **),
-                    ldap_first_attribute);
-  DYNA_GET_FUNCTION(char *(__cdecl *)(void *, void *, void *),
-                    ldap_next_attribute);
-  DYNA_GET_FUNCTION(void **(__cdecl *)(void *, void *, const char *),
-                    ldap_get_values_len);
-  DYNA_GET_FUNCTION(void (__cdecl *)(void **), ldap_value_free_len);
-  DYNA_GET_FUNCTION(void (__cdecl *)(void *), ldap_memfree);
-  DYNA_GET_FUNCTION(void (__cdecl *)(void *, int), ber_free);
-  DYNA_GET_FUNCTION(int (__cdecl *)(void *, int, void *), ldap_set_option);
-
-  server = (*ldap_init)(conn->host.name, (int)conn->port);
+  server = ldap_init(conn->host.name, (int)conn->port);
   if (server == NULL) {
     failf(data, "LDAP local: Cannot connect to %s:%d",
           conn->host.name, conn->port);
@@ -331,63 +177,63 @@
   }
 
   ldap_proto = LDAP_VERSION3;
-  (*ldap_set_option)(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
-  rc = (*ldap_simple_bind_s)(server,
-                             conn->bits.user_passwd ? conn->user : NULL,
-                             conn->bits.user_passwd ? conn->passwd : NULL);
+  ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
+  rc = ldap_simple_bind_s(server,
+                          conn->bits.user_passwd ? conn->user : NULL,
+                          conn->bits.user_passwd ? conn->passwd : NULL);
   if (rc != 0) {
     ldap_proto = LDAP_VERSION2;
-    (*ldap_set_option)(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
-    rc = (*ldap_simple_bind_s)(server,
-                               conn->bits.user_passwd ? conn->user : NULL,
-                               conn->bits.user_passwd ? conn->passwd : NULL);
+    ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
+    rc = ldap_simple_bind_s(server,
+                            conn->bits.user_passwd ? conn->user : NULL,
+                            conn->bits.user_passwd ? conn->passwd : NULL);
   }
   if (rc != 0) {
-     failf(data, "LDAP local: %s", (*ldap_err2string)(rc));
+     failf(data, "LDAP local: %s", ldap_err2string(rc));
      status = CURLE_LDAP_CANNOT_BIND;
      goto quit;
   }
 
-#ifdef WIN32
+#if defined(WIN32) || !defined(HAVE_LDAP_URL_PARSE)
   rc = _ldap_url_parse(conn, &ludp);
 #else
-  rc = (*ldap_url_parse)(data->change.url, &ludp);
+  rc = ldap_url_parse(data->change.url, &ludp);
 #endif
 
   if (rc != 0) {
-     failf(data, "LDAP local: %s", (*ldap_err2string)(rc));
+     failf(data, "LDAP local: %s", ldap_err2string(rc));
      status = CURLE_LDAP_INVALID_URL;
      goto quit;
   }
 
-  rc = (*ldap_search_s)(server, ludp->lud_dn, ludp->lud_scope,
-                        ludp->lud_filter, ludp->lud_attrs, 0, &result);
+  rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
+                     ludp->lud_filter, ludp->lud_attrs, 0, &result);
 
   if (rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
-    failf(data, "LDAP remote: %s", (*ldap_err2string)(rc));
+    failf(data, "LDAP remote: %s", ldap_err2string(rc));
     status = CURLE_LDAP_SEARCH_FAILED;
     goto quit;
   }
 
-  for(num = 0, entryIterator = (*ldap_first_entry)(server, result);
+  for(num = 0, entryIterator = ldap_first_entry(server, result);
       entryIterator;
-      entryIterator = (*ldap_next_entry)(server, entryIterator), num++)
+      entryIterator = ldap_next_entry(server, entryIterator), num++)
   {
-    void  *ber = NULL;      /*! is really 'BerElement **' */
+    BerElement *ber = NULL;
     void  *attribute;       /*! suspicious that this isn't 'const' */
-    char  *dn = (*ldap_get_dn)(server, entryIterator);
+    char  *dn = ldap_get_dn(server, entryIterator);
     int i;
 
     Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
     Curl_client_write(conn, CLIENTWRITE_BODY, (char *)dn, 0);
     Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
 
-    for (attribute = (*ldap_first_attribute)(server, entryIterator, &ber);
+    for (attribute = ldap_first_attribute(server, entryIterator, &ber);
          attribute;
-         attribute = (*ldap_next_attribute)(server, entryIterator, ber))
+         attribute = ldap_next_attribute(server, entryIterator, ber))
     {
       struct bv **vals = (struct bv **)
-        (*ldap_get_values_len)(server, entryIterator, attribute);
+        ldap_get_values_len(server, entryIterator, attribute);
 
       if (vals != NULL)
       {
@@ -416,15 +262,15 @@
         }
 
         /* Free memory used to store values */
-        (*ldap_value_free_len)((void **)vals);
+        ldap_value_free_len((BerValue **)vals);
       }
       Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
 
-      (*ldap_memfree)(attribute);
+      ldap_memfree(attribute);
     }
-    (*ldap_memfree)(dn);
+    ldap_memfree(dn);
     if (ber)
-       (*ber_free)(ber, 0);
+       ber_free(ber, 0);
   }
 
 quit:
@@ -432,11 +278,9 @@
   if (rc == LDAP_SIZELIMIT_EXCEEDED)
      infof(data, "There are more than %d entries\n", num);
   if (ludp)
-     (*ldap_free_urldesc)(ludp);
+     ldap_free_urldesc(ludp);
   if (server)
-     (*ldap_unbind_s)(server);
-
-  DynaClose();
+     ldap_unbind_s(server);
 
   /* no data to transfer */
   Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
@@ -464,7 +308,8 @@
 }
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) || !defined(HAVE_LDAP_URL_PARSE)
+
 /*
  * Return scope-value for a scope-string.
  */
Index: packages/vms/config-vms.h
===================================================================
RCS file: /cvsroot/curl/curl/packages/vms/config-vms.h,v
retrieving revision 1.11
diff -u -r1.11 config-vms.h
--- packages/vms/config-vms.h	28 Mar 2007 23:53:13 -0000	1.11
+++ packages/vms/config-vms.h	7 Aug 2007 13:31:14 -0000
@@ -227,9 +227,6 @@
 /* Define if you have the getpass function.  */
 #undef HAVE_GETPASS
 
-/* Define if you have the `dlopen' function. */
-#define HAVE_DLOPEN 1
-
 /* Define if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -262,9 +259,6 @@
 /* Define to 1 if you have the <limits.h> header file. */
 #define HAVE_LIMITS_H 1
 
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
 /* Define to 1 if you have the <sys/ioctl.h> header file. */
 #define HAVE_SYS_IOCTL_H 1
 
Index: src/Makefile.netware
===================================================================
RCS file: /cvsroot/curl/curl/src/Makefile.netware,v
retrieving revision 1.53
diff -u -r1.53 Makefile.netware
--- src/Makefile.netware	4 Aug 2007 23:35:23 -0000	1.53
+++ src/Makefile.netware	7 Aug 2007 13:26:11 -0000
@@ -356,8 +356,6 @@
 	@echo $(DL)#define pressanykey PressAnyKeyToContinue$(DL) >> $@
 else
 	@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
-	@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
-	@echo $(DL)#define HAVE_DLOPEN 1$(DL) >> $@
 	@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
 	@echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@
 	@echo $(DL)#define HAVE_INET_PTON 1$(DL) >> $@
Index: src/config-riscos.h
===================================================================
RCS file: /cvsroot/curl/curl/src/config-riscos.h,v
retrieving revision 1.7
diff -u -r1.7 config-riscos.h
--- src/config-riscos.h	14 Oct 2006 12:01:45 -0000	1.7
+++ src/config-riscos.h	7 Aug 2007 13:33:22 -0000
@@ -77,12 +77,6 @@
 /* Define if you have the <des.h> header file. */
 #undef HAVE_DES_H
 
-/* Define if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define if you have the `dlopen' function. */
-#undef HAVE_DLOPEN
-
 /* Define if you have the <err.h> header file. */
 #undef HAVE_ERR_H
 
@@ -152,9 +146,6 @@
 /* Define if you have the `crypto' library (-lcrypto). */
 #undef HAVE_LIBCRYPTO
 
-/* Define if you have the `dl' library (-ldl). */
-#undef HAVE_LIBDL
-
 /* Define if you have the `nsl' library (-lnsl). */
 #undef HAVE_LIBNSL
 
