1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
5 * Function:..DN-Handling-Functions *
7 * from LDAP3.2 University of Michigan *
11 * Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
12 * Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
13 * neuer Dienste, Universitaet Tuebingen, GERMANY *
16 * Creation date: Z D D V V *
17 * April 24 1996 Z D D V V *
18 * Last modification: Z D D V V *
19 * September 13 1999 ZZZZ DDD V *
21 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
24 * $Id: dn.c,v 1.8 1999/09/13 13:47:44 zrnsk01 Exp $
28 /* dn.c - routines for dealing with distinguished names */
32 #include "strng_exp.h"
36 #define LDAP_DEBUG_ANY 0xffff
41 * dn_normalize - put dn into a canonical format. the dn is
42 * normalized in place, as well as returned.
45 PUBLIC char * dn_normalize( dn )
51 /* Debug( LDAP_DEBUG_TRACE, "=> dn_normalize \"%s\"\n", dn, 0, 0 ); */
55 for ( d = s = dn; *s; s++ ) {
58 if ( ! SPACE( *s ) ) {
67 } else if ( SPACE( *s ) ) {
77 } else if ( ! SPACE( *s ) ) {
78 /* not a valid dn - but what can we do here? */
84 state = INQUOTEDVALUE;
86 } else if ( ! SPACE( *s ) ) {
92 if ( !gotesc && SEPARATOR( *s ) ) {
93 while ( SPACE( *(d - 1) ) )
101 } else if ( gotesc && !NEEDSESCAPE( *s ) &&
110 if ( !gotesc && *s == '"' ) {
113 } else if ( gotesc && !NEEDSESCAPE( *s ) ) {
121 if ( SEPARATOR( *s ) ) {
130 if ( ldap_debug & LDAP_DEBUG_ANY )
131 fprintf( stderr, "dn_normalize - unknown state %d\n", state );
133 if ( ldap_syslog & LDAP_DEBUG_ANY )
134 syslog( ldap_syslog_level,
135 "dn_normalize - unknown state %d\n", state );
138 Debug( LDAP_DEBUG_ANY,
139 "dn_normalize - unknown state %d\n", state, 0, 0 );
152 /* Debug( LDAP_DEBUG_TRACE, "<= dn_normalize \"%s\"\n", dn, 0, 0 ); */
155 /* end of function: dn_normalize */
158 * dn_normalize_case - put dn into a canonical form suitable for storing
159 * in a hash database. this involves normalizing the case as well as
160 * the format. the dn is normalized in place as well as returned.
163 PUBLIC char * dn_normalize_case( dn )
167 /* normalize format */
175 /* end of function: dn_normalize_case */
178 * dn_issuffix - tells whether suffix is a suffix of dn. both dn
179 * and suffix must be normalized.
182 PUBLIC int dn_issuffix( dn, suffix )
186 int dnlen, suffixlen;
192 suffixlen = strlen( suffix );
193 dnlen = strlen( dn );
195 if ( suffixlen > dnlen ) {
199 return( strcasecmp( dn + dnlen - suffixlen, suffix ) == 0 );
201 /* end of function: dn_issuffix */