diff --git a/src/core/charset.c b/src/core/charset.c index eab2b10..cc0621a 100644 --- a/src/core/charset.c +++ b/src/core/charset.c @@ -274,15 +274,13 @@ LIB3270_EXPORT const char * lib3270_get_default_charset(void) return "ISO-8859-1"; } -LIB3270_EXPORT const char * lib3270_get_display_charset(H3270 *hSession) +LIB3270_EXPORT const char * lib3270_get_display_charset(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; } -LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession) +LIB3270_EXPORT const char * lib3270_get_host_charset(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return hSession->charset.host; } diff --git a/src/core/host.c b/src/core/host.c index f89974b..d1efe7c 100644 --- a/src/core/host.c +++ b/src/core/host.c @@ -315,10 +315,8 @@ LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname) return 0; } -LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession) +LIB3270_EXPORT const char * lib3270_get_url(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); - if(hSession->host.full) return hSession->host.full; @@ -330,7 +328,7 @@ LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession) } -LIB3270_EXPORT const char * lib3270_get_default_host(H3270 GNUC_UNUSED(*hSession)) +LIB3270_EXPORT const char * lib3270_get_default_host(const H3270 GNUC_UNUSED(*hSession)) { #ifdef LIB3270_DEFAULT_HOST return LIB3270_DEFAULT_HOST; @@ -461,14 +459,8 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) return 0; } -LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h) +LIB3270_EXPORT const char * lib3270_get_hostname(const H3270 *h) { - CHECK_SESSION_HANDLE(h); - - // TODO: Find a better way! - if(!h->host.current) - lib3270_set_url(h,NULL); - if(h->host.current) return h->host.current; @@ -482,14 +474,8 @@ LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname) update_host(h); } -LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h) +LIB3270_EXPORT const char * lib3270_get_srvcname(const H3270 *h) { - CHECK_SESSION_HANDLE(h); - - // TODO: Find a better way! - if(!h->host.srvc) - lib3270_set_url(h,NULL); - if(h->host.srvc) return h->host.srvc; return "telnet"; @@ -502,38 +488,32 @@ LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc) update_host(h); } -LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) +LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return h->host.full; } -LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h) +LIB3270_EXPORT const char * lib3270_get_luname(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return h->connected_lu; } -LIB3270_EXPORT int lib3270_has_active_script(H3270 *h) +LIB3270_EXPORT int lib3270_has_active_script(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return (h->oia.flag[LIB3270_FLAG_SCRIPT] != 0); } -LIB3270_EXPORT int lib3270_get_typeahead(H3270 *h) +LIB3270_EXPORT int lib3270_get_typeahead(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return (h->oia.flag[LIB3270_FLAG_TYPEAHEAD] != 0); } -LIB3270_EXPORT int lib3270_get_undera(H3270 *h) +LIB3270_EXPORT int lib3270_get_undera(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return (h->oia.flag[LIB3270_FLAG_UNDERA] != 0); } -LIB3270_EXPORT int lib3270_get_oia_box_solid(H3270 *h) +LIB3270_EXPORT int lib3270_get_oia_box_solid(const H3270 *h) { - CHECK_SESSION_HANDLE(h); return (h->oia.flag[LIB3270_FLAG_BOXSOLID] != 0); } diff --git a/src/core/model.c b/src/core/model.c index 5e32abd..1b59ee3 100644 --- a/src/core/model.c +++ b/src/core/model.c @@ -34,12 +34,12 @@ #include #include - const char * lib3270_get_oversize(H3270 *hSession) + const char * lib3270_get_oversize(const H3270 *hSession) { return hSession->oversize.str; } - int lib3270_set_oversize(H3270 *hSession, const char GNUC_UNUSED(*value)) + int lib3270_set_oversize(H3270 *hSession, const char *value) { if(hSession->cstate != LIB3270_NOT_CONNECTED) return errno = EISCONN; @@ -47,10 +47,34 @@ if(!hSession->extended) return errno = ENOTSUP; - // TODO: Implement it! - // Replace(hSession->oversize.str,value); + if(hSession->oversize.str) + { + // Do nothing if it's the same value! + if(value && !strcasecmp(hSession->oversize.str,value)) + return 0; + + lib3270_free(hSession->oversize.str); + hSession->oversize.str = NULL; + } + + int ovc = 0, ovr = 0; + + if(value) + { + char junk; + + if(sscanf(value, "%dx%d%c", &ovc, &ovr, &junk) != 2) + return errno = EINVAL; - return errno = ENOTSUP; + hSession->oversize.str = lib3270_strdup(value); + + } + + ctlr_set_rows_cols(hSession, hSession->model_num, ovc, ovr); + ctlr_reinit(hSession,MODEL_CHANGE); + screen_update(hSession,0,hSession->view.rows*hSession->view.cols); + + return 0; } @@ -62,13 +86,11 @@ */ int lib3270_get_model_number(H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return hSession->model_num; } -const char * lib3270_get_model(H3270 *hSession) +const char * lib3270_get_model(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return hSession->model_name; } @@ -152,9 +174,7 @@ static int parse_model_number(H3270 *session, const char *m) int lib3270_set_model(H3270 *hSession, const char *model) { - int ovc, ovr; - char junk; - int model_number; + int model_number; if(hSession->cstate != LIB3270_NOT_CONNECTED) return errno = EISCONN; @@ -200,13 +220,6 @@ int lib3270_set_model(H3270 *hSession, const char *model) trace("Model_number: %d",model_number); - if (!hSession->extended || hSession->oversize.str == CN || sscanf(hSession->oversize.str, "%dx%d%c", &ovc, &ovr, &junk) != 2) - { - ovc = 0; - ovr = 0; - } - ctlr_set_rows_cols(hSession, model_number, ovc, ovr); - if (hSession->termname != CN) hSession->termtype = hSession->termname; else @@ -214,6 +227,18 @@ int lib3270_set_model(H3270 *hSession, const char *model) trace("Termtype: %s",hSession->termtype); + + // Check for oversize + char junk; + int ovc, ovr; + + if (!hSession->extended || hSession->oversize.str == CN || sscanf(hSession->oversize.str, "%dx%d%c", &ovc, &ovr, &junk) != 2) + { + ovc = 0; + ovr = 0; + } + + ctlr_set_rows_cols(hSession, model_number, ovc, ovr); ctlr_reinit(hSession,MODEL_CHANGE); screen_update(hSession,0,hSession->view.rows*hSession->view.cols); diff --git a/src/core/options.c b/src/core/options.c index 7e7ea36..4596297 100644 --- a/src/core/options.c +++ b/src/core/options.c @@ -73,9 +73,8 @@ /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ -LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_get_host_type(H3270 *hSession) +LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_get_host_type(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return hSession->host_type; } @@ -86,9 +85,8 @@ LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt) return 0; } -LIB3270_EXPORT int lib3270_get_color_type(H3270 *hSession) +LIB3270_EXPORT int lib3270_get_color_type(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return (int) (hSession->mono ? 2 : hSession->colors); } @@ -134,9 +132,8 @@ LIB3270_EXPORT const LIB3270_HOST_TYPE_ENTRY * lib3270_get_option_list(void) return host_type; } -LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession) +LIB3270_EXPORT int lib3270_is_tso(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return (hSession->host_type & LIB3270_HOST_TSO) != 0; } @@ -152,9 +149,8 @@ LIB3270_EXPORT int lib3270_set_tso(H3270 *hSession, int on) return 0; } -LIB3270_EXPORT int lib3270_is_as400(H3270 *hSession) +LIB3270_EXPORT int lib3270_is_as400(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return (hSession->host_type & LIB3270_HOST_AS400) != 0; } @@ -202,7 +198,7 @@ LIB3270_EXPORT int lib3270_set_host_type_by_name(H3270 *hSession, const char *na return errno = EINVAL; } -LIB3270_EXPORT const char * lib3270_get_host_type_name(H3270 *hSession) +LIB3270_EXPORT const char * lib3270_get_host_type_name(const H3270 *hSession) { size_t f; diff --git a/src/core/properties/string.c b/src/core/properties/string.c index f950d1e..57390d1 100644 --- a/src/core/properties/string.c +++ b/src/core/properties/string.c @@ -34,12 +34,12 @@ #include #include - static const char * get_version(H3270 GNUC_UNUSED(*hSession)) + static const char * get_version(const H3270 GNUC_UNUSED(*hSession)) { return lib3270_get_version(); } - static const char * get_revision(H3270 GNUC_UNUSED(*hSession)) + static const char * get_revision(const H3270 GNUC_UNUSED(*hSession)) { return lib3270_get_revision(); } diff --git a/src/core/screen.c b/src/core/screen.c index 61ff3cd..40f55c8 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -423,7 +423,7 @@ LIB3270_EXPORT unsigned int lib3270_get_cursor_address(H3270 *hSession) * @return Current address or -1 if invalid (sets errno). * */ -LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int row, unsigned int col) +LIB3270_EXPORT int lib3270_translate_to_address(const H3270 *hSession, unsigned int row, unsigned int col) { FAIL_IF_NOT_ONLINE(hSession); @@ -600,11 +600,12 @@ LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_program_message(H3270 *session) * * @return 0 if the terminal is ready (no message, keyboard unlocked), LIB3270_MESSAGE if not * + * @retval LIB3270_MESSAGE_KYBDLOCK Keyboard is locked. + * @retval LIB3270_MESSAGE_NONE Terminal is ready. + * */ -LIB3270_EXPORT LIB3270_MESSAGE lib3270_lock_status(H3270 *hSession) +LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_lock_status(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); - if(hSession->oia.status) return hSession->oia.status; @@ -623,9 +624,9 @@ LIB3270_EXPORT LIB3270_MESSAGE lib3270_lock_status(H3270 *hSession) * @return Non zero if terminal is ready for commands. * */ -LIB3270_EXPORT int lib3270_is_ready(H3270 *hSession) +LIB3270_EXPORT int lib3270_is_ready(const H3270 *hSession) { - return lib3270_lock_status(hSession) == LIB3270_MESSAGE_NONE; + return lib3270_get_lock_status(hSession) == LIB3270_MESSAGE_NONE; } diff --git a/src/core/state.c b/src/core/state.c index e4eb817..048ec3c 100644 --- a/src/core/state.c +++ b/src/core/state.c @@ -31,136 +31,63 @@ /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ -LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(H3270 *h) +LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return h->cstate; } -LIB3270_EXPORT int lib3270_pconnected(H3270 *h) +LIB3270_EXPORT int lib3270_pconnected(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (((int) h->cstate) >= (int)LIB3270_RESOLVING); } -LIB3270_EXPORT int lib3270_half_connected(H3270 *h) +LIB3270_EXPORT int lib3270_half_connected(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate == LIB3270_RESOLVING || h->cstate == LIB3270_PENDING); } -LIB3270_EXPORT int lib3270_connected(H3270 *h) +LIB3270_EXPORT int lib3270_connected(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return ((int) h->cstate >= (int)LIB3270_CONNECTED_INITIAL); } -LIB3270_EXPORT int lib3270_disconnected(H3270 *h) +LIB3270_EXPORT int lib3270_disconnected(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return ((int) h->cstate == (int)LIB3270_NOT_CONNECTED); } - -LIB3270_EXPORT int lib3270_in_neither(H3270 *h) +LIB3270_EXPORT int lib3270_in_neither(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate == LIB3270_CONNECTED_INITIAL); } -LIB3270_EXPORT int lib3270_in_ansi(H3270 *h) +LIB3270_EXPORT int lib3270_in_ansi(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate == LIB3270_CONNECTED_ANSI || h->cstate == LIB3270_CONNECTED_NVT); } -LIB3270_EXPORT int lib3270_in_3270(H3270 *h) +LIB3270_EXPORT int lib3270_in_3270(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate == LIB3270_CONNECTED_3270 || h->cstate == LIB3270_CONNECTED_TN3270E || h->cstate == LIB3270_CONNECTED_SSCP); } -LIB3270_EXPORT int lib3270_in_sscp(H3270 *h) +LIB3270_EXPORT int lib3270_in_sscp(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate == LIB3270_CONNECTED_SSCP); } -LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h) +LIB3270_EXPORT int lib3270_in_tn3270e(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate == LIB3270_CONNECTED_TN3270E); } -LIB3270_EXPORT int lib3270_is_connected(H3270 *h) +LIB3270_EXPORT int lib3270_is_connected(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate == LIB3270_CONNECTED_TN3270E); } -LIB3270_EXPORT int lib3270_in_e(H3270 *h) +LIB3270_EXPORT int lib3270_in_e(const H3270 *h) { - if(!h) - { - errno = EINVAL; - return -1; - } - return (h->cstate >= LIB3270_CONNECTED_INITIAL_E); } diff --git a/src/core/wait.c b/src/core/wait.c index b58e9b9..adcba0c 100644 --- a/src/core/wait.c +++ b/src/core/wait.c @@ -53,7 +53,7 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) do { - if(!lib3270_lock_status(hSession)) + if(!lib3270_get_lock_status(hSession)) return 0; if(!lib3270_connected(hSession)) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 02df917..21f21fa 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -511,7 +511,7 @@ * * @return URL of the predefined host in the format tn3270://hostname:service or tn3270s://hostname:service */ - LIB3270_EXPORT const char * lib3270_get_default_host(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_default_host(const H3270 *hSession); /** * @brief Set URL for the certificate revocation list. @@ -524,7 +524,7 @@ */ LIB3270_EXPORT int lib3270_set_crl_url(H3270 *hSession, const char *crl); - LIB3270_EXPORT const char * lib3270_get_crl_url(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_crl_url(const H3270 *hSession); /** * @brief Get hostname for the connect/reconnect operations. @@ -534,9 +534,9 @@ * @return Pointer to host id set (internal data, do not change it) * */ - LIB3270_EXPORT const char * lib3270_get_hostname(H3270 *h); + LIB3270_EXPORT const char * LIB3270_DEPRECATED(lib3270_get_hostname(const H3270 *h)); - LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname); + LIB3270_EXPORT void LIB3270_DEPRECATED(lib3270_set_hostname(H3270 *h, const char *hostname)); /** * @brief Get SSL host option. @@ -544,32 +544,32 @@ * @return Non zero if the host URL has SSL scheme. * */ - LIB3270_EXPORT int lib3270_get_secure_host(H3270 *hSession); + LIB3270_EXPORT int lib3270_get_secure_host(const H3270 *hSession); /** * @brief Get security state. * */ - LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_ssl_state(H3270 *session); + LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_ssl_state(const H3270 *session); - LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *session); + LIB3270_EXPORT long lib3270_get_SSL_verify_result(const H3270 *session); /** * @brief Get security state as text. * */ - LIB3270_EXPORT const char * lib3270_get_ssl_state_message(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_ssl_state_message(const H3270 *hSession); - LIB3270_EXPORT const char * lib3270_get_ssl_state_icon_name(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_ssl_state_icon_name(const H3270 *hSession); /** * @brief Get security state message. * */ - LIB3270_EXPORT const char * lib3270_get_ssl_state_description(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_ssl_state_description(const H3270 *hSession); - LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 *hSession); - LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(H3270 *hSession); + LIB3270_EXPORT char * lib3270_get_ssl_crl_text(const H3270 *hSession); + LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(const H3270 *hSession); /** @@ -580,9 +580,9 @@ * @return Pointer to service name (internal data, do not change it) * */ - LIB3270_EXPORT const char * lib3270_get_srvcname(H3270 *h); + LIB3270_EXPORT const char * LIB3270_DEPRECATED(lib3270_get_srvcname(const H3270 *h)); - LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc); + LIB3270_EXPORT void LIB3270_DEPRECATED(lib3270_set_srvcname(H3270 *h, const char *srvc)); /** * @brief Get HOST URL. @@ -590,7 +590,7 @@ * @return TN3270 Connection URL. * */ - LIB3270_EXPORT const char * lib3270_get_url(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_url(const H3270 *hSession); /** * @brief Get session options. @@ -598,9 +598,9 @@ * @param h Session handle. * */ - LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_get_host_type(H3270 *hSession); + LIB3270_EXPORT LIB3270_HOST_TYPE lib3270_get_host_type(const H3270 *hSession); - LIB3270_EXPORT const char * lib3270_get_host_type_name(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_host_type_name(const H3270 *hSession); /** * @brief Get URL of the hostname for the connect/reconnect operations. @@ -610,7 +610,7 @@ * @return Pointer to host URL set (internal data, do not change it) * */ - LIB3270_EXPORT const char * lib3270_get_host(H3270 *h); + LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h); /** @@ -655,7 +655,7 @@ * @return Connection state. * */ - LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(H3270 *h); + LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(const H3270 *h); /** * @brief Pretend that a sequence of keys was entered at the keyboard. @@ -690,7 +690,7 @@ * @retval -EOVERFLOW The coordinates are out of the screen. * */ - LIB3270_EXPORT int lib3270_translate_to_address(H3270 *hSession, unsigned int row, unsigned int col); + LIB3270_EXPORT int lib3270_translate_to_address(const H3270 *hSession, unsigned int row, unsigned int col); /** * @brief Set string at current cursor position. @@ -979,30 +979,30 @@ * @return conected LU name or NULL if not connected. * */ - LIB3270_EXPORT const char * lib3270_get_luname(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_luname(const H3270 *hSession); LIB3270_EXPORT int lib3270_set_luname(H3270 *hSession, const char *luname); - LIB3270_EXPORT int lib3270_has_active_script(H3270 *h); - LIB3270_EXPORT int lib3270_get_typeahead(H3270 *h); - LIB3270_EXPORT int lib3270_get_undera(H3270 *h); - LIB3270_EXPORT int lib3270_get_oia_box_solid(H3270 *h); - LIB3270_EXPORT int lib3270_pconnected(H3270 *h); - LIB3270_EXPORT int lib3270_half_connected(H3270 *h); - LIB3270_EXPORT int lib3270_connected(H3270 *h); - LIB3270_EXPORT int lib3270_disconnected(H3270 *h); - LIB3270_EXPORT int lib3270_in_neither(H3270 *h); - LIB3270_EXPORT int lib3270_in_ansi(H3270 *h); - LIB3270_EXPORT int lib3270_in_3270(H3270 *h); - LIB3270_EXPORT int lib3270_in_sscp(H3270 *h); - LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h); - LIB3270_EXPORT int lib3270_in_e(H3270 *h); + LIB3270_EXPORT int lib3270_has_active_script(const H3270 *h); + LIB3270_EXPORT int lib3270_get_typeahead(const H3270 *h); + LIB3270_EXPORT int lib3270_get_undera(const H3270 *h); + LIB3270_EXPORT int lib3270_get_oia_box_solid(const H3270 *h); + LIB3270_EXPORT int lib3270_pconnected(const H3270 *h); + LIB3270_EXPORT int lib3270_half_connected(const H3270 *h); + LIB3270_EXPORT int lib3270_connected(const H3270 *h); + LIB3270_EXPORT int lib3270_disconnected(const H3270 *h); + LIB3270_EXPORT int lib3270_in_neither(const H3270 *h); + LIB3270_EXPORT int lib3270_in_ansi(const H3270 *h); + LIB3270_EXPORT int lib3270_in_3270(const H3270 *h); + LIB3270_EXPORT int lib3270_in_sscp(const H3270 *h); + LIB3270_EXPORT int lib3270_in_tn3270e(const H3270 *h); + LIB3270_EXPORT int lib3270_in_e(const H3270 *h); - LIB3270_EXPORT int lib3270_is_ready(H3270 *h); - LIB3270_EXPORT int lib3270_is_connected(H3270 *h); - LIB3270_EXPORT int lib3270_is_secure(H3270 *h); + LIB3270_EXPORT int lib3270_is_ready(const H3270 *h); + LIB3270_EXPORT int lib3270_is_connected(const H3270 *h); + LIB3270_EXPORT int lib3270_is_secure(const H3270 *h); - LIB3270_EXPORT LIB3270_MESSAGE lib3270_lock_status(H3270 *h); + LIB3270_EXPORT LIB3270_MESSAGE lib3270_get_lock_status(const H3270 *h); /** * Run main iteration. @@ -1071,7 +1071,7 @@ * @return String with current encoding. * */ - LIB3270_EXPORT const char * lib3270_get_display_charset(H3270 *session); + LIB3270_EXPORT const char * lib3270_get_display_charset(const H3270 *session); #define lib3270_get_charset(s) lib3270_get_display_charset(s) @@ -1303,7 +1303,7 @@ LIB3270_EXPORT int lib3270_set_model(H3270 *hSession, const char *name); - LIB3270_EXPORT const char * lib3270_get_model(H3270 *session); + LIB3270_EXPORT const char * lib3270_get_model(const H3270 *session); LIB3270_EXPORT int lib3270_get_model_number(H3270 *hSession); LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name); @@ -1398,7 +1398,7 @@ LIB3270_EXPORT int lib3270_set_color_type(H3270 *hSession, int colortype); - LIB3270_EXPORT int lib3270_get_color_type(H3270 *hSession); + LIB3270_EXPORT int lib3270_get_color_type(const H3270 *hSession); LIB3270_EXPORT int lib3270_set_host_type_by_name(H3270 *hSession, const char *name); LIB3270_EXPORT int lib3270_set_host_type(H3270 *hSession, LIB3270_HOST_TYPE opt); @@ -1430,7 +1430,7 @@ * @return Non zero if the host is TSO. * */ - LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession); + LIB3270_EXPORT int lib3270_is_tso(const H3270 *hSession); LIB3270_EXPORT int lib3270_set_tso(H3270 *hSession, int on); @@ -1442,7 +1442,7 @@ * @return Non zero if the host is AS400. * */ - LIB3270_EXPORT int lib3270_is_as400(H3270 *hSession); + LIB3270_EXPORT int lib3270_is_as400(const H3270 *hSession); LIB3270_EXPORT int lib3270_set_as400(H3270 *hSession, int on); diff --git a/src/include/lib3270/charset.h b/src/include/lib3270/charset.h index d555886..2d8a3f1 100644 --- a/src/include/lib3270/charset.h +++ b/src/include/lib3270/charset.h @@ -59,7 +59,7 @@ } lib3270_remap_scope; LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name); - LIB3270_EXPORT const char * lib3270_get_host_charset(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_host_charset(const H3270 *hSession); LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, const char * display, unsigned long cgcsgid); LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way); diff --git a/src/include/lib3270/popup.h b/src/include/lib3270/popup.h index 3969fd7..dda9624 100644 --- a/src/include/lib3270/popup.h +++ b/src/include/lib3270/popup.h @@ -68,8 +68,8 @@ LIB3270_EXPORT void lib3270_popup_va(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, va_list); - LIB3270_EXPORT LIB3270_NOTIFY lib3270_get_ssl_state_icon(H3270 *hSession); - LIB3270_EXPORT const char * lib3270_get_ssl_state_icon_name(H3270 *hSession); + LIB3270_EXPORT LIB3270_NOTIFY lib3270_get_ssl_state_icon(const H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_ssl_state_icon_name(const H3270 *hSession); #ifdef __cplusplus } diff --git a/src/include/lib3270/properties.h b/src/include/lib3270/properties.h index b43785a..fd5c17d 100644 --- a/src/include/lib3270/properties.h +++ b/src/include/lib3270/properties.h @@ -64,7 +64,7 @@ { const char * name; ///< @brief Property name. const char * description; ///< @brief Property description. - const char * (*get)(H3270 *hSession); ///< @brief Get value. + const char * (*get)(const H3270 *hSession); ///< @brief Get value. int (*set)(H3270 *hSession, const char * value); ///< @brief Set value. } LIB3270_STRING_PROPERTY; @@ -147,7 +147,7 @@ * @return Oversize definition (NULL if not set). * */ - LIB3270_EXPORT const char * lib3270_get_oversize(H3270 *hSession); + LIB3270_EXPORT const char * lib3270_get_oversize(const H3270 *hSession); /** * @brief Set oversize. diff --git a/src/ssl/properties.c b/src/ssl/properties.c index 6ffe7b8..3f88e9f 100644 --- a/src/ssl/properties.c +++ b/src/ssl/properties.c @@ -41,14 +41,8 @@ * @return Non zero if the host URL has SSL scheme. * */ -LIB3270_EXPORT int lib3270_get_secure_host(H3270 *hSession) +LIB3270_EXPORT int lib3270_get_secure_host(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); - - // TODO: Find a better way! - if(!hSession->host.current) - lib3270_set_url(hSession,NULL); - #ifdef HAVE_LIBSSL return hSession->ssl.enabled ? 1 : 0; #else @@ -58,7 +52,7 @@ LIB3270_EXPORT int lib3270_get_secure_host(H3270 *hSession) } #ifdef SSL_ENABLE_CRL_CHECK -LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 *hSession) +LIB3270_EXPORT char * lib3270_get_ssl_crl_text(const H3270 *hSession) { if(hSession->ssl.crl.cert) @@ -86,14 +80,14 @@ LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 *hSession) } #else -LIB3270_EXPORT char * lib3270_get_ssl_crl_text(H3270 GNUC_UNUSED(*hSession)) +LIB3270_EXPORT char * lib3270_get_ssl_crl_text(const H3270 GNUC_UNUSED(*hSession)) { return NULL; } #endif // SSL_ENABLE_CRL_CHECK -LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(H3270 *hSession) +LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(const H3270 *hSession) { #ifdef HAVE_LIBSSL if(hSession->ssl.con) @@ -124,7 +118,7 @@ LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(H3270 *hSession) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" - const char * lib3270_get_crl_url(H3270 *hSession) + const char * lib3270_get_crl_url(const H3270 *hSession) { #ifdef SSL_ENABLE_CRL_CHECK if(hSession->ssl.crl.url) diff --git a/src/ssl/state.c b/src/ssl/state.c index f5b6c18..dca4224 100644 --- a/src/ssl/state.c +++ b/src/ssl/state.c @@ -45,24 +45,24 @@ /*--[ Implement ]------------------------------------------------------------------------------------*/ -LIB3270_EXPORT int lib3270_is_secure(H3270 *hSession) +LIB3270_EXPORT int lib3270_is_secure(const H3270 *hSession) { return lib3270_get_ssl_state(hSession) == LIB3270_SSL_SECURE; } -LIB3270_EXPORT long lib3270_get_SSL_verify_result(H3270 *hSession) +LIB3270_EXPORT long lib3270_get_SSL_verify_result(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); #if defined(HAVE_LIBSSL) if(hSession->ssl.con) return SSL_get_verify_result(hSession->ssl.con); +#else + errno = ENOTSUP; #endif // HAVE_LIBSSL return -1; } -LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_ssl_state(H3270 *hSession) +LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_ssl_state(const H3270 *hSession) { - CHECK_SESSION_HANDLE(hSession); return hSession->ssl.state; } @@ -358,12 +358,12 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) return NULL; } - static const struct ssl_status_msg * get_ssl_status_msg(H3270 *hSession) + static const struct ssl_status_msg * get_ssl_status_msg(const H3270 *hSession) { return ssl_get_status_from_error_code(lib3270_get_SSL_verify_result(hSession)); } - const char * lib3270_get_ssl_state_message(H3270 *hSession) + const char * lib3270_get_ssl_state_message(const H3270 *hSession) { if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE) { @@ -376,7 +376,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) } - const char * lib3270_get_ssl_state_icon_name(H3270 *hSession) + const char * lib3270_get_ssl_state_icon_name(const H3270 *hSession) { if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE) { @@ -390,7 +390,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) } - const char * lib3270_get_ssl_state_description(H3270 *hSession) + const char * lib3270_get_ssl_state_description(const H3270 *hSession) { if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE) { @@ -406,7 +406,7 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) return _( "Unexpected or unknown security status"); } - LIB3270_NOTIFY lib3270_get_ssl_state_icon(H3270 *hSession) + LIB3270_NOTIFY lib3270_get_ssl_state_icon(const H3270 *hSession) { if(lib3270_get_ssl_state(hSession) != LIB3270_SSL_UNSECURE) { -- libgit2 0.21.2