diff --git a/latest/src/include/lib3270.h b/latest/src/include/lib3270.h index 2481050..efcf8b6 100644 --- a/latest/src/include/lib3270.h +++ b/latest/src/include/lib3270.h @@ -280,4 +280,14 @@ #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0) #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0) + 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_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); + #endif // LIB3270_H_INCLUDED diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index 7d73687..aab0cc6 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -386,22 +386,33 @@ LIB3270_EXPORT int RegisterFTCallbacks(const struct filetransfer_callbacks *cbk); - #define QueryCstate() lib3270_get_connection_state(NULL) +// #define QueryCstate() lib3270_get_connection_state(NULL) + + #define PCONNECTED lib3270_pconnected(NULL) + #define HALF_CONNECTED lib3270_half_connected(NULL) + #define CONNECTED lib3270_connected(NULL) + + #define IN_NEITHER lib3270_in_neither(NULL) + #define IN_ANSI lib3270_in_ansi(NULL) + #define IN_3270 lib3270_in_3270(NULL) + #define IN_SSCP lib3270_in_sscp(NULL) + #define IN_TN3270E lib3270_in_tn3270e(NULL) + #define IN_E lib3270_in_e(NULL) #ifndef LIB3270 LIB3270_EXPORT enum ft_state QueryFTstate(void); - #define PCONNECTED ((int) QueryCstate() >= (int)RESOLVING) - #define HALF_CONNECTED (QueryCstate() == RESOLVING || QueryCstate() == PENDING) - #define CONNECTED ((int) QueryCstate() >= (int)CONNECTED_INITIAL) - #define IN_NEITHER (QueryCstate() == CONNECTED_INITIAL) - #define IN_ANSI (QueryCstate() == CONNECTED_ANSI || QueryCstate() == CONNECTED_NVT) - #define IN_3270 (QueryCstate() == CONNECTED_3270 || QueryCstate() == CONNECTED_TN3270E || QueryCstate() == CONNECTED_SSCP) - #define IN_SSCP (QueryCstate() == CONNECTED_SSCP) - #define IN_TN3270E (QueryCstate() == CONNECTED_TN3270E) - #define IN_E (QueryCstate() >= CONNECTED_INITIAL_E) +// #define PCONNECTED ((int) QueryCstate() >= (int)RESOLVING) +// #define HALF_CONNECTED (QueryCstate() == RESOLVING || QueryCstate() == PENDING) +// #define CONNECTED ((int) QueryCstate() >= (int)CONNECTED_INITIAL) +// #define IN_NEITHER (QueryCstate() == CONNECTED_INITIAL) +// #define IN_ANSI (QueryCstate() == CONNECTED_ANSI || QueryCstate() == CONNECTED_NVT) +// #define IN_3270 (QueryCstate() == CONNECTED_3270 || QueryCstate() == CONNECTED_TN3270E || QueryCstate() == CONNECTED_SSCP) +// #define IN_SSCP (QueryCstate() == CONNECTED_SSCP) +// #define IN_TN3270E (QueryCstate() == CONNECTED_TN3270E) +// #define IN_E (QueryCstate() >= CONNECTED_INITIAL_E) #endif diff --git a/latest/src/lib/XtGlue.c b/latest/src/lib/XtGlue.c index ab151fe..f5566c3 100644 --- a/latest/src/lib/XtGlue.c +++ b/latest/src/lib/XtGlue.c @@ -903,6 +903,60 @@ LIB3270_EXPORT enum cstate lib3270_get_connection_state(H3270 *h) return h->cstate; } +LIB3270_EXPORT int lib3270_pconnected(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (((int) h->cstate) >= (int)RESOLVING); +} + +LIB3270_EXPORT int lib3270_half_connected(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (h->cstate == RESOLVING || h->cstate == PENDING); +} + +LIB3270_EXPORT int lib3270_connected(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return ((int) h->cstate >= (int)CONNECTED_INITIAL); +} + +LIB3270_EXPORT int lib3270_in_neither(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (h->cstate == CONNECTED_INITIAL); +} + +LIB3270_EXPORT int lib3270_in_ansi(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (h->cstate == CONNECTED_ANSI || h->cstate == CONNECTED_NVT); +} + +LIB3270_EXPORT int lib3270_in_3270(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (h->cstate == CONNECTED_3270 || h->cstate == CONNECTED_TN3270E || h->cstate == CONNECTED_SSCP); +} + +LIB3270_EXPORT int lib3270_in_sscp(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (h->cstate == CONNECTED_SSCP); +} + +LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (h->cstate == CONNECTED_TN3270E); +} + +LIB3270_EXPORT int lib3270_in_e(H3270 *h) +{ + CHECK_SESSION_HANDLE(h); + return (h->cstate >= CONNECTED_INITIAL_E); +} + int CallAndWait(int(*callback)(void *),void *parm) { if(callbacks->CallAndWait) diff --git a/latest/src/lib/globals.h b/latest/src/lib/globals.h index f119bb1..96c71c7 100644 --- a/latest/src/lib/globals.h +++ b/latest/src/lib/globals.h @@ -245,8 +245,9 @@ LIB3270_INTERNAL int *xtra_width; /* Connection state */ LIB3270_INTERNAL enum ft_state ft_state; -LIB3270_INTERNAL enum cstate cstate; +/* +LIB3270_INTERNAL enum cstate cstate; #define PCONNECTED ((int)h3270.cstate >= (int)RESOLVING) #define HALF_CONNECTED (h3270.cstate == RESOLVING || h3270.cstate == PENDING) #define CONNECTED ((int)h3270.cstate >= (int)CONNECTED_INITIAL) @@ -256,6 +257,7 @@ LIB3270_INTERNAL enum cstate cstate; #define IN_SSCP (h3270.cstate == CONNECTED_SSCP) #define IN_TN3270E (h3270.cstate == CONNECTED_TN3270E) #define IN_E (h3270.cstate >= CONNECTED_INITIAL_E) +*/ /* keyboard modifer bitmap */ #define ShiftKeyDown 0x01 -- libgit2 0.21.2