]> git.sur5r.net Git - openldap/commitdiff
More for ITS#6645
authorQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 20:43:06 +0000 (20:43 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 20:43:06 +0000 (20:43 +0000)
clients/tools/common.c
clients/tools/common.h
doc/devel/args
libraries/liblutil/ldif.c

index bd6df553288b37207f7129833c27f70c63486b52..b191fa3935e4a04502d943c16c4d1750ec643a72 100644 (file)
@@ -66,6 +66,7 @@ int           nocanon = 0;
 int            referrals = 0;
 int            verbose = 0;
 int            ldif = 0;
+ber_len_t      ldif_wrap = LDIF_LINE_WIDTH;
 char           *prog = NULL;
 
 /* connection */
@@ -311,6 +312,7 @@ N_("  -N         do not use reverse DNS to canonicalize SASL host name\n"),
 N_("  -O props   SASL security properties\n"),
 N_("  -o <opt>[=<optparam] general options\n"),
 N_("             nettimeout=<timeout> (in seconds, or \"none\" or \"max\")\n"),
+N_("             ldif-wrap=<width> (in columns, or \"no\" for no wrapping)\n"),
 N_("  -p port    port on LDAP server\n"),
 N_("  -Q         use SASL Quiet mode\n"),
 N_("  -R realm   SASL realm\n"),
@@ -751,11 +753,30 @@ tool_args( int argc, char **argv )
                                                prog, (long)nettimeout.tv_sec );
                                        exit( EXIT_FAILURE );
                                }
+
+                       } else if ( strcasecmp( control, "ldif-wrap" ) == 0 ) {
+                               if ( cvalue == 0 ) {
+                                       ldif_wrap = LDIF_LINE_WIDTH;
+
+                               } else if ( strcasecmp( cvalue, "no" ) == 0 ) {
+                                       ldif_wrap = LDIF_LINE_WIDTH_MAX;
+
+                               } else {
+                                       unsigned int u;
+                                       if ( lutil_atou( &u, cvalue ) ) {
+                                               fprintf( stderr,
+                                                       _("Unable to parse ldif-wrap=\"%s\"\n"), cvalue );
+                                               exit( EXIT_FAILURE );
+                                       }
+                                       ldif_wrap = (ber_len_t)u;
+                               }
+
                        } else {
                                fprintf( stderr, "Invalid general option name: %s\n",
                                        control );
                                usage();
                        }
+                       ber_memfree(control);
                        break;
                case 'O':
 #ifdef HAVE_CYRUS_SASL
@@ -2249,7 +2270,7 @@ tool_write_ldif( int type, char *name, char *value, ber_len_t vallen )
 {
        char    *ldif;
 
-       if (( ldif = ldif_put( type, name, value, vallen )) == NULL ) {
+       if (( ldif = ldif_put_wrap( type, name, value, vallen, ldif_wrap )) == NULL ) {
                return( -1 );
        }
 
index 257f520522b9e83b006d3bfabf37837d9fe53cfe..f1105542fd0ab3c68311a43e5d5d64958e4b29ba 100644 (file)
@@ -55,6 +55,7 @@ extern int            dont;
 extern int             referrals;
 extern int             verbose;
 extern int             ldif;
+extern ber_len_t       ldif_wrap;
 extern char            *prog;
 
 /* connection */
index 271eed951c6f8d0ee4c5f7688ebf7b69b436e0f5..7805eff1c9444d6fb5d85cd2458a4eb96cb00760 100644 (file)
@@ -27,7 +27,7 @@ ldapwhoami       * DE**HI**  NO QR  UVWXYZ   def*h*** *nop*    vwxy
        -h host
        -n no-op
        -N no (SASLprep) normalization of simple bind password
-       -o general connection options (currently nettimeout only)
+       -o general options (currently nettimeout and ldif-wrap only)
        -p port
        -v verbose
        -V version
index c0801991514c79fe1b187416ae18506147a584bf..7f009245fc4ea50f83e230c6ab3a26fdd9c4717d 100644 (file)
@@ -742,7 +742,7 @@ ldif_put_wrap(
     }
 
     p = buf;
-    ldif_sput( &p, type, name, val, vlen );
+    ldif_sput_wrap( &p, type, name, val, vlen, wrap );
     *p = '\0';
 
     return( buf );