/* $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"
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;
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;
}
}
+ if ( flags[ 1 ] == 0 )
+ flags[ 1 ] = LDAP_DN_FORMAT_LDAPV3;
+
f2 = 1;
rc = ldap_str2dn( strin, &dn, flags[ 0 ] );
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 );
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 ) ) {
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 ) ) {