caddr_t clr_deserialize (dk_session_t * ses, long mode, caddr_t asm_name, caddr_t type, void *udt) { MonoArray *v_args = NULL, *bin_data; MonoArray *mono_list; int len; caddr_t in_values, bin_data_ptr; MonoDomain *domain = virtuoso_domain; get_mono_thread (); in_values = (caddr_t) scan_session_boxing (ses); if (DV_TYPE_OF (in_values) != DV_BIN) return (caddr_t) box_num (0); len = box_length (in_values); bin_data = mono_array_new (domain, mono_get_byte_class(), len); bin_data_ptr = mono_array_addr (bin_data, char, 0); memcpy (bin_data_ptr, in_values, len); if (in_values) dk_free_tree (in_values); v_args = MAKE_PARAM_ARRAY (domain, 4); mono_array_set (v_args, gpointer, 0, bin_data); SET_INT_ARG (domain, v_args, 1, mode); SET_STRING_ARG (domain, v_args, 2, asm_name); SET_STRING_ARG (domain, v_args, 3, type); QR_RESET_CTX { mono_list = (MonoArray *) call_mono (VIRTCLR_NAME, "VInvoke:obj_deserialize", v_args, domain); } QR_RESET_CODE { caddr_t err; POP_QR_RESET; err = thr_get_error_code (THREAD_CURRENT_THREAD); if (ARRAYP (err)) log_error ("Mono Deserialization error : [%s] [%s]", ERR_STATE(err), ERR_MESSAGE (err)); else log_error ("Mono Deserialization error : unknown"); dk_free_tree (err); return 0; } END_QR_RESET; return sa_to_dk ((MonoArray *) mono_list, 0, 0, udt); }
int sql_ext_fetch_fwd (SQLHSTMT hstmt, SQLULEN * pcrow, SQLUSMALLINT * rgfRowStatus) { int rc = 0; int row_count = 0; STMT (stmt, hstmt); int inx; SQLULEN rssz = stmt->stmt_rowset_size; dk_free_tree ((box_t) stmt->stmt_rowset); stmt->stmt_current_row = NULL; stmt->stmt_rowset = (caddr_t **) dk_alloc_box (rssz * sizeof (caddr_t), DV_ARRAY_OF_POINTER); memset (stmt->stmt_rowset, 0, rssz * sizeof (caddr_t)); for (inx = 0; inx < rssz; inx++) { stmt->stmt_fwd_fetch_irow = inx; stmt->stmt_current_of = stmt->stmt_fetch_current_of; rc = virtodbc__SQLFetch (hstmt, 1); stmt->stmt_fetch_current_of = stmt->stmt_current_of; stmt->stmt_fwd_fetch_irow = 0; if (rc == SQL_ERROR) break; if (rc == SQL_NO_DATA_FOUND) break; row_count++; stmt->stmt_rowset[inx] = stmt->stmt_current_row; stmt->stmt_current_row = NULL; if (rgfRowStatus) rgfRowStatus[inx] = SQL_ROW_SUCCESS; } if (rgfRowStatus) for (inx = inx; inx < rssz; inx++) rgfRowStatus[inx] = SQL_ROW_NOROW; if (row_count) { stmt_reset_getdata_status (stmt, stmt->stmt_rowset[0]); stmt->stmt_current_row = stmt->stmt_rowset[0]; stmt->stmt_current_of = 0; } stmt->stmt_rowset_fill = row_count; if (pcrow) *pcrow = row_count; stmt->stmt_row_status = rgfRowStatus; if (row_count > 0 && SQL_NO_DATA_FOUND == rc) rc = SQL_SUCCESS; return rc; }
/* INFO: toplevel udt_clr_serialize */ int clr_serialize (int _gc_in, dk_session_t * ses) { MonoArray *v_args = NULL; MonoArray *mono_list; int len, inx; MonoDomain *domain = virtuoso_domain; get_mono_thread (); v_args = MAKE_PARAM_ARRAY (domain, 1); SET_INT_ARG (domain, v_args, 0, _gc_in); QR_RESET_CTX { mono_list = (MonoArray *) call_mono (VIRTCLR_NAME, "VInvoke:obj_serialize_soap", v_args, domain); } QR_RESET_CODE { caddr_t err; POP_QR_RESET; err = thr_get_error_code (THREAD_CURRENT_THREAD); if (ARRAYP (err)) log_error ("Mono Serialization error : [%s] [%s]", ERR_STATE(err), ERR_MESSAGE (err)); else log_error ("Mono Serialization error : unknown"); dk_free_tree (err); goto no_obj; } END_QR_RESET; len = mono_array_length (mono_list); if (len - 1 < 256) { session_buffered_write_char (DV_BIN, ses); session_buffered_write_char (len - 1, ses); } else { session_buffered_write_char (DV_LONG_BIN, ses); print_long (len - 1, ses); } for (inx = 1; inx < len; inx++) { MonoObject *obj = (MonoObject *)mono_array_get (mono_list, gpointer, inx); guint8 b = *(guint8 *)((char *)obj + sizeof (MonoObject)); session_buffered_write_char (b, ses); } return len; no_obj: session_buffered_write_char (DV_DB_NULL, ses); return 1; }
static caddr_t bif_do_something_bif (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args) { JNIEnv *env = NULL; jclass class_obj; jmethodID work_method_obj, cleanup_method_obj; jint ret; jvalue jargs[1]; query_instance_t *qi = (query_instance_t *)qst; if (NULL != (*err_ret = java_vm_attach (&env))) goto finish; class_obj = (*env)->FindClass (env, "handler_class"); work_method_obj = (*env)->GetStaticMethodID (env, class_obj, "do_bit_of_work", "()I"); cleanup_method_obj = (*env)->GetStaticMethodID (env, class_obj, "cleanup_the_staff", "()V"); while (0 < (ret = (*env)->CallStaticIntMethodA (env, class_obj, work_method_obj, jargs))) { if (qi_have_trx_error (qi)) { (*env)->CallStaticVoidMethodA (env, class_obj, cleanup_method_obj, jargs); goto finish; } } finish: if (env) { caddr_t err = java_vm_detach (); if (!*err_ret) *err_ret = err; else dk_free_tree (err); } qi_check_trx_error (qi, 1); return NULL; }
/*mapping schema*/ void xmlview_join_elt_free (xv_join_elt_t * xj) { int inx; if (xj->xj_mp_schema) { ST * st; while (NULL != (st = (ST *) dk_set_pop (&xj->xj_mp_schema->xj_child_cols))) { dk_free_tree ((box_t) st); } } /* DO_SET (caddr_t , xc, &xj->xj_mp_schema->xj_child_cols) { dk_free_tree ((caddr_t) xc); } END_DO_SET (); dk_set_free (xj->xj_mp_schema->xj_child_cols); xj->xj_mp_schema->xj_child_cols = NULL; } */ DO_BOX (xj_col_t *, xc, inx, xj->xj_cols) { if (xc->xc_relationship) { xc->xc_relationship->xj_parent = NULL; } } END_DO_BOX; DO_BOX (xv_join_elt_t *, c, inx, xj->xj_children) { c->xj_parent = NULL; xmlview_join_elt_free (c); } END_DO_BOX; }
void stmt_free_bookmarks (cli_stmt_t * stmt) { caddr_t k, id; dk_hash_iterator_t hit; if (!stmt->stmt_bookmarks) return; IN_CON (stmt->stmt_connection); dk_hash_iterator (&hit, stmt->stmt_bookmarks); while (dk_hit_next (&hit, (void **) &k, (void **) &id)) { remhash ((void *) k, stmt->stmt_connection->con_bookmarks); dk_free_tree (id); } hash_table_free (stmt->stmt_bookmarks); id_hash_free (stmt->stmt_bookmarks_rev); LEAVE_CON (stmt->stmt_connection); }
void xmlview_free (xml_view_t * xv) { xmlview_join_elt_free (xv->xv_tree); dk_free_tree ((box_t) xv); }
int dotnet_is_instance_of (int _clr_ret, caddr_t class_name) { MonoDomain *domain = virtuoso_domain; MonoArray *v_args = NULL, *mono_list; MonoObject *arg = NULL; char *p1=NULL, *p2=NULL, *p3 = NULL; char t_class_name[200]; int fl = 1, ret = 0; if (!class_name) return 0; strcpy (t_class_name, class_name); p1 = p3 = t_class_name; for (;;) { p2 = strstr (p3, "/"); if (!p2) break; else p3 = p2 + 1; fl = fl - 1; } p1 [p3 - p1 - 1] = 0; get_mono_thread (); v_args = MAKE_PARAM_ARRAY (domain, 4); SET_INT_ARG (domain, v_args, 0, _clr_ret); SET_INT_ARG (domain, v_args, 1, fl); SET_STRING_ARG (domain, v_args, 2, p1); SET_STRING_ARG (domain, v_args, 3, p3); QR_RESET_CTX { mono_list = (MonoArray *) call_mono (VIRTCLR_NAME, "VInvoke:get_IsInstanceOf", v_args, domain); } QR_RESET_CODE { caddr_t err; err = thr_get_error_code (THREAD_CURRENT_THREAD); dk_free_tree (err); POP_QR_RESET; return 0; } END_QR_RESET; arg = (MonoObject *) mono_array_get (mono_list, gpointer, 0); #ifdef MONO_DEBUG fprintf (stderr, "VInvoke:get_IsInstanceOf CLR ret=%s data_sz=%d gboolean_sz=%d guint8_sz=%d\n", arg->vtable->klass->name, (int) (arg->vtable->klass->instance_size - sizeof (MonoObject)), sizeof (gboolean), sizeof (guint8)); #endif ret = *(((guint8 *)arg) + sizeof (MonoObject)); #ifdef MONO_DEBUG fprintf (stderr, "VInvoke:get_IsInstanceOf C ret=%d\n", ret); #endif return ret; }
caddr_t bif_im_get_impl (caddr_t * qst, caddr_t * err, state_slot_t ** args, int is_file_in, int op, const char *bifname) { im_env_t env; char *strg_value = NULL; unsigned long ul_value = 0; caddr_t res = NULL; int is_string_res = (('A' == op) || ('F' == op) || ('I' == op)); int is_list_res = ('2' == op); int is_key_needed = ('A' == op); caddr_t key = is_key_needed ? bif_string_arg (qst, args, (is_file_in ? 1 : 2), bifname) : NULL; im_init (&env, qst, args, bifname); if (is_file_in) im_env_set_filenames (&env, 0, -1); else { im_env_set_input_blob (&env, 0); im_env_set_blob_ext (&env, (is_key_needed ? 3 : 2), -1); } im_read (&env); MagickResetIterator(env.ime_magick_wand); while (MagickNextImage (env.ime_magick_wand) != MagickFalse) { switch (op) { case 'A': strg_value = MagickGetImageAttribute (env.ime_magick_wand, key); break; case 'F': strg_value = MagickGetImageFormat (env.ime_magick_wand); break; case 'I': strg_value = MagickIdentifyImage (env.ime_magick_wand); break; case 'W': ul_value = MagickGetImageWidth (env.ime_magick_wand); break; case 'H': ul_value = MagickGetImageHeight (env.ime_magick_wand); break; case 'D': ul_value = MagickGetImageDepth (env.ime_magick_wand); break; case '2': ul_value = MagickGetImageWidth (env.ime_magick_wand); if (ul_value) { dk_free_tree (res); res = dk_alloc_box (2 * sizeof (caddr_t), DV_ARRAY_OF_POINTER); ((caddr_t *)res)[0] = box_num (ul_value); ((caddr_t *)res)[1] = box_num (MagickGetImageHeight (env.ime_magick_wand)); } break; } } if (is_string_res) { if (strg_value) { res = box_dv_short_string (strg_value); MagickRelinquishMemory (strg_value); } } else if (!is_list_res) { if (ul_value) res = box_num (ul_value); } if (NULL == res) res = NEW_DB_NULL; im_leave (&env); return res; }
void virtm_client_free (void *cli) { dk_free_tree (cli); }
SQLRETURN SQL_API virtodbc__SQLSetPos ( SQLHSTMT hstmt, SQLSETPOSIROW _irow, SQLUSMALLINT fOption, SQLUSMALLINT fLock) { sql_error_rec_t *err_queue = NULL; int irow = (int) _irow; STMT (stmt, hstmt); int n_rows = (int) (irow != 0 ? 1 : (fOption == SQL_ADD ? stmt->stmt_rowset_size : stmt->stmt_rowset_fill)); /* insert irow==0 is by rowset sz, others are by rowset fill */ int inx = 0, rc = 0, firstinx = 0, lastinx = 0; int co = irow == 0 ? 0 : irow - 1; cli_stmt_t *sps = NULL; long op = fOption; long row_no = irow; caddr_t *params = NULL; int all_errors = 1; stmt->stmt_pending.p_api = SQL_API_SQLSETPOS; stmt->stmt_pending.psp_op = fOption; stmt->stmt_pending.psp_irow = irow; set_error (&stmt->stmt_error, NULL, NULL, NULL); if (stmt->stmt_fetch_mode != FETCH_EXT) { if (!irow && fOption == SQL_POSITION && fLock == SQL_LOCK_NO_CHANGE) return SQL_SUCCESS; /* this is NOP in fact */ set_error (&stmt->stmt_error, "S1010", "CL007", "SQLSetPos only allowed after SQLExtendedFetch"); return SQL_ERROR; } if (co >= stmt->stmt_rowset_fill && op != SQL_ADD) { set_error (&stmt->stmt_error, "HY092", "CL008", "SQLSetPos irow out of range"); return SQL_ERROR; } if (fOption != SQL_REFRESH) { stmt->stmt_current_of = co; stmt_reset_getdata_status (stmt, stmt->stmt_rowset[co]); stmt->stmt_current_row = stmt->stmt_rowset[co]; } if (fOption == SQL_POSITION) return SQL_SUCCESS; if (stmt->stmt_opts->so_cursor_type == SQL_CURSOR_FORWARD_ONLY) { set_error (&stmt->stmt_error, "HY109", "CL009", "Only SQL_POSITION SQLSetPos option supported for forward cursors"); return SQL_ERROR; } if (!stmt->stmt_set_pos_stmt) { virtodbc__SQLAllocStmt ((SQLHDBC) stmt->stmt_connection, (SQLHSTMT *) & stmt->stmt_set_pos_stmt); virtodbc__SQLPrepare ((SQLHSTMT) stmt->stmt_set_pos_stmt, (SQLCHAR *) "__set_pos (?, ?, ?, ?)", SQL_NTS); } sps = stmt->stmt_set_pos_stmt; if (fOption == SQL_POSITION) { stmt->stmt_current_of = irow; return SQL_SUCCESS; } if (SQL_UPDATE == fOption || SQL_ADD == fOption) { params = stmt->stmt_param_array; if (!params) { if (0 == irow) { params = (caddr_t *) dk_alloc_box_zero (n_rows * sizeof (caddr_t), DV_ARRAY_OF_POINTER); for (inx = 0; inx < n_rows; inx++) { if (NULL == (params[inx] = (caddr_t) set_pos_param_row (stmt, inx))) { dk_free_tree ((box_t) params); return SQL_ERROR; } } } else if (NULL == (params = set_pos_param_row (stmt, irow - 1))) return SQL_ERROR; if (stmt->stmt_dae) { stmt->stmt_status = STS_LOCAL_DAE; stmt->stmt_param_array = params; return SQL_NEED_DATA; } } stmt->stmt_param_array = NULL; } memset (&stmt->stmt_pending, 0, sizeof (pending_call_t)); virtodbc__SQLSetParam ((SQLHSTMT) sps, 1, SQL_C_CHAR, SQL_VARCHAR, 0, 0, stmt->stmt_id, NULL); virtodbc__SQLSetParam ((SQLHSTMT) sps, 2, SQL_C_LONG, SQL_INTEGER, 0, 0, &op, NULL); virtodbc__SQLSetParam ((SQLHSTMT) sps, 3, SQL_C_LONG, SQL_INTEGER, 0, 0, &row_no, NULL); virtodbc__SQLSetParam ((SQLHSTMT) sps, 4, SQL_C_BOX, SQL_VARCHAR, 0, 0, ¶ms, NULL); stmt->stmt_status = STS_SERVER_DAE; rc = virtodbc__SQLExecDirect ((SQLHSTMT) sps, NULL, 0); dk_free_tree ((caddr_t) params); if (SQL_ERROR == rc) { err_queue_append (&stmt->stmt_error.err_queue, &sps->stmt_error.err_queue); return SQL_ERROR; } if (0 == irow) { firstinx = 0; lastinx = n_rows; } else { firstinx = irow - 1; lastinx = irow; } for (inx = firstinx; inx < lastinx; inx++) { rc = stmt_process_result ((cli_stmt_t *) sps, 1); if (SQL_ERROR == rc) { sql_error_rec_t *err1 = cli_make_error ("01S01", "CL082", "Error in row in SQLSetPos", 0); if (stmt->stmt_row_status) stmt->stmt_row_status[inx] = SQL_ROW_ERROR; err_queue_append (&err_queue, &err1); err_queue_append (&err_queue, &sps->stmt_error.err_queue); } else if (rc == SQL_SUCCESS && sps->stmt_prefetch_row) { long stat = (long) unbox (((caddr_t *) sps->stmt_prefetch_row)[0]); if (stmt->stmt_row_status) stmt->stmt_row_status[inx] = qa_to_row_stat (stat); stmt_set_columns (stmt, (caddr_t *) sps->stmt_prefetch_row, inx); dk_free_tree ((caddr_t) stmt->stmt_rowset[inx]); stmt->stmt_rowset[inx] = (caddr_t *) sps->stmt_prefetch_row; sps->stmt_prefetch_row = NULL; all_errors = 0; } else { int stat = SQL_ROW_SUCCESS; all_errors = 0; switch (op) { case SQL_UPDATE: stat = SQL_ROW_UPDATED; break; case SQL_DELETE: stat = SQL_ROW_DELETED; break; case SQL_ADD: stat = SQL_ROW_ADDED; break; } if (stmt->stmt_row_status) stmt->stmt_row_status[inx] = stat; } } if (SQL_REFRESH == fOption) stmt->stmt_current_row = stmt->stmt_rowset[co]; stmt->stmt_rows_affected = sps->stmt_rows_affected; rc = stmt_process_result (sps, 1); /* the ret from the proc call, w/ possible autocommit txn error code */ if (rc == SQL_ERROR) err_queue_append (&err_queue, &sps->stmt_error.err_queue); if (rc == SQL_NO_DATA_FOUND) rc = SQL_SUCCESS; if (SQL_SUCCESS == rc && err_queue) { if (all_errors) rc = SQL_ERROR; else rc = SQL_SUCCESS_WITH_INFO; } set_error (&stmt->stmt_error, NULL, NULL, NULL); stmt->stmt_error.err_queue = err_queue; stmt->stmt_error.err_queue_head = err_queue; return (rc); }
RETCODE stmt_process_rowset (cli_stmt_t * stmt, int ftype, SQLULEN * pcrow) { int is_error = 0; int rc; SQLULEN rssz = stmt->stmt_rowset_size; int inx, nth; if (stmt->stmt_rowset) dk_free_tree ((box_t) stmt->stmt_rowset); stmt->stmt_rowset = (caddr_t **) dk_alloc_box (rssz * sizeof (caddr_t), DV_ARRAY_OF_POINTER); memset (stmt->stmt_rowset, 0, rssz * sizeof (caddr_t)); stmt->stmt_current_row = NULL; for (nth = 0; nth < rssz; nth++) { rc = stmt_process_result (stmt, 1); if (SQL_ERROR == rc) { is_error = 1; break; } if (stmt->stmt_at_end) break; stmt->stmt_rowset[nth] = (caddr_t *) stmt->stmt_prefetch_row; stmt->stmt_prefetch_row = NULL; } for (inx = 0; inx < nth; inx++) { int rstat = qa_to_row_stat ((int) (ptrlong) stmt->stmt_rowset[inx][0]); stmt_set_columns (stmt, stmt->stmt_rowset[inx], inx); if (stmt->stmt_row_status) stmt->stmt_row_status[inx] = (SQLUSMALLINT) rstat; } if (pcrow) *pcrow = nth; if (stmt->stmt_row_status) for (inx = nth; inx < rssz; inx++) stmt->stmt_row_status[inx] = SQL_ROW_NOROW; if (nth > 0) { stmt->stmt_current_row = stmt->stmt_rowset[0]; stmt->stmt_current_of = 0; } else { stmt->stmt_current_row = NULL; stmt->stmt_current_of = -1; } stmt->stmt_rowset_fill = nth; if (is_error) return SQL_ERROR; if (nth == 0) return SQL_NO_DATA_FOUND; return SQL_SUCCESS; }