1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A/*
1N/A * The contents of this file are subject to the Netscape Public
1N/A * License Version 1.1 (the "License"); you may not use this file
1N/A * except in compliance with the License. You may obtain a copy of
1N/A * the License at http://www.mozilla.org/NPL/
1N/A *
1N/A * Software distributed under the License is distributed on an "AS
1N/A * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
1N/A * implied. See the License for the specific language governing
1N/A * rights and limitations under the License.
1N/A *
1N/A * The Original Code is Mozilla Communicator client code, released
1N/A * March 31, 1998.
1N/A *
1N/A * The Initial Developer of the Original Code is Netscape
1N/A * Communications Corporation. Portions created by Netscape are
1N/A * Copyright (C) 1998-1999 Netscape Communications Corporation. All
1N/A * Rights Reserved.
1N/A *
1N/A * Contributor(s):
1N/A */
1N/A
1N/A/*
1N/A * LIBLDAP unescape.c -- LDAP URL un-escape routines
1N/A * We also tolerate URLs that look like: <ldapurl> and <URL:ldapurl>
1N/A */
1N/A
1N/A#include "ldap-int.h"
1N/A
1N/A
1N/Astatic int unhex( char c );
1N/A
1N/A
1N/Avoid
1N/Ansldapi_hex_unescape( char *s )
1N/A{
1N/A/*
1N/A * Remove URL hex escapes from s... done in place. The basic concept for
1N/A * this routine is borrowed from the WWW library HTUnEscape() routine.
1N/A */
1N/A char *p;
1N/A
1N/A for ( p = s; *s != '\0'; ++s ) {
1N/A if ( *s == '%' ) {
1N/A if ( *++s != '\0' ) {
1N/A *p = unhex( *s ) << 4;
1N/A }
1N/A if ( *++s != '\0' ) {
1N/A *p++ += unhex( *s );
1N/A }
1N/A } else {
1N/A *p++ = *s;
1N/A }
1N/A }
1N/A
1N/A *p = '\0';
1N/A}
1N/A
1N/A
1N/Astatic int
1N/Aunhex( char c )
1N/A{
1N/A return( c >= '0' && c <= '9' ? c - '0'
1N/A : c >= 'A' && c <= 'F' ? c - 'A' + 10
1N/A : c - 'a' + 10 );
1N/A}