| 1534 | |
| 1535 | |
| 1536 | int DSC_string_length(const dsc* desc) |
| 1537 | { |
| 1538 | /************************************** |
| 1539 | * |
| 1540 | * D S C _ s t r i n g _ l e n g t h |
| 1541 | * |
| 1542 | ************************************** |
| 1543 | * |
| 1544 | * Functional description |
| 1545 | * Estimate length of string (in bytes) based on descriptor. |
| 1546 | * Estimated length assumes representing string in |
| 1547 | * narrow-char ASCII format. |
| 1548 | * |
| 1549 | * Note that this strips off the short at the |
| 1550 | * start of dtype_varying, and the NULL for dtype_cstring. |
| 1551 | * |
| 1552 | **************************************/ |
| 1553 | |
| 1554 | switch (desc->dsc_dtype) |
| 1555 | { |
| 1556 | case dtype_text: |
| 1557 | return desc->dsc_length; |
| 1558 | case dtype_cstring: |
| 1559 | return desc->dsc_length - 1; |
| 1560 | case dtype_varying: |
| 1561 | return desc->dsc_length - sizeof(USHORT); |
| 1562 | default: |
| 1563 | if (!DTYPE_IS_EXACT(desc->dsc_dtype) || desc->dsc_scale == 0) |
| 1564 | return (int) _DSC_convert_to_text_length[desc->dsc_dtype]; |
| 1565 | if (desc->dsc_scale < 0) |
| 1566 | return (int) _DSC_convert_to_text_length[desc->dsc_dtype] + 1; |
| 1567 | return (int) _DSC_convert_to_text_length[desc->dsc_dtype] + desc->dsc_scale; |
| 1568 | } |
| 1569 | } |
| 1570 | |
| 1571 | |
| 1572 | const TEXT *DSC_dtype_tostring(UCHAR dtype) |
no test coverage detected