From: Pierangelo Masarati Date: Thu, 21 Nov 2002 22:13:07 +0000 (+0000) Subject: enforce the declared behavior when using -L[L[L]] X-Git-Tag: NO_SLAP_OP_BLOCKS~781 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e8439a9276d19c54787ca61efe54c5934ca7754b;p=openldap enforce the declared behavior when using -L[L[L]] --- diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 9c9a8224a3..0c8f1126cf 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -1740,13 +1740,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 ); } @@ -1774,15 +1778,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 ); } @@ -1881,8 +1888,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 @@ -1906,7 +1914,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" ); @@ -1915,8 +1928,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 );