From 8885132a33fa264d1a6c940bba4a9a809487603a Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 17 Jul 2019 11:32:38 -0300 Subject: [PATCH] Updating properties, fixing warnings. --- src/include/lib3270.h | 9 ++++----- src/include/lib3270/properties.h | 2 +- src/lib3270/kybd.c | 8 ++++---- src/lib3270/properties.c | 70 +++++++++++++++++++++++++++++++++++----------------------------------- src/lib3270/screen.c | 8 +++++--- src/lib3270/selection/actions.c | 4 ++-- 6 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 8593b86..e2f4c66 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -738,11 +738,10 @@ * * @param hSession Session handle. * - * @return Cursor address or -1 if invalid (sets errno). + * @return Cursor address or 0 if invalid (sets errno). * */ - LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *hSession); - + LIB3270_EXPORT unsigned int lib3270_get_cursor_address(H3270 *hSession); /** * @brief Move cursor @@ -1238,8 +1237,8 @@ * @param Delay in milliseconds. * */ - LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *session, int delay); - LIB3270_EXPORT int lib3270_get_unlock_delay(H3270 *session); + LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *session, unsigned int delay); + LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(H3270 *session); /** * @brief Alloc/Realloc memory buffer. diff --git a/src/include/lib3270/properties.h b/src/include/lib3270/properties.h index bd56699..c6d1df9 100644 --- a/src/include/lib3270/properties.h +++ b/src/include/lib3270/properties.h @@ -56,7 +56,7 @@ const char * name; ///< @brief Property name. const char * description; ///< @brief Property description. unsigned int (*get)(H3270 *hSession); ///< @brief Get value. - unsigned int (*set)(H3270 *hSession, unsigned int value); ///< @brief Set value. + int (*set)(H3270 *hSession, unsigned int value); ///< @brief Set value. } LIB3270_UINT_PROPERTY; diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index 52961f4..09d2d8a 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -2759,21 +2759,21 @@ int kybd_prime(H3270 *hSession) } #endif /*]*/ -LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *session, int delay) +LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *session, unsigned int delay) { CHECK_SESSION_HANDLE(session); - trace("%s(%d)",__FUNCTION__,(int) delay); + trace("%s(%u)",__FUNCTION__,delay); session->unlock_delay_ms = (unsigned short) delay; return 0; } -LIB3270_EXPORT int lib3270_get_unlock_delay(H3270 *session) +LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(H3270 *session) { CHECK_SESSION_HANDLE(session); - return (int) session->unlock_delay_ms; + return (unsigned int) session->unlock_delay_ms; } diff --git a/src/lib3270/properties.c b/src/lib3270/properties.c index 81a1f25..33d59e1 100644 --- a/src/lib3270/properties.c +++ b/src/lib3270/properties.c @@ -204,6 +204,41 @@ static const LIB3270_UINT_PROPERTY properties[] = { + { + "cursor_address", // Property name. + N_( "Cursor address" ), // Property description. + lib3270_get_cursor_address, // Get value. + lib3270_set_cursor_address // Set value. + }, + + { + "width",// Property name. + N_( "Current screen width in columns" ), // Property description. + lib3270_get_width, // Get value. + NULL // Set value. + }, + + { + "height", // Property name. + N_( "Current screen height in rows" ), // Property description. + lib3270_get_height, // Get value. + NULL // Set value. + }, + + { + "length", // Property name. + N_( "Screen buffer length in bytes" ), // Property description. + lib3270_get_length, // Get value. + NULL // Set value. + }, + + { + "unlock_delay", // Property name. + N_( "The delay between the host unlocking the keyboard and the actual unlock" ), // Property description. + lib3270_get_unlock_delay, // Get value. + lib3270_set_unlock_delay // Set value. + }, + /* { "", // Property name. @@ -230,13 +265,6 @@ static const LIB3270_INT_PROPERTY properties[] = { { - "cursor_address", // Property name. - N_( "Cursor address" ), // Property description. - lib3270_get_cursor_address, // Get value. - lib3270_set_cursor_address // Set value. - }, - - { "model_number", // Property name. N_( "The model number" ), // Property description. lib3270_get_model_number, // Get value. @@ -251,27 +279,6 @@ }, { - "width",// Property name. - N_( "Current screen width in columns" ), // Property description. - lib3270_get_width, // Get value. - NULL // Set value. - }, - - { - "height", // Property name. - N_( "Current screen width in rows" ), // Property description. - lib3270_get_height, // Get value. - NULL // Set value. - }, - - { - "length", // Property name. - N_( "Screen buffer length in bytes" ), // Property description. - lib3270_get_length, // Get value. - NULL // Set value. - }, - - { "cstate", // Property name. N_( "Connection state" ), // Property description. lib3270_get_connection_state_as_int, // Get value. @@ -285,13 +292,6 @@ NULL // Set value. }, - { - "unlock_delay", // Property name. - N_( "The delay between the host unlocking the keyboard and the actual unlock" ), // Property description. - lib3270_get_unlock_delay, // Get value. - lib3270_set_unlock_delay // Set value. - }, - /* { "", // Property name. diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 1796ddd..e20955f 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -404,10 +404,12 @@ void screen_update(H3270 *session, int bstart, int bend) } -LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h) +LIB3270_EXPORT unsigned int lib3270_get_cursor_address(H3270 *hSession) { - CHECK_SESSION_HANDLE(h); - return h->cursor_addr; + if(check_online_session(hSession)) + return 0; + + return hSession->cursor_addr; } /** diff --git a/src/lib3270/selection/actions.c b/src/lib3270/selection/actions.c index 9f8bfa2..6950b84 100644 --- a/src/lib3270/selection/actions.c +++ b/src/lib3270/selection/actions.c @@ -290,14 +290,14 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir switch(dir) { case LIB3270_DIR_UP: - if(start <= hSession->cols) + if(start <= ((int) hSession->cols)) return EINVAL; start -= hSession->cols; end -= hSession->cols; break; case LIB3270_DIR_DOWN: - if(end >= (hSession->cols * (hSession->rows-1))) + if(end >= ((int) (hSession->cols * (hSession->rows-1)))) return EINVAL; start += hSession->cols; end += hSession->cols; -- libgit2 0.21.2