* and pretty if appropriate
*/
for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) {
- struct berval *pval;
+ struct berval *pval = NULL;
if( pretty ) {
rc = pretty( ad->ad_type->sat_syntax,
ml->ml_bvalues[nvals], &pval );
break;
}
- /* make sure the DN is valid */
- if( dn_normalize( e->e_ndn ) == NULL || e->e_ndn[0] == '\0' ) {
- fprintf( stderr, "%s: invalid dn=\"%s\" (line=%d)\n",
- progname, e->e_dn, lineno );
- rc = EXIT_FAILURE;
- entry_free( e );
- if( continuemode ) continue;
- break;
- }
-
/* make sure the DN is not empty */
- if( e->e_ndn == '\0' ) {
+ if( !e->e_nname.bv_len ) {
fprintf( stderr, "%s: empty dn=\"%s\" (line=%d)\n",
progname, e->e_dn, lineno );
rc = EXIT_FAILURE;
int argc, char **argv )
{
char *options;
- char *base = NULL;
+ struct berval base = { 0, NULL };
int rc, i, dbnum;
int mode = SLAP_TOOL_MODE;
while ( (i = getopt( argc, argv, options )) != EOF ) {
switch ( i ) {
case 'b':
- base = strdup( optarg );
+ base.bv_val = strdup( optarg );
+ base.bv_len = strlen( optarg );
case 'c': /* enable continue mode */
continuemode++;
}
}
- if ( ( argc != optind ) || (dbnum >= 0 && base != NULL ) ) {
+ if ( ( argc != optind ) || (dbnum >= 0 && base.bv_val != NULL ) ) {
usage( tool );
}
exit( EXIT_FAILURE );
}
- if( base != NULL ) {
- char *tbase = ch_strdup( base );
+ if( base.bv_val != NULL ) {
+ struct berval *nbase = NULL;
- if( dn_normalize( tbase ) == NULL ) {
+ rc = dnNormalize( NULL, &base, &nbase );
+ if( rc != LDAP_SUCCESS ) {
fprintf( stderr, "%s: slap_init invalid suffix (\"%s\")\n",
progname, base );
exit( EXIT_FAILURE );
}
- be = select_backend( tbase, 0, 0 );
- free( tbase );
+ be = select_backend( nbase->bv_val, 0, 0 );
+ ber_bvfree( nbase );
if( be == NULL ) {
fprintf( stderr, "%s: slap_init no backend for \"%s\"\n",