+ ber_tag_t tag;
+ ber_int_t msgid;
+ char *tmp = NULL;
+
+ assert( !LDAP_API_ERROR( err ) );
+
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ENTRY,
+ "send_ldap_result : conn %lu op=%lu p=%d\n",
+ op->o_connid, op->o_opid, op->o_protocol );
+#else
+ Debug( LDAP_DEBUG_TRACE,
+ "send_ldap_result: conn=%lu op=%lu p=%d\n",
+ op->o_connid, op->o_opid, op->o_protocol );
+#endif
+
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ARGS,
+ "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n",
+ err, matched ? matched : "", text ? text : "" );
+#else
+ Debug( LDAP_DEBUG_ARGS,
+ "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n",
+ err, matched ? matched : "", text ? text : "" );
+#endif
+
+
+ if( ref ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ARGS,
+ "send_ldap_result: referral=\"%s\"\n",
+ ref[0].bv_val ? ref[0].bv_val : "NULL", 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ARGS,
+ "send_ldap_result: referral=\"%s\"\n",
+ ref[0].bv_val ? ref[0].bv_val : "NULL",
+ NULL, NULL );
+#endif
+ }
+
+ assert( err != LDAP_PARTIAL_RESULTS );
+
+ if ( err == LDAP_REFERRAL ) {
+ if( ref == NULL ) {
+ err = LDAP_NO_SUCH_OBJECT;
+ } else if ( op->o_protocol < LDAP_VERSION3 ) {
+ err = LDAP_PARTIAL_RESULTS;
+ }
+ }
+
+ if ( op->o_protocol < LDAP_VERSION3 ) {
+ tmp = v2ref( ref, text );
+ text = tmp;
+ ref = NULL;
+ }
+
+ tag = req2res( op->o_tag );
+ msgid = (tag != LBER_SEQUENCE) ? op->o_msgid : 0;
+
+ send_ldap_response( conn, op, tag, msgid,
+ err, matched, text, ref,
+ NULL, NULL, NULL, ctrls );
+
+ Statslog( LDAP_DEBUG_STATS,
+ "conn=%lu op=%lu RESULT tag=%lu err=%d text=%s\n",
+ op->o_connid, op->o_opid, tag, err, text ? text : "" );
+
+ if( tmp != NULL ) {
+ ch_free(tmp);
+ }
+}
+
+void
+send_ldap_sasl(
+ Connection *conn,
+ Operation *op,
+ ber_int_t err,
+ const char *matched,
+ const char *text,
+ BerVarray ref,
+ LDAPControl **ctrls,
+ struct berval *cred
+)
+{
+ ber_tag_t tag;
+ ber_int_t msgid;
+
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ENTRY,
+ "send_ldap_sasl: conn %lu err=%d len=%lu\n",
+ op->o_connid, err, cred ? cred->bv_len : -1 );
+#else
+ Debug( LDAP_DEBUG_TRACE, "send_ldap_sasl: err=%d len=%ld\n",
+ err, cred ? (long) cred->bv_len : -1, NULL );
+#endif
+
+
+ tag = req2res( op->o_tag );
+ msgid = (tag != LBER_SEQUENCE) ? op->o_msgid : 0;
+
+ send_ldap_response( conn, op, tag, msgid,
+ err, matched, text, ref,
+ NULL, NULL, cred, ctrls );
+}
+
+void
+send_ldap_extended(
+ Connection *conn,
+ Operation *op,
+ ber_int_t err,
+ const char *matched,
+ const char *text,
+ BerVarray refs,
+ const char *rspoid,
+ struct berval *rspdata,
+ LDAPControl **ctrls
+)
+{
+ ber_tag_t tag;
+ ber_int_t msgid;
+
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, ENTRY,
+ "send_ldap_extended: err=%d oid=%s len=%ld\n",
+ err, rspoid ? rspoid : "",
+ rspdata != NULL ? rspdata->bv_len : 0 );
+#else
+ Debug( LDAP_DEBUG_TRACE,
+ "send_ldap_extended err=%d oid=%s len=%ld\n",
+ err,
+ rspoid ? rspoid : "",
+ rspdata != NULL ? rspdata->bv_len : 0 );
+#endif
+
+
+ tag = req2res( op->o_tag );
+ msgid = (tag != LBER_SEQUENCE) ? op->o_msgid : 0;
+
+ send_ldap_response( conn, op, tag, msgid,
+ err, matched, text, refs,
+ rspoid, rspdata, NULL, ctrls );