Commit 9a1f7f939917ce041a616c30a876de5312e67491

Authored by perry.werneck@gmail.com
1 parent 76eb1849

Movendo mais campos para a estrutura de sessao

src/include/lib3270/session.h
... ... @@ -36,6 +36,8 @@
36 36 #define LIB3270_LUNAME_LENGTH 16
37 37 #define LIB3270_FULL_MODEL_NAME_LENGTH 13
38 38  
  39 + #define LIB3270_TELNET_N_OPTS 256
  40 +
39 41 /** extended attributes */
40 42 struct ea
41 43 {
... ... @@ -164,7 +166,8 @@
164 166 // Telnet.c
165 167 unsigned char * ibuf;
166 168 int ibuf_size; /**< size of ibuf */
167   -
  169 + unsigned char myopts[LIB3270_TELNET_N_OPTS];
  170 + unsigned char hisopts[LIB3270_TELNET_N_OPTS];
168 171  
169 172 // Widget info
170 173 void * widget;
... ...
src/lib3270/telnet.c
... ... @@ -114,8 +114,6 @@
114 114 #define BUFSZ 16384
115 115 #define TRACELINE 72
116 116  
117   -#define N_OPTS 256
118   -
119 117 /* Globals */
120 118 // char *hostname = CN;
121 119 time_t ns_time;
... ... @@ -148,7 +146,7 @@ extern struct timeval ds_ts;
148 146 //static HANDLE sock_handle = NULL;
149 147 //#endif /*]*/
150 148  
151   -static unsigned char myopts[N_OPTS], hisopts[N_OPTS];
  149 +// static unsigned char myopts[LIB3270_TELNET_N_OPTS], hisopts[LIB3270_TELNET_N_OPTS];
152 150  
153 151 /* telnet option flags */
154 152 // static unsigned char *ibuf = (unsigned char *) NULL;
... ... @@ -856,8 +854,8 @@ static void net_connected(H3270 *session)
856 854 #endif /*]*/
857 855  
858 856 /* set up telnet options */
859   - (void) memset((char *) myopts, 0, sizeof(myopts));
860   - (void) memset((char *) hisopts, 0, sizeof(hisopts));
  857 + (void) memset((char *) h3270.myopts, 0, sizeof(h3270.myopts));
  858 + (void) memset((char *) h3270.hisopts, 0, sizeof(h3270.hisopts));
861 859  
862 860 #if defined(X3270_TN3270E) /*[*/
863 861 e_funcs = E_OPT(TN3270E_FUNC_BIND_IMAGE) |
... ... @@ -1309,8 +1307,8 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1309 1307 case TELOPT_TN3270E:
1310 1308 #endif /*]*/
1311 1309 if (c != TELOPT_TN3270E || !h3270.non_tn3270e_host) {
1312   - if (!hisopts[c]) {
1313   - hisopts[c] = 1;
  1310 + if (!h3270.hisopts[c]) {
  1311 + h3270.hisopts[c] = 1;
1314 1312 do_opt[2] = c;
1315 1313 net_rawout(do_opt, sizeof(do_opt));
1316 1314 trace_dsn("SENT %s %s\n",
... ... @@ -1320,8 +1318,8 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1320 1318 * For UTS, volunteer to do EOR when
1321 1319 * they do.
1322 1320 */
1323   - if (c == TELOPT_EOR && !myopts[c]) {
1324   - myopts[c] = 1;
  1321 + if (c == TELOPT_EOR && !h3270.myopts[c]) {
  1322 + h3270.myopts[c] = 1;
1325 1323 will_opt[2] = c;
1326 1324 net_rawout(will_opt,
1327 1325 sizeof(will_opt));
... ... @@ -1344,8 +1342,8 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1344 1342 break;
1345 1343 case TNS_WONT: /* telnet WONT DO OPTION command */
1346 1344 trace_dsn("%s\n", opt(c));
1347   - if (hisopts[c]) {
1348   - hisopts[c] = 0;
  1345 + if (h3270.hisopts[c]) {
  1346 + h3270.hisopts[c] = 0;
1349 1347 dont_opt[2] = c;
1350 1348 net_rawout(dont_opt, sizeof(dont_opt));
1351 1349 trace_dsn("SENT %s %s\n", cmd(DONT), opt(c));
... ... @@ -1374,9 +1372,9 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1374 1372 if (c == TELOPT_TM && !session->bsd_tm)
1375 1373 goto wont;
1376 1374  
1377   - if (!myopts[c]) {
  1375 + if (!h3270.myopts[c]) {
1378 1376 if (c != TELOPT_TM)
1379   - myopts[c] = 1;
  1377 + h3270.myopts[c] = 1;
1380 1378 will_opt[2] = c;
1381 1379 net_rawout(will_opt, sizeof(will_opt));
1382 1380 trace_dsn("SENT %s %s\n", cmd(WILL), opt(c));
... ... @@ -1417,8 +1415,8 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1417 1415 break;
1418 1416 case TNS_DONT: /* telnet PLEASE DON'T DO OPTION command */
1419 1417 trace_dsn("%s\n", opt(c));
1420   - if (myopts[c]) {
1421   - myopts[c] = 0;
  1418 + if (h3270.myopts[c]) {
  1419 + h3270.myopts[c] = 0;
1422 1420 wont_opt[2] = c;
1423 1421 net_rawout(wont_opt, sizeof(wont_opt));
1424 1422 trace_dsn("SENT %s %s\n", cmd(WONT), opt(c));
... ... @@ -1479,7 +1477,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1479 1477 next_lu();
1480 1478 }
1481 1479 #if defined(X3270_TN3270E) /*[*/
1482   - else if (myopts[TELOPT_TN3270E] &&
  1480 + else if (h3270.myopts[TELOPT_TN3270E] &&
1483 1481 sbbuf[0] == TELOPT_TN3270E) {
1484 1482 if (tn3270e_negotiate())
1485 1483 return -1;
... ... @@ -1487,7 +1485,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1487 1485 #endif /*]*/
1488 1486 #if defined(HAVE_LIBSSL) /*[*/
1489 1487 else if (need_tls_follows &&
1490   - myopts[TELOPT_STARTTLS] &&
  1488 + h3270.myopts[TELOPT_STARTTLS] &&
1491 1489 sbbuf[0] == TELOPT_STARTTLS) {
1492 1490 continue_tls(sbbuf, sbptr - sbbuf);
1493 1491 }
... ... @@ -1558,7 +1556,7 @@ backoff_tn3270e(const char *why)
1558 1556 setup_lus();
1559 1557  
1560 1558 /* Reset our internal state. */
1561   - myopts[TELOPT_TN3270E] = 0;
  1559 + h3270.myopts[TELOPT_TN3270E] = 0;
1562 1560 check_in3270(&h3270);
1563 1561 }
1564 1562  
... ... @@ -2417,7 +2415,7 @@ check_in3270(H3270 *session)
2417 2415 #endif /*]*/
2418 2416  
2419 2417 #if defined(X3270_TN3270E) /*[*/
2420   - if (myopts[TELOPT_TN3270E]) {
  2418 + if (h3270.myopts[TELOPT_TN3270E]) {
2421 2419 if (!tn3270e_negotiated)
2422 2420 new_cstate = CONNECTED_INITIAL_E;
2423 2421 else switch (tn3270e_submode) {
... ... @@ -2436,11 +2434,11 @@ check_in3270(H3270 *session)
2436 2434 }
2437 2435 } else
2438 2436 #endif /*]*/
2439   - if (myopts[TELOPT_BINARY] &&
2440   - myopts[TELOPT_EOR] &&
2441   - myopts[TELOPT_TTYPE] &&
2442   - hisopts[TELOPT_BINARY] &&
2443   - hisopts[TELOPT_EOR]) {
  2437 + if (h3270.myopts[TELOPT_BINARY] &&
  2438 + h3270.myopts[TELOPT_EOR] &&
  2439 + h3270.myopts[TELOPT_TTYPE] &&
  2440 + h3270.hisopts[TELOPT_BINARY] &&
  2441 + h3270.hisopts[TELOPT_EOR]) {
2444 2442 new_cstate = CONNECTED_3270;
2445 2443 } else if (session->cstate == CONNECTED_INITIAL) {
2446 2444 /* Nothing has happened, yet. */
... ... @@ -2483,7 +2481,7 @@ check_in3270(H3270 *session)
2483 2481  
2484 2482 #if defined(X3270_TN3270E) /*[*/
2485 2483 /* If we fell out of TN3270E, remove the state. */
2486   - if (!myopts[TELOPT_TN3270E]) {
  2484 + if (!h3270.myopts[TELOPT_TN3270E]) {
2487 2485 tn3270e_negotiated = 0;
2488 2486 tn3270e_submode = E_NONE;
2489 2487 tn3270e_bound = 0;
... ... @@ -2564,7 +2562,7 @@ check_linemode(Boolean init)
2564 2562 * mode" properly by asking for both SGA and ECHO to be off or on, but
2565 2563 * we basically ignore the reply for SGA.
2566 2564 */
2567   - linemode = !hisopts[TELOPT_ECHO] /* && !hisopts[TELOPT_SGA] */;
  2565 + linemode = !h3270.hisopts[TELOPT_ECHO] /* && !hisopts[TELOPT_SGA] */;
2568 2566  
2569 2567 if (init || linemode != wasline)
2570 2568 {
... ... @@ -3092,7 +3090,7 @@ net_snap_options(void)
3092 3090 obptr = obuf;
3093 3091  
3094 3092 /* Do TTYPE first. */
3095   - if (myopts[TELOPT_TTYPE]) {
  3093 + if (h3270.myopts[TELOPT_TTYPE]) {
3096 3094 unsigned j;
3097 3095  
3098 3096 space3270out(sizeof(ttype_str));
... ... @@ -3101,17 +3099,17 @@ net_snap_options(void)
3101 3099 }
3102 3100  
3103 3101 /* Do the other options. */
3104   - for (i = 0; i < N_OPTS; i++) {
  3102 + for (i = 0; i < LIB3270_TELNET_N_OPTS; i++) {
3105 3103 space3270out(6);
3106 3104 if (i == TELOPT_TTYPE)
3107 3105 continue;
3108   - if (hisopts[i]) {
  3106 + if (h3270.hisopts[i]) {
3109 3107 *obptr++ = IAC;
3110 3108 *obptr++ = WILL;
3111 3109 *obptr++ = (unsigned char)i;
3112 3110 any = True;
3113 3111 }
3114   - if (myopts[i]) {
  3112 + if (h3270.myopts[i]) {
3115 3113 *obptr++ = IAC;
3116 3114 *obptr++ = DO;
3117 3115 *obptr++ = (unsigned char)i;
... ... @@ -3121,7 +3119,7 @@ net_snap_options(void)
3121 3119  
3122 3120 #if defined(X3270_TN3270E) /*[*/
3123 3121 /* If we're in TN3270E mode, snap the subnegotations as well. */
3124   - if (myopts[TELOPT_TN3270E]) {
  3122 + if (h3270.myopts[TELOPT_TN3270E]) {
3125 3123 any = True;
3126 3124  
3127 3125 space3270out(5 +
... ...