Commit 69991adda77ab35606b2c043d708857bfbe93a88
1 parent
ac9261ce
Exists in
master
and in
5 other branches
Ajustando macros e chamadas da GSource para tratar o handle de sessao
Showing
8 changed files
with
288 additions
and
297 deletions
Show diff stats
src/lib3270/api.h
| ... | ... | @@ -242,16 +242,16 @@ |
| 242 | 242 | LOCAL_EXTERN int RegisterFTCallbacks(const struct filetransfer_callbacks *cbk); |
| 243 | 243 | */ |
| 244 | 244 | |
| 245 | - #define PCONNECTED lib3270_pconnected(NULL) | |
| 246 | - #define HALF_CONNECTED lib3270_half_connected(NULL) | |
| 247 | - #define CONNECTED lib3270_connected(NULL) | |
| 248 | - | |
| 249 | - #define IN_NEITHER lib3270_in_neither(NULL) | |
| 250 | - #define IN_ANSI lib3270_in_ansi(NULL) | |
| 251 | - #define IN_3270 lib3270_in_3270(NULL) | |
| 252 | - #define IN_SSCP lib3270_in_sscp(NULL) | |
| 253 | - #define IN_TN3270E lib3270_in_tn3270e(NULL) | |
| 254 | - #define IN_E lib3270_in_e(NULL) | |
| 245 | + #define PCONNECTED lib3270_pconnected(hSession) | |
| 246 | + #define HALF_CONNECTED lib3270_half_connected(hSession) | |
| 247 | + #define CONNECTED lib3270_connected(hSession) | |
| 248 | + | |
| 249 | + #define IN_NEITHER lib3270_in_neither(hSession) | |
| 250 | + #define IN_ANSI lib3270_in_ansi(hSession) | |
| 251 | + #define IN_3270 lib3270_in_3270(hSession) | |
| 252 | + #define IN_SSCP lib3270_in_sscp(hSession) | |
| 253 | + #define IN_TN3270E lib3270_in_tn3270e(hSession) | |
| 254 | + #define IN_E lib3270_in_e(hSession) | |
| 255 | 255 | |
| 256 | 256 | #ifndef LIB3270 |
| 257 | 257 | ... | ... |
src/lib3270/ctlr.c
| ... | ... | @@ -155,26 +155,27 @@ void ctlr_reinit(H3270 *session, unsigned cmask) |
| 155 | 155 | /** |
| 156 | 156 | * Get current 3270 model. |
| 157 | 157 | * |
| 158 | - * @param session selected 3270 session. | |
| 158 | + * @param hSession selected 3270 session. | |
| 159 | 159 | * @return Current model number. |
| 160 | 160 | */ |
| 161 | -int lib3270_get_model(H3270 *session) | |
| 161 | +int lib3270_get_model(H3270 *hSession) | |
| 162 | 162 | { |
| 163 | - return session->model_num; | |
| 163 | + return hSession->model_num; | |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * Deal with the relationships between model numbers and rows/cols. |
| 168 | 168 | * |
| 169 | - * @param model New model (updates model name) | |
| 169 | + * @param hSession Session handle. | |
| 170 | + * @param model New model (updates model name) | |
| 170 | 171 | */ |
| 171 | -int lib3270_set_model(H3270 *session, int model) | |
| 172 | +int lib3270_set_model(H3270 *hSession, int model) | |
| 172 | 173 | { |
| 173 | 174 | if(CONNECTED) |
| 174 | 175 | return EBUSY; |
| 175 | 176 | |
| 176 | - ctlr_set_rows_cols(session,model,session->ov_cols,session->ov_rows); | |
| 177 | - ctlr_reinit(session,MODEL_CHANGE); | |
| 177 | + ctlr_set_rows_cols(hSession,model,hSession->ov_cols,hSession->ov_rows); | |
| 178 | + ctlr_reinit(hSession,MODEL_CHANGE); | |
| 178 | 179 | |
| 179 | 180 | return 0; |
| 180 | 181 | } | ... | ... |
src/lib3270/ft.c
| ... | ... | @@ -514,17 +514,17 @@ void ft_aborting(H3270FT *h) |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /* Process a disconnect abort. */ |
| 517 | -static void ft_connected(H3270 *session, int ignored, void *dunno) | |
| 517 | +static void ft_connected(H3270 *hSession, int ignored, void *dunno) | |
| 518 | 518 | { |
| 519 | - if (!CONNECTED && lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE) | |
| 520 | - ft_complete(get_ft_handle(session),_("Host disconnected, transfer cancelled")); | |
| 519 | + if (!CONNECTED && lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE) | |
| 520 | + ft_complete(get_ft_handle(hSession),_("Host disconnected, transfer cancelled")); | |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | /* Process an abort from no longer being in 3270 mode. */ |
| 524 | -static void ft_in3270(H3270 *session, int ignored, void *dunno) | |
| 524 | +static void ft_in3270(H3270 *hSession, int ignored, void *dunno) | |
| 525 | 525 | { |
| 526 | - if (!IN_3270 && lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE) | |
| 527 | - ft_complete(get_ft_handle(session),_("Not in 3270 mode, transfer cancelled")); | |
| 526 | + if (!IN_3270 && lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE) | |
| 527 | + ft_complete(get_ft_handle(hSession),_("Not in 3270 mode, transfer cancelled")); | |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | LIB3270_EXPORT LIB3270_FT_STATE lib3270_get_ft_state(H3270 *session) | ... | ... |
src/lib3270/host.c
| ... | ... | @@ -605,15 +605,15 @@ static int do_connect(H3270 *hSession, const char *n) |
| 605 | 605 | * @return 0 if the connection was ok, non zero on error. |
| 606 | 606 | * |
| 607 | 607 | */ |
| 608 | -int lib3270_connect(H3270 *h, const char *n, int wait) | |
| 608 | +int lib3270_connect(H3270 *hSession, const char *n, int wait) | |
| 609 | 609 | { |
| 610 | 610 | int rc; |
| 611 | 611 | |
| 612 | - CHECK_SESSION_HANDLE(h); | |
| 612 | + CHECK_SESSION_HANDLE(hSession); | |
| 613 | 613 | |
| 614 | - lib3270_main_iterate(h,0); | |
| 614 | + lib3270_main_iterate(hSession,0); | |
| 615 | 615 | |
| 616 | - if(h->auto_reconnect_inprogress) | |
| 616 | + if(hSession->auto_reconnect_inprogress) | |
| 617 | 617 | return EAGAIN; |
| 618 | 618 | |
| 619 | 619 | if(PCONNECTED) |
| ... | ... | @@ -621,12 +621,12 @@ int lib3270_connect(H3270 *h, const char *n, int wait) |
| 621 | 621 | |
| 622 | 622 | if(!n) |
| 623 | 623 | { |
| 624 | - n = h->full_current_host; | |
| 624 | + n = hSession->full_current_host; | |
| 625 | 625 | if(!n) |
| 626 | 626 | return EINVAL; |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - rc = do_connect(h,n); | |
| 629 | + rc = do_connect(hSession,n); | |
| 630 | 630 | if(rc) |
| 631 | 631 | return rc; |
| 632 | 632 | |
| ... | ... | @@ -634,7 +634,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait) |
| 634 | 634 | { |
| 635 | 635 | while(!IN_ANSI && !IN_3270) |
| 636 | 636 | { |
| 637 | - lib3270_main_iterate(h,1); | |
| 637 | + lib3270_main_iterate(hSession,1); | |
| 638 | 638 | |
| 639 | 639 | if(!PCONNECTED) |
| 640 | 640 | { |
| ... | ... | @@ -661,22 +661,22 @@ LIB3270_EXPORT void lib3270_disconnect(H3270 *h) |
| 661 | 661 | host_disconnect(h,0); |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | -void host_disconnect(H3270 *h, int failed) | |
| 664 | +void host_disconnect(H3270 *hSession, int failed) | |
| 665 | 665 | { |
| 666 | - CHECK_SESSION_HANDLE(h); | |
| 666 | + CHECK_SESSION_HANDLE(hSession); | |
| 667 | 667 | |
| 668 | 668 | if (CONNECTED || HALF_CONNECTED) |
| 669 | 669 | { |
| 670 | 670 | // Disconecting, disable input |
| 671 | - remove_input_calls(h); | |
| 672 | - net_disconnect(h); | |
| 671 | + remove_input_calls(hSession); | |
| 672 | + net_disconnect(hSession); | |
| 673 | 673 | |
| 674 | - trace("Disconnected (Failed: %d Reconnect: %d in_progress: %d)",failed,lib3270_get_toggle(h,LIB3270_TOGGLE_RECONNECT),h->auto_reconnect_inprogress); | |
| 675 | - if (lib3270_get_toggle(h,LIB3270_TOGGLE_RECONNECT) && !h->auto_reconnect_inprogress) | |
| 674 | + trace("Disconnected (Failed: %d Reconnect: %d in_progress: %d)",failed,lib3270_get_toggle(hSession,LIB3270_TOGGLE_RECONNECT),hSession->auto_reconnect_inprogress); | |
| 675 | + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_RECONNECT) && !hSession->auto_reconnect_inprogress) | |
| 676 | 676 | { |
| 677 | 677 | /* Schedule an automatic reconnection. */ |
| 678 | - h->auto_reconnect_inprogress = 1; | |
| 679 | - (void) AddTimeOut(failed ? RECONNECT_ERR_MS: RECONNECT_MS, h, try_reconnect); | |
| 678 | + hSession->auto_reconnect_inprogress = 1; | |
| 679 | + (void) AddTimeOut(failed ? RECONNECT_ERR_MS: RECONNECT_MS, hSession, try_reconnect); | |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | /* |
| ... | ... | @@ -684,24 +684,24 @@ void host_disconnect(H3270 *h, int failed) |
| 684 | 684 | * in sync. |
| 685 | 685 | */ |
| 686 | 686 | #if defined(X3270_TRACE) /*[*/ |
| 687 | - if (IN_ANSI && lib3270_get_toggle(h,LIB3270_TOGGLE_SCREEN_TRACE)) | |
| 688 | - trace_ansi_disc(h); | |
| 687 | + if (IN_ANSI && lib3270_get_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE)) | |
| 688 | + trace_ansi_disc(hSession); | |
| 689 | 689 | #endif /*]*/ |
| 690 | 690 | |
| 691 | - lib3270_set_disconnected(h); | |
| 691 | + lib3270_set_disconnected(hSession); | |
| 692 | 692 | } |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | /* The host has entered 3270 or ANSI mode, or switched between them. */ |
| 696 | -void host_in3270(H3270 *session, LIB3270_CSTATE new_cstate) | |
| 696 | +void host_in3270(H3270 *hSession, LIB3270_CSTATE new_cstate) | |
| 697 | 697 | { |
| 698 | 698 | Boolean now3270 = (new_cstate == CONNECTED_3270 || |
| 699 | 699 | new_cstate == CONNECTED_SSCP || |
| 700 | 700 | new_cstate == CONNECTED_TN3270E); |
| 701 | 701 | |
| 702 | - session->cstate = new_cstate; | |
| 703 | - session->ever_3270 = now3270; | |
| 704 | - lib3270_st_changed(session, LIB3270_STATE_3270_MODE, now3270); | |
| 702 | + hSession->cstate = new_cstate; | |
| 703 | + hSession->ever_3270 = now3270; | |
| 704 | + lib3270_st_changed(hSession, LIB3270_STATE_3270_MODE, now3270); | |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | void lib3270_set_connected(H3270 *hSession) |
| ... | ... | @@ -805,26 +805,26 @@ LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) |
| 805 | 805 | return h->full_current_host; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | -LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait) | |
| 808 | +LIB3270_EXPORT int lib3270_reconnect(H3270 *hSession,int wait) | |
| 809 | 809 | { |
| 810 | 810 | int rc; |
| 811 | 811 | |
| 812 | - CHECK_SESSION_HANDLE(h); | |
| 812 | + CHECK_SESSION_HANDLE(hSession); | |
| 813 | 813 | |
| 814 | 814 | if (CONNECTED || HALF_CONNECTED) |
| 815 | 815 | return EBUSY; |
| 816 | 816 | |
| 817 | - if (h->full_current_host == CN) | |
| 817 | + if (hSession->full_current_host == CN) | |
| 818 | 818 | return EINVAL; |
| 819 | 819 | |
| 820 | - if (h->auto_reconnect_inprogress) | |
| 820 | + if (hSession->auto_reconnect_inprogress) | |
| 821 | 821 | return EBUSY; |
| 822 | 822 | |
| 823 | - rc = lib3270_connect(h,h->full_current_host,wait); | |
| 823 | + rc = lib3270_connect(hSession,hSession->full_current_host,wait); | |
| 824 | 824 | |
| 825 | 825 | if(rc) |
| 826 | 826 | { |
| 827 | - h->auto_reconnect_inprogress = 0; | |
| 827 | + hSession->auto_reconnect_inprogress = 0; | |
| 828 | 828 | return rc; |
| 829 | 829 | } |
| 830 | 830 | ... | ... |
src/lib3270/kybd.c
| ... | ... | @@ -456,15 +456,15 @@ void kybd_connect(H3270 *session, int connected, void *dunno) |
| 456 | 456 | /* |
| 457 | 457 | * Called when we switch between 3270 and ANSI modes. |
| 458 | 458 | */ |
| 459 | -void kybd_in3270(H3270 *session, int in3270 unused, void *dunno) | |
| 459 | +void kybd_in3270(H3270 *hSession, int in3270 unused, void *dunno) | |
| 460 | 460 | { |
| 461 | - if (session->kybdlock & KL_DEFERRED_UNLOCK) | |
| 462 | - RemoveTimeOut(session->unlock_id); | |
| 463 | - lib3270_kybdlock_clear(session,~KL_AWAITING_FIRST); | |
| 461 | + if (hSession->kybdlock & KL_DEFERRED_UNLOCK) | |
| 462 | + RemoveTimeOut(hSession->unlock_id); | |
| 463 | + lib3270_kybdlock_clear(hSession,~KL_AWAITING_FIRST); | |
| 464 | 464 | |
| 465 | 465 | /* There might be a macro pending. */ |
| 466 | 466 | if (CONNECTED) |
| 467 | - ps_process(session); | |
| 467 | + ps_process(hSession); | |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /* |
| ... | ... | @@ -1113,19 +1113,19 @@ LIB3270_ACTION( previousfield ) |
| 1113 | 1113 | * Deferred keyboard unlock. |
| 1114 | 1114 | */ |
| 1115 | 1115 | |
| 1116 | -static void defer_unlock(H3270 *session) | |
| 1116 | +static void defer_unlock(H3270 *hSession) | |
| 1117 | 1117 | { |
| 1118 | 1118 | // trace("%s",__FUNCTION__); |
| 1119 | - lib3270_kybdlock_clear(session,KL_DEFERRED_UNLOCK); | |
| 1120 | - status_reset(session); | |
| 1119 | + lib3270_kybdlock_clear(hSession,KL_DEFERRED_UNLOCK); | |
| 1120 | + status_reset(hSession); | |
| 1121 | 1121 | if(CONNECTED) |
| 1122 | - ps_process(session); | |
| 1122 | + ps_process(hSession); | |
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /* |
| 1126 | 1126 | * Reset keyboard lock. |
| 1127 | 1127 | */ |
| 1128 | -void do_reset(H3270 *session, Boolean explicit) | |
| 1128 | +void do_reset(H3270 *hSession, Boolean explicit) | |
| 1129 | 1129 | { |
| 1130 | 1130 | /* |
| 1131 | 1131 | * If explicit (from the keyboard) and there is typeahead or |
| ... | ... | @@ -1134,12 +1134,12 @@ void do_reset(H3270 *session, Boolean explicit) |
| 1134 | 1134 | |
| 1135 | 1135 | if (explicit |
| 1136 | 1136 | #if defined(X3270_FT) /*[*/ |
| 1137 | - || lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE | |
| 1137 | + || lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE | |
| 1138 | 1138 | #endif /*]*/ |
| 1139 | 1139 | ) { |
| 1140 | 1140 | Boolean half_reset = False; |
| 1141 | 1141 | |
| 1142 | - if (flush_ta(session)) | |
| 1142 | + if (flush_ta(hSession)) | |
| 1143 | 1143 | half_reset = True; |
| 1144 | 1144 | |
| 1145 | 1145 | if (half_reset) |
| ... | ... | @@ -1147,7 +1147,7 @@ void do_reset(H3270 *session, Boolean explicit) |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | /* Always clear insert mode. */ |
| 1150 | - lib3270_set_toggle(session,LIB3270_TOGGLE_INSERT,0); | |
| 1150 | + lib3270_set_toggle(hSession,LIB3270_TOGGLE_INSERT,0); | |
| 1151 | 1151 | |
| 1152 | 1152 | /* Otherwise, if not connect, reset is a no-op. */ |
| 1153 | 1153 | if (!CONNECTED) |
| ... | ... | @@ -1157,8 +1157,8 @@ void do_reset(H3270 *session, Boolean explicit) |
| 1157 | 1157 | * Remove any deferred keyboard unlock. We will either unlock the |
| 1158 | 1158 | * keyboard now, or want to defer further into the future. |
| 1159 | 1159 | */ |
| 1160 | - if (session->kybdlock & KL_DEFERRED_UNLOCK) | |
| 1161 | - RemoveTimeOut(session->unlock_id); | |
| 1160 | + if (hSession->kybdlock & KL_DEFERRED_UNLOCK) | |
| 1161 | + RemoveTimeOut(hSession->unlock_id); | |
| 1162 | 1162 | |
| 1163 | 1163 | /* |
| 1164 | 1164 | * If explicit (from the keyboard), unlock the keyboard now. |
| ... | ... | @@ -1166,21 +1166,21 @@ void do_reset(H3270 *session, Boolean explicit) |
| 1166 | 1166 | */ |
| 1167 | 1167 | if (explicit |
| 1168 | 1168 | #if defined(X3270_FT) /*[*/ |
| 1169 | - || lib3270_get_ft_state(session) != LIB3270_FT_STATE_NONE | |
| 1169 | + || lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE | |
| 1170 | 1170 | #endif /*]*/ |
| 1171 | - || (!session->unlock_delay) // && !sms_in_macro()) | |
| 1172 | - || (session->unlock_delay_time != 0 && (time(NULL) - session->unlock_delay_time) > 1)) { | |
| 1173 | - lib3270_kybdlock_clear(session,-1); | |
| 1174 | - } else if (session->kybdlock & | |
| 1171 | + || (!hSession->unlock_delay) // && !sms_in_macro()) | |
| 1172 | + || (hSession->unlock_delay_time != 0 && (time(NULL) - hSession->unlock_delay_time) > 1)) { | |
| 1173 | + lib3270_kybdlock_clear(hSession,-1); | |
| 1174 | + } else if (hSession->kybdlock & | |
| 1175 | 1175 | (KL_DEFERRED_UNLOCK | KL_OIA_TWAIT | KL_OIA_LOCKED | KL_AWAITING_FIRST)) { |
| 1176 | - lib3270_kybdlock_clear(session,~KL_DEFERRED_UNLOCK); | |
| 1177 | - kybdlock_set(session,KL_DEFERRED_UNLOCK); | |
| 1178 | - session->unlock_id = AddTimeOut(UNLOCK_MS, session, defer_unlock); | |
| 1176 | + lib3270_kybdlock_clear(hSession,~KL_DEFERRED_UNLOCK); | |
| 1177 | + kybdlock_set(hSession,KL_DEFERRED_UNLOCK); | |
| 1178 | + hSession->unlock_id = AddTimeOut(UNLOCK_MS, hSession, defer_unlock); | |
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | /* Clean up other modes. */ |
| 1182 | - status_reset(session); | |
| 1183 | - mcursor_normal(session); | |
| 1182 | + status_reset(hSession); | |
| 1183 | + mcursor_normal(hSession); | |
| 1184 | 1184 | |
| 1185 | 1185 | } |
| 1186 | 1186 | ... | ... |
src/lib3270/screen.c
| ... | ... | @@ -538,51 +538,41 @@ void status_lu(H3270 *session, const char *lu) |
| 538 | 538 | |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | -static void status_connect(H3270 *session, int connected, void *dunno) | |
| 541 | +static void status_connect(H3270 *hSession, int connected, void *dunno) | |
| 542 | 542 | { |
| 543 | 543 | LIB3270_STATUS id = LIB3270_STATUS_USER; |
| 544 | 544 | |
| 545 | - ctlr_erase(session,1); | |
| 545 | + ctlr_erase(hSession,1); | |
| 546 | 546 | |
| 547 | 547 | if (connected) |
| 548 | 548 | { |
| 549 | - set_status(session,OIA_FLAG_BOXSOLID,IN_3270 && !IN_SSCP); | |
| 549 | + set_status(hSession,OIA_FLAG_BOXSOLID,IN_3270 && !IN_SSCP); | |
| 550 | 550 | |
| 551 | - if (session->kybdlock & KL_AWAITING_FIRST) | |
| 551 | + if (hSession->kybdlock & KL_AWAITING_FIRST) | |
| 552 | 552 | id = LIB3270_STATUS_AWAITING_FIRST; |
| 553 | 553 | else |
| 554 | 554 | id = LIB3270_STATUS_CONNECTED; |
| 555 | 555 | |
| 556 | -/* | |
| 557 | -#if defined(HAVE_LIBSSL) | |
| 558 | - set_status(session,OIA_FLAG_SECURE,session->secure_connection); | |
| 559 | -#endif | |
| 560 | -*/ | |
| 561 | - | |
| 562 | 556 | } |
| 563 | 557 | else |
| 564 | 558 | { |
| 565 | - set_status(session,OIA_FLAG_BOXSOLID,False); | |
| 566 | -/* | |
| 567 | - set_status(session,OIA_FLAG_SECURE,False); | |
| 568 | -*/ | |
| 569 | - | |
| 559 | + set_status(hSession,OIA_FLAG_BOXSOLID,False); | |
| 570 | 560 | id = LIB3270_STATUS_DISCONNECTED; |
| 571 | 561 | } |
| 572 | 562 | |
| 573 | - status_changed(session,id); | |
| 563 | + status_changed(hSession,id); | |
| 574 | 564 | |
| 575 | 565 | } |
| 576 | 566 | |
| 577 | -static void status_3270_mode(H3270 *session, int ignored unused, void *dunno) | |
| 567 | +static void status_3270_mode(H3270 *hSession, int ignored unused, void *dunno) | |
| 578 | 568 | { |
| 579 | 569 | Boolean oia_boxsolid = (IN_3270 && !IN_SSCP); |
| 580 | 570 | |
| 581 | - CHECK_SESSION_HANDLE(session); | |
| 571 | + CHECK_SESSION_HANDLE(hSession); | |
| 582 | 572 | |
| 583 | 573 | if(oia_boxsolid) |
| 584 | - set_status(session,OIA_FLAG_UNDERA,True); | |
| 585 | - set_status(session,OIA_FLAG_BOXSOLID,oia_boxsolid); | |
| 574 | + set_status(hSession,OIA_FLAG_UNDERA,True); | |
| 575 | + set_status(hSession,OIA_FLAG_BOXSOLID,oia_boxsolid); | |
| 586 | 576 | |
| 587 | 577 | } |
| 588 | 578 | ... | ... |
src/lib3270/telnet.c
| ... | ... | @@ -1009,43 +1009,46 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned |
| 1009 | 1009 | #endif // X3270_ANSI |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - | |
| 1013 | -/* | |
| 1014 | - * net_input | |
| 1015 | - * Called by the toolkit whenever there is input available on the | |
| 1016 | - * socket. Reads the data, processes the special telnet commands | |
| 1017 | - * and calls process_ds to process the 3270 data stream. | |
| 1012 | +/** | |
| 1013 | + * net_input. | |
| 1014 | + * | |
| 1015 | + * Called by the toolkit whenever there is input available on the | |
| 1016 | + * socket. Reads the data, processes the special telnet commands | |
| 1017 | + * and calls process_ds to process the 3270 data stream. | |
| 1018 | + * | |
| 1019 | + * @param hSession Session handle | |
| 1020 | + * | |
| 1018 | 1021 | */ |
| 1019 | -void net_input(H3270 *session) | |
| 1022 | +void net_input(H3270 *hSession) | |
| 1020 | 1023 | { |
| 1021 | 1024 | // register unsigned char * cp; |
| 1022 | 1025 | int nr; |
| 1023 | 1026 | unsigned char buffer[BUFSZ]; |
| 1024 | 1027 | |
| 1025 | - CHECK_SESSION_HANDLE(session); | |
| 1028 | + CHECK_SESSION_HANDLE(hSession); | |
| 1026 | 1029 | |
| 1027 | 1030 | #if defined(_WIN32) |
| 1028 | 1031 | for (;;) |
| 1029 | 1032 | #endif |
| 1030 | 1033 | { |
| 1031 | - if (session->sock < 0) | |
| 1034 | + if (hSession->sock < 0) | |
| 1032 | 1035 | return; |
| 1033 | 1036 | |
| 1034 | 1037 | #if defined(X3270_ANSI) |
| 1035 | - session->ansi_data = 0; | |
| 1038 | + hSession->ansi_data = 0; | |
| 1036 | 1039 | #endif |
| 1037 | 1040 | |
| 1038 | 1041 | #if defined(_WIN32) |
| 1039 | - ResetEvent(session->sockEvent); | |
| 1042 | + ResetEvent(hSession->sockEvent); | |
| 1040 | 1043 | #endif |
| 1041 | 1044 | |
| 1042 | 1045 | #if defined(HAVE_LIBSSL) |
| 1043 | - if (session->ssl_con != NULL) | |
| 1044 | - nr = SSL_read(session->ssl_con, (char *) buffer, BUFSZ); | |
| 1046 | + if (hSession->ssl_con != NULL) | |
| 1047 | + nr = SSL_read(hSession->ssl_con, (char *) buffer, BUFSZ); | |
| 1045 | 1048 | else |
| 1046 | - nr = recv(session->sock, (char *) buffer, BUFSZ, 0); | |
| 1049 | + nr = recv(hSession->sock, (char *) buffer, BUFSZ, 0); | |
| 1047 | 1050 | #else |
| 1048 | - nr = recv(session->sock, (char *) buffer, BUFSZ, 0); | |
| 1051 | + nr = recv(hSession->sock, (char *) buffer, BUFSZ, 0); | |
| 1049 | 1052 | #endif // HAVE_LIBSSL |
| 1050 | 1053 | |
| 1051 | 1054 | if (nr < 0) |
| ... | ... | @@ -1054,7 +1057,7 @@ void net_input(H3270 *session) |
| 1054 | 1057 | return; |
| 1055 | 1058 | |
| 1056 | 1059 | #if defined(HAVE_LIBSSL) /*[*/ |
| 1057 | - if(session->ssl_con != NULL) | |
| 1060 | + if(hSession->ssl_con != NULL) | |
| 1058 | 1061 | { |
| 1059 | 1062 | unsigned long e; |
| 1060 | 1063 | char err_buf[120]; |
| ... | ... | @@ -1065,55 +1068,55 @@ void net_input(H3270 *session) |
| 1065 | 1068 | else |
| 1066 | 1069 | strcpy(err_buf, _( "unknown error" ) ); |
| 1067 | 1070 | |
| 1068 | - trace_dsn(session,"RCVD SSL_read error %ld (%s)\n", e,err_buf); | |
| 1071 | + trace_dsn(hSession,"RCVD SSL_read error %ld (%s)\n", e,err_buf); | |
| 1069 | 1072 | |
| 1070 | - session->message( session,LIB3270_NOTIFY_ERROR,_( "SSL Error" ),_( "SSL Read error" ),err_buf ); | |
| 1073 | + hSession->message(hSession,LIB3270_NOTIFY_ERROR,_( "SSL Error" ),_( "SSL Read error" ),err_buf ); | |
| 1071 | 1074 | |
| 1072 | - host_disconnect(session,True); | |
| 1075 | + host_disconnect(hSession,True); | |
| 1073 | 1076 | return; |
| 1074 | 1077 | } |
| 1075 | 1078 | #endif /*]*/ |
| 1076 | 1079 | |
| 1077 | 1080 | if (HALF_CONNECTED && socket_errno() == SE_EAGAIN) |
| 1078 | 1081 | { |
| 1079 | - connection_complete(session); | |
| 1082 | + connection_complete(hSession); | |
| 1080 | 1083 | return; |
| 1081 | 1084 | } |
| 1082 | 1085 | |
| 1083 | - trace_dsn(session,"RCVD socket error %d\n", errno); | |
| 1086 | + trace_dsn(hSession,"RCVD socket error %d\n", errno); | |
| 1084 | 1087 | |
| 1085 | 1088 | if (HALF_CONNECTED) |
| 1086 | 1089 | { |
| 1087 | - popup_a_sockerr(session, N_( "%s:%d" ),session->hostname, session->current_port); | |
| 1090 | + popup_a_sockerr(hSession, N_( "%s:%d" ),hSession->hostname, hSession->current_port); | |
| 1088 | 1091 | } |
| 1089 | 1092 | else if (socket_errno() != SE_ECONNRESET) |
| 1090 | 1093 | { |
| 1091 | - popup_a_sockerr(session, N_( "Socket read error" ) ); | |
| 1094 | + popup_a_sockerr(hSession, N_( "Socket read error" ) ); | |
| 1092 | 1095 | } |
| 1093 | 1096 | |
| 1094 | - host_disconnect(session,True); | |
| 1097 | + host_disconnect(hSession,True); | |
| 1095 | 1098 | return; |
| 1096 | 1099 | } else if (nr == 0) |
| 1097 | 1100 | { |
| 1098 | 1101 | /* Host disconnected. */ |
| 1099 | - trace_dsn(session,"RCVD disconnect\n"); | |
| 1100 | - host_disconnect(session,False); | |
| 1102 | + trace_dsn(hSession,"RCVD disconnect\n"); | |
| 1103 | + host_disconnect(hSession,False); | |
| 1101 | 1104 | return; |
| 1102 | 1105 | } |
| 1103 | 1106 | |
| 1104 | 1107 | /* Process the data. */ |
| 1105 | 1108 | if (HALF_CONNECTED) |
| 1106 | 1109 | { |
| 1107 | - if (non_blocking(session,False) < 0) | |
| 1110 | + if (non_blocking(hSession,False) < 0) | |
| 1108 | 1111 | { |
| 1109 | - host_disconnect(session,True); | |
| 1112 | + host_disconnect(hSession,True); | |
| 1110 | 1113 | return; |
| 1111 | 1114 | } |
| 1112 | - lib3270_set_connected(session); | |
| 1113 | - net_connected(session); | |
| 1115 | + lib3270_set_connected(hSession); | |
| 1116 | + net_connected(hSession); | |
| 1114 | 1117 | } |
| 1115 | 1118 | |
| 1116 | - lib3270_data_recv(session, nr, buffer); | |
| 1119 | + lib3270_data_recv(hSession, nr, buffer); | |
| 1117 | 1120 | |
| 1118 | 1121 | /* |
| 1119 | 1122 | trace_netdata('<', session->netrbuf, nr); |
| ... | ... | @@ -1201,65 +1204,64 @@ static void next_lu(H3270 *hSession) |
| 1201 | 1204 | * Telnet finite-state machine. |
| 1202 | 1205 | * Returns 0 for okay, -1 for errors. |
| 1203 | 1206 | */ |
| 1204 | -static int telnet_fsm(H3270 *session, unsigned char c) | |
| 1207 | +static int telnet_fsm(H3270 *hSession, unsigned char c) | |
| 1205 | 1208 | { |
| 1206 | 1209 | #if defined(X3270_ANSI) /*[*/ |
| 1207 | 1210 | char *see_chr; |
| 1208 | 1211 | int sl; |
| 1209 | 1212 | #endif /*]*/ |
| 1210 | 1213 | |
| 1211 | - switch (session->telnet_state) | |
| 1214 | + switch (hSession->telnet_state) | |
| 1212 | 1215 | { |
| 1213 | 1216 | case TNS_DATA: /* normal data processing */ |
| 1214 | 1217 | if (c == IAC) { /* got a telnet command */ |
| 1215 | - session->telnet_state = TNS_IAC; | |
| 1218 | + hSession->telnet_state = TNS_IAC; | |
| 1216 | 1219 | #if defined(X3270_ANSI) /*[*/ |
| 1217 | - if (session->ansi_data) { | |
| 1218 | - trace_dsn(session,"\n"); | |
| 1219 | - session->ansi_data = 0; | |
| 1220 | + if (hSession->ansi_data) { | |
| 1221 | + trace_dsn(hSession,"\n"); | |
| 1222 | + hSession->ansi_data = 0; | |
| 1220 | 1223 | } |
| 1221 | 1224 | #endif /*]*/ |
| 1222 | 1225 | break; |
| 1223 | 1226 | } |
| 1224 | 1227 | if (IN_NEITHER) { /* now can assume ANSI mode */ |
| 1225 | 1228 | #if defined(X3270_ANSI)/*[*/ |
| 1226 | - if (session->linemode) | |
| 1227 | - cooked_init(session); | |
| 1229 | + if (hSession->linemode) | |
| 1230 | + cooked_init(hSession); | |
| 1228 | 1231 | #endif /*]*/ |
| 1229 | - host_in3270(session,CONNECTED_ANSI); | |
| 1230 | - lib3270_kybdlock_clear(session,KL_AWAITING_FIRST); | |
| 1231 | - status_reset(session); | |
| 1232 | - ps_process(session); | |
| 1232 | + host_in3270(hSession,CONNECTED_ANSI); | |
| 1233 | + lib3270_kybdlock_clear(hSession,KL_AWAITING_FIRST); | |
| 1234 | + status_reset(hSession); | |
| 1235 | + ps_process(hSession); | |
| 1233 | 1236 | } |
| 1234 | 1237 | if (IN_ANSI && !IN_E) { |
| 1235 | 1238 | #if defined(X3270_ANSI) /*[*/ |
| 1236 | - if (!session->ansi_data) { | |
| 1237 | - trace_dsn(session,"<.. "); | |
| 1238 | - session->ansi_data = 4; | |
| 1239 | + if (!hSession->ansi_data) { | |
| 1240 | + trace_dsn(hSession,"<.. "); | |
| 1241 | + hSession->ansi_data = 4; | |
| 1239 | 1242 | } |
| 1240 | 1243 | see_chr = ctl_see((int) c); |
| 1241 | - session->ansi_data += (sl = strlen(see_chr)); | |
| 1242 | - if (session->ansi_data >= TRACELINE) { | |
| 1243 | - trace_dsn(session," ...\n... "); | |
| 1244 | - session->ansi_data = 4 + sl; | |
| 1244 | + hSession->ansi_data += (sl = strlen(see_chr)); | |
| 1245 | + if (hSession->ansi_data >= TRACELINE) { | |
| 1246 | + trace_dsn(hSession," ...\n... "); | |
| 1247 | + hSession->ansi_data = 4 + sl; | |
| 1245 | 1248 | } |
| 1246 | - trace_dsn(session,"%s",see_chr); | |
| 1247 | - if (!session->syncing) | |
| 1249 | + trace_dsn(hSession,"%s",see_chr); | |
| 1250 | + if (!hSession->syncing) | |
| 1248 | 1251 | { |
| 1249 | - if (session->linemode && session->onlcr && c == '\n') | |
| 1250 | - ansi_process(session,(unsigned int) '\r'); | |
| 1251 | - ansi_process(session,(unsigned int) c); | |
| 1252 | -// sms_store(c); | |
| 1252 | + if (hSession->linemode && hSession->onlcr && c == '\n') | |
| 1253 | + ansi_process(hSession,(unsigned int) '\r'); | |
| 1254 | + ansi_process(hSession,(unsigned int) c); | |
| 1253 | 1255 | } |
| 1254 | 1256 | #endif /*]*/ |
| 1255 | 1257 | } else { |
| 1256 | - store3270in(session,c); | |
| 1258 | + store3270in(hSession,c); | |
| 1257 | 1259 | } |
| 1258 | 1260 | break; |
| 1259 | 1261 | case TNS_IAC: /* process a telnet command */ |
| 1260 | 1262 | if (c != EOR && c != IAC) |
| 1261 | 1263 | { |
| 1262 | - trace_dsn(session,"RCVD %s ", cmd(c)); | |
| 1264 | + trace_dsn(hSession,"RCVD %s ", cmd(c)); | |
| 1263 | 1265 | } |
| 1264 | 1266 | |
| 1265 | 1267 | switch (c) |
| ... | ... | @@ -1268,91 +1270,91 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1268 | 1270 | if (IN_ANSI && !IN_E) |
| 1269 | 1271 | { |
| 1270 | 1272 | #if defined(X3270_ANSI) /*[*/ |
| 1271 | - if (!session->ansi_data) | |
| 1273 | + if (!hSession->ansi_data) | |
| 1272 | 1274 | { |
| 1273 | - trace_dsn(session,"<.. "); | |
| 1274 | - session->ansi_data = 4; | |
| 1275 | + trace_dsn(hSession,"<.. "); | |
| 1276 | + hSession->ansi_data = 4; | |
| 1275 | 1277 | } |
| 1276 | 1278 | see_chr = ctl_see((int) c); |
| 1277 | - session->ansi_data += (sl = strlen(see_chr)); | |
| 1278 | - if (session->ansi_data >= TRACELINE) | |
| 1279 | + hSession->ansi_data += (sl = strlen(see_chr)); | |
| 1280 | + if (hSession->ansi_data >= TRACELINE) | |
| 1279 | 1281 | { |
| 1280 | - trace_dsn(session," ...\n ..."); | |
| 1281 | - session->ansi_data = 4 + sl; | |
| 1282 | + trace_dsn(hSession," ...\n ..."); | |
| 1283 | + hSession->ansi_data = 4 + sl; | |
| 1282 | 1284 | } |
| 1283 | - trace_dsn(session,"%s",see_chr); | |
| 1284 | - ansi_process(session,(unsigned int) c); | |
| 1285 | + trace_dsn(hSession,"%s",see_chr); | |
| 1286 | + ansi_process(hSession,(unsigned int) c); | |
| 1285 | 1287 | #endif /*]*/ |
| 1286 | 1288 | } |
| 1287 | 1289 | else |
| 1288 | 1290 | { |
| 1289 | - store3270in(session,c); | |
| 1291 | + store3270in(hSession,c); | |
| 1290 | 1292 | } |
| 1291 | - session->telnet_state = TNS_DATA; | |
| 1293 | + hSession->telnet_state = TNS_DATA; | |
| 1292 | 1294 | break; |
| 1293 | 1295 | |
| 1294 | 1296 | case EOR: /* eor, process accumulated input */ |
| 1295 | 1297 | |
| 1296 | - if (IN_3270 || (IN_E && session->tn3270e_negotiated)) | |
| 1298 | + if (IN_3270 || (IN_E && hSession->tn3270e_negotiated)) | |
| 1297 | 1299 | { |
| 1298 | - session->ns_rrcvd++; | |
| 1299 | - if (process_eor(session)) | |
| 1300 | + hSession->ns_rrcvd++; | |
| 1301 | + if (process_eor(hSession)) | |
| 1300 | 1302 | return -1; |
| 1301 | 1303 | } else |
| 1302 | - Warning(session, _( "EOR received when not in 3270 mode, ignored." )); | |
| 1304 | + Warning(hSession, _( "EOR received when not in 3270 mode, ignored." )); | |
| 1303 | 1305 | |
| 1304 | - trace_dsn(session,"RCVD EOR\n"); | |
| 1305 | - session->ibptr = session->ibuf; | |
| 1306 | - session->telnet_state = TNS_DATA; | |
| 1306 | + trace_dsn(hSession,"RCVD EOR\n"); | |
| 1307 | + hSession->ibptr = hSession->ibuf; | |
| 1308 | + hSession->telnet_state = TNS_DATA; | |
| 1307 | 1309 | break; |
| 1308 | 1310 | |
| 1309 | 1311 | case WILL: |
| 1310 | - session->telnet_state = TNS_WILL; | |
| 1312 | + hSession->telnet_state = TNS_WILL; | |
| 1311 | 1313 | break; |
| 1312 | 1314 | |
| 1313 | 1315 | case WONT: |
| 1314 | - session->telnet_state = TNS_WONT; | |
| 1316 | + hSession->telnet_state = TNS_WONT; | |
| 1315 | 1317 | break; |
| 1316 | 1318 | |
| 1317 | 1319 | case DO: |
| 1318 | - session->telnet_state = TNS_DO; | |
| 1320 | + hSession->telnet_state = TNS_DO; | |
| 1319 | 1321 | break; |
| 1320 | 1322 | |
| 1321 | 1323 | case DONT: |
| 1322 | - session->telnet_state = TNS_DONT; | |
| 1324 | + hSession->telnet_state = TNS_DONT; | |
| 1323 | 1325 | break; |
| 1324 | 1326 | |
| 1325 | 1327 | case SB: |
| 1326 | - session->telnet_state = TNS_SB; | |
| 1327 | - if (session->sbbuf == (unsigned char *)NULL) | |
| 1328 | - session->sbbuf = (unsigned char *)lib3270_malloc(1024); | |
| 1329 | - session->sbptr = session->sbbuf; | |
| 1328 | + hSession->telnet_state = TNS_SB; | |
| 1329 | + if (hSession->sbbuf == (unsigned char *)NULL) | |
| 1330 | + hSession->sbbuf = (unsigned char *)lib3270_malloc(1024); | |
| 1331 | + hSession->sbptr = hSession->sbbuf; | |
| 1330 | 1332 | break; |
| 1331 | 1333 | |
| 1332 | 1334 | case DM: |
| 1333 | - trace_dsn(session,"\n"); | |
| 1334 | - if (session->syncing) | |
| 1335 | + trace_dsn(hSession,"\n"); | |
| 1336 | + if (hSession->syncing) | |
| 1335 | 1337 | { |
| 1336 | - session->syncing = 0; | |
| 1337 | - x_except_on(session); | |
| 1338 | + hSession->syncing = 0; | |
| 1339 | + x_except_on(hSession); | |
| 1338 | 1340 | } |
| 1339 | - session->telnet_state = TNS_DATA; | |
| 1341 | + hSession->telnet_state = TNS_DATA; | |
| 1340 | 1342 | break; |
| 1341 | 1343 | |
| 1342 | 1344 | case GA: |
| 1343 | 1345 | case NOP: |
| 1344 | - trace_dsn(session,"\n"); | |
| 1345 | - session->telnet_state = TNS_DATA; | |
| 1346 | + trace_dsn(hSession,"\n"); | |
| 1347 | + hSession->telnet_state = TNS_DATA; | |
| 1346 | 1348 | break; |
| 1347 | 1349 | |
| 1348 | 1350 | default: |
| 1349 | - trace_dsn(session,"???\n"); | |
| 1350 | - session->telnet_state = TNS_DATA; | |
| 1351 | + trace_dsn(hSession,"???\n"); | |
| 1352 | + hSession->telnet_state = TNS_DATA; | |
| 1351 | 1353 | break; |
| 1352 | 1354 | } |
| 1353 | 1355 | break; |
| 1354 | 1356 | case TNS_WILL: /* telnet WILL DO OPTION command */ |
| 1355 | - trace_dsn(session,"%s\n", opt(c)); | |
| 1357 | + trace_dsn(hSession,"%s\n", opt(c)); | |
| 1356 | 1358 | switch (c) { |
| 1357 | 1359 | case TELOPT_SGA: |
| 1358 | 1360 | case TELOPT_BINARY: |
| ... | ... | @@ -1362,54 +1364,54 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1362 | 1364 | #if defined(X3270_TN3270E) /*[*/ |
| 1363 | 1365 | case TELOPT_TN3270E: |
| 1364 | 1366 | #endif /*]*/ |
| 1365 | - if (c != TELOPT_TN3270E || !session->non_tn3270e_host) { | |
| 1366 | - if (!session->hisopts[c]) { | |
| 1367 | - session->hisopts[c] = 1; | |
| 1367 | + if (c != TELOPT_TN3270E || !hSession->non_tn3270e_host) { | |
| 1368 | + if (!hSession->hisopts[c]) { | |
| 1369 | + hSession->hisopts[c] = 1; | |
| 1368 | 1370 | do_opt[2] = c; |
| 1369 | - net_rawout(session,do_opt, sizeof(do_opt)); | |
| 1370 | - trace_dsn(session,"SENT %s %s\n", | |
| 1371 | + net_rawout(hSession,do_opt, sizeof(do_opt)); | |
| 1372 | + trace_dsn(hSession,"SENT %s %s\n", | |
| 1371 | 1373 | cmd(DO), opt(c)); |
| 1372 | 1374 | |
| 1373 | 1375 | /* |
| 1374 | 1376 | * For UTS, volunteer to do EOR when |
| 1375 | 1377 | * they do. |
| 1376 | 1378 | */ |
| 1377 | - if (c == TELOPT_EOR && !session->myopts[c]) { | |
| 1378 | - session->myopts[c] = 1; | |
| 1379 | + if (c == TELOPT_EOR && !hSession->myopts[c]) { | |
| 1380 | + hSession->myopts[c] = 1; | |
| 1379 | 1381 | will_opt[2] = c; |
| 1380 | - net_rawout(session,will_opt,sizeof(will_opt)); | |
| 1381 | - trace_dsn(session,"SENT %s %s\n",cmd(WILL), opt(c)); | |
| 1382 | + net_rawout(hSession,will_opt,sizeof(will_opt)); | |
| 1383 | + trace_dsn(hSession,"SENT %s %s\n",cmd(WILL), opt(c)); | |
| 1382 | 1384 | } |
| 1383 | 1385 | |
| 1384 | - check_in3270(session); | |
| 1385 | - check_linemode(session,False); | |
| 1386 | + check_in3270(hSession); | |
| 1387 | + check_linemode(hSession,False); | |
| 1386 | 1388 | } |
| 1387 | 1389 | break; |
| 1388 | 1390 | } |
| 1389 | 1391 | default: |
| 1390 | 1392 | dont_opt[2] = c; |
| 1391 | - net_rawout(session,dont_opt, sizeof(dont_opt)); | |
| 1392 | - trace_dsn(session,"SENT %s %s\n", cmd(DONT), opt(c)); | |
| 1393 | + net_rawout(hSession,dont_opt, sizeof(dont_opt)); | |
| 1394 | + trace_dsn(hSession,"SENT %s %s\n", cmd(DONT), opt(c)); | |
| 1393 | 1395 | break; |
| 1394 | 1396 | } |
| 1395 | - session->telnet_state = TNS_DATA; | |
| 1397 | + hSession->telnet_state = TNS_DATA; | |
| 1396 | 1398 | break; |
| 1397 | 1399 | case TNS_WONT: /* telnet WONT DO OPTION command */ |
| 1398 | - trace_dsn(session,"%s\n", opt(c)); | |
| 1399 | - if (session->hisopts[c]) | |
| 1400 | + trace_dsn(hSession,"%s\n", opt(c)); | |
| 1401 | + if (hSession->hisopts[c]) | |
| 1400 | 1402 | { |
| 1401 | - session->hisopts[c] = 0; | |
| 1403 | + hSession->hisopts[c] = 0; | |
| 1402 | 1404 | dont_opt[2] = c; |
| 1403 | - net_rawout(session, dont_opt, sizeof(dont_opt)); | |
| 1404 | - trace_dsn(session,"SENT %s %s\n", cmd(DONT), opt(c)); | |
| 1405 | - check_in3270(session); | |
| 1406 | - check_linemode(session,False); | |
| 1405 | + net_rawout(hSession, dont_opt, sizeof(dont_opt)); | |
| 1406 | + trace_dsn(hSession,"SENT %s %s\n", cmd(DONT), opt(c)); | |
| 1407 | + check_in3270(hSession); | |
| 1408 | + check_linemode(hSession,False); | |
| 1407 | 1409 | } |
| 1408 | 1410 | |
| 1409 | - session->telnet_state = TNS_DATA; | |
| 1411 | + hSession->telnet_state = TNS_DATA; | |
| 1410 | 1412 | break; |
| 1411 | 1413 | case TNS_DO: /* telnet PLEASE DO OPTION command */ |
| 1412 | - trace_dsn(session,"%s\n", opt(c)); | |
| 1414 | + trace_dsn(hSession,"%s\n", opt(c)); | |
| 1413 | 1415 | switch (c) { |
| 1414 | 1416 | case TELOPT_BINARY: |
| 1415 | 1417 | case TELOPT_EOR: |
| ... | ... | @@ -1423,24 +1425,24 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1423 | 1425 | #if defined(HAVE_LIBSSL) /*[*/ |
| 1424 | 1426 | case TELOPT_STARTTLS: |
| 1425 | 1427 | #endif /*]*/ |
| 1426 | - if (c == TELOPT_TN3270E && session->non_tn3270e_host) | |
| 1428 | + if (c == TELOPT_TN3270E && hSession->non_tn3270e_host) | |
| 1427 | 1429 | goto wont; |
| 1428 | - if (c == TELOPT_TM && !session->bsd_tm) | |
| 1430 | + if (c == TELOPT_TM && !hSession->bsd_tm) | |
| 1429 | 1431 | goto wont; |
| 1430 | 1432 | |
| 1431 | - trace("session->myopts[c]=%d",session->myopts[c]); | |
| 1432 | - if (!session->myopts[c]) | |
| 1433 | + trace("hSession->myopts[c]=%d",hSession->myopts[c]); | |
| 1434 | + if (!hSession->myopts[c]) | |
| 1433 | 1435 | { |
| 1434 | 1436 | if (c != TELOPT_TM) |
| 1435 | - session->myopts[c] = 1; | |
| 1437 | + hSession->myopts[c] = 1; | |
| 1436 | 1438 | will_opt[2] = c; |
| 1437 | - net_rawout(session, will_opt, sizeof(will_opt)); | |
| 1438 | - trace_dsn(session,"SENT %s %s\n", cmd(WILL), opt(c)); | |
| 1439 | - check_in3270(session); | |
| 1440 | - check_linemode(session,False); | |
| 1439 | + net_rawout(hSession, will_opt, sizeof(will_opt)); | |
| 1440 | + trace_dsn(hSession,"SENT %s %s\n", cmd(WILL), opt(c)); | |
| 1441 | + check_in3270(hSession); | |
| 1442 | + check_linemode(hSession,False); | |
| 1441 | 1443 | } |
| 1442 | 1444 | if (c == TELOPT_NAWS) |
| 1443 | - send_naws(session); | |
| 1445 | + send_naws(hSession); | |
| 1444 | 1446 | #if defined(HAVE_LIBSSL) /*[*/ |
| 1445 | 1447 | if (c == TELOPT_STARTTLS) { |
| 1446 | 1448 | static unsigned char follows_msg[] = { |
| ... | ... | @@ -1452,82 +1454,82 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1452 | 1454 | * Send IAC SB STARTTLS FOLLOWS IAC SE |
| 1453 | 1455 | * to announce that what follows is TLS. |
| 1454 | 1456 | */ |
| 1455 | - net_rawout(session, follows_msg, sizeof(follows_msg)); | |
| 1456 | - trace_dsn(session,"SENT %s %s FOLLOWS %s\n", | |
| 1457 | + net_rawout(hSession, follows_msg, sizeof(follows_msg)); | |
| 1458 | + trace_dsn(hSession,"SENT %s %s FOLLOWS %s\n", | |
| 1457 | 1459 | cmd(SB), |
| 1458 | 1460 | opt(TELOPT_STARTTLS), |
| 1459 | 1461 | cmd(SE)); |
| 1460 | - session->need_tls_follows = 1; | |
| 1462 | + hSession->need_tls_follows = 1; | |
| 1461 | 1463 | } |
| 1462 | 1464 | #endif /*]*/ |
| 1463 | 1465 | break; |
| 1464 | 1466 | default: |
| 1465 | 1467 | wont: |
| 1466 | 1468 | wont_opt[2] = c; |
| 1467 | - net_rawout(session, wont_opt, sizeof(wont_opt)); | |
| 1468 | - trace_dsn(session,"SENT %s %s\n", cmd(WONT), opt(c)); | |
| 1469 | + net_rawout(hSession, wont_opt, sizeof(wont_opt)); | |
| 1470 | + trace_dsn(hSession,"SENT %s %s\n", cmd(WONT), opt(c)); | |
| 1469 | 1471 | break; |
| 1470 | 1472 | } |
| 1471 | - session->telnet_state = TNS_DATA; | |
| 1473 | + hSession->telnet_state = TNS_DATA; | |
| 1472 | 1474 | break; |
| 1473 | 1475 | case TNS_DONT: /* telnet PLEASE DON'T DO OPTION command */ |
| 1474 | - trace_dsn(session,"%s\n", opt(c)); | |
| 1475 | - if (session->myopts[c]) { | |
| 1476 | - session->myopts[c] = 0; | |
| 1476 | + trace_dsn(hSession,"%s\n", opt(c)); | |
| 1477 | + if (hSession->myopts[c]) { | |
| 1478 | + hSession->myopts[c] = 0; | |
| 1477 | 1479 | wont_opt[2] = c; |
| 1478 | - net_rawout(session, wont_opt, sizeof(wont_opt)); | |
| 1479 | - trace_dsn(session,"SENT %s %s\n", cmd(WONT), opt(c)); | |
| 1480 | - check_in3270(session); | |
| 1481 | - check_linemode(session,False); | |
| 1480 | + net_rawout(hSession, wont_opt, sizeof(wont_opt)); | |
| 1481 | + trace_dsn(hSession,"SENT %s %s\n", cmd(WONT), opt(c)); | |
| 1482 | + check_in3270(hSession); | |
| 1483 | + check_linemode(hSession,False); | |
| 1482 | 1484 | } |
| 1483 | - session->telnet_state = TNS_DATA; | |
| 1485 | + hSession->telnet_state = TNS_DATA; | |
| 1484 | 1486 | break; |
| 1485 | 1487 | case TNS_SB: /* telnet sub-option string command */ |
| 1486 | 1488 | if (c == IAC) |
| 1487 | - session->telnet_state = TNS_SB_IAC; | |
| 1489 | + hSession->telnet_state = TNS_SB_IAC; | |
| 1488 | 1490 | else |
| 1489 | - *session->sbptr++ = c; | |
| 1491 | + *hSession->sbptr++ = c; | |
| 1490 | 1492 | break; |
| 1491 | 1493 | case TNS_SB_IAC: /* telnet sub-option string command */ |
| 1492 | - *session->sbptr++ = c; | |
| 1494 | + *hSession->sbptr++ = c; | |
| 1493 | 1495 | if (c == SE) { |
| 1494 | - session->telnet_state = TNS_DATA; | |
| 1495 | - if (session->sbbuf[0] == TELOPT_TTYPE && session->sbbuf[1] == TELQUAL_SEND) | |
| 1496 | + hSession->telnet_state = TNS_DATA; | |
| 1497 | + if (hSession->sbbuf[0] == TELOPT_TTYPE && hSession->sbbuf[1] == TELQUAL_SEND) | |
| 1496 | 1498 | { |
| 1497 | 1499 | int tt_len, tb_len; |
| 1498 | 1500 | char *tt_out; |
| 1499 | 1501 | |
| 1500 | - trace_dsn(session,"%s %s\n", opt(session->sbbuf[0]),telquals[session->sbbuf[1]]); | |
| 1502 | + trace_dsn(hSession,"%s %s\n", opt(hSession->sbbuf[0]),telquals[hSession->sbbuf[1]]); | |
| 1501 | 1503 | |
| 1502 | - if (session->lus != (char **)NULL && session->try_lu == CN) | |
| 1504 | + if (hSession->lus != (char **)NULL && hSession->try_lu == CN) | |
| 1503 | 1505 | { |
| 1504 | 1506 | /* None of the LUs worked. */ |
| 1505 | 1507 | popup_an_error(NULL,"Cannot connect to specified LU"); |
| 1506 | 1508 | return -1; |
| 1507 | 1509 | } |
| 1508 | 1510 | |
| 1509 | - tt_len = strlen(session->termtype); | |
| 1510 | - if (session->try_lu != CN && *session->try_lu) | |
| 1511 | + tt_len = strlen(hSession->termtype); | |
| 1512 | + if (hSession->try_lu != CN && *hSession->try_lu) | |
| 1511 | 1513 | { |
| 1512 | - tt_len += strlen(session->try_lu) + 1; | |
| 1513 | - session->connected_lu = session->try_lu; | |
| 1514 | + tt_len += strlen(hSession->try_lu) + 1; | |
| 1515 | + hSession->connected_lu = hSession->try_lu; | |
| 1514 | 1516 | } |
| 1515 | 1517 | else |
| 1516 | - session->connected_lu = CN; | |
| 1518 | + hSession->connected_lu = CN; | |
| 1517 | 1519 | |
| 1518 | - status_lu(session,session->connected_lu); | |
| 1520 | + status_lu(hSession,hSession->connected_lu); | |
| 1519 | 1521 | |
| 1520 | 1522 | tb_len = 4 + tt_len + 2; |
| 1521 | 1523 | tt_out = lib3270_malloc(tb_len + 1); |
| 1522 | 1524 | (void) sprintf(tt_out, "%c%c%c%c%s%s%s%c%c", |
| 1523 | 1525 | IAC, SB, TELOPT_TTYPE, TELQUAL_IS, |
| 1524 | - session->termtype, | |
| 1525 | - (session->try_lu != CN && *session->try_lu) ? "@" : "", | |
| 1526 | - (session->try_lu != CN && *session->try_lu) ? session->try_lu : "", | |
| 1526 | + hSession->termtype, | |
| 1527 | + (hSession->try_lu != CN && *hSession->try_lu) ? "@" : "", | |
| 1528 | + (hSession->try_lu != CN && *hSession->try_lu) ? hSession->try_lu : "", | |
| 1527 | 1529 | IAC, SE); |
| 1528 | - net_rawout(session, (unsigned char *)tt_out, tb_len); | |
| 1530 | + net_rawout(hSession, (unsigned char *)tt_out, tb_len); | |
| 1529 | 1531 | |
| 1530 | - trace_dsn(session,"SENT %s %s %s %.*s %s\n", | |
| 1532 | + trace_dsn(hSession,"SENT %s %s %s %.*s %s\n", | |
| 1531 | 1533 | cmd(SB), opt(TELOPT_TTYPE), |
| 1532 | 1534 | telquals[TELQUAL_IS], |
| 1533 | 1535 | tt_len, tt_out + 4, |
| ... | ... | @@ -1535,24 +1537,24 @@ static int telnet_fsm(H3270 *session, unsigned char c) |
| 1535 | 1537 | lib3270_free(tt_out); |
| 1536 | 1538 | |
| 1537 | 1539 | /* Advance to the next LU name. */ |
| 1538 | - next_lu(session); | |
| 1540 | + next_lu(hSession); | |
| 1539 | 1541 | } |
| 1540 | 1542 | #if defined(X3270_TN3270E) /*[*/ |
| 1541 | - else if (session->myopts[TELOPT_TN3270E] && session->sbbuf[0] == TELOPT_TN3270E) | |
| 1543 | + else if (hSession->myopts[TELOPT_TN3270E] && hSession->sbbuf[0] == TELOPT_TN3270E) | |
| 1542 | 1544 | { |
| 1543 | - if (tn3270e_negotiate(session)) | |
| 1545 | + if (tn3270e_negotiate(hSession)) | |
| 1544 | 1546 | return -1; |
| 1545 | 1547 | } |
| 1546 | 1548 | #endif /*]*/ |
| 1547 | 1549 | #if defined(HAVE_LIBSSL) /*[*/ |
| 1548 | - else if (session->need_tls_follows && session->myopts[TELOPT_STARTTLS] && session->sbbuf[0] == TELOPT_STARTTLS) | |
| 1550 | + else if (hSession->need_tls_follows && hSession->myopts[TELOPT_STARTTLS] && hSession->sbbuf[0] == TELOPT_STARTTLS) | |
| 1549 | 1551 | { |
| 1550 | - continue_tls(session,session->sbbuf, session->sbptr - session->sbbuf); | |
| 1552 | + continue_tls(hSession,hSession->sbbuf, hSession->sbptr - hSession->sbbuf); | |
| 1551 | 1553 | } |
| 1552 | 1554 | #endif /*]*/ |
| 1553 | 1555 | |
| 1554 | 1556 | } else { |
| 1555 | - session->telnet_state = TNS_SB; | |
| 1557 | + hSession->telnet_state = TNS_SB; | |
| 1556 | 1558 | } |
| 1557 | 1559 | break; |
| 1558 | 1560 | } |
| ... | ... | @@ -2405,18 +2407,19 @@ static void do_lnext(H3270 *hSession, char c) |
| 2405 | 2407 | #endif /*]*/ |
| 2406 | 2408 | |
| 2407 | 2409 | |
| 2408 | - | |
| 2409 | -/* | |
| 2410 | - * check_in3270 | |
| 2411 | - * Check for switches between NVT, SSCP-LU and 3270 modes. | |
| 2410 | +/** | |
| 2411 | + * Check for switches between NVT, SSCP-LU and 3270 modes. | |
| 2412 | + * | |
| 2413 | + * @param hSession Session handle. | |
| 2414 | + * | |
| 2412 | 2415 | */ |
| 2413 | -static void | |
| 2414 | -check_in3270(H3270 *session) | |
| 2416 | +static void check_in3270(H3270 *hSession) | |
| 2415 | 2417 | { |
| 2416 | 2418 | LIB3270_CSTATE new_cstate = NOT_CONNECTED; |
| 2417 | 2419 | |
| 2418 | 2420 | #if defined(X3270_TRACE) /*[*/ |
| 2419 | - static const char *state_name[] = { | |
| 2421 | + static const char *state_name[] = | |
| 2422 | + { | |
| 2420 | 2423 | "unconnected", |
| 2421 | 2424 | "resolving", |
| 2422 | 2425 | "pending", |
| ... | ... | @@ -2431,10 +2434,10 @@ check_in3270(H3270 *session) |
| 2431 | 2434 | #endif /*]*/ |
| 2432 | 2435 | |
| 2433 | 2436 | #if defined(X3270_TN3270E) /*[*/ |
| 2434 | - if (session->myopts[TELOPT_TN3270E]) { | |
| 2435 | - if (!session->tn3270e_negotiated) | |
| 2437 | + if (hSession->myopts[TELOPT_TN3270E]) { | |
| 2438 | + if (!hSession->tn3270e_negotiated) | |
| 2436 | 2439 | new_cstate = CONNECTED_INITIAL_E; |
| 2437 | - else switch (session->tn3270e_submode) { | |
| 2440 | + else switch (hSession->tn3270e_submode) { | |
| 2438 | 2441 | case E_NONE: |
| 2439 | 2442 | new_cstate = CONNECTED_INITIAL_E; |
| 2440 | 2443 | break; |
| ... | ... | @@ -2450,20 +2453,20 @@ check_in3270(H3270 *session) |
| 2450 | 2453 | } |
| 2451 | 2454 | } else |
| 2452 | 2455 | #endif /*]*/ |
| 2453 | - if (session->myopts[TELOPT_BINARY] && | |
| 2454 | - session->myopts[TELOPT_EOR] && | |
| 2455 | - session->myopts[TELOPT_TTYPE] && | |
| 2456 | - session->hisopts[TELOPT_BINARY] && | |
| 2457 | - session->hisopts[TELOPT_EOR]) { | |
| 2456 | + if (hSession->myopts[TELOPT_BINARY] && | |
| 2457 | + hSession->myopts[TELOPT_EOR] && | |
| 2458 | + hSession->myopts[TELOPT_TTYPE] && | |
| 2459 | + hSession->hisopts[TELOPT_BINARY] && | |
| 2460 | + hSession->hisopts[TELOPT_EOR]) { | |
| 2458 | 2461 | new_cstate = CONNECTED_3270; |
| 2459 | - } else if (session->cstate == CONNECTED_INITIAL) { | |
| 2462 | + } else if (hSession->cstate == CONNECTED_INITIAL) { | |
| 2460 | 2463 | /* Nothing has happened, yet. */ |
| 2461 | 2464 | return; |
| 2462 | 2465 | } else { |
| 2463 | 2466 | new_cstate = CONNECTED_ANSI; |
| 2464 | 2467 | } |
| 2465 | 2468 | |
| 2466 | - if (new_cstate != session->cstate) { | |
| 2469 | + if (new_cstate != hSession->cstate) { | |
| 2467 | 2470 | #if defined(X3270_TN3270E) /*[*/ |
| 2468 | 2471 | int was_in_e = IN_E; |
| 2469 | 2472 | #endif /*]*/ |
| ... | ... | @@ -2474,37 +2477,37 @@ check_in3270(H3270 *session) |
| 2474 | 2477 | * TN3270E mode, reset the LU list so we can try again |
| 2475 | 2478 | * in the new mode. |
| 2476 | 2479 | */ |
| 2477 | - if (session->lus != (char **)NULL && was_in_e != IN_E) { | |
| 2478 | - session->curr_lu = session->lus; | |
| 2479 | - session->try_lu = *session->curr_lu; | |
| 2480 | + if (hSession->lus != (char **)NULL && was_in_e != IN_E) { | |
| 2481 | + hSession->curr_lu = hSession->lus; | |
| 2482 | + hSession->try_lu = *hSession->curr_lu; | |
| 2480 | 2483 | } |
| 2481 | 2484 | #endif /*]*/ |
| 2482 | 2485 | |
| 2483 | 2486 | /* Allocate the initial 3270 input buffer. */ |
| 2484 | - if(new_cstate >= CONNECTED_INITIAL && !(session->ibuf_size && session->ibuf)) | |
| 2487 | + if(new_cstate >= CONNECTED_INITIAL && !(hSession->ibuf_size && hSession->ibuf)) | |
| 2485 | 2488 | { |
| 2486 | - session->ibuf = (unsigned char *) lib3270_malloc(BUFSIZ); | |
| 2487 | - session->ibuf_size = BUFSIZ; | |
| 2488 | - session->ibptr = session->ibuf; | |
| 2489 | + hSession->ibuf = (unsigned char *) lib3270_malloc(BUFSIZ); | |
| 2490 | + hSession->ibuf_size = BUFSIZ; | |
| 2491 | + hSession->ibptr = hSession->ibuf; | |
| 2489 | 2492 | } |
| 2490 | 2493 | |
| 2491 | 2494 | #if defined(X3270_ANSI) /*[*/ |
| 2492 | 2495 | /* Reinitialize line mode. */ |
| 2493 | - if ((new_cstate == CONNECTED_ANSI && session->linemode) || | |
| 2496 | + if ((new_cstate == CONNECTED_ANSI && hSession->linemode) || | |
| 2494 | 2497 | new_cstate == CONNECTED_NVT) |
| 2495 | - cooked_init(session); | |
| 2498 | + cooked_init(hSession); | |
| 2496 | 2499 | #endif /*]*/ |
| 2497 | 2500 | |
| 2498 | 2501 | #if defined(X3270_TN3270E) /*[*/ |
| 2499 | 2502 | /* If we fell out of TN3270E, remove the state. */ |
| 2500 | - if (!session->myopts[TELOPT_TN3270E]) { | |
| 2501 | - session->tn3270e_negotiated = 0; | |
| 2502 | - session->tn3270e_submode = E_NONE; | |
| 2503 | - session->tn3270e_bound = 0; | |
| 2503 | + if (!hSession->myopts[TELOPT_TN3270E]) { | |
| 2504 | + hSession->tn3270e_negotiated = 0; | |
| 2505 | + hSession->tn3270e_submode = E_NONE; | |
| 2506 | + hSession->tn3270e_bound = 0; | |
| 2504 | 2507 | } |
| 2505 | 2508 | #endif /*]*/ |
| 2506 | - trace_dsn(session,"Now operating in %s mode.\n",state_name[new_cstate]); | |
| 2507 | - host_in3270(session,new_cstate); | |
| 2509 | + trace_dsn(hSession,"Now operating in %s mode.\n",state_name[new_cstate]); | |
| 2510 | + host_in3270(hSession,new_cstate); | |
| 2508 | 2511 | } |
| 2509 | 2512 | } |
| 2510 | 2513 | ... | ... |
src/pw3270/v3270/iocallback.c
| ... | ... | @@ -111,6 +111,7 @@ static void * AddSource(int source, H3270 *session, gushort events, void (*fn)(H |
| 111 | 111 | src->fn = fn; |
| 112 | 112 | src->poll.fd = (int) source; |
| 113 | 113 | src->poll.events = events; |
| 114 | + src->session = session; | |
| 114 | 115 | |
| 115 | 116 | g_source_attach((GSource *) src,NULL); |
| 116 | 117 | g_source_add_poll((GSource *) src,&src->poll); |
| ... | ... | @@ -329,10 +330,6 @@ void v3270_register_io_handlers(v3270Class *cls) |
| 329 | 330 | |
| 330 | 331 | static_AddExcept, |
| 331 | 332 | |
| 332 | -// #if !defined(_WIN32) | |
| 333 | -// static_AddOutput, | |
| 334 | -// #endif | |
| 335 | - | |
| 336 | 333 | #ifdef G_THREADS_ENABLED |
| 337 | 334 | static_CallAndWait, |
| 338 | 335 | #else | ... | ... |