X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Furl.c;h=b632c688f8da78a9b5014bf506d60ab48bef76a9;hb=91e24173d0fa168bdd3e585af2d56f3299a20c00;hp=57c4391c806f125c1c29e32e9ca92c0de1171e92;hpb=de67e6d32761fc1dbf8144efca995d94e09380a6;p=openldap diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index 57c4391c80..b632c688f8 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -40,8 +41,6 @@ static const char* skip_url_prefix LDAP_P(( const char *url, int *enclosedp, int *ldaps )); -static void hex_unescape LDAP_P(( char *s )); -static int unhex( char c ); int @@ -88,13 +87,13 @@ skip_url_prefix( * return non-zero if this looks like a LDAP URL; zero if not * if non-zero returned, *urlp will be moved past "ldap://" part of URL */ - char* p; + const char *p; if ( url == NULL ) { return( NULL ); } - p = (char *) url; + p = url; /* skip leading '<' (if any) */ if ( *p == '<' ) { @@ -229,7 +228,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) if (( q = strchr( url, ':' )) != NULL ) { *q++ = '\0'; - hex_unescape( q ); + ldap_pvt_hex_unescape( q ); if( *q == '\0' ) { LDAP_FREE( url ); @@ -240,7 +239,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) ludp->lud_port = atoi( q ); } - hex_unescape( url ); + ldap_pvt_hex_unescape( url ); ludp->lud_host = LDAP_STRDUP( url ); if( ludp->lud_host == NULL ) { @@ -265,7 +264,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) if( *p != '\0' ) { /* parse dn part */ - hex_unescape( p ); + ldap_pvt_hex_unescape( p ); ludp->lud_dn = LDAP_STRDUP( p ); } else { ludp->lud_dn = LDAP_STRDUP( "" ); @@ -295,7 +294,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) if( *p != '\0' ) { /* parse attributes */ - hex_unescape( p ); + ldap_pvt_hex_unescape( p ); ludp->lud_attrs = ldap_str2charray( p, "," ); if( ludp->lud_attrs == NULL ) { @@ -323,7 +322,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) if( *p != '\0' ) { /* parse the scope */ - hex_unescape( p ); + ldap_pvt_hex_unescape( p ); ludp->lud_scope = str2scope( p ); if( ludp->lud_scope == -1 ) { @@ -351,7 +350,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) if( *p != '\0' ) { /* parse the filter */ - hex_unescape( p ); + ldap_pvt_hex_unescape( p ); if( ! *p ) { /* missing filter */ @@ -398,7 +397,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) } for( i=0; ludp->lud_exts[i] != NULL; i++ ) { - hex_unescape( ludp->lud_exts[i] ); + ldap_pvt_hex_unescape( ludp->lud_exts[i] ); } if( i == 0 ) { @@ -544,8 +543,8 @@ ldap_url_search_s( } -static void -hex_unescape( char *s ) +void +ldap_pvt_hex_unescape( char *s ) { /* * Remove URL hex escapes from s... done in place. The basic concept for @@ -556,10 +555,10 @@ hex_unescape( char *s ) for ( p = s; *s != '\0'; ++s ) { if ( *s == '%' ) { if ( *++s != '\0' ) { - *p = unhex( *s ) << 4; + *p = ldap_pvt_unhex( *s ) << 4; } if ( *++s != '\0' ) { - *p++ += unhex( *s ); + *p++ += ldap_pvt_unhex( *s ); } } else { *p++ = *s; @@ -570,8 +569,8 @@ hex_unescape( char *s ) } -static int -unhex( char c ) +int +ldap_pvt_unhex( int c ) { return( c >= '0' && c <= '9' ? c - '0' : c >= 'A' && c <= 'F' ? c - 'A' + 10