Commit 909b81b4deba804ca39da1dcbdf44f658dc1bbd0

Authored by perry.werneck@gmail.com
1 parent f8a7ffc3

Movendo mais campos para estrutura de sessão

src/include/lib3270/session.h
... ... @@ -194,6 +194,19 @@
194 194 unsigned long e_funcs; /**< negotiated TN3270E functions */
195 195 unsigned short e_xmit_seq; /**< transmit sequence number */
196 196 int response_required;
  197 + int tn3270e_bound;
  198 + int tn3270e_negotiated;
  199 +
  200 + enum
  201 + {
  202 + E_NONE,
  203 + E_3270,
  204 + E_NVT,
  205 + E_SSCP
  206 + } tn3270e_submode;
  207 +
  208 + unsigned char * lbuf; /**< line-mode input buffer */
  209 + unsigned char * lbptr;
197 210  
198 211  
199 212 // 3270 input buffer
... ...
src/lib3270/session.c
... ... @@ -199,7 +199,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model)
199 199 hSession->aid = AID_NO;
200 200 hSession->reply_mode = SF_SRM_FIELD;
201 201 hSession->linemode = 1;
202   -
  202 + hSession->tn3270e_submode = E_NONE;
203 203  
204 204 #ifdef _WIN32
205 205 hSession->sockEvent = NULL;
... ...
src/lib3270/telnet.c
... ... @@ -178,9 +178,9 @@ Boolean local_process = False;
178 178  
179 179 #if defined(X3270_ANSI) /*[*/
180 180 static int ansi_data = 0;
181   -static unsigned char *lbuf = (unsigned char *)NULL;
182   - /* line-mode input buffer */
183   -static unsigned char *lbptr;
  181 +// static unsigned char *lbuf = (unsigned char *)NULL;
  182 +/* line-mode input buffer */
  183 +// static unsigned char *lbptr;
184 184 static int lnext = 0;
185 185 static int backslashed = 0;
186 186 static int t_valid = 0;
... ... @@ -194,9 +194,9 @@ static char vrprnt;
194 194 static char vlnext;
195 195 #endif /*]*/
196 196  
197   -static int tn3270e_negotiated = 0;
198   -static enum { E_NONE, E_3270, E_NVT, E_SSCP } tn3270e_submode = E_NONE;
199   -static int tn3270e_bound = 0;
  197 +// static int tn3270e_negotiated = 0;
  198 +//static enum { E_NONE, E_3270, E_NVT, E_SSCP } tn3270e_submode = E_NONE;
  199 +// static int tn3270e_bound = 0;
200 200 static char plu_name[BIND_PLU_NAME_MAX+1];
201 201 static char **lus = (char **)NULL;
202 202 static char **curr_lu = (char **)NULL;
... ... @@ -887,9 +887,9 @@ static void net_connected(H3270 *session)
887 887 session->ns_bsent = 0;
888 888 session->ns_rsent = 0;
889 889 session->syncing = 0;
890   - tn3270e_negotiated = 0;
891   - tn3270e_submode = E_NONE;
892   - tn3270e_bound = 0;
  890 + session->tn3270e_negotiated = 0;
  891 + session->tn3270e_submode = E_NONE;
  892 + session->tn3270e_bound = 0;
893 893  
894 894 setup_lus();
895 895  
... ... @@ -1256,7 +1256,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1256 1256 h3270.telnet_state = TNS_DATA;
1257 1257 break;
1258 1258 case EOR: /* eor, process accumulated input */
1259   - if (IN_3270 || (IN_E && tn3270e_negotiated)) {
  1259 + if (IN_3270 || (IN_E && h3270.tn3270e_negotiated)) {
1260 1260 h3270.ns_rrcvd++;
1261 1261 if (process_eor())
1262 1262 return -1;
... ... @@ -1700,7 +1700,7 @@ tn3270e_negotiate(void)
1700 1700 /* They want what we want, or less. Done. */
1701 1701 h3270.e_funcs = e_rcvd;
1702 1702 tn3270e_subneg_send(TN3270E_OP_IS, h3270.e_funcs);
1703   - tn3270e_negotiated = 1;
  1703 + h3270.tn3270e_negotiated = 1;
1704 1704 trace_dsn("TN3270E option negotiation complete.\n");
1705 1705 check_in3270(&h3270);
1706 1706 } else {
... ... @@ -1736,7 +1736,7 @@ tn3270e_negotiate(void)
1736 1736 break;
1737 1737 }
1738 1738 }
1739   - tn3270e_negotiated = 1;
  1739 + h3270.tn3270e_negotiated = 1;
1740 1740 trace_dsn("TN3270E option negotiation complete.\n");
1741 1741 check_in3270(&h3270);
1742 1742 break;
... ... @@ -1886,9 +1886,9 @@ process_eor(void)
1886 1886 switch (h->data_type) {
1887 1887 case TN3270E_DT_3270_DATA:
1888 1888 if ((h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)) &&
1889   - !tn3270e_bound)
  1889 + !h3270.tn3270e_bound)
1890 1890 return 0;
1891   - tn3270e_submode = E_3270;
  1891 + h3270.tn3270e_submode = E_3270;
1892 1892 check_in3270(&h3270);
1893 1893 h3270.response_required = h->response_flag;
1894 1894 rv = process_ds(h3270.ibuf + EH_SIZE,
... ... @@ -1906,20 +1906,20 @@ process_eor(void)
1906 1906 return 0;
1907 1907 process_bind(h3270.ibuf + EH_SIZE, (h3270.ibptr - h3270.ibuf) - EH_SIZE);
1908 1908 trace_dsn("< BIND PLU-name '%s'\n", plu_name);
1909   - tn3270e_bound = 1;
  1909 + h3270.tn3270e_bound = 1;
1910 1910 check_in3270(&h3270);
1911 1911 return 0;
1912 1912 case TN3270E_DT_UNBIND:
1913 1913 if (!(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1914 1914 return 0;
1915   - tn3270e_bound = 0;
1916   - if (tn3270e_submode == E_3270)
1917   - tn3270e_submode = E_NONE;
  1915 + h3270.tn3270e_bound = 0;
  1916 + if (h3270.tn3270e_submode == E_3270)
  1917 + h3270.tn3270e_submode = E_NONE;
1918 1918 check_in3270(&h3270);
1919 1919 return 0;
1920 1920 case TN3270E_DT_NVT_DATA:
1921 1921 /* In tn3270e NVT mode */
1922   - tn3270e_submode = E_NVT;
  1922 + h3270.tn3270e_submode = E_NVT;
1923 1923 check_in3270(&h3270);
1924 1924 for (s = h3270.ibuf; s < h3270.ibptr; s++) {
1925 1925 ansi_process(*s++);
... ... @@ -1928,7 +1928,7 @@ process_eor(void)
1928 1928 case TN3270E_DT_SSCP_LU_DATA:
1929 1929 if (!(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1930 1930 return 0;
1931   - tn3270e_submode = E_SSCP;
  1931 + h3270.tn3270e_submode = E_SSCP;
1932 1932 check_in3270(&h3270);
1933 1933 ctlr_write_sscp_lu(&h3270, h3270.ibuf + EH_SIZE,(h3270.ibptr - h3270.ibuf) - EH_SIZE);
1934 1934 return 0;
... ... @@ -2196,9 +2196,9 @@ static void net_cookout(H3270 *hSession, const char *buf, int len)
2196 2196 static void
2197 2197 cooked_init(void)
2198 2198 {
2199   - if (lbuf == (unsigned char *)NULL)
2200   - lbuf = (unsigned char *)lib3270_malloc(BUFSZ);
2201   - lbptr = lbuf;
  2199 + if (h3270.lbuf == (unsigned char *)NULL)
  2200 + h3270.lbuf = (unsigned char *)lib3270_malloc(BUFSZ);
  2201 + h3270.lbptr = h3270.lbuf;
2202 2202 lnext = 0;
2203 2203 backslashed = 0;
2204 2204 }
... ... @@ -2213,17 +2213,17 @@ ansi_process_s(const char *data)
2213 2213 static void
2214 2214 forward_data(void)
2215 2215 {
2216   - net_cookedout(&h3270, (char *) lbuf, lbptr - lbuf);
  2216 + net_cookedout(&h3270, (char *) h3270.lbuf, h3270.lbptr - h3270.lbuf);
2217 2217 cooked_init();
2218 2218 }
2219 2219  
2220 2220 static void
2221 2221 do_data(char c)
2222 2222 {
2223   - if (lbptr+1 < lbuf + BUFSZ) {
2224   - *lbptr++ = c;
  2223 + if (h3270.lbptr+1 < h3270.lbuf + BUFSZ) {
  2224 + *h3270.lbptr++ = c;
2225 2225 if (c == '\r')
2226   - *lbptr++ = 'lbptr++ = '\0';';
  2226 + *h3270.lbptr++ = 'lbptr++ = '\0';';
2227 2227 if (c == '\t')
2228 2228 ansi_process((unsigned int) c);
2229 2229 else
... ... @@ -2264,7 +2264,7 @@ do_cerase(char c)
2264 2264 int len;
2265 2265  
2266 2266 if (backslashed) {
2267   - lbptr--;
  2267 + h3270.lbptr--;
2268 2268 ansi_process_s("\b");
2269 2269 do_data(c);
2270 2270 return;
... ... @@ -2273,8 +2273,8 @@ do_cerase(char c)
2273 2273 do_data(c);
2274 2274 return;
2275 2275 }
2276   - if (lbptr > lbuf) {
2277   - len = strlen(ctl_see((int) *--lbptr));
  2276 + if (h3270.lbptr > h3270.lbuf) {
  2277 + len = strlen(ctl_see((int) *--h3270.lbptr));
2278 2278  
2279 2279 while (len--)
2280 2280 ansi_process_s("\b \b");
... ... @@ -2291,14 +2291,14 @@ do_werase(char c)
2291 2291 do_data(c);
2292 2292 return;
2293 2293 }
2294   - while (lbptr > lbuf) {
  2294 + while (h3270.lbptr > h3270.lbuf) {
2295 2295 char ch;
2296 2296  
2297   - ch = *--lbptr;
  2297 + ch = *--h3270.lbptr;
2298 2298  
2299 2299 if (ch == ' ' || ch == '\t') {
2300 2300 if (any) {
2301   - ++lbptr;
  2301 + ++h3270.lbptr;
2302 2302 break;
2303 2303 }
2304 2304 } else
... ... @@ -2316,7 +2316,7 @@ do_kill(char c)
2316 2316 int i, len;
2317 2317  
2318 2318 if (backslashed) {
2319   - lbptr--;
  2319 + h3270.lbptr--;
2320 2320 ansi_process_s("\b");
2321 2321 do_data(c);
2322 2322 return;
... ... @@ -2325,8 +2325,8 @@ do_kill(char c)
2325 2325 do_data(c);
2326 2326 return;
2327 2327 }
2328   - while (lbptr > lbuf) {
2329   - len = strlen(ctl_see((int) *--lbptr));
  2328 + while (h3270.lbptr > h3270.lbuf) {
  2329 + len = strlen(ctl_see((int) *--h3270.lbptr));
2330 2330  
2331 2331 for (i = 0; i < len; i++)
2332 2332 ansi_process_s("\b \b");
... ... @@ -2344,7 +2344,7 @@ do_rprnt(char c)
2344 2344 }
2345 2345 ansi_process_s(ctl_see((int) c));
2346 2346 ansi_process_s("\r\n");
2347   - for (p = lbuf; p < lbptr; p++)
  2347 + for (p = h3270.lbuf; p < h3270.lbptr; p++)
2348 2348 ansi_process_s(ctl_see((int) *p));
2349 2349 }
2350 2350  
... ... @@ -2352,7 +2352,7 @@ static void
2352 2352 do_eof(char c)
2353 2353 {
2354 2354 if (backslashed) {
2355   - lbptr--;
  2355 + h3270.lbptr--;
2356 2356 ansi_process_s("\b");
2357 2357 do_data(c);
2358 2358 return;
... ... @@ -2372,12 +2372,12 @@ do_eol(char c)
2372 2372 do_data(c);
2373 2373 return;
2374 2374 }
2375   - if (lbptr+2 >= lbuf + BUFSZ) {
  2375 + if (h3270.lbptr+2 >= h3270.lbuf + BUFSZ) {
2376 2376 ansi_process_s("\007");
2377 2377 return;
2378 2378 }
2379   - *lbptr++ = '\r';
2380   - *lbptr++ = '\n';
  2379 + *h3270.lbptr++ = '\r';
  2380 + *h3270.lbptr++ = '\n';
2381 2381 ansi_process_s("\r\n");
2382 2382 forward_data();
2383 2383 }
... ... @@ -2422,9 +2422,9 @@ check_in3270(H3270 *session)
2422 2422  
2423 2423 #if defined(X3270_TN3270E) /*[*/
2424 2424 if (h3270.myopts[TELOPT_TN3270E]) {
2425   - if (!tn3270e_negotiated)
  2425 + if (!h3270.tn3270e_negotiated)
2426 2426 new_cstate = CONNECTED_INITIAL_E;
2427   - else switch (tn3270e_submode) {
  2427 + else switch (h3270.tn3270e_submode) {
2428 2428 case E_NONE:
2429 2429 new_cstate = CONNECTED_INITIAL_E;
2430 2430 break;
... ... @@ -2488,9 +2488,9 @@ check_in3270(H3270 *session)
2488 2488 #if defined(X3270_TN3270E) /*[*/
2489 2489 /* If we fell out of TN3270E, remove the state. */
2490 2490 if (!h3270.myopts[TELOPT_TN3270E]) {
2491   - tn3270e_negotiated = 0;
2492   - tn3270e_submode = E_NONE;
2493   - tn3270e_bound = 0;
  2491 + h3270.tn3270e_negotiated = 0;
  2492 + h3270.tn3270e_submode = E_NONE;
  2493 + h3270.tn3270e_bound = 0;
2494 2494 }
2495 2495 #endif /*]*/
2496 2496 trace_dsn("Now operating in %s mode.\n",state_name[new_cstate]);
... ... @@ -2803,13 +2803,13 @@ net_add_dummy_tn3270e(void)
2803 2803 {
2804 2804 tn3270e_header *h;
2805 2805  
2806   - if (!IN_E || tn3270e_submode == E_NONE)
  2806 + if (!IN_E || h3270.tn3270e_submode == E_NONE)
2807 2807 return False;
2808 2808  
2809 2809 space3270out(EH_SIZE);
2810 2810 h = (tn3270e_header *)h3270.obptr;
2811 2811  
2812   - switch (tn3270e_submode) {
  2812 + switch (h3270.tn3270e_submode) {
2813 2813 case E_NONE:
2814 2814 break;
2815 2815 case E_NVT:
... ... @@ -3001,23 +3001,23 @@ net_abort(void)
3001 3001 * SSCP-LU mode), or should we put ourselves in it?
3002 3002 * Time, and testers, will tell.
3003 3003 */
3004   - switch (tn3270e_submode) {
  3004 + switch (h3270.tn3270e_submode) {
3005 3005 case E_NONE:
3006 3006 case E_NVT:
3007 3007 break;
3008 3008 case E_SSCP:
3009 3009 net_rawout(&h3270, buf, sizeof(buf));
3010 3010 trace_dsn("SENT AO\n");
3011   - if (tn3270e_bound ||
  3011 + if (h3270.tn3270e_bound ||
3012 3012 !(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) {
3013   - tn3270e_submode = E_3270;
  3013 + h3270.tn3270e_submode = E_3270;
3014 3014 check_in3270(&h3270);
3015 3015 }
3016 3016 break;
3017 3017 case E_3270:
3018 3018 net_rawout(&h3270, buf, sizeof(buf));
3019 3019 trace_dsn("SENT AO\n");
3020   - tn3270e_submode = E_SSCP;
  3020 + h3270.tn3270e_submode = E_SSCP;
3021 3021 check_in3270(&h3270);
3022 3022 break;
3023 3023 }
... ... @@ -3157,7 +3157,7 @@ net_snap_options(void)
3157 3157 *h3270.obptr++ = IAC;
3158 3158 *h3270.obptr++ = SE;
3159 3159  
3160   - if (tn3270e_bound) {
  3160 + if (h3270.tn3270e_bound) {
3161 3161 tn3270e_header *h;
3162 3162  
3163 3163 space3270out(EH_SIZE + 3);
... ...