Commit 967b31891095625142bc81eaaa93e0bd8863aeee

Authored by perry.werneck@gmail.com
1 parent 191035a3
Exists in master

Incluindo suporte multi-sessao em xio.c

latest/src/include/lib3270/api.h
... ... @@ -203,6 +203,12 @@
203 203 // Widget info
204 204 void * widget;
205 205  
  206 + // xio
  207 + unsigned long ns_read_id;
  208 + unsigned long ns_exception_id;
  209 + char reading;
  210 + char excepting;
  211 +
206 212 /* State change callbacks. */
207 213 struct lib3270_state_callback *st_callbacks[N_ST];
208 214 struct lib3270_state_callback *st_last[N_ST];
... ...
latest/src/lib/host.c
... ... @@ -83,8 +83,7 @@ static struct host *last_host = (struct host *)NULL;
83 83  
84 84 static void try_reconnect(H3270 *session);
85 85  
86   -static char *
87   -stoken(char **s)
  86 +static char * stoken(char **s)
88 87 {
89 88 char *r;
90 89 char *ss = *s;
... ... @@ -598,26 +597,18 @@ static int do_connect(H3270 *hSession, const char *n)
598 597  
599 598 /* Attempt contact. */
600 599 ever_3270 = False;
601   - hSession->net_sock = net_connect(chost, port, localprocess_cmd != CN, &resolving,
602   - &pending);
603   - if (hSession->net_sock < 0 && !resolving) {
604   -#if defined(X3270_DISPLAY) /*[*/
605   - if (appres.once) {
606   - /* Exit when the error pop-up pops down. */
607   - exiting = True;
608   - }
609   - else if ( toggled(RECONNECT) ) {
610   - auto_reconnect_inprogress = True;
611   - (void) AddTimeOut(RECONNECT_ERR_MS, try_reconnect);
612   - }
613   -#endif /*]*/
  600 + hSession->net_sock = net_connect(chost, port, localprocess_cmd != CN, &resolving,&pending);
  601 +
  602 + if (hSession->net_sock < 0 && !resolving)
  603 + {
614 604 /* Redundantly signal a disconnect. */
615 605 lib3270_st_changed(hSession, ST_CONNECT, False);
616 606 return -1;
617 607 }
618 608  
619 609 /* Still thinking about it? */
620   - if (resolving) {
  610 + if (resolving)
  611 + {
621 612 hSession->cstate = RESOLVING;
622 613 lib3270_st_changed(hSession, ST_RESOLVING, True);
623 614 return 0;
... ... @@ -633,7 +624,7 @@ static int do_connect(H3270 *hSession, const char *n)
633 624 // login_macro(ps);
634 625  
635 626 /* Prepare Xt for I/O. */
636   - x_add_input(hSession->net_sock);
  627 + x_add_input(hSession,hSession->net_sock);
637 628  
638 629 /* Set state and tell the world. */
639 630 if (pending)
... ... @@ -702,7 +693,7 @@ void host_disconnect(H3270 *h, int failed)
702 693 h = &h3270;
703 694  
704 695 if (CONNECTED || HALF_CONNECTED) {
705   - x_remove_input();
  696 + x_remove_input(h);
706 697 net_disconnect();
707 698 h->net_sock = -1;
708 699  
... ...
latest/src/lib/telnet.c
... ... @@ -1261,7 +1261,7 @@ telnet_fsm(unsigned char c)
1261 1261 trace_dsn("\n");
1262 1262 if (syncing) {
1263 1263 syncing = 0;
1264   - x_except_on(h3270.sock);
  1264 + x_except_on(&h3270,h3270.sock);
1265 1265 }
1266 1266 telnet_state = TNS_DATA;
1267 1267 break;
... ... @@ -1937,7 +1937,7 @@ void net_exception(H3270 *session)
1937 1937 trace_dsn("RCVD urgent data indication\n");
1938 1938 if (!syncing) {
1939 1939 syncing = 1;
1940   - x_except_off();
  1940 + x_except_off(session);
1941 1941 }
1942 1942 }
1943 1943 }
... ...
latest/src/lib/xio.c
... ... @@ -45,32 +45,31 @@
45 45 #include "xioc.h"
46 46  
47 47 /* Statics. */
48   -static unsigned long ns_read_id;
49   -static unsigned long ns_exception_id;
50   -static Boolean reading = False;
51   -static Boolean excepting = False;
  48 +// static unsigned long ns_read_id;
  49 +// static unsigned long ns_exception_id;
  50 +// static Boolean reading = False;
  51 +// static Boolean excepting = False;
52 52  
53 53 /*
54 54 * Called to set up input on a new network connection.
55 55 */
56   -void
57   -x_add_input(int net_sock)
  56 +void x_add_input(H3270 *h,int net_sock)
58 57 {
59   - ns_exception_id = AddExcept(net_sock, &h3270, net_exception);
60   - excepting = True;
61   - ns_read_id = AddInput(net_sock, &h3270, net_input);
62   - reading = True;
  58 + h->ns_exception_id = AddExcept(net_sock, h, net_exception);
  59 + h->excepting = True;
  60 + h->ns_read_id = AddInput(net_sock, h, net_input);
  61 + h->reading = True;
63 62 }
64 63  
65 64 /*
66 65 * Called when an exception is received to disable further exceptions.
67 66 */
68   -void
69   -x_except_off(void)
  67 +void x_except_off(H3270 *h)
70 68 {
71   - if (excepting) {
72   - RemoveInput(ns_exception_id);
73   - excepting = False;
  69 + if(h->excepting)
  70 + {
  71 + RemoveInput(h->ns_exception_id);
  72 + h->excepting = False;
74 73 }
75 74 }
76 75  
... ... @@ -79,66 +78,34 @@ x_except_off(void)
79 78 * This includes removing and restoring reading, so the exceptions are always
80 79 * processed first.
81 80 */
82   -void
83   -x_except_on(int net_sock)
  81 +void x_except_on(H3270 *h,int net_sock)
84 82 {
85   - if (excepting)
  83 + if(h->excepting)
86 84 return;
87   - if (reading)
88   - RemoveInput(ns_read_id);
89   - ns_exception_id = AddExcept(net_sock, &h3270, net_exception);
90   - excepting = True;
91   - if (reading)
92   - ns_read_id = AddInput(net_sock, &h3270, net_input);
  85 +
  86 + if(h->reading)
  87 + RemoveInput(h->ns_read_id);
  88 +
  89 + h->ns_exception_id = AddExcept(net_sock, h, net_exception);
  90 + h->excepting = True;
  91 +
  92 + if(h->reading)
  93 + h->ns_read_id = AddInput(net_sock, h, net_input);
93 94 }
94 95  
95 96 /*
96 97 * Called to disable input on a closing network connection.
97 98 */
98   -void
99   -x_remove_input(void)
  99 +void x_remove_input(H3270 *h)
100 100 {
101   - if (reading) {
102   - RemoveInput(ns_read_id);
103   - reading = False;
  101 + if(h->reading)
  102 + {
  103 + RemoveInput(h->ns_read_id);
  104 + h->reading = False;
104 105 }
105   - if (excepting) {
106   - RemoveInput(ns_exception_id);
107   - excepting = False;
108   - }
109   -}
110   -
111   -/*
112   - * Application exit, with cleanup.
113   - */
114   - /*
115   -void
116   -x3270_exit(int n)
117   -{
118   - static Boolean already_exiting = 0;
119   -
120   - // Handle unintentional recursion.
121   - if (already_exiting)
122   - return;
123   - already_exiting = True;
124   -
125   - // Turn off toggle-related activity.
126   - shutdown_toggles();
127   -
128   - // Shut down the socket gracefully.
129   - host_disconnect(&h3270,False);
130   -
131   - // Tell anyone else who's interested.
132   - st_changed(ST_EXITING, True);
133   -
134   - exit(n);
135   -}
136   -
137   -void
138   -Quit_action(Widget w, XEvent *event, String *params, Cardinal *num_params)
139   -{
140   - if (!w || !CONNECTED) {
141   - x3270_exit(0);
  106 + if(h->excepting)
  107 + {
  108 + RemoveInput(h->ns_exception_id);
  109 + h->excepting = False;
142 110 }
143 111 }
144   -*/
... ...
latest/src/lib/xioc.h
... ... @@ -35,11 +35,8 @@
35 35 * Global declarations for xio.c.
36 36 */
37 37  
38   -// LIB3270_INTERNAL void Quit_action(Widget w, XEvent *event, String *params, Cardinal *num_params) __attribute__ ((deprecated));
39   -//LIB3270_INTERNAL void x3270_exit(int n) __attribute__ ((deprecated));
40   -
41   -LIB3270_INTERNAL void x_add_input(int net_sock);
42   -LIB3270_INTERNAL void x_except_off(void);
43   -LIB3270_INTERNAL void x_except_on(int net_sock);
44   -LIB3270_INTERNAL void x_remove_input(void);
  38 +LIB3270_INTERNAL void x_add_input(H3270 *h,int net_sock);
  39 +LIB3270_INTERNAL void x_except_off(H3270 *h);
  40 +LIB3270_INTERNAL void x_except_on(H3270 *h,int net_sock);
  41 +LIB3270_INTERNAL void x_remove_input(H3270 *h);
45 42  
... ...