]> git.sur5r.net Git - openldap/commitdiff
return error codes from new internal API
authorLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 15:04:19 +0000 (15:04 +0000)
committerLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 15:04:19 +0000 (15:04 +0000)
servers/slapd/slapi/slapi_utils.c
servers/slapd/slapi/slapi_utils.h

index 24d5e5a737b2cd7322bc84852c010625d75d562c..06b862bb89e896c1753a73b6f2be14a0a9018836 100644 (file)
@@ -1133,25 +1133,41 @@ slapi_free_search_results_internal( Slapi_PBlock *pb )
 /*
  * Internal API to prime a Slapi_PBlock with a Backend.
  */
-void slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be )
+int slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be )
 {
 #if defined(LDAP_SLAPI)
-       slapi_pblock_set(pb, SLAPI_BACKEND, (void *)be);
-       slapi_pblock_set(pb, SLAPI_BE_TYPE, (void *)be->bd_info->bi_type);
+       int rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_BACKEND, (void *)be);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_BE_TYPE, (void *)be->bd_info->bi_type);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+#else
+       return -1;
 #endif /* defined(LDAP_SLAPI) */
 }
 
 /*
  * Internal API to prime a Slapi_PBlock with a Connection.
  */
-void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
+int slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
 {
 #if defined(LDAP_SLAPI)
        char *connAuthType;
        size_t len;
+       int rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_CONNECTION, (void *)conn);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid);
+       if (rc != LDAP_SUCCESS)
+               return rc;
 
-       slapi_pblock_set(pb, SLAPI_CONNECTION, (void *)conn);
-       slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid);
        switch (conn->c_authz.sai_method) {
        case LDAP_AUTH_SASL: 
                len = sizeof(SLAPD_AUTH_SASL) + conn->c_authz.sai_mech.bv_len;
@@ -1172,23 +1188,31 @@ void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
                connAuthType = slapi_ch_strdup(SLAPD_AUTH_SSL);
        }
        if (connAuthType != NULL) {
-               slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, (void *)connAuthType);
+               rc = slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, (void *)connAuthType);
+               if (rc != LDAP_SUCCESS)
+                       return rc;
        }
        if (conn->c_authz.sai_dn.bv_val != NULL) {
                char *connDn = slapi_ch_strdup(conn->c_authz.sai_dn.bv_val);
-               slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn);
+               rc = slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn);
+               if (rc != LDAP_SUCCESS)
+                       return rc;
        }
+       return LDAP_SUCCESS;
+#else
+       return -1;
 #endif /* defined(LDAP_SLAPI) */
 }
 
 /*
  * Internal API to prime a Slapi_PBlock with an Operation.
  */
-void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op )
+int slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op )
 {
 #if defined(LDAP_SLAPI)
        int isRoot = 0;
        int isUpdateDn = 0;
+       int rc;
        Backend *be;
 
        if (slapi_pblock_get(pb, SLAPI_BACKEND, (void *)&be) != 0) {
@@ -1199,12 +1223,31 @@ void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op )
                isUpdateDn = be_isupdate(be, &op->o_ndn);
        }
                
-       slapi_pblock_set(pb, SLAPI_OPERATION, (void *)op);
-       slapi_pblock_set(pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time);
-       slapi_pblock_set(pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot);
-       slapi_pblock_set(pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn);
-       slapi_pblock_set(pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls);
-       slapi_pblock_set(pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val);
+       rc = slapi_pblock_set(pb, SLAPI_OPERATION, (void *)op);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls);
+       if (rc != LDAP_SUCCESS)
+               return rc;
+
+       rc = slapi_pblock_set(pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val);
+
+       return rc;
+#else
+       return -1;
 #endif
 }
 
index 5f03a9b5b83533258252256845edebe8ae25f201..252a4f60dd4aae8ffad98716b631a83c1ba03c2d 100644 (file)
@@ -108,9 +108,9 @@ int slapi_audit_init_header( Connection *conn, Operation *op,
 int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn, 
                                                Operation *op, int rc);
 
-void slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be );
-void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn );
-void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op );
+int slapi_backend_set_pb( Slapi_PBlock *pb, Backend *be );
+int slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn );
+int slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op );
 
 extern ldap_pvt_thread_mutex_t slapi_hn_mutex;
 extern ldap_pvt_thread_mutex_t slapi_time_mutex;