/* * Takes an array of mappings, similar to modify above, with the * exception that the 'op' field is ignored and not used at all. */ static void f_ldap_add(INT32 args) { struct pike_string *dn; struct array *arr; struct mapping *m; struct svalue *val; LDAPMod **mods; int i, ret; if (!THIS->bound) Pike_error("OpenLDAP.Client: attempting operation on an unbound connection\n"); get_all_args("OpenLDAP.Client->add()", args, "%S%a", &dn, &arr); mods = (LDAPMod**)calloc((arr->size + 1), sizeof(LDAPMod*)); if (!mods) Pike_error("OpenLDAP.Client: OUT OF MEMORY!\n"); for (i = 0; i < arr->size; i++) { mods[i] = (LDAPMod*)calloc(1, sizeof(LDAPMod)); if (!mods[i]) Pike_error("OpenLDAP.Client: OUT OF MEMORY!\n"); mods[i]->mod_op = LDAP_MOD_BVALUES; if (arr->item[i].type != T_MAPPING) Pike_error("OpenLDAP.Client->add(): array member is not a mapping.\n"); m = arr->item[i].u.mapping; val = low_mapping_string_lookup(m, modify_type); if (!val) Pike_error("OpenLDAP.Client->add(): invalid modification mapping. " "Missing the '%s' field\n", "type"); if (val->type != T_STRING || val->u.string->size_shift > 0) Pike_error("OpenLDAP.Client->add(): invalid modification mapping. " "The '%s' field is not an 8-bit string\n", "type"); mods[i]->mod_type = val->u.string->str; val = low_mapping_string_lookup(m, modify_values); if (!val) Pike_error("OpenLDAP.Client->add(): invalid modification mapping. " "Missing the '%s' field\n", "values"); if (val->type != T_ARRAY) Pike_error("OpenLDAP.Client->add(): invalid modification mapping. " "The '%s' field is not an array\n", "values"); mods[i]->mod_bvalues = make_berval_array(val); } ret = ldap_add_s(THIS->conn, dn->str, mods); if (ret != LDAP_SUCCESS) Pike_error("OpenLDAP.Client->add(): %s\n", ldap_err2string(ret)); free_mods(mods); pop_n_elems(args); }
void test_remove_connection(connection_t *conn) { test_pars_t *tp; int s; s = splbio(); if ((tp = conn->test_pars) != NULL) { conn->test_pars = NULL; TAILQ_REMOVE(&test_list, tp, link); splx(s); DEB(9, ("Remove test %d from connection %d\n", tp->test_id, conn->id)); free_negs(tp); free_mods(tp, ISCSI_STATUS_TEST_CONNECTION_CLOSED); free(tp, M_TEMP); } else { splx(s); } }
void test_cancel(iscsi_test_cancel_parameters_t *par) { test_pars_t *tp; int s; if ((tp = find_test_id(par->test_id)) == NULL) { par->status = ISCSI_STATUS_INVALID_ID; return; } DEB(1, ("Test Cancel, id %d\n", par->test_id)); s = splbio(); if (tp->connection) tp->connection->test_pars = NULL; TAILQ_REMOVE(&test_list, tp, link); splx(s); free_negs(tp); free_mods(tp, ISCSI_STATUS_TEST_CANCELED); free(tp, M_TEMP); par->status = ISCSI_STATUS_SUCCESS; }