]> git.sur5r.net Git - openldap/commitdiff
modify ldap_dn2ufn() to return completely typeless UFNs
authorKurt Zeilenga <kurt@openldap.org>
Sat, 16 Sep 2000 04:33:52 +0000 (04:33 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 16 Sep 2000 04:33:52 +0000 (04:33 +0000)
hide rest of UFN code behind #ifdef LDAP_UFN in preparation
for eventual removal.

clients/ud/find.c
include/ldap.h
libraries/libldap/getdn.c
libraries/libldap/test.c
libraries/libldap/ufn.c

index 9525c86b972ac44f2daa5623caad709eedf1d1d9..75166b85f28473eb1b718b1558812b243facebad 100644 (file)
@@ -199,6 +199,7 @@ find( char *who, int quiet )
                search_attrs[k] = NULL;
        }
 
+#if LDAP_UFN
        /*
         *  If the user-supplied name has any commas in it, we
         *  assume that it is a UFN, and do everything right
@@ -240,6 +241,7 @@ find( char *who, int quiet )
                }
                ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
        }
+#endif
 
        /*
         *  Old users of the MTS *USERDIRECTORY will likely wrap the name
index 5b4d611ac8d4c78ec8d305014d593ef81b55d9a3..4aa439fc757045e740646736bf340a080359c029 100644 (file)
@@ -1312,7 +1312,7 @@ ldap_search_st LDAP_P((   /* deprecated */
        struct timeval *timeout,
        LDAPMessage **res ));
 
-
+#ifdef LDAP_UFN
 /*
  * in ufn.c                                                    
  *     (deprecated)
@@ -1361,7 +1361,7 @@ ldap_ufn_setprefix LDAP_P(( /* deprecated */
 LDAP_F( int )
 ldap_ufn_timeout LDAP_P(( /* deprecated */
        void *tvparam ));
-
+#endif
 
 /*
  * in unbind.c
index 3ed841ab5eb22261622e7bc92fb2a908ab531923..3fe68f5466107aeab1045dcbe3099952ed9b541c 100644 (file)
@@ -54,88 +54,26 @@ ldap_get_dn( LDAP *ld, LDAPMessage *entry )
 char *
 ldap_dn2ufn( LDAP_CONST char *dn )
 {
-       char    *p, *ufn, *r;
-       int     state;
+       char    *ufn;
+       char    **vals;
 
        Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 );
 
+       /* produces completely untyped UFNs */
+
        if( dn == NULL ) {
                return NULL;
        }
 
-       if ( ( p = ldap_utf8_strpbrk( dn, "=" ) ) == NULL ) {
-               return( LDAP_STRDUP( dn ) );
+       vals = ldap_explode_dn( dn , 1 );
+       if( vals == NULL ) {
+               return NULL;
        }
-       ufn = LDAP_STRDUP( ++p );
-
-       if( ufn == NULL ) return NULL;
-
-#define INQUOTE                1
-#define OUTQUOTE       2
-       state = OUTQUOTE;
-       for ( p = ufn, r = ufn; *p; LDAP_UTF8_INCR(p) ) {
-               switch ( *p ) {
-               case '\\':
-                       if ( p[1] != '\0' ) {
-                               *r++ = '\\';
-                               LDAP_UTF8_COPY(r,++p);
-                               LDAP_UTF8_INCR(r);
-                       }
-                       break;
 
-               case '"':
-                       if ( state == INQUOTE )
-                               state = OUTQUOTE;
-                       else
-                               state = INQUOTE;
-                       *r++ = *p;
-                       break;
+       ufn = ldap_charray2str( vals, ", " );
 
-               case ';':
-               case ',':
-                       if ( state == OUTQUOTE )
-                               *r++ = ',';
-                       else
-                               *r++ = *p;
-                       break;
-
-               case '=':
-                       if ( state == INQUOTE ) {
-                               *r++ = *p;
-                       } else {
-                               char    *rsave = r;
-
-                               *r = '\0';
-                               LDAP_UTF8_DECR( r );
-
-                               while ( !ldap_utf8_isspace( r )
-                                       && *r != ';' && *r != ',' && r > ufn )
-                               {
-                                       LDAP_UTF8_DECR( r );
-                               }
-                               LDAP_UTF8_INCR( r );
-
-                               if ( strcasecmp( r, "c" )
-                                   && strcasecmp( r, "o" )
-                                   && strcasecmp( r, "ou" )
-                                   && strcasecmp( r, "st" )
-                                   && strcasecmp( r, "l" )
-                                   && strcasecmp( r, "cn" ) ) {
-                                       r = rsave;
-                                       *r++ = '=';
-                               }
-                       }
-                       break;
-
-               default:
-                       LDAP_UTF8_COPY(r, p);
-                       LDAP_UTF8_INCR(r);
-                       break;
-               }
-       }
-       *r = '\0';
-
-       return( ufn );
+       ldap_memvfree( vals );
+       return ufn;
 }
 
 char **
@@ -237,6 +175,9 @@ ldap_dcedn2dn( LDAP_CONST char *dce )
        return dn;
 }
 
+#define INQUOTE                1
+#define OUTQUOTE       2
+
 static char **
 explode_name( const char *name, int notypes, int is_type )
 {
index a64dfc6b45b17ea6867ea0f8a2eb22efda7a80f5..c4f0ba5dfec530f2423158ae07889894a9d2d619 100644 (file)
@@ -599,6 +599,7 @@ main( int argc, char **argv )
                        timeout.tv_sec = atoi( line );
                        break;
 
+#ifdef LDAP_UFN
                case 'U':       /* set ufn search prefix */
                        getline( line, sizeof(line), stdin, "ufn prefix? " );
                        ldap_ufn_setprefix( ld, line );
@@ -629,6 +630,7 @@ main( int argc, char **argv )
                        }
                        free_list( types );
                        break;
+#endif
 
                case 'l':       /* URL search */
                        getline( line, sizeof(line), stdin,
@@ -765,12 +767,14 @@ main( int argc, char **argv )
     printf( "          [B]ind async  [c]ompare         [l]URL search\n" );
     printf( "          [modi]fy      [modr]dn          [rem]ove\n" );
     printf( "          [res]ult      [s]earch          [q]uit/unbind\n\n" );
-    printf( "          [u]fn search  [ut]fn search with timeout\n" );
+#ifdef LDAP_UFN
+    printf( "          [u]fn search  [ut]fn search with timeout [U]fn prefix\n" );
+#endif
     printf( "          [d]ebug       [e]nable cache    set ms[g]id\n" );
     printf( "          d[n]suffix    [t]imeout         [v]ersion\n" );
-    printf( "          [U]fn prefix  [x]uncache entry  [X]uncache request\n" );
     printf( "          [?]help       [o]ptions         [O]cache options\n" );
     printf( "          [E]xplode dn  [p]arse LDAP URL\n" );
+    printf( "          [x]uncache entry  [X]uncache request\n" );
                        break;
 
                default:
index ec79348fec07bafe4a57ec13f923f5deb2e0862d..343c3ba184e4a08289ff6915abbacfeb4f2677b6 100644 (file)
@@ -12,6 +12,8 @@
 
 #include "portable.h"
 
+#ifdef LDAP_UFN
+
 #include <stdio.h>
 
 #include <ac/stdlib.h>
@@ -496,3 +498,5 @@ ldap_ufn_timeout( void *tvparam )
 
        return( tv->tv_usec <= 0 ? 1 : 0 );
 }
+
+#endif
\ No newline at end of file