Commit e035bbac37a61991708d89122811309186d33dd7
1 parent
4ee2d89f
Exists in
master
and in
3 other branches
Adding print methods in the main library.
Showing
4 changed files
with
40 additions
and
10 deletions
Show diff stats
src/include/lib3270.h
@@ -82,6 +82,17 @@ | @@ -82,6 +82,17 @@ | ||
82 | #define LIB3270_LUNAME_LENGTH 16 | 82 | #define LIB3270_LUNAME_LENGTH 16 |
83 | 83 | ||
84 | /** | 84 | /** |
85 | + * @brief Print modes. | ||
86 | + * | ||
87 | + */ | ||
88 | + typedef enum _lib3270_print_mode | ||
89 | + { | ||
90 | + LIB3270_PRINT_ALL, | ||
91 | + LIB3270_PRINT_SELECTED, | ||
92 | + LIB3270_PRINT_COPY | ||
93 | + } LIB3270_PRINT_MODE; | ||
94 | + | ||
95 | + /** | ||
85 | * @brief Character attributes. | 96 | * @brief Character attributes. |
86 | */ | 97 | */ |
87 | typedef enum _lib3270_attr | 98 | typedef enum _lib3270_attr |
@@ -720,15 +731,21 @@ | @@ -720,15 +731,21 @@ | ||
720 | */ | 731 | */ |
721 | LIB3270_EXPORT int lib3270_move_cursor(H3270 *h, LIB3270_DIRECTION dir, unsigned char sel); | 732 | LIB3270_EXPORT int lib3270_move_cursor(H3270 *h, LIB3270_DIRECTION dir, unsigned char sel); |
722 | 733 | ||
734 | + | ||
723 | /** | 735 | /** |
724 | * @brief Print page | 736 | * @brief Print page |
725 | * | 737 | * |
726 | - * @param h Session Handle. | 738 | + * @param hSession Session Handle. |
739 | + * @param mode Print mode. | ||
727 | * | 740 | * |
728 | * @return 0 if ok, error code if not. | 741 | * @return 0 if ok, error code if not. |
729 | * | 742 | * |
730 | */ | 743 | */ |
731 | - LIB3270_EXPORT int lib3270_print(H3270 *h); | 744 | + LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_PRINT_MODE mode); |
745 | + | ||
746 | + LIB3270_EXPORT int lib3270_print_all(H3270 *hSession); | ||
747 | + LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession); | ||
748 | + LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession); | ||
732 | 749 | ||
733 | /** | 750 | /** |
734 | * @brief Get buffer contents. | 751 | * @brief Get buffer contents. |
src/include/lib3270/session.h
@@ -74,8 +74,7 @@ | @@ -74,8 +74,7 @@ | ||
74 | void (*set_selection)(H3270 *session, unsigned char on); | 74 | void (*set_selection)(H3270 *session, unsigned char on); |
75 | void (*ctlr_done)(H3270 *session); | 75 | void (*ctlr_done)(H3270 *session); |
76 | void (*autostart)(H3270 *session); | 76 | void (*autostart)(H3270 *session); |
77 | - int (*print)(H3270 *session); | ||
78 | - | 77 | + int (*print)(H3270 *session, LIB3270_PRINT_MODE mode); |
79 | 78 | ||
80 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); | 79 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); |
81 | void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); | 80 | void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); |
src/lib3270/session.c
@@ -185,10 +185,10 @@ static void set_cursor(H3270 *session unused, LIB3270_POINTER id unused) | @@ -185,10 +185,10 @@ static void set_cursor(H3270 *session unused, LIB3270_POINTER id unused) | ||
185 | { | 185 | { |
186 | } | 186 | } |
187 | 187 | ||
188 | -static int print(H3270 *session) | 188 | +static int print(H3270 *session, LIB3270_PRINT_MODE mode unused) |
189 | { | 189 | { |
190 | lib3270_write_log(session, "print", "%s", "Printing is unavailable"); | 190 | lib3270_write_log(session, "print", "%s", "Printing is unavailable"); |
191 | - return -1; | 191 | + return errno = ENOTSUP; |
192 | } | 192 | } |
193 | 193 | ||
194 | static void message(H3270 *session, LIB3270_NOTIFY id unused, const char *title, const char *msg, const char *text) | 194 | static void message(H3270 *session, LIB3270_NOTIFY id unused, const char *title, const char *msg, const char *text) |
src/lib3270/util.c
@@ -592,13 +592,27 @@ void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...) | @@ -592,13 +592,27 @@ void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...) | ||
592 | 592 | ||
593 | } | 593 | } |
594 | 594 | ||
595 | -LIB3270_EXPORT int lib3270_print(H3270 *h) | 595 | +LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_PRINT_MODE mode) |
596 | { | 596 | { |
597 | - CHECK_SESSION_HANDLE(h); | ||
598 | - trace("%s(%p)",__FUNCTION__,h); | ||
599 | - return h->cbk.print(h); | 597 | + return hSession->cbk.print(hSession, mode); |
600 | } | 598 | } |
601 | 599 | ||
600 | +LIB3270_EXPORT int lib3270_print_all(H3270 *hSession) | ||
601 | +{ | ||
602 | + return lib3270_print(hSession,LIB3270_PRINT_ALL); | ||
603 | +} | ||
604 | + | ||
605 | +LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession) | ||
606 | +{ | ||
607 | + if(lib3270_has_selection(hSession)) | ||
608 | + return lib3270_print(hSession,LIB3270_PRINT_SELECTED); | ||
609 | + return errno = ENODATA; | ||
610 | +} | ||
611 | + | ||
612 | +LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) | ||
613 | +{ | ||
614 | + return lib3270_print(hSession,LIB3270_PRINT_COPY); | ||
615 | +} | ||
602 | 616 | ||
603 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) | 617 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) |
604 | { | 618 | { |