]> git.sur5r.net Git - openldap/commitdiff
allow slapdn to return the DN in pretty/normal only mode, without diagnostics, to...
authorPierangelo Masarati <ando@openldap.org>
Fri, 1 Apr 2005 12:59:26 +0000 (12:59 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 1 Apr 2005 12:59:26 +0000 (12:59 +0000)
servers/slapd/slapcommon.c
servers/slapd/slapcommon.h
servers/slapd/slapdn.c

index 1306b884111caaa2a7f83c72c5b5bcb60f269399..e3f94152f3df51233e28f6406d3e794a7c2d6558 100644 (file)
@@ -74,7 +74,7 @@ usage( int tool, const char *progname )
                break;
 
        case SLAPDN:
-               options = " DN [...]\n";
+               options = "\n\t[-N | -P] DN [...]\n";
                break;
 
        case SLAPINDEX:
@@ -194,7 +194,7 @@ slap_tool_init(
                break;
 
        case SLAPDN:
-               options = "d:f:F:v";
+               options = "d:f:F:NPv";
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
                break;
 
@@ -262,6 +262,13 @@ slap_tool_init(
                        ber_str2bv( optarg, 0, 0, &mech );
                        break;
 
+               case 'N':
+                       if ( dn_mode && dn_mode != SLAP_TOOL_LDAPDN_NORMAL ) {
+                               usage( tool, progname );
+                       }
+                       dn_mode = SLAP_TOOL_LDAPDN_NORMAL;
+                       break;
+
                case 'n':       /* which config file db to index */
                        dbnum = atoi( optarg );
                        break;
@@ -272,6 +279,13 @@ slap_tool_init(
                        }
                        break;
 
+               case 'P':
+                       if ( dn_mode && dn_mode != SLAP_TOOL_LDAPDN_PRETTY ) {
+                               usage( tool, progname );
+                       }
+                       dn_mode = SLAP_TOOL_LDAPDN_PRETTY;
+                       break;
+
                case 'q':       /* turn on quick */
                        mode |= SLAP_TOOL_QUICK;
                        break;
index e3def431a5bc83fbc4386727886e0006e31f822c..423f0fbd87974357b432cae6bcd8ee11d8e11392 100644 (file)
@@ -56,6 +56,7 @@ typedef struct tool_vars {
        slap_ssf_t tv_transport_ssf;
        slap_ssf_t tv_tls_ssf;
        slap_ssf_t tv_sasl_ssf;
+       unsigned tv_dn_mode;
 } tool_vars;
 
 extern tool_vars tool_globals;
@@ -83,6 +84,9 @@ extern tool_vars tool_globals;
 #define transport_ssf tool_globals.tv_transport_ssf
 #define tls_ssf tool_globals.tv_tls_ssf
 #define sasl_ssf tool_globals.tv_sasl_ssf
+#define dn_mode tool_globals.tv_dn_mode
+#define SLAP_TOOL_LDAPDN_PRETTY                SLAP_LDAPDN_PRETTY
+#define SLAP_TOOL_LDAPDN_NORMAL                (SLAP_LDAPDN_PRETTY << 1)
 
 void slap_tool_init LDAP_P((
        const char* name,
index 400d5071db5b2bfb6fe81c441654cf749ac4c26d..0119e7fab595d4cf500938204fcb1ea57db3e378 100644 (file)
@@ -62,11 +62,24 @@ slapdn( int argc, char **argv )
                        }
                        
                } 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 );
                }