]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/url.c
Remove LDAP_PORT dependencies so that ldap.conf defaults take over.
[openldap] / libraries / libldap / url.c
index 83ccbdc5460bf73e198985d0265b17dabb91816b..510d89ac1ac013c85c25fd946bdec95a0c25445d 100644 (file)
@@ -31,14 +31,13 @@ static char copyright[] = "@(#) Copyright (c) 1996 Regents of the University of
 #include <ac/string.h>
 #include <ac/time.h>
 
-#include "lber.h"
-#include "ldap.h"
 #include "ldap-int.h"
 
 
+/* local functions */
 static int skip_url_prefix LDAP_P(( char **urlp, int *enclosedp ));
 static void hex_unescape LDAP_P(( char *s ));
-static int unhex LDAP_P(( char c ));
+static int unhex( char c );
 
 
 int
@@ -114,7 +113,7 @@ ldap_url_parse( char *url, LDAPURLDesc **ludpp )
        }
 
        /* make working copy of the remainder of the URL */
-       if (( url = strdup( url )) == NULL ) {
+       if (( url = ldap_strdup( url )) == NULL ) {
                ldap_free_urldesc( ludp );
                return( LDAP_URL_ERR_MEM );
        }
@@ -245,9 +244,9 @@ ldap_url_search( LDAP *ld, char *url, int attrsonly )
        int             err;
        LDAPURLDesc     *ludp;
        BerElement      *ber;
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        LDAPServer      *srv = NULL;
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 
        if ( ldap_url_parse( url, &ludp ) != 0 ) {
                ld->ld_errno = LDAP_PARAM_ERROR;
@@ -262,9 +261,9 @@ ldap_url_search( LDAP *ld, char *url, int attrsonly )
        err = 0;
 
        if ( ludp->lud_host != NULL || ludp->lud_port != 0 ) {
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
                if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer )))
-                   == NULL || ( srv->lsrv_host = strdup( ludp->lud_host ==
+                   == NULL || ( srv->lsrv_host = ldap_strdup( ludp->lud_host ==
                    NULL ? ld->ld_defhost : ludp->lud_host )) == NULL ) {
                        if ( srv != NULL ) {
                                free( srv );
@@ -273,27 +272,27 @@ ldap_url_search( LDAP *ld, char *url, int attrsonly )
                        err = -1;
                } else {
                        if ( ludp->lud_port == 0 ) {
-                               srv->lsrv_port = LDAP_PORT;
+                               srv->lsrv_port = openldap_ldap_global_options.ldo_defport;
                        } else {
                                 srv->lsrv_port = ludp->lud_port;
                        }
                }
-#else /* LDAP_REFERRALS */
+#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
                ld->ld_errno = LDAP_LOCAL_ERROR;
                err = -1;
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
        }
 
        if ( err != 0 ) {
                ber_free( ber, 1 );
        } else {
-#ifdef LDAP_REFERRALS
+#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
                err = ldap_send_server_request( ld, ber, ld->ld_msgid, NULL, srv,
                    NULL, 1 );
-#else /* LDAP_REFERRALS */
+#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
                err = ldap_send_initial_request( ld, LDAP_REQ_SEARCH,
                    ludp->lud_dn, ber );
-#endif /* LDAP_REFERRALS */
+#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
        }
 
        ldap_free_urldesc( ludp );