Commit 67a51e3a364a5c26008d1366c70e5a9a2bee7789
1 parent
25546cf9
Exists in
master
and in
3 other branches
Exporting "save" options.
Showing
4 changed files
with
60 additions
and
14 deletions
Show diff stats
src/core/session.c
@@ -192,12 +192,18 @@ static void set_cursor(H3270 GNUC_UNUSED(*session), LIB3270_POINTER GNUC_UNUSED( | @@ -192,12 +192,18 @@ static void set_cursor(H3270 GNUC_UNUSED(*session), LIB3270_POINTER GNUC_UNUSED( | ||
192 | { | 192 | { |
193 | } | 193 | } |
194 | 194 | ||
195 | -static int print(H3270 *session, LIB3270_PRINT_MODE GNUC_UNUSED(mode)) | 195 | +static int print(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode)) |
196 | { | 196 | { |
197 | lib3270_write_log(session, "print", "%s", "Printing is unavailable"); | 197 | lib3270_write_log(session, "print", "%s", "Printing is unavailable"); |
198 | return errno = ENOTSUP; | 198 | return errno = ENOTSUP; |
199 | } | 199 | } |
200 | 200 | ||
201 | +static int save(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode), const char GNUC_UNUSED(*filename)) | ||
202 | +{ | ||
203 | + lib3270_write_log(session, "save", "%s", "Saving is unavailable"); | ||
204 | + return errno = ENOTSUP; | ||
205 | +} | ||
206 | + | ||
201 | static void message(H3270 *session, LIB3270_NOTIFY GNUC_UNUSED(id), const char *title, const char *msg, const char *text) | 207 | static void message(H3270 *session, LIB3270_NOTIFY GNUC_UNUSED(id), const char *title, const char *msg, const char *text) |
202 | { | 208 | { |
203 | #ifdef ANDROID | 209 | #ifdef ANDROID |
@@ -301,6 +307,7 @@ void lib3270_reset_callbacks(H3270 *hSession) | @@ -301,6 +307,7 @@ void lib3270_reset_callbacks(H3270 *hSession) | ||
301 | hSession->cbk.autostart = nop; | 307 | hSession->cbk.autostart = nop; |
302 | hSession->cbk.set_timer = set_timer; | 308 | hSession->cbk.set_timer = set_timer; |
303 | hSession->cbk.print = print; | 309 | hSession->cbk.print = print; |
310 | + hSession->cbk.save = save; | ||
304 | hSession->cbk.set_peer_certificate = set_peer_certificate; | 311 | hSession->cbk.set_peer_certificate = set_peer_certificate; |
305 | hSession->cbk.update_luname = default_update_luname; | 312 | hSession->cbk.update_luname = default_update_luname; |
306 | 313 |
src/core/util.c
@@ -593,28 +593,51 @@ void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...) | @@ -593,28 +593,51 @@ 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_PRINT_MODE mode) | 596 | +LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_CONTENT_OPTION mode) |
597 | { | 597 | { |
598 | return hSession->cbk.print(hSession, mode); | 598 | return hSession->cbk.print(hSession, mode); |
599 | } | 599 | } |
600 | 600 | ||
601 | LIB3270_EXPORT int lib3270_print_all(H3270 *hSession) | 601 | LIB3270_EXPORT int lib3270_print_all(H3270 *hSession) |
602 | { | 602 | { |
603 | - return lib3270_print(hSession,LIB3270_PRINT_ALL); | 603 | + return lib3270_print(hSession,LIB3270_CONTENT_ALL); |
604 | } | 604 | } |
605 | 605 | ||
606 | LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession) | 606 | LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession) |
607 | { | 607 | { |
608 | if(lib3270_has_selection(hSession)) | 608 | if(lib3270_has_selection(hSession)) |
609 | - return lib3270_print(hSession,LIB3270_PRINT_SELECTED); | 609 | + return lib3270_print(hSession,LIB3270_CONTENT_SELECTED); |
610 | return errno = ENODATA; | 610 | return errno = ENODATA; |
611 | } | 611 | } |
612 | 612 | ||
613 | LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) | 613 | LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) |
614 | { | 614 | { |
615 | - return lib3270_print(hSession,LIB3270_PRINT_COPY); | 615 | + return lib3270_print(hSession,LIB3270_CONTENT_COPY); |
616 | } | 616 | } |
617 | 617 | ||
618 | +LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, const char *filename) | ||
619 | +{ | ||
620 | + return hSession->cbk.save(hSession, mode, filename); | ||
621 | +} | ||
622 | + | ||
623 | +LIB3270_EXPORT int lib3270_save_all(H3270 *hSession, const char *filename) | ||
624 | +{ | ||
625 | + return lib3270_save(hSession,LIB3270_CONTENT_ALL,filename); | ||
626 | +} | ||
627 | + | ||
628 | +LIB3270_EXPORT int lib3270_save_selected(H3270 *hSession, const char *filename) | ||
629 | +{ | ||
630 | + if(lib3270_has_selection(hSession)) | ||
631 | + return lib3270_save(hSession,LIB3270_CONTENT_SELECTED,filename); | ||
632 | + return errno = ENODATA; | ||
633 | +} | ||
634 | + | ||
635 | +LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename) | ||
636 | +{ | ||
637 | + return lib3270_save(hSession,LIB3270_CONTENT_COPY,filename); | ||
638 | +} | ||
639 | + | ||
640 | + | ||
618 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) | 641 | LIB3270_EXPORT LIB3270_POINTER lib3270_get_pointer(H3270 *hSession, int baddr) |
619 | { | 642 | { |
620 | static const struct _ptr { | 643 | static const struct _ptr { |
src/include/lib3270.h
@@ -84,15 +84,15 @@ | @@ -84,15 +84,15 @@ | ||
84 | #define LIB3270_LUNAME_LENGTH 16 | 84 | #define LIB3270_LUNAME_LENGTH 16 |
85 | 85 | ||
86 | /** | 86 | /** |
87 | - * @brief Print modes. | 87 | + * @brief Selection mode. |
88 | * | 88 | * |
89 | */ | 89 | */ |
90 | - typedef enum _lib3270_print_mode | 90 | + typedef enum _lib3270_content_option |
91 | { | 91 | { |
92 | - LIB3270_PRINT_ALL, | ||
93 | - LIB3270_PRINT_SELECTED, | ||
94 | - LIB3270_PRINT_COPY | ||
95 | - } LIB3270_PRINT_MODE; | 92 | + LIB3270_CONTENT_ALL, ///< @brief Get all the terminal data. |
93 | + LIB3270_CONTENT_SELECTED, ///< @brief Get only selected contents. | ||
94 | + LIB3270_CONTENT_COPY ///< @brief Get internal copy. | ||
95 | + } LIB3270_CONTENT_OPTION; | ||
96 | 96 | ||
97 | /** | 97 | /** |
98 | * @brief Character attributes. | 98 | * @brief Character attributes. |
@@ -784,18 +784,33 @@ | @@ -784,18 +784,33 @@ | ||
784 | * @brief Print page | 784 | * @brief Print page |
785 | * | 785 | * |
786 | * @param hSession Session Handle. | 786 | * @param hSession Session Handle. |
787 | - * @param mode Print mode. | 787 | + * @param mode Content option. |
788 | * | 788 | * |
789 | * @return 0 if ok, error code if not. | 789 | * @return 0 if ok, error code if not. |
790 | * | 790 | * |
791 | */ | 791 | */ |
792 | - LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_PRINT_MODE mode); | 792 | + LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_CONTENT_OPTION mode); |
793 | 793 | ||
794 | LIB3270_EXPORT int lib3270_print_all(H3270 *hSession); | 794 | LIB3270_EXPORT int lib3270_print_all(H3270 *hSession); |
795 | LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession); | 795 | LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession); |
796 | LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession); | 796 | LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession); |
797 | 797 | ||
798 | /** | 798 | /** |
799 | + * @brief Save contents to file. | ||
800 | + * | ||
801 | + * @param hSession Session Handle. | ||
802 | + * @param mode Content option. | ||
803 | + * @param filename File name. | ||
804 | + * | ||
805 | + * @return 0 if ok, error code if not. | ||
806 | + */ | ||
807 | + LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, const char *filename); | ||
808 | + | ||
809 | + LIB3270_EXPORT int lib3270_save_all(H3270 *hSession, const char *filename); | ||
810 | + LIB3270_EXPORT int lib3270_save_selected(H3270 *hSession, const char *filename); | ||
811 | + LIB3270_EXPORT int lib3270_save_copy(H3270 *hSession, const char *filename); | ||
812 | + | ||
813 | + /** | ||
799 | * @brief Get buffer contents. | 814 | * @brief Get buffer contents. |
800 | * | 815 | * |
801 | * @param h Session handle. | 816 | * @param h Session handle. |
src/include/lib3270/session.h
@@ -74,7 +74,8 @@ | @@ -74,7 +74,8 @@ | ||
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, LIB3270_PRINT_MODE mode); | 77 | + int (*print)(H3270 *session, LIB3270_CONTENT_OPTION mode); |
78 | + int (*save)(H3270 *session, LIB3270_CONTENT_OPTION mode, const char *filename); | ||
78 | 79 | ||
79 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); | 80 | void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); |
80 | void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); | 81 | void (*popup)(H3270 *session, LIB3270_NOTIFY id, const char *title, const char *msg, const char *fmt, va_list); |