]> git.sur5r.net Git - openldap/commitdiff
Misc DN cleanup, no functional changes
authorKurt Zeilenga <kurt@openldap.org>
Mon, 24 Dec 2001 06:00:02 +0000 (06:00 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 24 Dec 2001 06:00:02 +0000 (06:00 +0000)
libraries/libldap/Makefile.in
libraries/libldap/dn.c [deleted file]
libraries/libldap_r/Makefile.in
servers/slapd/backglue.c
servers/slapd/dn.c
servers/slapd/proto-slap.h

index f32ec13117ccea027dc0505aaabd35540c3f6b6d..a73b656f2b41d3e1ac06f0ec1e8f64b390d29cff 100644 (file)
@@ -17,8 +17,7 @@ SRCS  = bind.c open.c result.c error.c compare.c search.c \
        getdn.c getentry.c getattr.c getvalues.c addentry.c \
        request.c os-ip.c url.c sortctrl.c vlvctrl.c \
        init.c options.c print.c string.c util-int.c schema.c \
-       charray.c tls.c dn.c os-local.c dnssrv.c \
-       utf-8.c utf-8-conv.c
+       charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c
 OBJS   = bind.lo open.lo result.lo error.lo compare.lo search.lo \
        controls.lo messages.lo references.lo extended.lo cyrus.lo \
        modify.lo add.lo modrdn.lo delete.lo abandon.lo cache.lo \
@@ -27,8 +26,7 @@ OBJS  = bind.lo open.lo result.lo error.lo compare.lo search.lo \
        getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
        request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
        init.lo options.lo print.lo string.lo util-int.lo schema.lo \
-       charray.lo tls.lo dn.lo os-local.lo dnssrv.lo \
-       utf-8.lo utf-8-conv.lo
+       charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo
 
 LDAP_INCDIR= ../../include       
 LDAP_LIBDIR= ../../libraries
diff --git a/libraries/libldap/dn.c b/libraries/libldap/dn.c
deleted file mode 100644 (file)
index d60edd0..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-/* dn.c - routines for dealing with distinguished names */
-/* $OpenLDAP$ */
-/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/socket.h>
-#include <ac/string.h>
-#include <ac/time.h>
-
-#include "ldap-int.h"
-
-#if 0
-/* this should wait for UTF-8 routines */
-
-#define B4LEADTYPE             0
-#define B4TYPE                 1
-#define INOIDTYPE              2
-#define INKEYTYPE              3
-#define B4EQUAL                        4
-#define B4VALUE                        5
-#define INVALUE                        6
-#define INQUOTEDVALUE  7
-#define B4SEPARATOR            8
-
-/*
- * ldap_dn_normalize - put dn into a canonical format
- * and return it.
- */
-
-char *
-ldap_dn_normalize( const char *dn )
-{
-       char    *d, *s;
-       int     state, gotesc;
-       char *ndn;
-
-       if( dn == NULL ) {
-               return NULL;
-       }
-
-       ndn = LDAP_STRDUP( dn );
-
-       if( ndn == NULL ) {
-               return NULL;
-       }
-
-       gotesc = 0;
-       state = B4LEADTYPE;
-       for ( d = s = ndn; *s; s++ ) {
-               switch ( state ) {
-               case B4LEADTYPE:
-               case B4TYPE:
-                       if ( LDAP_LEADOIDCHAR(*s) ) {
-                               state = INOIDTYPE;
-                               *d++ = *s;
-                       } else if ( LDAP_LEADKEYCHAR(*s) ) {
-                               state = INKEYTYPE;
-                               *d++ = *s;
-                       } else if ( ! LDAP_SPACE( *s ) ) {
-                               dn = NULL;
-                               state = INKEYTYPE;
-                               *d++ = *s;
-                       }
-                       break;
-
-               case INOIDTYPE:
-                       if ( LDAP_OIDCHAR(*s) ) {
-                               *d++ = *s;
-                       } else if ( *s == '=' ) {
-                               state = B4VALUE;
-                               *d++ = *s;
-                       } else if ( LDAP_SPACE( *s ) ) {
-                               state = B4EQUAL;
-                       } else {
-                               dn = NULL;
-                               *d++ = *s;
-                       }
-                       break;
-
-               case INKEYTYPE:
-                       if ( LDAP_KEYCHAR(*s) ) {
-                               *d++ = *s;
-                       } else if ( *s == '=' ) {
-                               state = B4VALUE;
-                               *d++ = *s;
-                       } else if ( LDAP_SPACE( *s ) ) {
-                               state = B4EQUAL;
-                       } else {
-                               dn = NULL;
-                               *d++ = *s;
-                       }
-                       break;
-
-               case B4EQUAL:
-                       if ( *s == '=' ) {
-                               state = B4VALUE;
-                               *d++ = *s;
-                       } else if ( ! LDAP_SPACE( *s ) ) {
-                               /* not a valid dn - but what can we do here? */
-                               *d++ = *s;
-                               dn = NULL;
-                       }
-                       break;
-
-               case B4VALUE:
-                       if ( *s == '"' ) {
-                               state = INQUOTEDVALUE;
-                               *d++ = *s;
-                       } else if ( ! LDAP_SPACE( *s ) ) { 
-                               state = INVALUE;
-                               *d++ = *s;
-                       }
-                       break;
-
-               case INVALUE:
-                       if ( !gotesc && LDAP_SEPARATOR( *s ) ) {
-                               while ( LDAP_SPACE( *(d - 1) ) )
-                                       d--;
-                               state = B4TYPE;
-                               if ( *s == '+' ) {
-                                       *d++ = *s;
-                               } else {
-                                       *d++ = ',';
-                               }
-                       } else if ( gotesc && !LDAP_NEEDSESCAPE( *s ) &&
-                           !LDAP_SEPARATOR( *s ) ) {
-                               *--d = *s;
-                               d++;
-                       } else {
-                               *d++ = *s;
-                       }
-                       break;
-
-               case INQUOTEDVALUE:
-                       if ( !gotesc && *s == '"' ) {
-                               state = B4SEPARATOR;
-                               *d++ = *s;
-                       } else if ( gotesc && !LDAP_NEEDSESCAPE( *s ) ) {
-                               *--d = *s;
-                               d++;
-                       } else {
-                               *d++ = *s;
-                       }
-                       break;
-               case B4SEPARATOR:
-                       if ( LDAP_SEPARATOR( *s ) ) {
-                               state = B4TYPE;
-                               *d++ = *s;
-                       }
-                       break;
-               default:
-                       dn = NULL;
-                       Debug( LDAP_DEBUG_ANY,
-                           "dn_normalize - unknown state %d\n", state, 0, 0 );
-                       break;
-               }
-               if ( *s == '\\' ) {
-                       gotesc = 1;
-               } else {
-                       gotesc = 0;
-               }
-       }
-       *d = '\0';
-
-       if( gotesc ) {
-               /* shouldn't be left in escape */
-               dn = NULL;
-       }
-
-       /* check end state */
-       switch( state ) {
-       case B4LEADTYPE:        /* looking for first type */
-       case B4SEPARATOR:       /* looking for separator */
-       case INVALUE:           /* inside value */
-               break;
-       default:
-               dn = NULL;
-       }
-
-       if( dn == NULL ) {
-               return( ndn );
-               ndn = NULL;
-       }
-
-       return( ndn );
-}
-
-/*
- * ldap_dn_parent - return a copy of the dn of dn's parent
- */
-
-char *
-ldap_dn_parent(
-    const char *dn
-)
-{
-       const char      *s;
-       int     inquote;
-
-       if( dn == NULL ) {
-               return NULL;
-       }
-
-       while(*dn && LDAP_SPACE(*dn)) {
-               dn++;
-       }
-
-       if( *dn == '\0' ) {
-               return( NULL );
-       }
-
-       /*
-        * assume it is an X.500-style name, which looks like
-        * foo=bar,sha=baz,...
-        */
-
-       inquote = 0;
-       for ( s = dn; *s; s++ ) {
-               if ( *s == '\\' ) {
-                       if ( *(s + 1) ) {
-                               s++;
-                       }
-                       continue;
-               }
-               if ( inquote ) {
-                       if ( *s == '"' ) {
-                               inquote = 0;
-                       }
-               } else {
-                       if ( *s == '"' ) {
-                               inquote = 1;
-                       } else if ( LDAP_DNSEPARATOR( *s ) ) {
-                               return( LDAP_STRDUP( &s[1] ) );
-                       }
-               }
-       }
-
-       return( LDAP_STRDUP( "" ) );
-}
-
-char * ldap_dn_relative( 
-    const char *dn )
-{
-       char    *s;
-       char    *rdn;
-       int     inquote;
-
-       if( dn == NULL ) {
-               return NULL;
-       }
-
-       while(*dn && LDAP_SPACE(*dn)) {
-               dn++;
-       }
-
-       if( *dn == '\0' ) {
-               return( NULL );
-       }
-
-       rdn = LDAP_STRDUP( dn );
-
-       if( rdn == NULL ) {
-               return NULL;
-       }
-
-       /*
-        * assume it is an X.500-style name, which looks like
-        * foo=bar,sha=baz,...
-        */
-
-       inquote = 0;
-
-       for ( s = rdn; *s; s++ ) {
-               if ( *s == '\\' ) {
-                       if ( *(s + 1) ) {
-                               s++;
-                       }
-                       continue;
-               }
-               if ( inquote ) {
-                       if ( *s == '"' ) {
-                               inquote = 0;
-                       }
-               } else {
-                       if ( *s == '"' ) {
-                               inquote = 1;
-                       } else if ( LDAP_DNSEPARATOR( *s ) ) {
-                               *s = '\0';
-                               return( rdn );
-                       }
-               }
-       }
-
-       return( rdn );
-}
-
-#endif
index 1d248d64d65aaaa9a5c609ed654c7bfad52ed9c5..42a535ec25e7dd168b35b7eadae677c6d9ca4abb 100644 (file)
@@ -18,8 +18,7 @@ XXSRCS        = apitest.c test.c extended.c \
        getdn.c getentry.c getattr.c getvalues.c addentry.c \
        request.c os-ip.c url.c sortctrl.c vlvctrl.c \
        init.c options.c print.c string.c util-int.c schema.c \
-       charray.c tls.c dn.c os-local.c dnssrv.c \
-       utf-8.c
+       charray.c tls.c os-local.c dnssrv.c utf-8.c utf-8-conv.c
 SRCS   = threads.c rdwr.c tpool.c \
        thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \
        thr_pth.c thr_stub.c
@@ -34,8 +33,7 @@ OBJS  = threads.lo rdwr.lo tpool.lo  \
        getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
        request.lo os-ip.lo url.lo sortctrl.lo vlvctrl.lo \
        init.lo options.lo print.lo string.lo util-int.lo schema.lo \
-       charray.lo tls.lo dn.lo os-local.lo dnssrv.lo \
-       utf-8.lo
+       charray.lo tls.lo os-local.lo dnssrv.lo utf-8.lo utf-8-conv.lo
 
 LDAP_INCDIR= ../../include       
 LDAP_LIBDIR= ../../libraries
index 17d742f4c0e9095e892fe4e51bb388d61bb053b9..13cfe7715ac6c9e1eefd35d410f4732aa7eb8e2f 100644 (file)
@@ -63,7 +63,7 @@ glue_back_select (
        bv.bv_val = (char *) dn;
 
        for (i = 0; i<gi->nodes; i++) {
-               if (dn_issuffixbv (&bv, gi->n[i].be->be_nsuffix[0])) {
+               if (dnIsSuffix(&bv, gi->n[i].be->be_nsuffix[0])) {
                        return gi->n[i].be;
                }
        }
@@ -334,14 +334,14 @@ glue_back_search (
                                        s2limit, t2limit, filter, filterstr,
                                                    attrs, attrsonly);
                        } else if (scope == LDAP_SCOPE_SUBTREE &&
-                               dn_issuffixbv (be->be_nsuffix[0], &bv)) {
+                               dnIsSuffix(be->be_nsuffix[0], &bv)) {
                                rc = be->be_search (be, conn, op,
                                                    be->be_suffix[0],
                                                    be->be_nsuffix[0]->bv_val,
                                                    scope, deref,
                                        s2limit, t2limit, filter, filterstr,
                                                    attrs, attrsonly);
-                       } else if (dn_issuffixbv (&bv, be->be_nsuffix[0])) {
+                       } else if (dnIsSuffix(&bv, be->be_nsuffix[0])) {
                                rc = be->be_search (be, conn, op,
                                                    dn, ndn, scope, deref,
                                        s2limit, t2limit, filter, filterstr,
@@ -797,7 +797,7 @@ glue_sub_init( )
                        /* We will only link it once */
                        if (be->be_glueflags & SLAP_GLUE_LINKED)
                                continue;
-                       if (!dn_issuffixbv(be->be_nsuffix[0],
+                       if (!dnIsSuffix(be->be_nsuffix[0],
                                b1->be_nsuffix[0]))
                                continue;
                        cont--;
index 1a7e19ee5ede12f549dd801cc565f7d538b615a8..806852172dc93eef3355a13ca89e0ea2a83aaa73 100644 (file)
@@ -418,7 +418,7 @@ dnPretty(
 }
 
 /*
- * dn match routine
+ * dnMatch routine
  *
  * note: uses exact string match (strcmp) because it is supposed to work
  * on normalized DNs.
@@ -472,6 +472,7 @@ dnMatch(
 /*
  * dn_validate - validate and compress dn.  the dn is
  * compressed in place are returned if valid.
+ * Deprecated in favor of dnValidate()
  */
 char *
 dn_validate( char *dn )
@@ -506,6 +507,7 @@ dn_validate( char *dn )
  * dn_normalize - put dn into a canonical form suitable for storing
  * in a hash database. this involves normalizing the case as well as
  * the format. the dn is normalized in place as well as returned if valid.
+ * Deprecated in favor of dnNormalize()
  */
 char *
 dn_normalize( char *dn )
@@ -673,48 +675,11 @@ char **dn_subtree(
        return subtree;
 }
 
-
-int
-dn_issuffixbv(
-       const struct berval *dn,
-       const struct berval *suffix
-)
-{
-       int     d = dn->bv_len - suffix->bv_len;
-
-       assert( dn );
-       assert( suffix );
-
-       /* empty suffix matches any dn */
-       if ( suffix->bv_len == 0 ) {
-               return 1;
-       }
-
-       /* suffix longer than dn */
-       if ( d < 0 ) {
-               return 0;
-       }
-
-       /* no rdn separator or escaped rdn separator */
-       if ( d > 1 && ( !DN_SEPARATOR( dn->bv_val[ d - 1 ] ) 
-                               || DN_ESCAPE( dn->bv_val[ d - 2 ] ) ) ) {
-               return 0;
-       }
-
-       /* no possible match or malformed dn */
-       if ( d == 1 ) {
-               return 0;
-       }
-
-       /* compare */
-       return( strcmp( dn->bv_val + d, suffix->bv_val ) == 0 );
-}
-
 /*
- * dn_issuffix - tells whether suffix is a suffix of dn. Both dn
- * and suffix must be normalized.
+ * dn_issuffix - tells whether suffix is a suffix of dn.
+ * Both dn and suffix must be normalized.
+ *     deprecated in favor of dnIsSuffix()
  */
-
 int
 dn_issuffix(
        const char      *dn,
@@ -731,7 +696,7 @@ dn_issuffix(
        bvsuffix.bv_val = (char *) suffix;
        bvsuffix.bv_len = strlen( suffix );
 
-       return dn_issuffixbv( &bvdn, &bvsuffix );
+       return dnIsSuffix( &bvdn, &bvsuffix );
 }
 
 /*
@@ -972,3 +937,42 @@ build_new_dn( char ** new_dn,
 }
 
 #endif /* SLAP_DN_MIGRATION */
+
+/*
+ * dnIsSuffix - tells whether suffix is a suffix of dn.
+ * Both dn and suffix must be normalized.
+ */
+int
+dnIsSuffix(
+       const struct berval *dn,
+       const struct berval *suffix )
+{
+       int     d = dn->bv_len - suffix->bv_len;
+
+       assert( dn );
+       assert( suffix );
+
+       /* empty suffix matches any dn */
+       if ( suffix->bv_len == 0 ) {
+               return 1;
+       }
+
+       /* suffix longer than dn */
+       if ( d < 0 ) {
+               return 0;
+       }
+
+       /* no rdn separator or escaped rdn separator */
+       if ( d > 1 && ( !DN_SEPARATOR( dn->bv_val[ d - 1 ] ) 
+                               || DN_ESCAPE( dn->bv_val[ d - 2 ] ) ) ) {
+               return 0;
+       }
+
+       /* no possible match or malformed dn */
+       if ( d == 1 ) {
+               return 0;
+       }
+
+       /* compare */
+       return( strcmp( dn->bv_val + d, suffix->bv_val ) == 0 );
+}
index e4adc641e9ecd39131ced6ab0a312132948eb0a1..1a24bdfc0043127499d985fdd0ecb2e18a3b5d02 100644 (file)
@@ -347,6 +347,9 @@ LDAP_SLAPD_F (int) dnMatch LDAP_P((
        struct berval *value, 
        void *assertedValue ));
 
+LDAP_SLAPD_F (int) dnIsSuffix LDAP_P((
+       const struct berval *dn, const struct berval *suffix ));
+
 #define SLAP_DN_MIGRATION
 #ifdef SLAP_DN_MIGRATION
 LDAP_SLAPD_F (char *) dn_validate LDAP_P(( char *dn ));
@@ -356,7 +359,6 @@ LDAP_SLAPD_F (char **) dn_subtree LDAP_P(( Backend *be, const char *dn ));
 LDAP_SLAPD_F (char *) dn_rdn LDAP_P(( Backend *be, const char *dn ));
 LDAP_SLAPD_F (int) dn_rdnlen LDAP_P(( Backend *be, const char *dn ));
 LDAP_SLAPD_F (int) dn_issuffix LDAP_P(( const char *dn, const char *suffix ));
-LDAP_SLAPD_F (int) dn_issuffixbv LDAP_P(( const struct berval *dn, const struct berval *suffix ));
 LDAP_SLAPD_F (int) rdn_validate LDAP_P(( const char* str ));
 LDAP_SLAPD_F (char *) rdn_attr_value LDAP_P(( const char * rdn ));
 LDAP_SLAPD_F (char *) rdn_attr_type LDAP_P(( const char * rdn ));