caddr_t box_narrow_string_as_wide (unsigned char *str, caddr_t wide, long max_len, wcharset_t *charset, caddr_t * err_ret, int isbox) { long i, len = (long)(isbox ? (box_length ((box_t) str) - 1) : strlen((const char *) str)); wchar_t *box; size_t wide_len; if (!charset) { client_connection_t *cli = GET_IMMEDIATE_CLIENT_OR_NULL; if (cli) charset = cli->cli_charset; } if (!charset) charset = default_charset; if (max_len > 0 && len > max_len) len = max_len; /* if (len == 0) return NULL; - explicit bug */ wide_len = (len + 1) * sizeof(wchar_t); if (wide_len > MAX_READ_STRING) { if (err_ret) *err_ret = srv_make_new_error ("22023", "SR578", "The expected result length of wide string is too large"); return NULL; } box = (wchar_t *) (wide ? wide : dk_alloc_box_zero (wide_len, DV_WIDE)); for (i = 0; i < len; i++) box[i] = CHAR_TO_WCHAR(str[i], charset); box[len] = L'\0'; return ((caddr_t) box); }
caddr_t box_wide_string_as_narrow (caddr_t _str, caddr_t narrow, long max_len, wcharset_t *charset) { wchar_t *str = (wchar_t *) _str; long len = box_length (str) / sizeof (wchar_t) - 1, i; unsigned char *box; if (!charset) { client_connection_t *cli = GET_IMMEDIATE_CLIENT_OR_NULL; if (cli) charset = cli->cli_charset; } if (!charset) charset = default_charset; if (max_len > 0 && len > max_len) len = max_len; /* if (len == 0) { if (narrow) narrow[0] = 0; return box_dv_short_string(""); } in case if not null narrow - leak */ box = (unsigned char *) (narrow ? narrow : dk_alloc_box (len + 1, DV_LONG_STRING)); for (i = 0; i < len && str[i]; i++) box[i] = WCHAR_TO_CHAR(str[i], charset); box[len] = 0; return ((caddr_t) box); }
caddr_t box_utf8_string_as_narrow (ccaddr_t _str, caddr_t narrow, long max_len, wcharset_t *charset) { virt_mbstate_t state; long len, inx; const unsigned char *str = (const unsigned char *) _str, *src = (const unsigned char *) _str; caddr_t box; if (!charset) { client_connection_t *cli = GET_IMMEDIATE_CLIENT_OR_NULL; if (cli) charset = cli->cli_charset; } if (!charset) charset = default_charset; memset (&state, 0, sizeof (virt_mbstate_t)); len = (long) virt_mbsnrtowcs (NULL, (unsigned char **) &src, box_length (str), 0, &state); if (max_len > 0 && len > max_len) len = max_len; if (len < 0) /* there was <= 0 - bug */ return NULL; box = narrow ? narrow : dk_alloc_box (len + 1, DV_LONG_STRING); for (inx = 0, src = str, memset (&state, 0, sizeof (virt_mbstate_t)); inx < len; inx++) { wchar_t wc; long char_len = (long) virt_mbrtowc (&wc, src, (box_length (str)) - (long)((src - str)), &state); if (char_len <= 0) { box[inx] = '?'; src++; } else { box[inx] = WCHAR_TO_CHAR (wc, charset); src += char_len; } } box[len] = 0; return box; }
caddr_t bif_im_AnnotateImageBlob (caddr_t * qst, caddr_t * err, state_slot_t ** args) { char * szMe = "IM AnnotateImageBlob"; caddr_t res; caddr_t blob = (caddr_t)bif_arg (qst, args, 0, szMe); long blob_size = box_length (blob) - 1; long x_pos = bif_long_arg (qst, args, 1, szMe); long y_pos = bif_long_arg (qst, args, 2, szMe); caddr_t text = bif_string_arg (qst, args, 3, szMe); int n_args = BOX_ELEMENTS(args); long angle = n_args > 4 ? bif_long_arg (qst, args, 4, szMe) : 0; long f_size = n_args > 5 ? bif_long_arg (qst, args, 5, szMe) : 12; char *text_color = n_args > 6 ? bif_string_arg (qst, args, 6, szMe) : "black" ; dtp_t dtp = DV_TYPE_OF (blob); im_env_t env; im_init (&env, qst, args, "IM AnnotateImageBlob"); if (IS_STRING_DTP (dtp)) blob_size = box_length (blob) - 1; else if (dtp == DV_BIN) blob_size = box_length (blob); else im_leave_with_error (&env, "22023", "IM001", "AnnotateImageBlob needs string or binary as 1-st argument"); im_env_set_blob_ext (&env, 7, -1); env.ime_drawing_wand = NewDrawingWand (); im_read (&env); im_set_background (&env, text_color); DrawSetFillColor (env.ime_drawing_wand, env.ime_background); DrawSetFontSize (env.ime_drawing_wand, f_size); MagickResetIterator (env.ime_magick_wand); while (MagickNextImage (env.ime_magick_wand) != MagickFalse) { env.ime_status = MagickAnnotateImage (env.ime_magick_wand, env.ime_drawing_wand, x_pos, y_pos, angle, text); if (env.ime_status == MagickFalse) im_leave_with_error (&env, "22023", "IM001", "Cannot annotate image"); } res = im_write (&env); im_leave (&env); return res; }
wchar_t * reverse_wide_string (wchar_t * str) { int inx; size_t len = box_length (str) / sizeof (wchar_t) - 1; for (inx=0;inx<len/2;inx++) { wchar_t tmp = str[inx]; str[inx]=str[len - inx - 1]; str[len - inx -1] = tmp; } return str; }
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); }
static caddr_t bif_mts_get_rmcookie (caddr_t * qst, caddr_t * err_ret, state_slot_t ** args) { caddr_t cookie = mts_get_rmcookie (); if (!cookie) { sqlr_error("MX008","Could not get resource manager cookie"); return NEW_DB_NULL; } else { caddr_t rmcookie_str = export_mts_bin_encode (cookie, box_length (cookie)); return rmcookie_str; } };
static MonoReflectionAssembly * ves_icall_VInvoke_LoadAssemblyFromVirtuoso (MonoAppDomain *ad, MonoString *message) { char *asm_name; caddr_t name = NULL; caddr_t code = NULL; long len; MonoAssembly *ass; MonoDomain *domain = virtuoso_domain; MonoImage *image = NULL; #ifdef OLD_KIT_1_1_5 MonoImageOpenStatus *status; #else MonoImageOpenStatus status; #endif asm_name = mono_string_to_utf8 (message); name = box_copy (asm_name); code = mono_get_assembly_by_name (&name); if (!code) return NULL; len = box_length (code); image = mono_image_open_from_data (code, len, 0, NULL); if (!image) return NULL; #ifdef OLD_KIT_1_1_5 ass = mono_assembly_open ("", NULL, image); #else ass = mono_assembly_load_from (image, "", &status); #endif if (!ass && !status) return NULL; return mono_assembly_get_object (domain, ass); }
caddr_t DBG_NAME(box_narrow_string_as_utf8) (DBG_PARAMS caddr_t _str, caddr_t narrow, long max_len, wcharset_t *charset, caddr_t * err_ret, int isbox) { caddr_t box = NULL, tmp; if (!charset) { client_connection_t *cli = GET_IMMEDIATE_CLIENT_OR_NULL; if (cli) charset = cli->cli_charset; } if (!charset) charset = default_charset; tmp = box_narrow_string_as_wide ((unsigned char *) narrow, NULL, 0, charset, err_ret, isbox); if (tmp) { box = DBG_NAME (box_wide_as_utf8_char) (DBG_ARGS tmp, box_length (tmp) / sizeof (wchar_t) - 1, DV_STRING); dk_free_box (tmp); } return box; }
int export_mts_recover (box_t recov_data) { XACTSTAT xact; dbg_printf (("MTS transaction recover... ")); if (local_rm && local_rm->rm) { HRESULT hr = local_rm->rm->Reenlist ((UCHAR *) recov_data, box_length (recov_data), 0, &xact); if (SUCCEEDED (hr)) { dbg_printf (("done %x\n", xact)); if (XACTSTAT_ABORTED == xact) return SQL_ROLLBACK; if (XACTSTAT_COMMITTED == xact) return SQL_COMMIT; /* local_rm->rm->ReenlistmentComplete(); */ } else dbg_printf (("reenlist error %x\n", hr)); } return SQL_ROLLBACK; }
/* slow solution, should be rewritten later */ caddr_t strstr_utf8_with_collation (caddr_t dv1, long n1, caddr_t dv2, long n2, caddr_t *next, collation_t *collation) { int n1inx = 0, n2inx = 0, n1inx_beg = 0; int utf8_1len = box_length (dv1) - 1; int utf8_2len = box_length (dv2) - 1; virt_mbstate_t state1, state2; wchar_t wtmp1, wtmp2; memset (&state1, 0, sizeof (virt_mbstate_t)); memset (&state2, 0, sizeof (virt_mbstate_t)); if (collation) { while (1) { int rc1, rc2; if (!n1inx_beg) n1inx_beg = n1inx; again: if (n1inx == utf8_1len && n2inx != utf8_2len) return 0; if (n2inx == utf8_2len) { if (next) next[0] = dv1+n1inx; while(1) { /* ignore all remaining ignorable signs */ rc1 = (int) virt_mbrtowc (&wtmp1, (unsigned char *) dv1+n1inx_beg, utf8_1len-n1inx_beg, &state1); if (rc1 < 0) GPF_T1 ("inconsistent wide char data"); if (!((wchar_t *)collation->co_table)[wtmp1]) { /* ignore symbol, unicode normalization algorithm */ n1inx_beg+=rc1; } else return dv1+n1inx_beg; } } rc2 = (int) virt_mbrtowc (&wtmp2, (unsigned char *) dv2+n2inx, utf8_2len-n2inx, &state2); if (rc2 < 0) GPF_T1 ("inconsistent wide char data"); if (!((wchar_t *)collation->co_table)[wtmp2]) { /* ignore symbol, unicode normalization algorithm */ n2inx+=rc2; goto again; } rc1 = (int) virt_mbrtowc (&wtmp1, (unsigned char *) dv1+n1inx, utf8_1len-n1inx, &state1); if (rc1 < 0) GPF_T1 ("inconsistent wide char data"); if (!((wchar_t *)collation->co_table)[wtmp1]) { /* ignore symbol, unicode normalization algorithm */ n1inx+=rc1; goto again; } if (((wchar_t *)collation->co_table)[wtmp1] != ((wchar_t *)collation->co_table)[wtmp2]) { n1inx+=rc1; n2inx=0; n1inx_beg=n1inx; memset (&state2, 0, sizeof (virt_mbstate_t)); continue; } n1inx+=rc1; n2inx+=rc2; } } else { while (1) { int rc1, rc2; if (!n1inx_beg) n1inx_beg = n1inx; if (n1inx == utf8_1len && n2inx != utf8_2len) return 0; if (n2inx == utf8_2len) { if (next) next[0] = dv1+n1inx; return dv1+n1inx_beg; } rc1 = (int) virt_mbrtowc (&wtmp1, (unsigned char *) dv1+n1inx, utf8_1len-n1inx, &state1); rc2 = (int) virt_mbrtowc (&wtmp2, (unsigned char *) dv2+n2inx, utf8_2len-n2inx, &state2); if (rc1 < 0 || rc2 < 0) GPF_T1 ("inconsistent wide char data"); if (wtmp1 != wtmp2) { n1inx+=rc1; n2inx=0; n1inx_beg=n1inx; memset (&state2, 0, sizeof (virt_mbstate_t)); continue; } n1inx+=rc1; n2inx+=rc2; } } return 0; }
void im_env_set_input_blob (im_env_t *env, int in_arg_no) { env->ime_input_blob = bif_string_arg (env->ime_qst, env->ime_args, in_arg_no, env->ime_bifname); env->ime_input_blob_len = bif_long_arg (env->ime_qst, env->ime_args, in_arg_no+1, env->ime_bifname); im_dbg_printf (("IM %p: %s() set input to blob, %ld bytes declared, %ld bytes actual with dtp %u\n", env, env->ime_bifname, (long)(env->ime_input_blob_len), (long)(box_length (env->ime_input_blob)), (unsigned)(DV_TYPE_OF(env->ime_input_blob)))); }
shuric_t *shuric_load (shuric_vtable_t *vt, caddr_t uri, caddr_t ts, caddr_t uri_text_content, shuric_t *loaded_by, struct query_instance_s *qi, void *env, caddr_t *err_ret ) { caddr_t str = NULL; shuric_t ** cached_shuric_ptr; shuric_t *new_cached_shuric = NULL, *old_cached_shuric = NULL; shuric_t * new_shuric = NULL; shuric_t * res = NULL; /* = NULL to keep compiler happy */ dk_set_t obsoletes = NULL; dbg_printf (("shuric_load started (\"%s\", \"%s\", \"%s\" @ %p)\n", vt->shuric_type_title, uri, loaded_by ? loaded_by->shuric_uri : "", loaded_by )); if (NULL != err_ret[0]) return NULL; if (NULL != uri) { if (DV_STRING != DV_TYPE_OF (uri)) { err_ret[0] = srv_make_new_error ("39000", "FA041", "A URI of a shareable XSLT/XQuery resource has invalid data type."); goto cleanup; } if (box_length (uri) > MAX_SHURIC_URI_LENGTH) { err_ret[0] = srv_make_new_error ("39000", "FA042", "An abnormally long string is passed as URI of a shareable XSLT/XQuery resource."); goto cleanup; } } if (NULL != uri) { if (NULL != loaded_by) { shuric_t *old_inc = shuric_scan_relations (loaded_by, uri, SHURIC_SCAN_INCLUDED_BY | SHURIC_SCAN_IMPORTED_BY); if (old_inc != NULL) { char impuri[300]; if (NULL != loaded_by->shuric_uri) strcpy (impuri, "(temporary resource with no URI)"); else { strcpy_ck (impuri, loaded_by->shuric_uri); } shuric_release (old_inc); err_ret[0] = srv_make_new_error ("39000", "FA048", "Cyclic references: '%.300s' refers to his ancestor '%.300s' as to child resource", impuri, uri); } } mutex_enter (shuric_mtx); cached_shuric_ptr = (shuric_t **) id_hash_get (shuric_global_hashtable, (caddr_t) &uri); old_cached_shuric = ((NULL == cached_shuric_ptr) ? NULL : cached_shuric_ptr[0]); if (NULL != old_cached_shuric) old_cached_shuric->shuric_ref_count++; /* Temporary lock to keep the pointer valid. */ mutex_leave (shuric_mtx); if ((NULL != old_cached_shuric) && (old_cached_shuric->_ != vt)) { err_ret[0] = srv_make_new_error ("39000", "FA046", "Server uses the content of URI '%.200s' as '%.30s' and can not load it as '%.30s'", uri, old_cached_shuric->_->shuric_type_title, vt->shuric_type_title ); goto cleanup; } } if (NULL == uri_text_content) { QR_RESET_CTX { str = vt->shuric_uri_to_text (uri, qi, env, err_ret); } QR_RESET_CODE { du_thread_t *self = THREAD_CURRENT_THREAD; err_ret[0] = thr_get_error_code (self); thr_set_error_code (self, NULL); } END_QR_RESET; }
dk_session_t * smtp_connect (char * host1, caddr_t * err_ret, caddr_t sender, caddr_t recipient, caddr_t msg_body) { volatile int rc, inx, len, addr, at; dk_session_t * volatile ses = dk_session_allocate (SESCLASS_TCPIP); caddr_t cmd = NULL; char resp [1024]; char tmp [1024], *ptmp; char c; caddr_t volatile hf = NULL, host; if (!strchr (host1, ':')) { host = dk_alloc_box (strlen (host1) + 4, DV_SHORT_STRING); strcpy_box_ck (host, host1); strcat_box_ck (host, ":25"); } else { host = box_dv_short_string (host1); } rc = session_set_address (ses->dks_session, host); dk_free_box (host); host = NULL; if (SER_SUCC != rc) { PrpcSessionFree (ses); *err_ret = srv_make_new_error ("2E000", "SM002", "Cannot resolve host in smtp_send"); return NULL; } rc = session_connect (ses->dks_session); if (SER_SUCC != rc) { if (rc != SER_NOREC) session_disconnect (ses->dks_session); PrpcSessionFree (ses); *err_ret = srv_make_new_error ("08001", "SM003", "Cannot connect in smtp_send"); return NULL; } cmd = dk_alloc_box (MAX (MAX (box_length(sender), box_length(recipient)), 1000) + 24, DV_LONG_STRING); /* get initial line */ IS_OK_GO (ses, resp, rc, RESP_OK) /* send HELO */ if (gethostname (tmp, sizeof (tmp))) strcpy_ck (tmp, "localhost"); snprintf (cmd, box_length (cmd), "HELO %s\r\n", tmp); /*WRITE_CMD (ses, rc, "HELO virtuoso.mail\r\n");*/ WRITE_CMD (ses, rc, cmd); IS_OK_GO (ses, resp, rc, RESP_OK) /* send SENDER */ len = box_length (sender); ptmp = tmp; addr = -1; at = 0; for (inx = 0; inx < len; inx++) { c = sender [inx]; if (c == '<') addr = 1; else if (c == '>' && addr == 1) addr = 2; else if (c == '>' && addr == -1) { strcpy_ck (resp, "Unbalanced <...> in sender e-mail address."); goto error_end; } else if (c == '@') at = 1; if (((ptmp - tmp) < sizeof(tmp)) && (addr == 1 || addr == 2)) *ptmp++ = c; else if ((ptmp - tmp) >= sizeof(tmp)) { strcpy_ck (resp, "Sender\'s e-mail address is too long."); goto error_end; } if (addr == 2) { *ptmp = 0; snprintf (cmd, box_length (cmd), "MAIL FROM: %s\r\n", tmp); WRITE_CMD (ses, rc, cmd); IS_OK_GO (ses, resp, rc, RESP_OK) break; } }
int cmp_boxes (ccaddr_t box1, ccaddr_t box2, collation_t *collation1, collation_t *collation2) #endif { NUMERIC_VAR (dn1); NUMERIC_VAR (dn2); dtp_t dtp1, dtp2, res_dtp; if ((IS_BOX_POINTER (box1) && DV_RDF == box_tag (box1)) || (IS_BOX_POINTER (box2) && DV_RDF == box_tag (box2))) return rdf_box_compare (box1, box2); NUM_TO_MEM (dn1, dtp1, box1); NUM_TO_MEM (dn2, dtp2, box2); if (dtp1 == DV_DB_NULL || dtp2 == DV_DB_NULL) return DVC_UNKNOWN; if (n_coerce ((caddr_t) & dn1, (caddr_t) & dn2, dtp1, dtp2, &res_dtp)) { switch (res_dtp) { case DV_LONG_INT: return (NUM_COMPARE (*(boxint *) &dn1, *(boxint *) &dn2)); case DV_SINGLE_FLOAT: return cmp_double (*(float *) &dn1, *(float *) &dn2, FLT_EPSILON); case DV_DOUBLE_FLOAT: return cmp_double (*(double *) &dn1, *(double *) &dn2, DBL_EPSILON); case DV_NUMERIC: return (numeric_compare_dvc ((numeric_t) &dn1, (numeric_t) &dn2)); } } else { int inx = 0, n1, n2; if (!IS_BOX_POINTER (box1) || !IS_BOX_POINTER (box2)) return DVC_LESS; if (DV_COMPOSITE == dtp1 && DV_COMPOSITE == dtp2) return (dv_composite_cmp ((db_buf_t) box1, (db_buf_t) box2, collation1)); if (DV_IRI_ID == dtp1 && DV_IRI_ID == dtp2) return NUM_COMPARE (unbox_iri_id (box1), unbox_iri_id (box2)); n1 = box_length (box1); n2 = box_length (box2); if ((dtp1 == DV_DATETIME && dtp2 == DV_BIN) || (dtp2 == DV_DATETIME && dtp1 == DV_BIN)) dtp1 = dtp2 = DV_DATETIME; switch (dtp1) { case DV_STRING: n1--; break; case DV_UNAME: n1--; dtp1 = DV_STRING; collation1 = collation2 = NULL; break; case DV_LONG_WIDE: dtp1 = DV_WIDE; case DV_WIDE: n1 = n1 / sizeof (wchar_t) - 1; break; case DV_LONG_BIN: dtp1 = DV_BIN; collation1 = collation2 = NULL; break; case DV_DATETIME: dtp1 = DV_BIN; n1 = DT_COMPARE_LENGTH; collation1 = collation2 = NULL; break; default: collation1 = collation2 = NULL; } switch (dtp2) { case DV_STRING: n2--; if (collation1) { if (collation2 && collation1 != collation2) collation1 = default_collation; } else collation1 = collation2; break; case DV_UNAME: n2--; dtp2 = DV_STRING; collation1 = NULL; break; case DV_LONG_BIN: dtp2 = DV_BIN; collation1 = NULL; break; case DV_DATETIME: dtp2 = DV_BIN; n2 = DT_COMPARE_LENGTH; collation1 = NULL; break; case DV_LONG_WIDE: dtp2 = DV_WIDE; case DV_WIDE: n2 = n2 / sizeof (wchar_t) - 1; break; default: collation1 = NULL; } if (IS_WIDE_STRING_DTP (dtp1) && IS_STRING_DTP (dtp2)) { if (box_flags (box2) & (BF_IRI | BF_UTF8)) return compare_wide_to_utf8_with_collation ((wchar_t *) box1, n1, (utf8char *) box2, n2, NULL); else return compare_wide_to_latin1 ((wchar_t *) box1, n1, (unsigned char *) box2, n2); } if (IS_STRING_DTP (dtp1) && IS_WIDE_STRING_DTP (dtp2)) { int res; if (box_flags (box2) & (BF_IRI | BF_UTF8)) res = compare_wide_to_utf8_with_collation ((wchar_t *)box2, n2, (utf8char *) box1, n1, NULL); else res = compare_wide_to_latin1 ((wchar_t *)box2, n2, (unsigned char *) box1, n1); return (res == DVC_LESS ? DVC_GREATER : (res == DVC_GREATER ? DVC_LESS : res)); } else if (dtp1 != dtp2) return DVC_LESS; if (dtp1 == DV_WIDE) { while (1) { if (inx == n1) /* box1 in end? */ { if (inx == n2) return DVC_MATCH; /* box2 of same length */ else return DVC_LESS; /* otherwise box1 is shorter than box2 */ } if (inx == n2) return DVC_GREATER; /* box2 in end (but not box1) */ if ((((wchar_t *) box1)[inx]) < (((wchar_t *) box2)[inx])) return DVC_LESS; if ((((wchar_t *) box1)[inx]) > (((wchar_t *) box2)[inx])) return DVC_GREATER; inx++; } } if (collation1 && !collation1->co_is_wide) { while (1) { if (inx == n1) /* box1 in end? */ { if (inx == n2) return DVC_MATCH; /* box2 of same length */ else return DVC_LESS; /* otherwise box1 is shorter than box2 */ } if (inx == n2) return DVC_GREATER; /* box2 in end (but not box1) */ if (collation1->co_table[(dtp_t) box1[inx]] < collation1->co_table[(dtp_t) box2[inx]]) return DVC_LESS; if (collation1->co_table[(dtp_t) box1[inx]] > collation1->co_table[(dtp_t) box2[inx]]) return DVC_GREATER; inx++; } } else { while (1) { if (inx == n1) /* box1 in end? */ { if (inx == n2) return DVC_MATCH; /* box2 of same length */ else return DVC_LESS; /* otherwise box1 is shorter than box2 */ } if (inx == n2) return DVC_GREATER; /* box2 in end (but not box1) */ if (((dtp_t) box1[inx]) < ((dtp_t) box2[inx])) return DVC_LESS; if (((dtp_t) box1[inx]) > ((dtp_t) box2[inx])) return DVC_GREATER; inx++; } } } return DVC_LESS; /* default, should not happen */ }