]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/dntest.c
according to sasl documentation, prompts is filled only if SASL_INTERACT is returned
[openldap] / libraries / libldap / dntest.c
index 913cb55f50f2ff0737cb02715216685a0d56614e..31342a5bae65ccc82db194efe31272117c5266a4 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
  */
 #include "portable.h"
 
+#include <stdio.h>
+
 #include <ac/stdlib.h>
 #include <ac/string.h>
 #include <ac/unistd.h>
 
-#include <stdio.h>
-
 #include <ldap.h>
 
 #include "ldap-int.h"
@@ -31,7 +31,7 @@ int
 main( int argc, char *argv[] )
 {
        int             rc, i, debug = 0, f2 = 0;
-       unsigned        flags[ 2 ] = { 0U, LDAP_DN_FORMAT_LDAPV3 };
+       unsigned        flags[ 2 ] = { 0U, 0 };
        char            *strin, *str = NULL, buf[ 1024 ];
        LDAPDN          *dn, *dn2 = NULL;
 
@@ -72,8 +72,8 @@ main( int argc, char *argv[] )
                size_t len;
                
                fgets( buf, sizeof( buf ), stdin );
-               len = strlen( buf ) - 1;
-               if ( len >= 0 && buf[ len ] == '\n' ) {
+               len = strlen( buf );
+               if ( len > 0 && buf[ --len ] == '\n' ) {
                        buf[ len ] = '\0';
                }
                strin = buf;
@@ -114,6 +114,9 @@ main( int argc, char *argv[] )
                }
        }
 
+       if ( flags[ 1 ] == 0 )
+               flags[ 1 ] = LDAP_DN_FORMAT_LDAPV3;
+
        f2 = 1;
 
        rc = ldap_str2dn( strin, &dn, flags[ 0 ] );
@@ -155,6 +158,15 @@ main( int argc, char *argv[] )
 
                case LDAP_DN_FORMAT_LDAPV3:
                case LDAP_DN_FORMAT_LDAPV2:
+                       n = ldap_dn2domain( strin, &tmp );
+                       if( n ) {
+                               fprintf( stdout, "\nldap_dn2domain(\"%s\") FAILED\n", strin );
+                       } else {
+                               fprintf( stdout, "\nldap_dn2domain(\"%s\")\n"
+                                       "\t= \"%s\"\n", strin, tmp );
+                       }
+                       ldap_memfree( tmp );
+
                        tmp = ldap_dn2ufn( strin );
                        fprintf( stdout, "\nldap_dn2ufn(\"%s\")\n"
                                        "\t= \"%s\"\n", strin, tmp );
@@ -240,7 +252,7 @@ main( int argc, char *argv[] )
                                        LDAPAVA         *a2 = r2[ 0 ][ iAVA ];
 
                                        if ( a->la_attr.bv_len != a2->la_attr.bv_len ) {
-                                               fprintf( stdout, "ava(%d), rdn(%d) attr len mismatch (%d->%d)\n", 
+                                               fprintf( stdout, "ava(%d), rdn(%d) attr len mismatch (%ld->%ld)\n", 
                                                                iAVA + 1, iRDN + 1,
                                                                a->la_attr.bv_len, a2->la_attr.bv_len );
                                        } else if ( memcmp( a->la_attr.bv_val, a2->la_attr.bv_val, a->la_attr.bv_len ) ) {
@@ -250,7 +262,7 @@ main( int argc, char *argv[] )
                                                fprintf( stdout, "ava(%d), rdn(%d) flag mismatch (%x->%x)\n", 
                                                                iAVA + 1, iRDN + 1, a->la_flags, a2->la_flags );
                                        } else if ( a->la_value.bv_len != a2->la_value.bv_len ) {
-                                               fprintf( stdout, "ava(%d), rdn(%d) value len mismatch (%d->%d)\n", 
+                                               fprintf( stdout, "ava(%d), rdn(%d) value len mismatch (%ld->%ld)\n", 
                                                                iAVA + 1, iRDN + 1, 
                                                                a->la_value.bv_len, a2->la_value.bv_len );
                                        } else if ( memcmp( a->la_value.bv_val, a2->la_value.bv_val, a->la_value.bv_len ) ) {