diff --git a/src/core/ctlr.c b/src/core/ctlr.c index e692fac..77abdfd 100644 --- a/src/core/ctlr.c +++ b/src/core/ctlr.c @@ -318,7 +318,7 @@ static void ctlr_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GNUC_UN hSession->crm_nattr = 0; } -LIB3270_EXPORT int lib3270_get_is_formatted(H3270 *hSession) +LIB3270_EXPORT int lib3270_get_is_formatted(const H3270 *hSession) { if(check_online_session(hSession)) return -1; @@ -389,7 +389,7 @@ LIB3270_EXPORT int lib3270_get_field_len(H3270 *hSession, int baddr) return -(errno = ENODATA); } -LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) +LIB3270_EXPORT int lib3270_field_addr(const H3270 *hSession, int baddr) { int sbaddr; @@ -525,11 +525,11 @@ LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0) return 0; } -LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, unsigned int row, unsigned int col) { - return lib3270_get_is_protected(h, ((row-1) * h->view.cols) + (col-1)); +LIB3270_EXPORT int lib3270_get_is_protected_at(const H3270 *h, unsigned int row, unsigned int col) { + return lib3270_get_is_protected(h, lib3270_translate_to_address(h,row,col)); } -LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr) +LIB3270_EXPORT int lib3270_get_is_protected(const H3270 *hSession, int baddr) { FAIL_IF_NOT_ONLINE(hSession); diff --git a/src/core/keyboard/properties.c b/src/core/keyboard/properties.c index 1e79740..531a84a 100644 --- a/src/core/keyboard/properties.c +++ b/src/core/keyboard/properties.c @@ -31,7 +31,7 @@ #include #include -LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_get_keyboard_lock_state(H3270 *hSession) +LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_get_keyboard_lock_state(const H3270 *hSession) { if(check_online_session(hSession)) return LIB3270_KL_NOT_CONNECTED; @@ -45,7 +45,7 @@ LIB3270_EXPORT int lib3270_set_lock_on_operator_error(H3270 *hSession, int enabl return 0; } -int lib3270_get_lock_on_operator_error(H3270 *hSession) +int lib3270_get_lock_on_operator_error(const H3270 *hSession) { return (int) hSession->oerr_lock; } @@ -57,7 +57,7 @@ LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *hSession, unsigned int delay) return 0; } -LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(H3270 *hSession) +LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(const H3270 *hSession) { return (unsigned int) hSession->unlock_delay_ms; } diff --git a/src/core/model.c b/src/core/model.c index 1b59ee3..3f9b6e5 100644 --- a/src/core/model.c +++ b/src/core/model.c @@ -84,7 +84,7 @@ * @param hSession selected 3270 session. * @return Current model number. */ -int lib3270_get_model_number(H3270 *hSession) +int lib3270_get_model_number(const H3270 *hSession) { return hSession->model_num; } diff --git a/src/core/properties/boolean.c b/src/core/properties/boolean.c index 74028b0..3f6cf52 100644 --- a/src/core/properties/boolean.c +++ b/src/core/properties/boolean.c @@ -34,7 +34,7 @@ #include #include - int lib3270_is_starting(H3270 *hSession) + int lib3270_is_starting(const H3270 *hSession) { return hSession->starting != 0; } diff --git a/src/core/properties/signed.c b/src/core/properties/signed.c index eb50054..8f7a22f 100644 --- a/src/core/properties/signed.c +++ b/src/core/properties/signed.c @@ -34,17 +34,17 @@ #include #include - static int lib3270_get_connection_state_as_int(H3270 *hSession) + static int lib3270_get_connection_state_as_int(const H3270 *hSession) { return (int) lib3270_get_connection_state(hSession); } - static int lib3270_get_program_message_as_int(H3270 *hSession) + static int lib3270_get_program_message_as_int(const H3270 *hSession) { return (int) lib3270_get_program_message(hSession); } - static int lib3270_get_ssl_state_as_int(H3270 * hSession) + static int lib3270_get_ssl_state_as_int(const H3270 * hSession) { return (int) lib3270_get_ssl_state(hSession); } diff --git a/src/core/properties/unsigned.c b/src/core/properties/unsigned.c index 2a52a61..573fda0 100644 --- a/src/core/properties/unsigned.c +++ b/src/core/properties/unsigned.c @@ -34,7 +34,7 @@ #include #include - unsigned int lib3270_get_kybdlock_as_int(H3270 *hSession) + unsigned int lib3270_get_kybdlock_as_int(const H3270 *hSession) { return (unsigned int) lib3270_get_keyboard_lock_state(hSession); } diff --git a/src/core/screen.c b/src/core/screen.c index 40f55c8..205be44 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -245,31 +245,24 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa) return a; } -LIB3270_EXPORT unsigned int lib3270_get_length(H3270 *h) +LIB3270_EXPORT unsigned int lib3270_get_length(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return h->view.rows * h->view.cols; } -LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, unsigned int *r, unsigned int *c) +LIB3270_EXPORT void lib3270_get_screen_size(const H3270 *h, unsigned int *r, unsigned int *c) { - CHECK_SESSION_HANDLE(h); *r = h->view.rows; *c = h->view.cols; - -// trace("%s: %d - %d",__FUNCTION__, h->rows, h->cols); - } -LIB3270_EXPORT unsigned int lib3270_get_width(H3270 *h) +LIB3270_EXPORT unsigned int lib3270_get_width(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return h->view.cols; } -LIB3270_EXPORT unsigned int lib3270_get_height(H3270 *h) +LIB3270_EXPORT unsigned int lib3270_get_height(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return h->view.rows; } @@ -405,7 +398,7 @@ void screen_update(H3270 *session, int bstart, int bend) } -LIB3270_EXPORT unsigned int lib3270_get_cursor_address(H3270 *hSession) +LIB3270_EXPORT unsigned int lib3270_get_cursor_address(const H3270 *hSession) { if(check_online_session(hSession)) return 0; @@ -587,9 +580,8 @@ void status_reset(H3270 *session) * * @see LIB3270_MESSAGE */ -LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_program_message(H3270 *session) +LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_program_message(const H3270 *session) { - CHECK_SESSION_HANDLE(session); return session->oia.status; } diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 21f21fa..f99ff41 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -425,7 +425,7 @@ * @param c Pointer to screen columns. * */ - LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, unsigned int *r, unsigned int *c); + LIB3270_EXPORT void lib3270_get_screen_size(const H3270 *h, unsigned int *r, unsigned int *c); /** * Get current screen width in columns. @@ -435,7 +435,7 @@ * @return screen width. * */ - LIB3270_EXPORT unsigned int lib3270_get_width(H3270 *h); + LIB3270_EXPORT unsigned int lib3270_get_width(const H3270 *h); /** * Get current screen width in rows. @@ -445,9 +445,9 @@ * @return screen rows. * */ - LIB3270_EXPORT unsigned int lib3270_get_height(H3270 *h); + LIB3270_EXPORT unsigned int lib3270_get_height(const H3270 *h); - LIB3270_EXPORT unsigned int lib3270_get_length(H3270 *h); + LIB3270_EXPORT unsigned int lib3270_get_length(const H3270 *h); /** * @brief Creates an empty TN3270 session. @@ -800,7 +800,7 @@ * @return Cursor address or 0 if invalid (sets errno). * */ - LIB3270_EXPORT unsigned int lib3270_get_cursor_address(H3270 *hSession); + LIB3270_EXPORT unsigned int lib3270_get_cursor_address(const H3270 *hSession); /** * @brief Move cursor @@ -966,7 +966,7 @@ * @return Latest program message. * */ - LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_program_message(H3270 *h); + LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_program_message(const H3270 *h); /** * Get connected LU name. @@ -1089,7 +1089,7 @@ LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession); - LIB3270_EXPORT int lib3270_has_selection(H3270 *hSession); + LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession); /** * @brief Get all text inside the terminal. @@ -1174,7 +1174,7 @@ * @return -1 when failed 1 if the addr is protected and 0 if not. * */ - LIB3270_EXPORT int lib3270_get_is_protected(H3270 *hSession, int baddr0); + LIB3270_EXPORT int lib3270_get_is_protected(const H3270 *hSession, int baddr0); LIB3270_EXPORT int LIB3270_DEPRECATED(lib3270_is_protected(H3270 *h, unsigned int baddr)); @@ -1185,8 +1185,11 @@ * * @return -1 when failed 1 if the session is formatted and 0 if not. * + * @retval -1 Failed (check errno for error code). + * @retval 0 Screen is not formatted. + * @retval 1 Screen is formatted. */ - LIB3270_EXPORT int lib3270_get_is_formatted(H3270 *hSession); + LIB3270_EXPORT int lib3270_get_is_formatted(const H3270 *hSession); /** * @brief Get Check if the screen position is protected. @@ -1196,7 +1199,7 @@ * @param col Desired col. * */ - LIB3270_EXPORT int lib3270_get_is_protected_at(H3270 *h, unsigned int row, unsigned int col); + LIB3270_EXPORT int lib3270_get_is_protected_at(const H3270 *h, unsigned int row, unsigned int col); /** * @brief Get address of the first blank. @@ -1225,7 +1228,7 @@ * @exception -ENODATA No field at the address. * */ - LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr); + LIB3270_EXPORT int lib3270_field_addr(const H3270 *hSession, int baddr); /** * @brief Get field attribute for a given buffer address. @@ -1304,7 +1307,7 @@ LIB3270_EXPORT int lib3270_set_model(H3270 *hSession, const char *name); LIB3270_EXPORT const char * lib3270_get_model(const H3270 *session); - LIB3270_EXPORT int lib3270_get_model_number(H3270 *hSession); + LIB3270_EXPORT int lib3270_get_model_number(const H3270 *hSession); LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name); @@ -1328,7 +1331,7 @@ * */ LIB3270_EXPORT int lib3270_set_unlock_delay(H3270 *session, unsigned int delay); - LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(H3270 *session); + LIB3270_EXPORT unsigned int lib3270_get_unlock_delay(const H3270 *session); /** * @brief Alloc/Realloc memory buffer. diff --git a/src/include/lib3270/keyboard.h b/src/include/lib3270/keyboard.h index 059a9f8..fbf4a2c 100644 --- a/src/include/lib3270/keyboard.h +++ b/src/include/lib3270/keyboard.h @@ -69,7 +69,7 @@ */ LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_wait_for_keyboard_unlock(H3270 *hSession, int seconds); - LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_get_keyboard_lock_state(H3270 *hSession); + LIB3270_EXPORT LIB3270_KEYBOARD_LOCK_STATE lib3270_get_keyboard_lock_state(const H3270 *hSession); /** * @brief Set te operator error lock. @@ -83,7 +83,7 @@ * */ LIB3270_EXPORT int lib3270_set_lock_on_operator_error(H3270 *hSession, int enable); - LIB3270_EXPORT int lib3270_get_lock_on_operator_error(H3270 *hSession); + LIB3270_EXPORT int lib3270_get_lock_on_operator_error(const H3270 *hSession); #ifdef __cplusplus } diff --git a/src/include/lib3270/properties.h b/src/include/lib3270/properties.h index fd5c17d..9d3a965 100644 --- a/src/include/lib3270/properties.h +++ b/src/include/lib3270/properties.h @@ -46,7 +46,7 @@ { const char * name; ///< @brief Property name. const char * description; ///< @brief Property description. - int (*get)(H3270 *hSession); ///< @brief Get value. + int (*get)(const H3270 *hSession); ///< @brief Get value. int (*set)(H3270 *hSession, int value); ///< @brief Set value. } LIB3270_INT_PROPERTY; @@ -55,7 +55,7 @@ { const char * name; ///< @brief Property name. const char * description; ///< @brief Property description. - unsigned int (*get)(H3270 *hSession); ///< @brief Get value. + unsigned int (*get)(const H3270 *hSession); ///< @brief Get value. int (*set)(H3270 *hSession, unsigned int value); ///< @brief Set value. } LIB3270_UINT_PROPERTY; diff --git a/src/selection/selection.c b/src/selection/selection.c index 961e410..c0c2095 100644 --- a/src/selection/selection.c +++ b/src/selection/selection.c @@ -390,7 +390,7 @@ LIB3270_EXPORT char * lib3270_get_field_string_at(H3270 *session, int baddr) return lib3270_get_string_at_address(session,first,lib3270_field_length(session,first)+1,0); } -LIB3270_EXPORT int lib3270_has_selection(H3270 *hSession) +LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) { if(check_online_session(hSession)) return 0; -- libgit2 0.21.2