| 661 | |
| 662 | |
| 663 | USHORT blb::BLB_get_segment(thread_db* tdbb, void* segment, USHORT buffer_length) |
| 664 | { |
| 665 | /************************************** |
| 666 | * |
| 667 | * b l b : : g e t _ s e g m e n t |
| 668 | * |
| 669 | ************************************** |
| 670 | * |
| 671 | * Functional description |
| 672 | * Get next segment or fragment from a blob. Return the number |
| 673 | * of bytes returned. |
| 674 | * |
| 675 | **************************************/ |
| 676 | SET_TDBB(tdbb); |
| 677 | Database* dbb = tdbb->getDatabase(); |
| 678 | |
| 679 | if (blb_flags & BLB_temporary) |
| 680 | ERR_post(Arg::Gds(isc_cannot_read_new_blob)); |
| 681 | |
| 682 | JRD_reschedule(tdbb); |
| 683 | |
| 684 | // If we reached end of file, we're still there |
| 685 | |
| 686 | if (blb_flags & BLB_eof) |
| 687 | return 0; |
| 688 | |
| 689 | if (blb_filter) |
| 690 | { |
| 691 | blb_fragment_size = 0; |
| 692 | USHORT tmp_len = 0; |
| 693 | const ISC_STATUS status = |
| 694 | BLF_get_segment(tdbb, &blb_filter, &tmp_len, buffer_length, segment); |
| 695 | |
| 696 | switch (status) |
| 697 | { |
| 698 | case isc_segstr_eof: |
| 699 | blb_flags |= BLB_eof; |
| 700 | break; |
| 701 | case isc_segment: |
| 702 | blb_fragment_size = 1; |
| 703 | break; |
| 704 | default: |
| 705 | fb_assert(status == 0); |
| 706 | } |
| 707 | |
| 708 | return tmp_len; |
| 709 | } |
| 710 | |
| 711 | // If there is a seek pending, handle it here |
| 712 | |
| 713 | USHORT seek = 0; |
| 714 | |
| 715 | if (blb_flags & BLB_seek) |
| 716 | { |
| 717 | if (blb_seek >= blb_length) |
| 718 | { |
| 719 | blb_flags |= BLB_eof; |
| 720 | return 0; |
no test coverage detected