size_t len = 0, i = 0;
char *v2;
- if(ref == NULL)
- {
+ if(ref == NULL) {
if (text)
return ch_strdup(text);
else
if (text) {
len = strlen( text );
- if (text[len-1] != '\n')
+ if (text[len-1] != '\n') {
i = 1;
+ }
}
v2 = ch_malloc( len+i+sizeof("Referral:") );
if (text) {
strcpy(v2, text);
- if (i)
+ if (i) {
v2[len++] = '\n';
+ }
}
strcpy( v2+len, "Referral:" );
len += sizeof("Referral:");
v2[len-1] = '\n';
AC_MEMCPY(&v2[len], ref[i]->bv_val, ref[i]->bv_len );
len += ref[i]->bv_len;
- if (ref[i]->bv_val[ref[i]->bv_len-1] != '/')
+ if (ref[i]->bv_val[ref[i]->bv_len-1] != '/') {
++len;
+ }
}
v2[len-1] = '\0';
return;
}
- {
- rc = ber_printf( ber, "{it{ess",
- msgid, tag, err,
- matched == NULL ? "" : matched,
- text == NULL ? "" : text );
-
- if( rc != -1 ) {
- if ( ref != NULL ) {
- assert( err == LDAP_REFERRAL );
- rc = ber_printf( ber, "t{V}",
- LDAP_TAG_REFERRAL, ref );
- } else {
- assert( err != LDAP_REFERRAL );
- }
- }
+ rc = ber_printf( ber, "{it{ess",
+ msgid, tag, err,
+ matched == NULL ? "" : matched,
+ text == NULL ? "" : text );
- if( rc != -1 && sasldata != NULL ) {
- rc = ber_printf( ber, "tO",
- LDAP_TAG_SASL_RES_CREDS, sasldata );
+ if( rc != -1 ) {
+ if ( ref != NULL ) {
+ assert( err == LDAP_REFERRAL );
+ rc = ber_printf( ber, "t{V}",
+ LDAP_TAG_REFERRAL, ref );
+ } else {
+ assert( err != LDAP_REFERRAL );
}
+ }
- if( rc != -1 && resoid != NULL ) {
- rc = ber_printf( ber, "ts",
- LDAP_TAG_EXOP_RES_OID, resoid );
- }
+ if( rc != -1 && sasldata != NULL ) {
+ rc = ber_printf( ber, "tO",
+ LDAP_TAG_SASL_RES_CREDS, sasldata );
+ }
- if( rc != -1 && resdata != NULL ) {
- rc = ber_printf( ber, "tO",
- LDAP_TAG_EXOP_RES_VALUE, resdata );
- }
+ if( rc != -1 && resoid != NULL ) {
+ rc = ber_printf( ber, "ts",
+ LDAP_TAG_EXOP_RES_OID, resoid );
+ }
- if( rc != -1 ) {
- rc = ber_printf( ber, "N}N}" );
- }
+ if( rc != -1 && resdata != NULL ) {
+ rc = ber_printf( ber, "tO",
+ LDAP_TAG_EXOP_RES_VALUE, resdata );
+ }
+
+ if( rc != -1 ) {
+ rc = ber_printf( ber, "N}N}" );
}
if ( rc == -1 ) {
(long) op->o_connid, (long) op->o_opid, op->o_protocol );
Debug( LDAP_DEBUG_ARGS, "send_ldap_result: %d:%s:%s\n",
err, matched ? matched : "", text ? text : "" );
+
if( ref ) {
- Debug( LDAP_DEBUG_ARGS, "send_ldap_result: referral: %s\n",
- ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL",
- NULL, NULL );
+ Debug( LDAP_DEBUG_ARGS, "send_ldap_result: referral: %s\n",
+ ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL",
+ NULL, NULL );
}
assert( err != LDAP_PARTIAL_RESULTS );
tmp = v2ref( refs, text );
text = tmp;
refs = NULL;
+
} else {
/* don't send references in search results */
assert( refs == NULL );
(long) op->o_connid, (long) op->o_opid,
(long) tag, (long) err, text ? text : "" );
- if (tmp != NULL)
+ if (tmp != NULL) {
ch_free(tmp);
+ }
}
if ( attrs == NULL ) {
/* all addrs request, skip operational attributes */
- if( is_at_operational( desc->ad_type ) )
- {
+ if( is_at_operational( desc->ad_type ) ) {
continue;
}
} else {
/* specific addrs requested */
- if ( is_at_operational( desc->ad_type ) )
- {
+ if ( is_at_operational( desc->ad_type ) ) {
if( !opattrs && !ad_inlist( desc, attrs ) ) {
continue;
}
+
} else {
if (!userattrs && !ad_inlist( desc, attrs ) ) {
continue;
} else {
/* specific addrs requested */
if( is_at_operational( desc->ad_type ) ) {
- if( !opattrs && !ad_inlist( desc, attrs ) )
- {
+ if( !opattrs && !ad_inlist( desc, attrs ) ) {
continue;
}
} else {