From 06893f2755c2e27bd250633c205c0cec9d62c435 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 31 Jul 2019 09:53:56 -0300 Subject: [PATCH] Updating print API. --- src/core/util.c | 23 ++++++++++++++++++----- src/include/lib3270.h | 33 ++++++++++++++++++++++++++++++--- src/testprogram/testprogram.c | 2 +- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/core/util.c b/src/core/util.c index 3d9cac7..7eac124 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -593,26 +593,39 @@ void lib3270_popup_an_errno(H3270 *hSession, int errn, const char *fmt, ...) } -LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_CONTENT_OPTION mode) +LIB3270_EXPORT int lib3270_print(H3270 *hSession) { - return hSession->cbk.print(hSession, mode); + if(check_online_session(hSession)) + return errno = ENOTCONN; + + return hSession->cbk.print(hSession, (hSession->selected ? LIB3270_CONTENT_SELECTED : LIB3270_CONTENT_ALL)); } LIB3270_EXPORT int lib3270_print_all(H3270 *hSession) { - return lib3270_print(hSession,LIB3270_CONTENT_ALL); + if(check_online_session(hSession)) + return errno = ENOTCONN; + + return hSession->cbk.print(hSession,LIB3270_CONTENT_ALL); } LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession) { + if(check_online_session(hSession)) + return errno = ENOTCONN; + if(lib3270_has_selection(hSession)) - return lib3270_print(hSession,LIB3270_CONTENT_SELECTED); + return hSession->cbk.print(hSession,LIB3270_CONTENT_SELECTED); + return errno = ENODATA; } LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession) { - return lib3270_print(hSession,LIB3270_CONTENT_COPY); + if(check_online_session(hSession)) + return errno = ENOTCONN; + + return hSession->cbk.print(hSession,LIB3270_CONTENT_COPY); } LIB3270_EXPORT int lib3270_save(H3270 *hSession, LIB3270_CONTENT_OPTION mode, const char *filename) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 9ea1553..54829d5 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -781,18 +781,45 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *h, LIB3270_DIRECTION dir, unsigned char sel); /** - * @brief Print page + * @brief Default print operation. + * + * If the terminal has selected area print them, if not, print all contents. * * @param hSession Session Handle. - * @param mode Content option. * * @return 0 if ok, error code if not. * */ - LIB3270_EXPORT int lib3270_print(H3270 *hSession, LIB3270_CONTENT_OPTION mode); + LIB3270_EXPORT int lib3270_print(H3270 *hSession); + /** + * @brief Print terminal screen. + * + * @param hSession Session Handle. + * + * @return 0 if ok, error code if not. + * + */ LIB3270_EXPORT int lib3270_print_all(H3270 *hSession); + + /** + * @brief Print only selected area (if available). + * + * @param hSession Session Handle. + * + * @return 0 if ok, error code if not. + * + */ LIB3270_EXPORT int lib3270_print_selected(H3270 *hSession); + + /** + * @brief Ask the front end module to print stored copy. + * + * @param hSession Session Handle. + * + * @return 0 if ok, error code if not. + * + */ LIB3270_EXPORT int lib3270_print_copy(H3270 *hSession); /** diff --git a/src/testprogram/testprogram.c b/src/testprogram/testprogram.c index f493304..2601ee5 100644 --- a/src/testprogram/testprogram.c +++ b/src/testprogram/testprogram.c @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include #include -- libgit2 0.21.2