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