Commit 06893f2755c2e27bd250633c205c0cec9d62c435
1 parent
e85d9d21
Exists in
master
and in
3 other branches
Updating print API.
Showing
3 changed files
with
49 additions
and
9 deletions
Show diff stats
src/core/util.c
| ... | ... | @@ -593,26 +593,39 @@ void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...) |
| 593 | 593 | |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | -LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_CONTENT_OPTION mode) | |
| 596 | +LIB3270_EXPORT int lib3270_print(H3270 *hSession) | |
| 597 | 597 | { |
| 598 | - return hSession->cbk.print(hSession, mode); | |
| 598 | + if(check_online_session(hSession)) | |
| 599 | + return errno = ENOTCONN; | |
| 600 | + | |
| 601 | + return hSession->cbk.print(hSession, (hSession->selected ? LIB3270_CONTENT_SELECTED : LIB3270_CONTENT_ALL)); | |
| 599 | 602 | } |
| 600 | 603 | |
| 601 | 604 | LIB3270_EXPORT int lib3270_print_all(H3270 *hSession) |
| 602 | 605 | { |
| 603 | - return lib3270_print(hSession,LIB3270_CONTENT_ALL); | |
| 606 | + if(check_online_session(hSession)) | |
| 607 | + return errno = ENOTCONN; | |
| 608 | + | |
| 609 | + return hSession->cbk.print(hSession,LIB3270_CONTENT_ALL); | |
| 604 | 610 | } |
| 605 | 611 | |
| 606 | 612 | LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession) |
| 607 | 613 | { |
| 614 | + if(check_online_session(hSession)) | |
| 615 | + return errno = ENOTCONN; | |
| 616 | + | |
| 608 | 617 | if(lib3270_has_selection(hSession)) |
| 609 | - return lib3270_print(hSession,LIB3270_CONTENT_SELECTED); | |
| 618 | + return hSession->cbk.print(hSession,LIB3270_CONTENT_SELECTED); | |
| 619 | + | |
| 610 | 620 | return errno = ENODATA; |
| 611 | 621 | } |
| 612 | 622 | |
| 613 | 623 | LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) |
| 614 | 624 | { |
| 615 | - return lib3270_print(hSession,LIB3270_CONTENT_COPY); | |
| 625 | + if(check_online_session(hSession)) | |
| 626 | + return errno = ENOTCONN; | |
| 627 | + | |
| 628 | + return hSession->cbk.print(hSession,LIB3270_CONTENT_COPY); | |
| 616 | 629 | } |
| 617 | 630 | |
| 618 | 631 | LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, const char *filename) | ... | ... |
src/include/lib3270.h
| ... | ... | @@ -781,18 +781,45 @@ |
| 781 | 781 | LIB3270_EXPORT int lib3270_move_cursor(H3270 *h, LIB3270_DIRECTION dir, unsigned char sel); |
| 782 | 782 | |
| 783 | 783 | /** |
| 784 | - * @brief Print page | |
| 784 | + * @brief Default print operation. | |
| 785 | + * | |
| 786 | + * If the terminal has selected area print them, if not, print all contents. | |
| 785 | 787 | * |
| 786 | 788 | * @param hSession Session Handle. |
| 787 | - * @param mode Content option. | |
| 788 | 789 | * |
| 789 | 790 | * @return 0 if ok, error code if not. |
| 790 | 791 | * |
| 791 | 792 | */ |
| 792 | - LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_CONTENT_OPTION mode); | |
| 793 | + LIB3270_EXPORT int lib3270_print(H3270 *hSession); | |
| 793 | 794 | |
| 795 | + /** | |
| 796 | + * @brief Print terminal screen. | |
| 797 | + * | |
| 798 | + * @param hSession Session Handle. | |
| 799 | + * | |
| 800 | + * @return 0 if ok, error code if not. | |
| 801 | + * | |
| 802 | + */ | |
| 794 | 803 | LIB3270_EXPORT int lib3270_print_all(H3270 *hSession); |
| 804 | + | |
| 805 | + /** | |
| 806 | + * @brief Print only selected area (if available). | |
| 807 | + * | |
| 808 | + * @param hSession Session Handle. | |
| 809 | + * | |
| 810 | + * @return 0 if ok, error code if not. | |
| 811 | + * | |
| 812 | + */ | |
| 795 | 813 | LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession); |
| 814 | + | |
| 815 | + /** | |
| 816 | + * @brief Ask the front end module to print stored copy. | |
| 817 | + * | |
| 818 | + * @param hSession Session Handle. | |
| 819 | + * | |
| 820 | + * @return 0 if ok, error code if not. | |
| 821 | + * | |
| 822 | + */ | |
| 796 | 823 | LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession); |
| 797 | 824 | |
| 798 | 825 | /** | ... | ... |
src/testprogram/testprogram.c