syslog\-level=<level> (see `\-S' in slapd(8))
syslog\-user=<user> (see `\-l' in slapd(8))
-.fi
+ ldif-wrap={no|<n>}
+
+.in
+\fIn\fP is the number of columns allowed for the LDIF output
+(\fIn\fP equal to \fI0\fP uses the default, corresponding to 76).
+Use \fIno\fP for no wrap.
.TP
.BI \-s \ subtree-dn
Only dump entries in the subtree specified by this DN.
/* This is NOT a bogus extern declaration (unlike ldap_debug) */
LDAP_LDIF_V (int) ldif_debug;
-#define LDIF_LINE_WIDTH 76 /* maximum length of LDIF lines */
+#define LDIF_LINE_WIDTH 76 /* default maximum length of LDIF lines */
+#define LDIF_LINE_WIDTH_MAX ((ber_len_t)-1) /* maximum length of LDIF lines */
+#define LDIF_LINE_WIDTH_WRAP(wrap) ((wrap) == 0 ? LDIF_LINE_WIDTH : (wrap))
/*
* Macro to calculate maximum number of bytes that the base64 equivalent
((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / LDIF_LINE_WIDTH * 2 ))
+#define LDIF_SIZE_NEEDED_WRAP(nlen,vlen,wrap) \
+ ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ + ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH ) * 2 ) : \
+ ((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap) * 2 ))))
+
LDAP_LDIF_F( int )
ldif_parse_line LDAP_P((
LDAP_CONST char *line,
LDAP_CONST char *val,
ber_len_t vlen ));
+LDAP_LDIF_F( void )
+ldif_sput_wrap LDAP_P((
+ char **out,
+ int type,
+ LDAP_CONST char *name,
+ LDAP_CONST char *val,
+ ber_len_t vlen,
+ ber_len_t wrap ));
+
LDAP_LDIF_F( char * )
ldif_put LDAP_P((
int type,
LDAP_CONST char *val,
ber_len_t vlen ));
+LDAP_LDIF_F( char * )
+ldif_put_wrap LDAP_P((
+ int type,
+ LDAP_CONST char *name,
+ LDAP_CONST char *val,
+ ber_len_t vlen,
+ ber_len_t wrap ));
+
LDAP_LDIF_F( int )
ldif_is_not_printable LDAP_P((
LDAP_CONST char *val,
/* compatibility with U-Mich off by one bug */
#define LDIF_KLUDGE 1
+/* NOTE: only preserved for binary compatibility */
void
ldif_sput(
char **out,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen )
+{
+ ldif_sput_wrap( out, type, name, val, vlen, LDIF_LINE_WIDTH );
+}
+
+void
+ldif_sput_wrap(
+ char **out,
+ int type,
+ LDAP_CONST char *name,
+ LDAP_CONST char *val,
+ ber_len_t vlen,
+ ber_len_t wrap )
{
const unsigned char *byte, *stop;
unsigned char buf[3];
ber_len_t len=0;
ber_len_t i;
+ wrap = LDIF_LINE_WIDTH_WRAP( wrap );
+
/* prefix */
switch( type ) {
case LDIF_PUT_COMMENT:
case LDIF_PUT_COMMENT:
/* pre-encoded names */
for ( i=0; i < vlen; i++ ) {
- if ( len > LDIF_LINE_WIDTH ) {
+ if ( len > wrap ) {
*(*out)++ = '\n';
*(*out)++ = ' ';
len = 1;
b64 = 1;
break;
}
- if ( len > LDIF_LINE_WIDTH+LDIF_KLUDGE ) {
+ if ( len - LDIF_KLUDGE > wrap ) {
*(*out)++ = '\n';
*(*out)++ = ' ';
len = 1;
bits |= (byte[2] & 0xff);
for ( i = 0; i < 4; i++, len++, bits <<= 6 ) {
- if ( len > LDIF_LINE_WIDTH+LDIF_KLUDGE ) {
+ if ( len - LDIF_KLUDGE > wrap ) {
*(*out)++ = '\n';
*(*out)++ = ' ';
len = 1;
bits |= (byte[2] & 0xff);
for ( i = 0; i < 4; i++, len++, bits <<= 6 ) {
- if ( len > LDIF_LINE_WIDTH+LDIF_KLUDGE ) {
+ if ( len - LDIF_KLUDGE > wrap ) {
*(*out)++ = '\n';
*(*out)++ = ' ';
len = 1;
/*
* ldif_type_and_value return BER malloc'd, zero-terminated LDIF line
*/
+
+/* NOTE: only preserved for binary compatibility */
char *
ldif_put(
int type,
LDAP_CONST char *name,
LDAP_CONST char *val,
ber_len_t vlen )
+{
+ return ldif_put_wrap( type, name, val, vlen, LDIF_LINE_WIDTH );
+}
+
+char *
+ldif_put_wrap(
+ int type,
+ LDAP_CONST char *name,
+ LDAP_CONST char *val,
+ ber_len_t vlen,
+ ber_len_t wrap )
{
char *buf, *p;
ber_len_t nlen;
nlen = ( name != NULL ) ? strlen( name ) : 0;
- buf = (char *) ber_memalloc( LDIF_SIZE_NEEDED( nlen, vlen ) + 1 );
+ buf = (char *) ber_memalloc( LDIF_SIZE_NEEDED_WRAP( nlen, vlen, wrap ) + 1 );
if ( buf == NULL ) {
ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
} \
}
+/* NOTE: only preserved for binary compatibility */
char *
entry2str(
Entry *e,
int *len )
+{
+ return entry2str_wrap( e, len, LDIF_LINE_WIDTH );
+}
+
+char *
+entry2str_wrap(
+ Entry *e,
+ int *len,
+ ber_len_t wrap )
{
Attribute *a;
struct berval *bv;
/* put "dn: <dn>" */
tmplen = e->e_name.bv_len;
MAKE_SPACE( LDIF_SIZE_NEEDED( 2, tmplen ));
- ldif_sput( &ecur, LDIF_PUT_VALUE, "dn", e->e_dn, tmplen );
+ ldif_sput_wrap( &ecur, LDIF_PUT_VALUE, "dn", e->e_dn, tmplen, wrap );
}
/* put the attributes */
bv = &a->a_vals[i];
tmplen = a->a_desc->ad_cname.bv_len;
MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len ));
- ldif_sput( &ecur, LDIF_PUT_VALUE,
+ ldif_sput_wrap( &ecur, LDIF_PUT_VALUE,
a->a_desc->ad_cname.bv_val,
- bv->bv_val, bv->bv_len );
+ bv->bv_val, bv->bv_len, wrap );
}
}
MAKE_SPACE( 1 );
LDAP_SLAPD_F (Entry *) str2entry LDAP_P(( char *s ));
LDAP_SLAPD_F (Entry *) str2entry2 LDAP_P(( char *s, int checkvals ));
LDAP_SLAPD_F (char *) entry2str LDAP_P(( Entry *e, int *len ));
+LDAP_SLAPD_F (char *) entry2str_wrap LDAP_P(( Entry *e, int *len, ber_len_t wrap ));
LDAP_SLAPD_F (ber_len_t) entry_flatsize LDAP_P(( Entry *e, int norm ));
LDAP_SLAPD_F (void) entry_partsize LDAP_P(( Entry *e, ber_len_t *len,
printf( "# id=%08lx\n", (long) id );
}
- data = entry2str( e, &len );
+ data = entry2str_wrap( e, &len, ldif_wrap );
be_entry_release_r( &op, e );
if ( data == NULL ) {
break;
}
+ } else if ( strncasecmp( optarg, "ldif-wrap", len ) == 0 ) {
+ switch ( tool ) {
+ case SLAPCAT:
+ if ( strcasecmp( p, "no" ) == 0 ) {
+ ldif_wrap = LDIF_LINE_WIDTH_MAX;
+
+ } else if ( lutil_atou( &ldif_wrap, p ) ) {
+ Debug( LDAP_DEBUG_ANY, "unable to parse ldif-wrap=\"%s\".\n", p, 0, 0 );
+ return -1;
+ }
+ break;
+
+ default:
+ Debug( LDAP_DEBUG_ANY, "value-check meaningless for tool.\n", 0, 0, 0 );
+ break;
+ }
+
} else {
return -1;
}
leakfilename = NULL;
#endif
+ ldif_wrap = LDIF_LINE_WIDTH;
+
scope = LDAP_SCOPE_DEFAULT;
switch( tool ) {
slap_ssf_t tv_sasl_ssf;
unsigned tv_dn_mode;
unsigned int tv_csnsid;
+ ber_len_t tv_ldif_wrap;
} tool_vars;
extern tool_vars tool_globals;
#define sasl_ssf tool_globals.tv_sasl_ssf
#define dn_mode tool_globals.tv_dn_mode
#define csnsid tool_globals.tv_csnsid
+#define ldif_wrap tool_globals.tv_ldif_wrap
+
#define SLAP_TOOL_LDAPDN_PRETTY SLAP_LDAPDN_PRETTY
#define SLAP_TOOL_LDAPDN_NORMAL (SLAP_LDAPDN_PRETTY << 1)