Back to index

openldap  2.4.31
Functions
slapdn.c File Reference
#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"

Go to the source code of this file.

Functions

int slapdn (int argc, char **argv)

Function Documentation

int slapdn ( int  argc,
char **  argv 
)

Definition at line 39 of file slapdn.c.

{
       int                  rc = 0;
       const char           *progname = "slapdn";

       slap_tool_init( progname, SLAPDN, argc, argv );

       argv = &argv[ optind ];
       argc -= optind;

       for ( ; argc--; argv++ ) {
              struct berval dn,
                            pdn = BER_BVNULL,
                            ndn = BER_BVNULL;

              ber_str2bv( argv[ 0 ], 0, 0, &dn );

              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,
                                   ldap_err2string( rc ) );
                     if ( !continuemode ) {
                            rc = -1;
                            break;
                     }
                     
              } else {
                     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 );
              }
       }
       
       if ( slap_tool_destroy())
              rc = EXIT_FAILURE;

       return rc;
}

Here is the call graph for this function: