/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2004-2005 The OpenLDAP Foundation.
+ * Copyright 2004-2008 The OpenLDAP Foundation.
* Portions Copyright 2004 Pierangelo Masarati.
* All rights reserved.
*
argc -= optind;
for ( ; argc--; argv++ ) {
- struct berval dn, pdn, ndn;
+ struct berval dn,
+ pdn = BER_BVNULL,
+ ndn = BER_BVNULL;
ber_str2bv( argv[ 0 ], 0, 0, &dn );
- rc = dnPrettyNormal( NULL, &dn,
- &pdn, &ndn, NULL );
+ switch ( dn_mode ) {
+ case SLAP_TOOL_LDAPDN_PRETTY:
+ rc = dnPretty( NULL, &dn, &pdn, NULL );
+ break;
+
+ case SLAP_TOOL_LDAPDN_NORMAL:
+ rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
+ break;
+
+ default:
+ rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL );
+ break;
+ }
+
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "DN: <%s> check failed %d (%s)\n",
dn.bv_val, rc,
}
} else {
- fprintf( stderr, "DN: <%s> check succeeded\n"
- "normalized: <%s>\n"
- "pretty: <%s>\n",
- dn.bv_val,
- ndn.bv_val, pdn.bv_val );
+ switch ( dn_mode ) {
+ case SLAP_TOOL_LDAPDN_PRETTY:
+ printf( "%s\n", pdn.bv_val );
+ break;
+
+ case SLAP_TOOL_LDAPDN_NORMAL:
+ printf( "%s\n", ndn.bv_val );
+ break;
+
+ default:
+ printf( "DN: <%s> check succeeded\n"
+ "normalized: <%s>\n"
+ "pretty: <%s>\n",
+ dn.bv_val,
+ ndn.bv_val, pdn.bv_val );
+ break;
+ }
+
ch_free( ndn.bv_val );
ch_free( pdn.bv_val );
}