From d1ef560ba0440fd727148047d11dde978909966a Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 15 Sep 2020 15:05:47 -0300 Subject: [PATCH] Updating get host and get service methods. --- src/core/actions/actions.c | 2 +- src/core/host.c | 45 ++++++++++----------------------------------- src/core/properties/string.c | 10 ++++++++++ src/include/lib3270.h | 24 ------------------------ src/include/lib3270/properties.h | 19 +++++++++++++++++++ src/testprogram/testprogram.c | 2 +- 6 files changed, 41 insertions(+), 61 deletions(-) diff --git a/src/core/actions/actions.c b/src/core/actions/actions.c index bb59242..b3b6422 100644 --- a/src/core/actions/actions.c +++ b/src/core/actions/actions.c @@ -99,7 +99,7 @@ LIB3270_EXPORT int lib3270_activate_by_name(H3270 *hSession, const char *name) LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) { - return lib3270_activate_by_name(name,hSession); + return lib3270_activate_by_name(hSession,name); } LIB3270_EXPORT void lib3270_action_group_notify(H3270 *hSession, LIB3270_ACTION_GROUP group) diff --git a/src/core/host.c b/src/core/host.c index 167807d..6a75da9 100644 --- a/src/core/host.c +++ b/src/core/host.c @@ -393,14 +393,18 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) srvc = ptr; query = strchr(ptr,'?'); - trace("QUERY=[%s]",query); - - if(query) - *(query++) = 0; - else - query = ""; + } + else + { + srvc = "3270"; + query = strchr(hostname,'?'); } + if(query) + *(query++) = 0; + else + query = ""; + trace("SRVC=[%s]",srvc); Replace(h->host.current,strdup(hostname)); @@ -452,35 +456,6 @@ LIB3270_EXPORT int lib3270_set_url(H3270 *h, const char *n) return 0; } -LIB3270_EXPORT const char * lib3270_get_hostname(const H3270 *h) -{ - if(h->host.current) - return h->host.current; - - return ""; -} - -LIB3270_EXPORT void lib3270_set_hostname(H3270 *h, const char *hostname) -{ - CHECK_SESSION_HANDLE(h); - Replace(h->host.current,strdup(hostname)); - update_url(h); -} - -LIB3270_EXPORT const char * lib3270_get_srvcname(const H3270 *h) -{ - if(h->host.srvc) - return h->host.srvc; - return "telnet"; -} - -LIB3270_EXPORT void lib3270_set_srvcname(H3270 *h, const char *srvc) -{ - CHECK_SESSION_HANDLE(h); - Replace(h->host.srvc,strdup(srvc)); - update_url(h); -} - LIB3270_EXPORT const char * lib3270_get_host(const H3270 *h) { return h->host.url; diff --git a/src/core/properties/string.c b/src/core/properties/string.c index cc75cd2..52a6719 100644 --- a/src/core/properties/string.c +++ b/src/core/properties/string.c @@ -376,3 +376,13 @@ LIB3270_EXPORT const char ** lib3270_get_lunames(H3270 *hSession) return (const char **) hSession->lu.names; } +LIB3270_EXPORT const char * lib3270_host_get_name(const H3270 *h) +{ + return h->host.current; +} + +LIB3270_EXPORT const char * lib3270_service_get_name(const H3270 *h) +{ + return h->host.srvc; +} + diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 00b9b26..46fea59 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -512,30 +512,6 @@ LIB3270_EXPORT const char * lib3270_get_default_host(const H3270 *hSession); /** - * @brief Get hostname for the connect/reconnect operations. - * - * @param h Session handle. - * - * @return Pointer to host id set (internal data, do not change it) - * - */ - LIB3270_EXPORT const char * LIB3270_DEPRECATED(lib3270_get_hostname(const H3270 *h)); - - LIB3270_EXPORT void LIB3270_DEPRECATED(lib3270_set_hostname(H3270 *h, const char *hostname)); - - /** - * @brief Get service or port for the connect/reconnect operations. - * - * @param h Session handle. - * - * @return Pointer to service name (internal data, do not change it) - * - */ - LIB3270_EXPORT const char * LIB3270_DEPRECATED(lib3270_get_srvcname(const H3270 *h)); - - LIB3270_EXPORT void LIB3270_DEPRECATED(lib3270_set_srvcname(H3270 *h, const char *srvc)); - - /** * @brief Get HOST URL. * * @return TN3270 Connection URL. diff --git a/src/include/lib3270/properties.h b/src/include/lib3270/properties.h index b11a712..476a504 100644 --- a/src/include/lib3270/properties.h +++ b/src/include/lib3270/properties.h @@ -219,6 +219,25 @@ */ LIB3270_EXPORT char * lib3270_get_version_info(void); + /** + * @brief Get hostname for the connect/reconnect operations. + * + * @param h Session handle. + * + * @return Pointer to host id set (internal data, do not change it) + * + */ + LIB3270_EXPORT const char * lib3270_host_get_name(const H3270 *h); + + /** + * @brief Get service or port for the connect/reconnect operations. + * + * @param h Session handle. + * + * @return Pointer to service name (internal data, do not change it) + * + */ + LIB3270_EXPORT const char * lib3270_service_get_name(const H3270 *h); #ifdef __cplusplus } diff --git a/src/testprogram/testprogram.c b/src/testprogram/testprogram.c index b552367..559700e 100644 --- a/src/testprogram/testprogram.c +++ b/src/testprogram/testprogram.c @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) #endif // HAVE_LDAP if(lib3270_set_url(h,NULL)) - lib3270_set_url(h,"tn3270://fandezhi.efglobe.com"); + lib3270_set_url(h,"tn3270://127.0.0.1"); int long_index =0; int opt; -- libgit2 0.21.2