Commit be4ee975 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

improved LDIF handling

parent 1d51247c
......@@ -1500,13 +1500,17 @@ static void print_extended(
exit( EXIT_FAILURE );
}
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"extended", retoid, retoid ? strlen(retoid) : 0 );
if ( ldif < 2 ) {
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"extended", retoid, retoid ? strlen(retoid) : 0 );
}
ber_memfree( retoid );
if(retdata) {
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_BINARY,
"data", retdata->bv_val, retdata->bv_len );
if ( ldif < 2 ) {
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_BINARY,
"data", retdata->bv_val, retdata->bv_len );
}
ber_bvfree( retdata );
}
......@@ -1534,15 +1538,18 @@ static void print_partial(
exit( EXIT_FAILURE );
}
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"partial", retoid, retoid ? strlen(retoid) : 0 );
if ( ldif < 2 ) {
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"partial", retoid, retoid ? strlen(retoid) : 0 );
}
ber_memfree( retoid );
if( retdata ) {
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_BINARY,
"data",
retdata->bv_val, retdata->bv_len );
if ( ldif < 2 ) {
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_BINARY,
"data", retdata->bv_val, retdata->bv_len );
}
ber_bvfree( retdata );
}
......@@ -1641,8 +1648,9 @@ static void print_ctrls(
struct berval *b64 = NULL;
ber_len_t len;
char *str;
len = strlen( ctrls[i]->ldctl_oid );
len = ldif ? 2 : 0;
len += strlen( ctrls[i]->ldctl_oid );
/* add enough for space after OID and the critical value itself */
len += ctrls[i]->ldctl_iscritical
......@@ -1666,7 +1674,12 @@ static void print_ctrls(
}
str = malloc( len + 1 );
strcpy( str, ctrls[i]->ldctl_oid );
if ( ldif ) {
strcpy( str, ": " );
} else {
str[0] = '\0';
}
strcat( str, ctrls[i]->ldctl_oid );
strcat( str, ctrls[i]->ldctl_iscritical
? " true" : " false" );
......@@ -1675,8 +1688,10 @@ static void print_ctrls(
strcat(str, b64->bv_val );
}
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"control", str, len );
if ( ldif < 2 ) {
write_ldif( ldif ? LDIF_PUT_COMMENT : LDIF_PUT_VALUE,
"control", str, len );
}
free( str );
ber_bvfree( b64 );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment