X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Furl.c;h=97059170b7d214db18b30fe4d1e417de65933ef9;hb=bb17493d31e19c47bc3a906a39ffa3d57e28aaa4;hp=c716f2f0356abf5adb6c384a0f1dce6ee94de42b;hpb=abd9be4def262989fda50137a75b2cb34868ab2b;p=openldap diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index c716f2f035..97059170b7 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -1,6 +1,6 @@ /* $OpenLDAP$ */ /* - * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* Portions @@ -445,7 +445,11 @@ ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) * because a call to LDAP_INT_GLOBAL_OPT() will try to allocate * the options and cause infinite recursion */ +#ifdef NEW_LOGGING + LDAP_LOG (( "url", LDAP_LEVEL_ENTRY, "ldap_url_parse_ext(%s)\n", url_in )); +#else Debug( LDAP_DEBUG_TRACE, "ldap_url_parse_ext(%s)\n", url_in, 0, 0 ); +#endif #endif *ludpp = NULL; /* pessimistic */ @@ -887,7 +891,7 @@ ldap_url_parselist (LDAPURLDesc **ludlist, const char *url ) if (url == NULL) return LDAP_PARAM_ERROR; - urls = ldap_str2charray((char *)url, ", "); + urls = ldap_str2charray(url, ", "); if (urls == NULL) return LDAP_NO_MEMORY; @@ -924,7 +928,7 @@ ldap_url_parsehosts( if (hosts == NULL) return LDAP_PARAM_ERROR; - specs = ldap_str2charray((char *)hosts, ", "); + specs = ldap_str2charray(hosts, ", "); if (specs == NULL) return LDAP_NO_MEMORY; @@ -1115,91 +1119,14 @@ ldap_free_urldesc( LDAPURLDesc *ludp ) LDAP_FREE( ludp ); } - -int -ldap_url_search( LDAP *ld, LDAP_CONST char *url, int attrsonly ) -{ - int err; - LDAPURLDesc *ludp; - BerElement *ber; - LDAPreqinfo bind; - - assert( ld != NULL ); - assert( LDAP_VALID( ld ) ); - - if ( ldap_url_parse( url, &ludp ) != 0 ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return( -1 ); - } - - if( ludp->lud_crit_exts ) { - /* we don't support any extension (yet) */ - ld->ld_errno = LDAP_NOT_SUPPORTED; - return( -1 ); - } - - ber = ldap_build_search_req( ld, ludp->lud_dn, ludp->lud_scope, - ludp->lud_filter, ludp->lud_attrs, attrsonly, NULL, NULL, - -1, -1 ); - - if ( ber == NULL ) { - err = -1; - } else { - bind.ri_request = LDAP_REQ_SEARCH; - bind.ri_msgid = ld->ld_msgid; - bind.ri_url = (char *)url; - err = ldap_send_server_request( - ld, ber, ld->ld_msgid, NULL, - ludp, NULL, &bind ); - } - - ldap_free_urldesc( ludp ); - return( err ); -} - - -int -ldap_url_search_st( LDAP *ld, LDAP_CONST char *url, int attrsonly, - struct timeval *timeout, LDAPMessage **res ) -{ - int msgid; - - if (( msgid = ldap_url_search( ld, url, attrsonly )) == -1 ) { - return( ld->ld_errno ); - } - - if ( ldap_result( ld, msgid, 1, timeout, res ) == -1 ) { - return( ld->ld_errno ); - } - - if ( ld->ld_errno == LDAP_TIMEOUT ) { - (void) ldap_abandon( ld, msgid ); - ld->ld_errno = LDAP_TIMEOUT; - return( ld->ld_errno ); - } - - return( ldap_result2error( ld, *res, 0 )); -} - - -int -ldap_url_search_s( - LDAP *ld, LDAP_CONST char *url, int attrsonly, LDAPMessage **res ) +static int +ldap_int_unhex( int c ) { - int msgid; - - if (( msgid = ldap_url_search( ld, url, attrsonly )) == -1 ) { - return( ld->ld_errno ); - } - - if ( ldap_result( ld, msgid, 1, (struct timeval *)NULL, res ) == -1 ) { - return( ld->ld_errno ); - } - - return( ldap_result2error( ld, *res, 0 )); + return( c >= '0' && c <= '9' ? c - '0' + : c >= 'A' && c <= 'F' ? c - 'A' + 10 + : c - 'a' + 10 ); } - void ldap_pvt_hex_unescape( char *s ) { @@ -1212,10 +1139,10 @@ ldap_pvt_hex_unescape( char *s ) for ( p = s; *s != '\0'; ++s ) { if ( *s == '%' ) { if ( *++s != '\0' ) { - *p = ldap_pvt_unhex( *s ) << 4; + *p = ldap_int_unhex( *s ) << 4; } if ( *++s != '\0' ) { - *p++ += ldap_pvt_unhex( *s ); + *p++ += ldap_int_unhex( *s ); } } else { *p++ = *s; @@ -1226,10 +1153,3 @@ ldap_pvt_hex_unescape( char *s ) } -int -ldap_pvt_unhex( int c ) -{ - return( c >= '0' && c <= '9' ? c - '0' - : c >= 'A' && c <= 'F' ? c - 'A' + 10 - : c - 'a' + 10 ); -}