openldap/servers/slapd/slapdn.c

79 lines
1.6 KiB
C
Raw Normal View History

2004-03-18 07:25:09 +08:00
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
2005-01-02 04:49:32 +08:00
* Copyright 2004-2005 The OpenLDAP Foundation.
2004-03-18 07:25:09 +08:00
* Portions Copyright 2004 Pierangelo Masarati.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* ACKNOWLEDGEMENTS:
* This work was initially developed by Pierangelo Masarati for inclusion
* in OpenLDAP Software.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/socket.h>
#include <ac/unistd.h>
#include <lber.h>
#include <ldif.h>
#include <lutil.h>
#include "slapcommon.h"
int
slapdn( int argc, char **argv )
{
2004-04-26 08:17:58 +08:00
int rc = 0;
2004-03-18 07:25:09 +08:00
const char *progname = "slapdn";
slap_tool_init( progname, SLAPDN, argc, argv );
argv = &argv[ optind ];
argc -= optind;
for ( ; argc--; argv++ ) {
struct berval dn, pdn, ndn;
2004-04-14 01:18:03 +08:00
ber_str2bv( argv[ 0 ], 0, 0, &dn );
2004-03-18 07:25:09 +08:00
rc = dnPrettyNormal( NULL, &dn,
&pdn, &ndn, NULL );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "DN: <%s> check failed %d (%s)\n",
dn.bv_val, rc,
ldap_err2string( rc ) );
2004-04-26 08:17:58 +08:00
if ( !continuemode ) {
rc = -1;
break;
}
2004-03-18 07:25:09 +08:00
} else {
fprintf( stderr, "DN: <%s> check succeeded\n"
"normalized: <%s>\n"
"pretty: <%s>\n",
dn.bv_val,
ndn.bv_val, pdn.bv_val );
ch_free( ndn.bv_val );
ch_free( pdn.bv_val );
}
}
slap_tool_destroy();
return rc;
}