Commit cee4a54f6ee0d94be60695e4b849b1c55244bf40

Authored by perry.werneck@gmail.com
1 parent 3cb6fd1b
Exists in master

Criando metodos para obtenção dos estados de conexão individuais por sessão

latest/src/include/lib3270.h
@@ -280,4 +280,14 @@ @@ -280,4 +280,14 @@
280 #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0) 280 #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0)
281 #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0) 281 #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0)
282 282
  283 + LIB3270_EXPORT int lib3270_pconnected(H3270 *h);
  284 + LIB3270_EXPORT int lib3270_half_connected(H3270 *h);
  285 + LIB3270_EXPORT int lib3270_connected(H3270 *h);
  286 + LIB3270_EXPORT int lib3270_in_neither(H3270 *h);
  287 + LIB3270_EXPORT int lib3270_in_ansi(H3270 *h);
  288 + LIB3270_EXPORT int lib3270_in_3270(H3270 *h);
  289 + LIB3270_EXPORT int lib3270_in_sscp(H3270 *h);
  290 + LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h);
  291 + LIB3270_EXPORT int lib3270_in_e(H3270 *h);
  292 +
283 #endif // LIB3270_H_INCLUDED 293 #endif // LIB3270_H_INCLUDED
latest/src/include/lib3270/api.h
@@ -386,22 +386,33 @@ @@ -386,22 +386,33 @@
386 386
387 LIB3270_EXPORT int RegisterFTCallbacks(const struct filetransfer_callbacks *cbk); 387 LIB3270_EXPORT int RegisterFTCallbacks(const struct filetransfer_callbacks *cbk);
388 388
389 - #define QueryCstate() lib3270_get_connection_state(NULL) 389 +// #define QueryCstate() lib3270_get_connection_state(NULL)
  390 +
  391 + #define PCONNECTED lib3270_pconnected(NULL)
  392 + #define HALF_CONNECTED lib3270_half_connected(NULL)
  393 + #define CONNECTED lib3270_connected(NULL)
  394 +
  395 + #define IN_NEITHER lib3270_in_neither(NULL)
  396 + #define IN_ANSI lib3270_in_ansi(NULL)
  397 + #define IN_3270 lib3270_in_3270(NULL)
  398 + #define IN_SSCP lib3270_in_sscp(NULL)
  399 + #define IN_TN3270E lib3270_in_tn3270e(NULL)
  400 + #define IN_E lib3270_in_e(NULL)
390 401
391 #ifndef LIB3270 402 #ifndef LIB3270
392 403
393 404
394 LIB3270_EXPORT enum ft_state QueryFTstate(void); 405 LIB3270_EXPORT enum ft_state QueryFTstate(void);
395 406
396 - #define PCONNECTED ((int) QueryCstate() >= (int)RESOLVING)  
397 - #define HALF_CONNECTED (QueryCstate() == RESOLVING || QueryCstate() == PENDING)  
398 - #define CONNECTED ((int) QueryCstate() >= (int)CONNECTED_INITIAL)  
399 - #define IN_NEITHER (QueryCstate() == CONNECTED_INITIAL)  
400 - #define IN_ANSI (QueryCstate() == CONNECTED_ANSI || QueryCstate() == CONNECTED_NVT)  
401 - #define IN_3270 (QueryCstate() == CONNECTED_3270 || QueryCstate() == CONNECTED_TN3270E || QueryCstate() == CONNECTED_SSCP)  
402 - #define IN_SSCP (QueryCstate() == CONNECTED_SSCP)  
403 - #define IN_TN3270E (QueryCstate() == CONNECTED_TN3270E)  
404 - #define IN_E (QueryCstate() >= CONNECTED_INITIAL_E) 407 +// #define PCONNECTED ((int) QueryCstate() >= (int)RESOLVING)
  408 +// #define HALF_CONNECTED (QueryCstate() == RESOLVING || QueryCstate() == PENDING)
  409 +// #define CONNECTED ((int) QueryCstate() >= (int)CONNECTED_INITIAL)
  410 +// #define IN_NEITHER (QueryCstate() == CONNECTED_INITIAL)
  411 +// #define IN_ANSI (QueryCstate() == CONNECTED_ANSI || QueryCstate() == CONNECTED_NVT)
  412 +// #define IN_3270 (QueryCstate() == CONNECTED_3270 || QueryCstate() == CONNECTED_TN3270E || QueryCstate() == CONNECTED_SSCP)
  413 +// #define IN_SSCP (QueryCstate() == CONNECTED_SSCP)
  414 +// #define IN_TN3270E (QueryCstate() == CONNECTED_TN3270E)
  415 +// #define IN_E (QueryCstate() >= CONNECTED_INITIAL_E)
405 416
406 #endif 417 #endif
407 418
latest/src/lib/XtGlue.c
@@ -903,6 +903,60 @@ LIB3270_EXPORT enum cstate lib3270_get_connection_state(H3270 *h) @@ -903,6 +903,60 @@ LIB3270_EXPORT enum cstate lib3270_get_connection_state(H3270 *h)
903 return h->cstate; 903 return h->cstate;
904 } 904 }
905 905
  906 +LIB3270_EXPORT int lib3270_pconnected(H3270 *h)
  907 +{
  908 + CHECK_SESSION_HANDLE(h);
  909 + return (((int) h->cstate) >= (int)RESOLVING);
  910 +}
  911 +
  912 +LIB3270_EXPORT int lib3270_half_connected(H3270 *h)
  913 +{
  914 + CHECK_SESSION_HANDLE(h);
  915 + return (h->cstate == RESOLVING || h->cstate == PENDING);
  916 +}
  917 +
  918 +LIB3270_EXPORT int lib3270_connected(H3270 *h)
  919 +{
  920 + CHECK_SESSION_HANDLE(h);
  921 + return ((int) h->cstate >= (int)CONNECTED_INITIAL);
  922 +}
  923 +
  924 +LIB3270_EXPORT int lib3270_in_neither(H3270 *h)
  925 +{
  926 + CHECK_SESSION_HANDLE(h);
  927 + return (h->cstate == CONNECTED_INITIAL);
  928 +}
  929 +
  930 +LIB3270_EXPORT int lib3270_in_ansi(H3270 *h)
  931 +{
  932 + CHECK_SESSION_HANDLE(h);
  933 + return (h->cstate == CONNECTED_ANSI || h->cstate == CONNECTED_NVT);
  934 +}
  935 +
  936 +LIB3270_EXPORT int lib3270_in_3270(H3270 *h)
  937 +{
  938 + CHECK_SESSION_HANDLE(h);
  939 + return (h->cstate == CONNECTED_3270 || h->cstate == CONNECTED_TN3270E || h->cstate == CONNECTED_SSCP);
  940 +}
  941 +
  942 +LIB3270_EXPORT int lib3270_in_sscp(H3270 *h)
  943 +{
  944 + CHECK_SESSION_HANDLE(h);
  945 + return (h->cstate == CONNECTED_SSCP);
  946 +}
  947 +
  948 +LIB3270_EXPORT int lib3270_in_tn3270e(H3270 *h)
  949 +{
  950 + CHECK_SESSION_HANDLE(h);
  951 + return (h->cstate == CONNECTED_TN3270E);
  952 +}
  953 +
  954 +LIB3270_EXPORT int lib3270_in_e(H3270 *h)
  955 +{
  956 + CHECK_SESSION_HANDLE(h);
  957 + return (h->cstate >= CONNECTED_INITIAL_E);
  958 +}
  959 +
906 int CallAndWait(int(*callback)(void *),void *parm) 960 int CallAndWait(int(*callback)(void *),void *parm)
907 { 961 {
908 if(callbacks->CallAndWait) 962 if(callbacks->CallAndWait)
latest/src/lib/globals.h
@@ -245,8 +245,9 @@ LIB3270_INTERNAL int *xtra_width; @@ -245,8 +245,9 @@ LIB3270_INTERNAL int *xtra_width;
245 245
246 /* Connection state */ 246 /* Connection state */
247 LIB3270_INTERNAL enum ft_state ft_state; 247 LIB3270_INTERNAL enum ft_state ft_state;
248 -LIB3270_INTERNAL enum cstate cstate;  
249 248
  249 +/*
  250 +LIB3270_INTERNAL enum cstate cstate;
250 #define PCONNECTED ((int)h3270.cstate >= (int)RESOLVING) 251 #define PCONNECTED ((int)h3270.cstate >= (int)RESOLVING)
251 #define HALF_CONNECTED (h3270.cstate == RESOLVING || h3270.cstate == PENDING) 252 #define HALF_CONNECTED (h3270.cstate == RESOLVING || h3270.cstate == PENDING)
252 #define CONNECTED ((int)h3270.cstate >= (int)CONNECTED_INITIAL) 253 #define CONNECTED ((int)h3270.cstate >= (int)CONNECTED_INITIAL)
@@ -256,6 +257,7 @@ LIB3270_INTERNAL enum cstate cstate; @@ -256,6 +257,7 @@ LIB3270_INTERNAL enum cstate cstate;
256 #define IN_SSCP (h3270.cstate == CONNECTED_SSCP) 257 #define IN_SSCP (h3270.cstate == CONNECTED_SSCP)
257 #define IN_TN3270E (h3270.cstate == CONNECTED_TN3270E) 258 #define IN_TN3270E (h3270.cstate == CONNECTED_TN3270E)
258 #define IN_E (h3270.cstate >= CONNECTED_INITIAL_E) 259 #define IN_E (h3270.cstate >= CONNECTED_INITIAL_E)
  260 +*/
259 261
260 /* keyboard modifer bitmap */ 262 /* keyboard modifer bitmap */
261 #define ShiftKeyDown 0x01 263 #define ShiftKeyDown 0x01