1 /* LIBLDAP url.c -- LDAP URL (RFC 2255) related routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1996 Regents of the University of Michigan.
17 * All rights reserved.
22 * LDAP URLs look like this:
23 * ldap[is]://host:port[/[dn[?[attributes][?[scope][?[filter][?exts]]]]]]
26 * attributes is a comma separated list
27 * scope is one of these three strings: base one sub (default=base)
28 * filter is an string-represented filter as in RFC 2254
30 * e.g., ldap://host:port/dc=com?o,cn?base?(o=openldap)?extension
32 * We also tolerate URLs that look like: <ldapurl> and <URL:ldapurl>
39 #include <ac/stdlib.h>
41 #include <ac/socket.h>
42 #include <ac/string.h>
48 static const char* skip_url_prefix LDAP_P((
51 const char **scheme ));
53 int ldap_pvt_url_scheme2proto( const char *scheme )
57 if( scheme == NULL ) {
61 if( strcmp("ldap", scheme) == 0 ) {
62 return LDAP_PROTO_TCP;
65 if( strcmp("ldapi", scheme) == 0 ) {
66 return LDAP_PROTO_IPC;
69 if( strcmp("ldaps", scheme) == 0 ) {
70 return LDAP_PROTO_TCP;
72 #ifdef LDAP_CONNECTIONLESS
73 if( strcmp("cldap", scheme) == 0 ) {
74 return LDAP_PROTO_UDP;
81 int ldap_pvt_url_scheme_port( const char *scheme, int port )
85 if( port ) return port;
86 if( scheme == NULL ) return port;
88 if( strcmp("ldap", scheme) == 0 ) {
92 if( strcmp("ldapi", scheme) == 0 ) {
96 if( strcmp("ldaps", scheme) == 0 ) {
100 #ifdef LDAP_CONNECTIONLESS
101 if( strcmp("cldap", scheme) == 0 ) {
110 ldap_pvt_url_scheme2tls( const char *scheme )
114 if( scheme == NULL ) {
118 return strcmp("ldaps", scheme) == 0;
122 ldap_is_ldap_url( LDAP_CONST char *url )
131 if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) {
139 ldap_is_ldaps_url( LDAP_CONST char *url )
148 if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) {
152 return strcmp(scheme, "ldaps") == 0;
156 ldap_is_ldapi_url( LDAP_CONST char *url )
165 if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) {
169 return strcmp(scheme, "ldapi") == 0;
172 #ifdef LDAP_CONNECTIONLESS
174 ldap_is_ldapc_url( LDAP_CONST char *url )
183 if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) {
187 return strcmp(scheme, "cldap") == 0;
195 const char **scheme )
198 * return non-zero if this looks like a LDAP URL; zero if not
199 * if non-zero returned, *urlp will be moved past "ldap://" part of URL
209 /* skip leading '<' (if any) */
217 /* skip leading "URL:" (if any) */
218 if ( strncasecmp( p, LDAP_URL_URLCOLON, LDAP_URL_URLCOLON_LEN ) == 0 ) {
219 p += LDAP_URL_URLCOLON_LEN;
222 /* check for "ldap://" prefix */
223 if ( strncasecmp( p, LDAP_URL_PREFIX, LDAP_URL_PREFIX_LEN ) == 0 ) {
224 /* skip over "ldap://" prefix and return success */
225 p += LDAP_URL_PREFIX_LEN;
230 /* check for "ldaps://" prefix */
231 if ( strncasecmp( p, LDAPS_URL_PREFIX, LDAPS_URL_PREFIX_LEN ) == 0 ) {
232 /* skip over "ldaps://" prefix and return success */
233 p += LDAPS_URL_PREFIX_LEN;
238 /* check for "ldapi://" prefix */
239 if ( strncasecmp( p, LDAPI_URL_PREFIX, LDAPI_URL_PREFIX_LEN ) == 0 ) {
240 /* skip over "ldapi://" prefix and return success */
241 p += LDAPI_URL_PREFIX_LEN;
246 #ifdef LDAP_CONNECTIONLESS
247 /* check for "cldap://" prefix */
248 if ( strncasecmp( p, LDAPC_URL_PREFIX, LDAPC_URL_PREFIX_LEN ) == 0 ) {
249 /* skip over "cldap://" prefix and return success */
250 p += LDAPC_URL_PREFIX_LEN;
260 static int str2scope( const char *p )
262 if ( strcasecmp( p, "one" ) == 0 ) {
263 return LDAP_SCOPE_ONELEVEL;
265 } else if ( strcasecmp( p, "onelevel" ) == 0 ) {
266 return LDAP_SCOPE_ONELEVEL;
268 } else if ( strcasecmp( p, "base" ) == 0 ) {
269 return LDAP_SCOPE_BASE;
271 } else if ( strcasecmp( p, "sub" ) == 0 ) {
272 return LDAP_SCOPE_SUBTREE;
274 } else if ( strcasecmp( p, "subtree" ) == 0 ) {
275 return LDAP_SCOPE_SUBTREE;
281 static int hex_escape( char *buf, const char *s, int list )
285 static const char hex[] = "0123456789ABCDEF";
287 if( s == NULL ) return 0;
289 for( pos=0,i=0; s[i]; i++ ) {
315 escape = s[i] < 0x20 || 0x1f >= s[i];
320 buf[pos++] = hex[ (s[i] >> 4) & 0x0f ];
321 buf[pos++] = hex[ s[i] & 0x0f ];
331 static int hex_escape_args( char *buf, char **s )
336 if( s == NULL ) return 0;
339 for( i=0; s[i] != NULL; i++ ) {
343 pos += hex_escape( &buf[pos], s[i], 1 );
349 char * ldap_url_desc2str( LDAPURLDesc *u )
356 if( u == NULL ) return NULL;
359 for( i=0; u->lud_exts[i]; i++ ) {
360 len += strlen( u->lud_exts[i] ) + 1;
365 if( u->lud_filter ) {
366 len += strlen( u->lud_filter );
369 if ( len ) len++; /* ? */
371 switch( u->lud_scope ) {
372 case LDAP_SCOPE_ONELEVEL:
373 case LDAP_SCOPE_SUBTREE:
374 case LDAP_SCOPE_BASE:
375 len += sizeof("base");
380 if ( len ) len++; /* ? */
384 for( i=0; u->lud_attrs[i]; i++ ) {
385 len += strlen( u->lud_attrs[i] ) + 1;
388 } else if ( len ) len++; /* ? */
391 len += strlen( u->lud_dn ) + 1;
396 len += sizeof(":65535") - 1;
400 len+=strlen( u->lud_host );
403 len += strlen( u->lud_scheme ) + sizeof("://");
405 /* allocate enough to hex escape everything -- overkill */
406 s = LDAP_MALLOC( 3*len );
408 if( s == NULL ) return NULL;
411 sprintf( s, "%s://%s:%d%n", u->lud_scheme,
412 u->lud_host, u->lud_port, &sofar );
414 sprintf( s, "%s://%s%n", u->lud_scheme,
415 u->lud_host, &sofar );
418 if( sep < 1 ) goto done;
421 sofar += hex_escape( &s[sofar], u->lud_dn, 0 );
423 if( sep < 2 ) goto done;
426 sofar += hex_escape_args( &s[sofar], u->lud_attrs );
428 if( sep < 3 ) goto done;
431 switch( u->lud_scope ) {
432 case LDAP_SCOPE_BASE:
433 strcpy( &s[sofar], "base" );
434 sofar += sizeof("base") - 1;
436 case LDAP_SCOPE_ONELEVEL:
437 strcpy( &s[sofar], "one" );
438 sofar += sizeof("one") - 1;
440 case LDAP_SCOPE_SUBTREE:
441 strcpy( &s[sofar], "sub" );
442 sofar += sizeof("sub") - 1;
446 if( sep < 4 ) goto done;
449 sofar += hex_escape( &s[sofar], u->lud_filter, 0 );
451 if( sep < 5 ) goto done;
454 sofar += hex_escape_args( &s[sofar], u->lud_exts );
462 ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
465 * Pick apart the pieces of an LDAP URL.
471 const char *scheme = NULL;
475 if( url_in == NULL || ludpp == NULL ) {
476 return LDAP_URL_ERR_PARAM;
479 #ifndef LDAP_INT_IN_KERNEL
480 /* Global options may not be created yet
481 * We can't test if the global options are initialized
482 * because a call to LDAP_INT_GLOBAL_OPT() will try to allocate
483 * the options and cause infinite recursion
486 LDAP_LOG ( OPERATION, ENTRY, "ldap_url_parse_ext(%s)\n", url_in, 0, 0 );
488 Debug( LDAP_DEBUG_TRACE, "ldap_url_parse_ext(%s)\n", url_in, 0, 0 );
492 *ludpp = NULL; /* pessimistic */
494 url_tmp = skip_url_prefix( url_in, &enclosed, &scheme );
496 if ( url_tmp == NULL ) {
497 return LDAP_URL_ERR_BADSCHEME;
502 /* make working copy of the remainder of the URL */
503 url = LDAP_STRDUP( url_tmp );
505 return LDAP_URL_ERR_MEM;
509 p = &url[strlen(url)-1];
513 return LDAP_URL_ERR_BADENCLOSURE;
519 /* allocate return struct */
520 ludp = (LDAPURLDesc *)LDAP_CALLOC( 1, sizeof( LDAPURLDesc ));
522 if ( ludp == NULL ) {
524 return LDAP_URL_ERR_MEM;
527 ludp->lud_next = NULL;
528 ludp->lud_host = NULL;
531 ludp->lud_attrs = NULL;
532 ludp->lud_filter = NULL;
533 ludp->lud_scope = LDAP_SCOPE_DEFAULT;
534 ludp->lud_filter = NULL;
535 ludp->lud_exts = NULL;
537 ludp->lud_scheme = LDAP_STRDUP( scheme );
539 if ( ludp->lud_scheme == NULL ) {
541 ldap_free_urldesc( ludp );
542 return LDAP_URL_ERR_MEM;
545 /* scan forward for '/' that marks end of hostport and begin. of dn */
546 p = strchr( url, '/' );
549 /* terminate hostport; point to start of dn */
553 /* IPv6 syntax with [ip address]:port */
555 r = strchr( url, ']' );
558 ldap_free_urldesc( ludp );
559 return LDAP_URL_ERR_BADURL;
562 q = strchr( r, ':' );
564 q = strchr( url, ':' );
571 ldap_pvt_hex_unescape( q );
575 ldap_free_urldesc( ludp );
576 return LDAP_URL_ERR_BADURL;
579 ludp->lud_port = strtol( q, &next, 10 );
580 if ( next == NULL || next[0] != '\0' ) {
582 ldap_free_urldesc( ludp );
583 return LDAP_URL_ERR_BADURL;
587 ldap_pvt_hex_unescape( url );
589 /* If [ip address]:port syntax, url is [ip and we skip the [ */
590 ludp->lud_host = LDAP_STRDUP( url + ( *url == '[' ) );
592 if( ludp->lud_host == NULL ) {
594 ldap_free_urldesc( ludp );
595 return LDAP_URL_ERR_MEM;
599 * Kludge. ldap://111.222.333.444:389??cn=abc,o=company
601 * On early Novell releases, search references/referrals were returned
602 * in this format, i.e., the dn was kind of in the scope position,
603 * but the required slash is missing. The whole thing is illegal syntax,
604 * but we need to account for it. Fortunately it can't be confused with
607 if( (p == NULL) && (q != NULL) && ((q = strchr( q, '?')) != NULL)) {
609 /* ? immediately followed by question */
614 ldap_pvt_hex_unescape( q );
615 ludp->lud_dn = LDAP_STRDUP( q );
617 ludp->lud_dn = LDAP_STRDUP( "" );
620 if( ludp->lud_dn == NULL ) {
622 ldap_free_urldesc( ludp );
623 return LDAP_URL_ERR_MEM;
631 return LDAP_URL_SUCCESS;
634 /* scan forward for '?' that may marks end of dn */
635 q = strchr( p, '?' );
638 /* terminate dn part */
644 ldap_pvt_hex_unescape( p );
645 ludp->lud_dn = LDAP_STRDUP( p );
647 ludp->lud_dn = LDAP_STRDUP( "" );
650 if( ludp->lud_dn == NULL ) {
652 ldap_free_urldesc( ludp );
653 return LDAP_URL_ERR_MEM;
660 return LDAP_URL_SUCCESS;
663 /* scan forward for '?' that may marks end of attributes */
665 q = strchr( p, '?' );
668 /* terminate attributes part */
673 /* parse attributes */
674 ldap_pvt_hex_unescape( p );
675 ludp->lud_attrs = ldap_str2charray( p, "," );
677 if( ludp->lud_attrs == NULL ) {
679 ldap_free_urldesc( ludp );
680 return LDAP_URL_ERR_BADATTRS;
688 return LDAP_URL_SUCCESS;
691 /* scan forward for '?' that may marks end of scope */
693 q = strchr( p, '?' );
696 /* terminate the scope part */
701 /* parse the scope */
702 ldap_pvt_hex_unescape( p );
703 ludp->lud_scope = str2scope( p );
705 if( ludp->lud_scope == -1 ) {
707 ldap_free_urldesc( ludp );
708 return LDAP_URL_ERR_BADSCOPE;
716 return LDAP_URL_SUCCESS;
719 /* scan forward for '?' that may marks end of filter */
721 q = strchr( p, '?' );
724 /* terminate the filter part */
729 /* parse the filter */
730 ldap_pvt_hex_unescape( p );
735 ldap_free_urldesc( ludp );
736 return LDAP_URL_ERR_BADFILTER;
739 LDAP_FREE( ludp->lud_filter );
740 ludp->lud_filter = LDAP_STRDUP( p );
742 if( ludp->lud_filter == NULL ) {
744 ldap_free_urldesc( ludp );
745 return LDAP_URL_ERR_MEM;
753 return LDAP_URL_SUCCESS;
756 /* scan forward for '?' that may marks end of extensions */
758 q = strchr( p, '?' );
763 ldap_free_urldesc( ludp );
764 return LDAP_URL_ERR_BADURL;
767 /* parse the extensions */
768 ludp->lud_exts = ldap_str2charray( p, "," );
770 if( ludp->lud_exts == NULL ) {
772 ldap_free_urldesc( ludp );
773 return LDAP_URL_ERR_BADEXTS;
776 for( i=0; ludp->lud_exts[i] != NULL; i++ ) {
777 ldap_pvt_hex_unescape( ludp->lud_exts[i] );
779 if( *ludp->lud_exts[i] == '!' ) {
780 /* count the number of critical extensions */
781 ludp->lud_crit_exts++;
786 /* must have 1 or more */
788 ldap_free_urldesc( ludp );
789 return LDAP_URL_ERR_BADEXTS;
795 return LDAP_URL_SUCCESS;
799 ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
801 int rc = ldap_url_parse_ext( url_in, ludpp );
803 if( rc != LDAP_URL_SUCCESS ) {
807 if ((*ludpp)->lud_scope == LDAP_SCOPE_DEFAULT) {
808 (*ludpp)->lud_scope = LDAP_SCOPE_BASE;
811 if ((*ludpp)->lud_host != NULL && *(*ludpp)->lud_host == '\0') {
812 LDAP_FREE( (*ludpp)->lud_host );
813 (*ludpp)->lud_host = NULL;
816 if ((*ludpp)->lud_port == 0) {
817 if( strcmp((*ludpp)->lud_scheme, "ldap") == 0 ) {
818 (*ludpp)->lud_port = LDAP_PORT;
819 #ifdef LDAP_CONNECTIONLESS
820 } else if( strcmp((*ludpp)->lud_scheme, "cldap") == 0 ) {
821 (*ludpp)->lud_port = LDAP_PORT;
823 } else if( strcmp((*ludpp)->lud_scheme, "ldaps") == 0 ) {
824 (*ludpp)->lud_port = LDAPS_PORT;
832 ldap_url_dup ( LDAPURLDesc *ludp )
836 if ( ludp == NULL ) {
840 dest = LDAP_MALLOC( sizeof(LDAPURLDesc) );
845 dest->lud_scheme = NULL;
846 dest->lud_host = NULL;
848 dest->lud_filter = NULL;
849 dest->lud_attrs = NULL;
850 dest->lud_exts = NULL;
851 dest->lud_next = NULL;
853 if ( ludp->lud_scheme != NULL ) {
854 dest->lud_scheme = LDAP_STRDUP( ludp->lud_scheme );
855 if (dest->lud_scheme == NULL) {
856 ldap_free_urldesc(dest);
861 if ( ludp->lud_host != NULL ) {
862 dest->lud_host = LDAP_STRDUP( ludp->lud_host );
863 if (dest->lud_host == NULL) {
864 ldap_free_urldesc(dest);
869 if ( ludp->lud_dn != NULL ) {
870 dest->lud_dn = LDAP_STRDUP( ludp->lud_dn );
871 if (dest->lud_dn == NULL) {
872 ldap_free_urldesc(dest);
877 if ( ludp->lud_filter != NULL ) {
878 dest->lud_filter = LDAP_STRDUP( ludp->lud_filter );
879 if (dest->lud_filter == NULL) {
880 ldap_free_urldesc(dest);
885 if ( ludp->lud_attrs != NULL ) {
886 dest->lud_attrs = ldap_charray_dup( ludp->lud_attrs );
887 if (dest->lud_attrs == NULL) {
888 ldap_free_urldesc(dest);
893 if ( ludp->lud_exts != NULL ) {
894 dest->lud_exts = ldap_charray_dup( ludp->lud_exts );
895 if (dest->lud_exts == NULL) {
896 ldap_free_urldesc(dest);
905 ldap_url_duplist (LDAPURLDesc *ludlist)
907 LDAPURLDesc *dest, *tail, *ludp, *newludp;
911 for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
912 newludp = ldap_url_dup(ludp);
913 if (newludp == NULL) {
914 ldap_free_urllist(dest);
920 tail->lud_next = newludp;
927 ldap_url_parselist (LDAPURLDesc **ludlist, const char *url )
929 return ldap_url_parselist_ext( ludlist, url, ", " );
933 ldap_url_parselist_ext (LDAPURLDesc **ludlist, const char *url, const char *sep )
939 assert( ludlist != NULL );
940 assert( url != NULL );
944 urls = ldap_str2charray(url, sep);
946 return LDAP_URL_ERR_MEM;
948 /* count the URLs... */
949 for (i = 0; urls[i] != NULL; i++) ;
950 /* ...and put them in the "stack" backward */
952 rc = ldap_url_parse( urls[i], &ludp );
954 ldap_charray_free(urls);
955 ldap_free_urllist(*ludlist);
959 ludp->lud_next = *ludlist;
962 ldap_charray_free(urls);
963 return LDAP_URL_SUCCESS;
968 LDAPURLDesc **ludlist,
976 assert( ludlist != NULL );
977 assert( hosts != NULL );
981 specs = ldap_str2charray(hosts, ", ");
983 return LDAP_NO_MEMORY;
985 /* count the URLs... */
986 for (i = 0; specs[i] != NULL; i++) /* EMPTY */;
988 /* ...and put them in the "stack" backward */
990 ludp = LDAP_CALLOC( 1, sizeof(LDAPURLDesc) );
992 ldap_charray_free(specs);
993 ldap_free_urllist(*ludlist);
995 return LDAP_NO_MEMORY;
997 ludp->lud_port = port;
998 ludp->lud_host = specs[i];
1000 p = strchr(ludp->lud_host, ':');
1002 /* more than one :, IPv6 address */
1003 if ( strchr(p+1, ':') != NULL ) {
1004 /* allow [address] and [address]:port */
1005 if ( *ludp->lud_host == '[' ) {
1006 p = LDAP_STRDUP(ludp->lud_host+1);
1007 /* copied, make sure we free source later */
1008 specs[i] = ludp->lud_host;
1010 p = strchr( ludp->lud_host, ']' );
1012 return LDAP_PARAM_ERROR;
1016 return LDAP_PARAM_ERROR;
1027 ldap_pvt_hex_unescape(p);
1028 ludp->lud_port = strtol( p, &next, 10 );
1029 if ( next == NULL || next[0] != '\0' ) {
1030 return LDAP_PARAM_ERROR;
1034 ldap_pvt_hex_unescape(ludp->lud_host);
1035 ludp->lud_scheme = LDAP_STRDUP("ldap");
1036 ludp->lud_next = *ludlist;
1040 /* this should be an array of NULLs now */
1041 /* except entries starting with [ */
1042 ldap_charray_free(specs);
1043 return LDAP_SUCCESS;
1047 ldap_url_list2hosts (LDAPURLDesc *ludlist)
1051 char *s, *p, buf[32]; /* big enough to hold a long decimal # (overkill) */
1053 if (ludlist == NULL)
1056 /* figure out how big the string is */
1057 size = 1; /* nul-term */
1058 for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
1059 size += strlen(ludp->lud_host) + 1; /* host and space */
1060 if (strchr(ludp->lud_host, ':')) /* will add [ ] below */
1062 if (ludp->lud_port != 0)
1063 size += sprintf(buf, ":%d", ludp->lud_port);
1065 s = LDAP_MALLOC(size);
1070 for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
1071 if (strchr(ludp->lud_host, ':')) {
1072 p += sprintf(p, "[%s]", ludp->lud_host);
1074 strcpy(p, ludp->lud_host);
1075 p += strlen(ludp->lud_host);
1077 if (ludp->lud_port != 0)
1078 p += sprintf(p, ":%d", ludp->lud_port);
1082 p--; /* nuke that extra space */
1089 LDAPURLDesc *ludlist )
1093 char *s, *p, buf[32]; /* big enough to hold a long decimal # (overkill) */
1095 if (ludlist == NULL)
1098 /* figure out how big the string is */
1099 size = 1; /* nul-term */
1100 for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
1101 size += strlen(ludp->lud_scheme);
1102 if ( ludp->lud_host ) {
1103 size += strlen(ludp->lud_host);
1104 /* will add [ ] below */
1105 if (strchr(ludp->lud_host, ':'))
1108 size += sizeof(":/// ");
1110 if (ludp->lud_port != 0) {
1111 size += sprintf(buf, ":%d", ludp->lud_port);
1115 s = LDAP_MALLOC(size);
1121 for (ludp = ludlist; ludp != NULL; ludp = ludp->lud_next) {
1122 p += sprintf(p, "%s://", ludp->lud_scheme);
1123 if ( ludp->lud_host ) {
1124 p += sprintf(p, strchr(ludp->lud_host, ':')
1125 ? "[%s]" : "%s", ludp->lud_host);
1127 if (ludp->lud_port != 0)
1128 p += sprintf(p, ":%d", ludp->lud_port);
1133 p--; /* nuke that extra space */
1139 ldap_free_urllist( LDAPURLDesc *ludlist )
1141 LDAPURLDesc *ludp, *next;
1143 for (ludp = ludlist; ludp != NULL; ludp = next) {
1144 next = ludp->lud_next;
1145 ldap_free_urldesc(ludp);
1150 ldap_free_urldesc( LDAPURLDesc *ludp )
1152 if ( ludp == NULL ) {
1156 if ( ludp->lud_scheme != NULL ) {
1157 LDAP_FREE( ludp->lud_scheme );
1160 if ( ludp->lud_host != NULL ) {
1161 LDAP_FREE( ludp->lud_host );
1164 if ( ludp->lud_dn != NULL ) {
1165 LDAP_FREE( ludp->lud_dn );
1168 if ( ludp->lud_filter != NULL ) {
1169 LDAP_FREE( ludp->lud_filter);
1172 if ( ludp->lud_attrs != NULL ) {
1173 LDAP_VFREE( ludp->lud_attrs );
1176 if ( ludp->lud_exts != NULL ) {
1177 LDAP_VFREE( ludp->lud_exts );
1184 ldap_int_unhex( int c )
1186 return( c >= '0' && c <= '9' ? c - '0'
1187 : c >= 'A' && c <= 'F' ? c - 'A' + 10
1192 ldap_pvt_hex_unescape( char *s )
1195 * Remove URL hex escapes from s... done in place. The basic concept for
1196 * this routine is borrowed from the WWW library HTUnEscape() routine.
1200 for ( p = s; *s != '\0'; ++s ) {
1202 if ( *++s == '\0' ) {
1205 *p = ldap_int_unhex( *s ) << 4;
1206 if ( *++s == '\0' ) {
1209 *p++ += ldap_int_unhex( *s );