| 2478 | |
| 2479 | |
| 2480 | USHORT CVT_make_string(const dsc* desc, |
| 2481 | USHORT to_interp, |
| 2482 | const char** address, |
| 2483 | vary* temp, |
| 2484 | USHORT length, |
| 2485 | DecimalStatus decSt, |
| 2486 | ErrorFunction err) |
| 2487 | { |
| 2488 | /************************************** |
| 2489 | * |
| 2490 | * C V T _ m a k e _ s t r i n g |
| 2491 | * |
| 2492 | ************************************** |
| 2493 | * |
| 2494 | * Functional description |
| 2495 | * Convert the data from the desc to a string in the specified interp. |
| 2496 | * The pointer to this string is returned in address. |
| 2497 | * |
| 2498 | **************************************/ |
| 2499 | fb_assert(desc != NULL); |
| 2500 | fb_assert(address != NULL); |
| 2501 | fb_assert(err != NULL); |
| 2502 | |
| 2503 | const USHORT from_interp = INTL_TTYPE(desc); |
| 2504 | |
| 2505 | const bool simple_return = desc->isText() && |
| 2506 | (from_interp == to_interp || to_interp == ttype_none || to_interp == ttype_binary); |
| 2507 | |
| 2508 | fb_assert((temp != NULL && length > 0) || simple_return); |
| 2509 | |
| 2510 | if (simple_return) |
| 2511 | { |
| 2512 | *address = reinterpret_cast<char*>(desc->dsc_address); |
| 2513 | const USHORT from_len = desc->dsc_length; |
| 2514 | |
| 2515 | if (desc->dsc_dtype == dtype_text) |
| 2516 | return from_len; |
| 2517 | |
| 2518 | if (desc->dsc_dtype == dtype_cstring) |
| 2519 | return MIN((USHORT) strlen((char *) desc->dsc_address), from_len - 1); |
| 2520 | |
| 2521 | if (desc->dsc_dtype == dtype_varying) |
| 2522 | { |
| 2523 | vary* varying = (vary*) desc->dsc_address; |
| 2524 | *address = varying->vary_string; |
| 2525 | return MIN(varying->vary_length, (USHORT) (from_len - sizeof(USHORT))); |
| 2526 | } |
| 2527 | } |
| 2528 | |
| 2529 | // Not string data, then -- convert value to varying string. |
| 2530 | |
| 2531 | dsc temp_desc; |
| 2532 | MOVE_CLEAR(&temp_desc, sizeof(temp_desc)); |
| 2533 | temp_desc.dsc_length = length; |
| 2534 | temp_desc.dsc_address = (UCHAR *) temp; |
| 2535 | temp_desc.dsc_dtype = dtype_varying; |
| 2536 | temp_desc.setTextType(to_interp); |
| 2537 | CVT_move(desc, &temp_desc, decSt, err); |
no test coverage detected