Commit e0dfd10d1ea27c149007ded01ad2d58efbb9a709
1 parent
05d59c25
Exists in
master
Movendo mais variaveis para a estrutura de controle de sessao
Showing
12 changed files
with
164 additions
and
137 deletions
Show diff stats
latest/src/gtk2/gui.h
... | ... | @@ -333,7 +333,7 @@ |
333 | 333 | void ReloadPixmaps(void); |
334 | 334 | void Reselect(void); |
335 | 335 | void set_rectangle_select(int value, enum toggle_type reason); |
336 | - void SetStatusCode(STATUS_CODE id); | |
336 | + void SetStatusCode(H3270 *session, LIB3270_STATUS id); | |
337 | 337 | void SetTerminalFont(const gchar *fontname); |
338 | 338 | |
339 | 339 | void init_gui_toggles(void); | ... | ... |
latest/src/gtk2/main.c
... | ... | @@ -88,7 +88,7 @@ static void connect_main(H3270 *session, int status, void *dunno) |
88 | 88 | } |
89 | 89 | else |
90 | 90 | { |
91 | - SetStatusCode(STATUS_CODE_DISCONNECTED); | |
91 | + SetStatusCode(session,LIB3270_STATUS_DISCONNECTED); | |
92 | 92 | cMode &= ~CURSOR_MODE_ENABLED; |
93 | 93 | // ctlr_erase(1); |
94 | 94 | online = FALSE; | ... | ... |
latest/src/gtk2/oia.c
... | ... | @@ -106,7 +106,7 @@ |
106 | 106 | #define OIAROW (view.top+4+(terminal_font_info.spacing*view.rows)) |
107 | 107 | |
108 | 108 | gboolean oia_flag[OIA_FLAG_USER]; |
109 | - STATUS_CODE terminal_message_id = (STATUS_CODE) -1; | |
109 | + LIB3270_STATUS terminal_message_id = (LIB3270_STATUS) -1; | |
110 | 110 | |
111 | 111 | SCRIPT_STATE oia_script_state = SCRIPT_STATE_NONE; |
112 | 112 | |
... | ... | @@ -811,65 +811,65 @@ |
811 | 811 | #endif |
812 | 812 | int color; |
813 | 813 | const gchar * string; |
814 | - } message[STATUS_CODE_USER] = | |
814 | + } message[LIB3270_STATUS_USER] = | |
815 | 815 | { |
816 | - OIA_MESSAGE( STATUS_CODE_BLANK, | |
816 | + OIA_MESSAGE( LIB3270_STATUS_BLANK, | |
817 | 817 | TERMINAL_COLOR_OIA_STATUS_OK, |
818 | 818 | "" ), |
819 | 819 | |
820 | - OIA_MESSAGE( STATUS_CODE_SYSWAIT, | |
820 | + OIA_MESSAGE( LIB3270_STATUS_SYSWAIT, | |
821 | 821 | TERMINAL_COLOR_OIA_STATUS_OK, |
822 | 822 | N_( "X System" ) ), |
823 | 823 | |
824 | - OIA_MESSAGE( STATUS_CODE_TWAIT, | |
824 | + OIA_MESSAGE( LIB3270_STATUS_TWAIT, | |
825 | 825 | TERMINAL_COLOR_OIA_STATUS_OK, |
826 | 826 | N_( "X Wait" ) ), |
827 | 827 | |
828 | - OIA_MESSAGE( STATUS_CODE_CONNECTED, | |
828 | + OIA_MESSAGE( LIB3270_STATUS_CONNECTED, | |
829 | 829 | TERMINAL_COLOR_OIA_STATUS_OK, |
830 | 830 | NULL ), |
831 | 831 | |
832 | - OIA_MESSAGE( STATUS_CODE_DISCONNECTED, | |
832 | + OIA_MESSAGE( LIB3270_STATUS_DISCONNECTED, | |
833 | 833 | TERMINAL_COLOR_OIA_STATUS_INVALID, |
834 | 834 | N_( "X Not Connected" ) ), |
835 | 835 | |
836 | - OIA_MESSAGE( STATUS_CODE_AWAITING_FIRST, | |
836 | + OIA_MESSAGE( LIB3270_STATUS_AWAITING_FIRST, | |
837 | 837 | TERMINAL_COLOR_OIA_STATUS_OK, |
838 | 838 | N_( "X" ) ), |
839 | 839 | |
840 | - OIA_MESSAGE( STATUS_CODE_MINUS, | |
840 | + OIA_MESSAGE( LIB3270_STATUS_MINUS, | |
841 | 841 | TERMINAL_COLOR_OIA_STATUS_OK, |
842 | 842 | N_( "X -f" ) ), |
843 | 843 | |
844 | - OIA_MESSAGE( STATUS_CODE_PROTECTED, | |
844 | + OIA_MESSAGE( LIB3270_STATUS_PROTECTED, | |
845 | 845 | TERMINAL_COLOR_OIA_STATUS_INVALID, |
846 | 846 | N_( "X Protected" ) ), |
847 | 847 | |
848 | - OIA_MESSAGE( STATUS_CODE_NUMERIC, | |
848 | + OIA_MESSAGE( LIB3270_STATUS_NUMERIC, | |
849 | 849 | TERMINAL_COLOR_OIA_STATUS_INVALID, |
850 | 850 | N_( "X Numeric" ) ), |
851 | 851 | |
852 | - OIA_MESSAGE( STATUS_CODE_OVERFLOW, | |
852 | + OIA_MESSAGE( LIB3270_STATUS_OVERFLOW, | |
853 | 853 | TERMINAL_COLOR_OIA_STATUS_INVALID, |
854 | 854 | N_( "X Overflow" ) ), |
855 | 855 | |
856 | - OIA_MESSAGE( STATUS_CODE_INHIBIT, | |
856 | + OIA_MESSAGE( LIB3270_STATUS_INHIBIT, | |
857 | 857 | TERMINAL_COLOR_OIA_STATUS_INVALID, |
858 | 858 | N_( "X Inhibit" ) ), |
859 | 859 | |
860 | - OIA_MESSAGE( STATUS_CODE_KYBDLOCK, | |
860 | + OIA_MESSAGE( LIB3270_STATUS_KYBDLOCK, | |
861 | 861 | TERMINAL_COLOR_OIA_STATUS_INVALID, |
862 | 862 | NULL ), |
863 | 863 | |
864 | - OIA_MESSAGE( STATUS_CODE_X, | |
864 | + OIA_MESSAGE( LIB3270_STATUS_X, | |
865 | 865 | TERMINAL_COLOR_OIA_STATUS_INVALID, |
866 | 866 | N_( "X" ) ), |
867 | 867 | |
868 | - OIA_MESSAGE( STATUS_CODE_RESOLVING, | |
868 | + OIA_MESSAGE( LIB3270_STATUS_RESOLVING, | |
869 | 869 | TERMINAL_COLOR_OIA_STATUS_WARNING, |
870 | 870 | N_( "X Resolving" ) ), |
871 | 871 | |
872 | - OIA_MESSAGE( STATUS_CODE_CONNECTING, | |
872 | + OIA_MESSAGE( LIB3270_STATUS_CONNECTING, | |
873 | 873 | TERMINAL_COLOR_OIA_STATUS_WARNING, |
874 | 874 | N_( "X Connecting" ) ), |
875 | 875 | ... | ... |
latest/src/gtk2/oia.h
... | ... | @@ -83,7 +83,7 @@ |
83 | 83 | LOCAL_EXTERN gboolean oia_caps_state; |
84 | 84 | #endif // HAVE_CAPS_STATE |
85 | 85 | |
86 | - LOCAL_EXTERN STATUS_CODE terminal_message_id; | |
86 | + LOCAL_EXTERN LIB3270_STATUS terminal_message_id; | |
87 | 87 | |
88 | 88 | LOCAL_EXTERN SCRIPT_STATE oia_script_state; |
89 | 89 | LOCAL_EXTERN gboolean oia_script_blink; | ... | ... |
latest/src/gtk2/screen.c
... | ... | @@ -505,19 +505,19 @@ |
505 | 505 | charset = g_strdup(dcs); |
506 | 506 | } |
507 | 507 | |
508 | - void SetStatusCode(STATUS_CODE id) | |
508 | + void SetStatusCode(H3270 *session, LIB3270_STATUS id) | |
509 | 509 | { |
510 | 510 | if(id == terminal_message_id) |
511 | 511 | return; |
512 | 512 | |
513 | 513 | terminal_message_id = id; |
514 | 514 | |
515 | - if(id == STATUS_CODE_BLANK) | |
515 | + if(id == LIB3270_STATUS_BLANK) | |
516 | 516 | { |
517 | 517 | set_cursor(CURSOR_MODE_NORMAL); |
518 | 518 | update_cursor_pixmap(); |
519 | 519 | } |
520 | - else if(id >= STATUS_CODE_USER) | |
520 | + else if(id >= LIB3270_STATUS_USER) | |
521 | 521 | { |
522 | 522 | Log("Unexpected status code %d",(int) id); |
523 | 523 | return; | ... | ... |
latest/src/gtk2/terminal.c
... | ... | @@ -371,7 +371,7 @@ |
371 | 371 | |
372 | 372 | static gboolean mouse_scroll(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) |
373 | 373 | { |
374 | - if(query_3270_terminal_status() != STATUS_CODE_BLANK || event->direction < 0 || event->direction > G_N_ELEMENTS(action_scroll)) | |
374 | + if(query_3270_terminal_status() != LIB3270_STATUS_BLANK || event->direction < 0 || event->direction > G_N_ELEMENTS(action_scroll)) | |
375 | 375 | return 0; |
376 | 376 | |
377 | 377 | Trace("Scroll: %d Action: %p",event->direction,action_scroll[event->direction]); | ... | ... |
latest/src/include/lib3270.h
... | ... | @@ -272,13 +272,15 @@ |
272 | 272 | int LIB3270_EXPORT lib3270_register_io_handlers(const struct lib3270_io_callbacks *cbk); |
273 | 273 | |
274 | 274 | |
275 | - LIB3270_EXPORT STATUS_CODE lib3270_get_oia_status(H3270 *h); | |
276 | - LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); | |
277 | - LIB3270_EXPORT const char * lib3270_get_host(H3270 *h); | |
275 | + LIB3270_EXPORT LIB3270_STATUS lib3270_get_oia_status(H3270 *h); | |
276 | + LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); | |
277 | + LIB3270_EXPORT const char * lib3270_get_host(H3270 *h); | |
278 | 278 | |
279 | 279 | #define lib3270_has_printer_session(h) (h->oia_flag[LIB3270_FLAG_PRINTER] != 0) |
280 | 280 | #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0) |
281 | 281 | #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0) |
282 | + #define lib3270_get_undera(h) (h->oia_flag[LIB3270_FLAG_UNDERA] != 0) | |
283 | + #define lib3270_get_oia_box_solid(h) (h->oia_flag[LIB3270_FLAG_BOXSOLID] != 0) | |
282 | 284 | |
283 | 285 | LIB3270_EXPORT int lib3270_pconnected(H3270 *h); |
284 | 286 | LIB3270_EXPORT int lib3270_half_connected(H3270 *h); | ... | ... |
latest/src/include/lib3270/api.h
... | ... | @@ -160,28 +160,28 @@ |
160 | 160 | CONNECTED_TN3270E /**< connected in TN3270E mode, 3270 mode */ |
161 | 161 | }; |
162 | 162 | |
163 | - typedef enum _STATUS_CODE | |
163 | + typedef enum _LIB3270_STATUS | |
164 | 164 | { |
165 | - STATUS_CODE_BLANK, | |
166 | - STATUS_CODE_SYSWAIT, | |
167 | - STATUS_CODE_TWAIT, | |
168 | - STATUS_CODE_CONNECTED, | |
169 | - STATUS_CODE_DISCONNECTED, | |
170 | - STATUS_CODE_AWAITING_FIRST, | |
171 | - STATUS_CODE_MINUS, | |
172 | - STATUS_CODE_PROTECTED, | |
173 | - STATUS_CODE_NUMERIC, | |
174 | - STATUS_CODE_OVERFLOW, | |
175 | - STATUS_CODE_INHIBIT, | |
176 | - STATUS_CODE_KYBDLOCK, | |
177 | - | |
178 | - STATUS_CODE_X, | |
179 | - STATUS_CODE_RESOLVING, | |
180 | - STATUS_CODE_CONNECTING, | |
181 | - | |
182 | - STATUS_CODE_USER | |
183 | - | |
184 | - } STATUS_CODE; | |
165 | + LIB3270_STATUS_BLANK, | |
166 | + LIB3270_STATUS_SYSWAIT, | |
167 | + LIB3270_STATUS_TWAIT, | |
168 | + LIB3270_STATUS_CONNECTED, | |
169 | + LIB3270_STATUS_DISCONNECTED, | |
170 | + LIB3270_STATUS_AWAITING_FIRST, | |
171 | + LIB3270_STATUS_MINUS, | |
172 | + LIB3270_STATUS_PROTECTED, | |
173 | + LIB3270_STATUS_NUMERIC, | |
174 | + LIB3270_STATUS_OVERFLOW, | |
175 | + LIB3270_STATUS_INHIBIT, | |
176 | + LIB3270_STATUS_KYBDLOCK, | |
177 | + | |
178 | + LIB3270_STATUS_X, | |
179 | + LIB3270_STATUS_RESOLVING, | |
180 | + LIB3270_STATUS_CONNECTING, | |
181 | + | |
182 | + LIB3270_STATUS_USER | |
183 | + | |
184 | + } LIB3270_STATUS; | |
185 | 185 | |
186 | 186 | #define OIA_FLAG_BOXSOLID LIB3270_FLAG_BOXSOLID |
187 | 187 | #define OIA_FLAG_UNDERA LIB3270_FLAG_UNDERA |
... | ... | @@ -226,7 +226,7 @@ |
226 | 226 | char * qualified_host; |
227 | 227 | char auto_reconnect_inprogress; |
228 | 228 | |
229 | - STATUS_CODE oia_status; | |
229 | + LIB3270_STATUS oia_status; | |
230 | 230 | |
231 | 231 | unsigned char oia_flag[LIB3270_FLAG_COUNT]; |
232 | 232 | |
... | ... | @@ -256,6 +256,7 @@ |
256 | 256 | char ssl_host; |
257 | 257 | char ever_3270; |
258 | 258 | |
259 | + | |
259 | 260 | // Widget info |
260 | 261 | void * widget; |
261 | 262 | |
... | ... | @@ -274,6 +275,8 @@ |
274 | 275 | void (*update)(H3270 *session, int baddr, unsigned char c, unsigned short attr); |
275 | 276 | void (*update_cursor)(H3270 *session, unsigned short row, unsigned short col); |
276 | 277 | void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); |
278 | + void (*update_luname)(H3270 *session, const char *name); | |
279 | + void (*update_status)(H3270 *session, LIB3270_STATUS id); | |
277 | 280 | |
278 | 281 | }; |
279 | 282 | |
... | ... | @@ -505,7 +508,7 @@ |
505 | 508 | int (*set_suspended)(int state); |
506 | 509 | void (*set_script)(SCRIPT_STATE state); |
507 | 510 | void (*reset)(int lock); |
508 | - void (*status)(STATUS_CODE id); | |
511 | + void (*status)(H3270 *session, LIB3270_STATUS id); | |
509 | 512 | void (*cursor)(CURSOR_MODE mode); |
510 | 513 | void (*lu)(const char *lu); |
511 | 514 | void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); | ... | ... |
latest/src/lib/macros.c
latest/src/lib/screen.c
... | ... | @@ -138,6 +138,12 @@ int screen_init(H3270 *session) |
138 | 138 | if(callbacks->set_viewsize) |
139 | 139 | session->configure = callbacks->set_viewsize; |
140 | 140 | |
141 | + if(callbacks->lu) | |
142 | + session->update_luname = callbacks->lu; | |
143 | + | |
144 | + if(callbacks->status) | |
145 | + session->update_status = callbacks->status; | |
146 | + | |
141 | 147 | if(callbacks->init()) |
142 | 148 | { |
143 | 149 | popup_an_error("Can't initialize terminal."); |
... | ... | @@ -503,20 +509,20 @@ void status_ctlr_done(H3270 *session) |
503 | 509 | |
504 | 510 | void status_oerr(H3270 *session, int error_type) |
505 | 511 | { |
506 | - STATUS_CODE sts = STATUS_CODE_USER; | |
512 | + LIB3270_STATUS sts = LIB3270_STATUS_USER; | |
507 | 513 | |
508 | 514 | CHECK_SESSION_HANDLE(session); |
509 | 515 | |
510 | 516 | switch (error_type) |
511 | 517 | { |
512 | 518 | case KL_OERR_PROTECTED: |
513 | - sts = STATUS_CODE_PROTECTED; | |
519 | + sts = LIB3270_STATUS_PROTECTED; | |
514 | 520 | break; |
515 | 521 | case KL_OERR_NUMERIC: |
516 | - sts = STATUS_CODE_NUMERIC; | |
522 | + sts = LIB3270_STATUS_NUMERIC; | |
517 | 523 | break; |
518 | 524 | case KL_OERR_OVERFLOW: |
519 | - sts = STATUS_CODE_OVERFLOW; | |
525 | + sts = LIB3270_STATUS_OVERFLOW; | |
520 | 526 | break; |
521 | 527 | |
522 | 528 | default: |
... | ... | @@ -532,7 +538,7 @@ void status_resolving(H3270 *session, Boolean on) |
532 | 538 | if(callbacks && callbacks->cursor) |
533 | 539 | callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); |
534 | 540 | |
535 | - status_changed(session, on ? STATUS_CODE_RESOLVING : STATUS_CODE_BLANK); | |
541 | + status_changed(session, on ? LIB3270_STATUS_RESOLVING : LIB3270_STATUS_BLANK); | |
536 | 542 | } |
537 | 543 | |
538 | 544 | void status_connecting(H3270 *session, Boolean on) |
... | ... | @@ -540,7 +546,7 @@ void status_connecting(H3270 *session, Boolean on) |
540 | 546 | if(callbacks && callbacks->cursor) |
541 | 547 | callbacks->cursor(on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); |
542 | 548 | |
543 | - status_changed(session, on ? STATUS_CODE_CONNECTING : STATUS_CODE_BLANK); | |
549 | + status_changed(session, on ? LIB3270_STATUS_CONNECTING : LIB3270_STATUS_BLANK); | |
544 | 550 | } |
545 | 551 | |
546 | 552 | void status_reset(H3270 *session) |
... | ... | @@ -548,11 +554,11 @@ void status_reset(H3270 *session) |
548 | 554 | CHECK_SESSION_HANDLE(session); |
549 | 555 | |
550 | 556 | if (kybdlock & KL_ENTER_INHIBIT) |
551 | - status_changed(session,STATUS_CODE_INHIBIT); | |
557 | + status_changed(session,LIB3270_STATUS_INHIBIT); | |
552 | 558 | else if (kybdlock & KL_DEFERRED_UNLOCK) |
553 | - status_changed(session,STATUS_CODE_X); | |
559 | + status_changed(session,LIB3270_STATUS_X); | |
554 | 560 | else |
555 | - status_changed(session,STATUS_CODE_BLANK); | |
561 | + status_changed(session,LIB3270_STATUS_BLANK); | |
556 | 562 | |
557 | 563 | screen_disp(session); |
558 | 564 | |
... | ... | @@ -564,22 +570,20 @@ void status_reset(H3270 *session) |
564 | 570 | |
565 | 571 | } |
566 | 572 | |
567 | -// static STATUS_CODE current_status_code = -1; | |
568 | - | |
569 | 573 | /** |
570 | 574 | * Query the updated terminal status. |
571 | 575 | * |
572 | 576 | * @return status-code. |
573 | 577 | * |
574 | - * @see STATUS_CODE | |
578 | + * @see LIB3270_STATUS | |
575 | 579 | */ |
576 | -LIB3270_EXPORT STATUS_CODE lib3270_get_oia_status(H3270 *session) | |
580 | +LIB3270_EXPORT LIB3270_STATUS lib3270_get_oia_status(H3270 *session) | |
577 | 581 | { |
578 | 582 | CHECK_SESSION_HANDLE(session); |
579 | 583 | return session->oia_status; |
580 | 584 | } |
581 | 585 | |
582 | -void status_changed(H3270 *session, STATUS_CODE id) | |
586 | +void status_changed(H3270 *session, LIB3270_STATUS id) | |
583 | 587 | { |
584 | 588 | CHECK_SESSION_HANDLE(session); |
585 | 589 | |
... | ... | @@ -588,15 +592,15 @@ void status_changed(H3270 *session, STATUS_CODE id) |
588 | 592 | |
589 | 593 | session->oia_status = id; |
590 | 594 | |
591 | - if(callbacks && callbacks->status) | |
592 | - callbacks->status(id); | |
595 | + if(session->update_status) | |
596 | + session->update_status(session,id); | |
593 | 597 | } |
594 | 598 | |
595 | 599 | void status_twait(H3270 *session) |
596 | 600 | { |
597 | 601 | CHECK_SESSION_HANDLE(session); |
598 | 602 | set_status(session,OIA_FLAG_UNDERA,False); |
599 | - status_changed(session,STATUS_CODE_TWAIT); | |
603 | + status_changed(session,LIB3270_STATUS_TWAIT); | |
600 | 604 | } |
601 | 605 | |
602 | 606 | void set_viewsize(H3270 *session, int rows, int cols) |
... | ... | @@ -616,13 +620,16 @@ void set_viewsize(H3270 *session, int rows, int cols) |
616 | 620 | |
617 | 621 | void status_lu(H3270 *session, const char *lu) |
618 | 622 | { |
619 | - if(callbacks && callbacks->lu) | |
620 | - callbacks->lu(lu); | |
623 | + CHECK_SESSION_HANDLE(session); | |
624 | + | |
625 | + if(session->update_luname) | |
626 | + session->update_luname(session,lu); | |
627 | + | |
621 | 628 | } |
622 | 629 | |
623 | 630 | static void status_connect(H3270 *session, int connected, void *dunno) |
624 | 631 | { |
625 | - STATUS_CODE id = STATUS_CODE_USER; | |
632 | + LIB3270_STATUS id = LIB3270_STATUS_USER; | |
626 | 633 | |
627 | 634 | ctlr_erase(session,1); |
628 | 635 | |
... | ... | @@ -631,9 +638,9 @@ static void status_connect(H3270 *session, int connected, void *dunno) |
631 | 638 | set_status(session,OIA_FLAG_BOXSOLID,IN_3270 && !IN_SSCP); |
632 | 639 | |
633 | 640 | if (kybdlock & KL_AWAITING_FIRST) |
634 | - id = STATUS_CODE_AWAITING_FIRST; | |
641 | + id = LIB3270_STATUS_AWAITING_FIRST; | |
635 | 642 | else |
636 | - id = STATUS_CODE_CONNECTED; | |
643 | + id = LIB3270_STATUS_CONNECTED; | |
637 | 644 | |
638 | 645 | #if defined(HAVE_LIBSSL) /*[*/ |
639 | 646 | set_status(session,OIA_FLAG_SECURE,session->secure_connection); |
... | ... | @@ -645,7 +652,7 @@ static void status_connect(H3270 *session, int connected, void *dunno) |
645 | 652 | set_status(session,OIA_FLAG_BOXSOLID,False); |
646 | 653 | set_status(session,OIA_FLAG_SECURE,False); |
647 | 654 | |
648 | - id = STATUS_CODE_DISCONNECTED; | |
655 | + id = LIB3270_STATUS_DISCONNECTED; | |
649 | 656 | } |
650 | 657 | |
651 | 658 | status_changed(session,id); | ... | ... |
latest/src/lib/statusc.h
... | ... | @@ -29,15 +29,15 @@ LIB3270_INTERNAL void status_twait(H3270 *session); |
29 | 29 | |
30 | 30 | |
31 | 31 | |
32 | -LIB3270_INTERNAL void status_changed(H3270 *session, STATUS_CODE id); | |
32 | +LIB3270_INTERNAL void status_changed(H3270 *session, LIB3270_STATUS id); | |
33 | 33 | |
34 | 34 | LIB3270_INTERNAL void set_status(H3270 *session, OIA_FLAG id, Boolean on); |
35 | 35 | |
36 | 36 | |
37 | 37 | #define status_typeahead(on) set_status(NULL,OIA_FLAG_TYPEAHEAD,on) |
38 | -#define status_kybdlock() status_changed(NULL,STATUS_CODE_KYBDLOCK) | |
39 | -#define status_syswait() status_changed(NULL,STATUS_CODE_SYSWAIT) | |
40 | -#define status_minus() status_changed(NULL,STATUS_CODE_MINUS) | |
38 | +#define status_kybdlock() status_changed(NULL,LIB3270_STATUS_KYBDLOCK) | |
39 | +#define status_syswait() status_changed(NULL,LIB3270_STATUS_SYSWAIT) | |
40 | +#define status_minus() status_changed(NULL,LIB3270_STATUS_MINUS) | |
41 | 41 | |
42 | 42 | |
43 | 43 | extern int lib3270_event_counter[COUNTER_ID_USER]; | ... | ... |
latest/src/lib/telnet.c
... | ... | @@ -111,10 +111,12 @@ int ns_rsent; |
111 | 111 | unsigned char *obuf; /* 3270 output buffer */ |
112 | 112 | unsigned char *obptr = (unsigned char *) NULL; |
113 | 113 | int linemode = 1; |
114 | -#if defined(LOCAL_PROCESS) /*[*/ | |
114 | +/* | |
115 | +#if defined(LOCAL_PROCESS) | |
115 | 116 | Boolean local_process = False; |
116 | -#endif /*]*/ | |
117 | +#endif | |
117 | 118 | // char *termtype; |
119 | +*/ | |
118 | 120 | |
119 | 121 | /* Externals */ |
120 | 122 | extern struct timeval ds_ts; |
... | ... | @@ -194,7 +196,7 @@ static void check_in3270(void); |
194 | 196 | static void store3270in(unsigned char c); |
195 | 197 | static void check_linemode(Boolean init); |
196 | 198 | static int non_blocking(Boolean on); |
197 | -static void net_connected(void); | |
199 | +static void net_connected(H3270 *session); | |
198 | 200 | #if defined(X3270_TN3270E) /*[*/ |
199 | 201 | static int tn3270e_negotiate(void); |
200 | 202 | #endif /*]*/ |
... | ... | @@ -526,14 +528,16 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
526 | 528 | status_resolving(&h3270,0); |
527 | 529 | } |
528 | 530 | } else { |
529 | -#if defined(LOCAL_PROCESS) /*[*/ | |
531 | +/* | |
532 | +#if defined(LOCAL_PROCESS) | |
530 | 533 | if (ls) { |
531 | 534 | local_process = True; |
532 | 535 | } else { |
533 | -#endif /*]*/ | |
534 | -#if defined(LOCAL_PROCESS) /*[*/ | |
536 | +#endif | |
537 | +#if defined(LOCAL_PROCESS) | |
535 | 538 | local_process = False; |
536 | -#endif /*]*/ | |
539 | +#endif | |
540 | +*/ | |
537 | 541 | status_resolving(&h3270,1); |
538 | 542 | if (resolve_host_and_port(host, portname, |
539 | 543 | &h3270.current_port, &haddr.sa, &ha_len, |
... | ... | @@ -543,13 +547,15 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
543 | 547 | return -1; |
544 | 548 | status_resolving(&h3270,0); |
545 | 549 | } |
546 | -#if defined(LOCAL_PROCESS) /*[*/ | |
550 | +/* | |
551 | +#if defined(LOCAL_PROCESS) | |
547 | 552 | } |
548 | -#endif /*]*/ | |
549 | - | |
553 | +#endif | |
554 | +*/ | |
550 | 555 | } |
551 | 556 | |
552 | -#if defined(LOCAL_PROCESS) /*[*/ | |
557 | +/* | |
558 | +#if defined(LOCAL_PROCESS) | |
553 | 559 | if (local_process) { |
554 | 560 | int amaster; |
555 | 561 | struct winsize w; |
... | ... | @@ -560,10 +566,10 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
560 | 566 | w.ws_ypixel = 0; |
561 | 567 | |
562 | 568 | switch (forkpty(&amaster, NULL, NULL, &w)) { |
563 | - case -1: /* failed */ | |
569 | + case -1: // failed | |
564 | 570 | popup_an_errno(errno, "forkpty"); |
565 | 571 | close_fail; |
566 | - case 0: /* child */ | |
572 | + case 0: // child | |
567 | 573 | putenv("TERM=xterm"); |
568 | 574 | if (strchr(host, ' ') != CN) { |
569 | 575 | (void) execlp("/bin/sh", "sh", "-c", host, |
... | ... | @@ -580,17 +586,18 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
580 | 586 | #warning Notify User |
581 | 587 | _exit(1); |
582 | 588 | break; |
583 | - default: /* parent */ | |
589 | + default: // parent | |
584 | 590 | sock = amaster; |
585 | -#if !defined(_WIN32) /*[*/ | |
591 | +#if !defined(_WIN32) | |
586 | 592 | (void) fcntl(sock, F_SETFD, 1); |
587 | -#endif /*]*/ | |
593 | +#endif | |
588 | 594 | net_connected(); |
589 | 595 | host_in3270(CONNECTED_ANSI); |
590 | 596 | break; |
591 | 597 | } |
592 | 598 | } else { |
593 | -#endif /*]*/ | |
599 | +#endif | |
600 | +*/ | |
594 | 601 | /* create the socket */ |
595 | 602 | if ((h3270.sock = socket(haddr.sa.sa_family, SOCK_STREAM, 0)) == -1) { |
596 | 603 | popup_a_sockerr( N_( "socket" ) ); |
... | ... | @@ -656,11 +663,13 @@ int net_connect(const char *host, char *portname, Boolean ls, Boolean *resolving |
656 | 663 | } else { |
657 | 664 | if (non_blocking(False) < 0) |
658 | 665 | close_fail; |
659 | - net_connected(); | |
666 | + net_connected(&h3270); | |
660 | 667 | } |
661 | -#if defined(LOCAL_PROCESS) /*[*/ | |
668 | +/* | |
669 | +#if defined(LOCAL_PROCESS) | |
662 | 670 | } |
663 | -#endif /*]*/ | |
671 | +#endif | |
672 | +*/ | |
664 | 673 | |
665 | 674 | /* set up temporary termtype */ |
666 | 675 | if (appres.termname == CN && h3270.std_ds_host) { |
... | ... | @@ -752,41 +761,41 @@ setup_lus(void) |
752 | 761 | try_lu = *curr_lu; |
753 | 762 | } |
754 | 763 | |
755 | -static void | |
756 | -net_connected(void) | |
764 | +static void net_connected(H3270 *session) | |
757 | 765 | { |
758 | - if (proxy_type > 0) { | |
759 | - | |
766 | + if (proxy_type > 0) | |
767 | + { | |
760 | 768 | /* Negotiate with the proxy. */ |
761 | - trace_dsn("Connected to proxy server %s, port %u.\n", | |
762 | - proxy_host, proxy_port); | |
769 | + trace_dsn("Connected to proxy server %s, port %u.\n",proxy_host, proxy_port); | |
763 | 770 | |
764 | - if (proxy_negotiate(proxy_type, h3270.sock, h3270.hostname, | |
765 | - h3270.current_port) < 0) { | |
766 | - host_disconnect(&h3270,True); | |
771 | + if (proxy_negotiate(proxy_type, session->sock, session->hostname,session->current_port) < 0) | |
772 | + { | |
773 | + host_disconnect(session,True); | |
767 | 774 | return; |
768 | 775 | } |
769 | 776 | } |
770 | 777 | |
771 | - trace_dsn("Connected to %s, port %u%s.\n", h3270.hostname, h3270.current_port,h3270.ssl_host? " via SSL": ""); | |
778 | + trace_dsn("Connected to %s, port %u%s.\n", session->hostname, session->current_port,session->ssl_host? " via SSL": ""); | |
772 | 779 | |
773 | 780 | #if defined(HAVE_LIBSSL) /*[*/ |
774 | 781 | /* Set up SSL. */ |
775 | - if (h3270.ssl_host && !h3270.secure_connection) { | |
776 | - if (SSL_set_fd(ssl_con, h3270.sock) != 1) { | |
782 | + if(session->ssl_host && !session->secure_connection) | |
783 | + { | |
784 | + if (SSL_set_fd(ssl_con, session->sock) != 1) | |
785 | + { | |
777 | 786 | trace_dsn("Can't set fd!\n"); |
778 | 787 | } |
779 | - if (SSL_connect(ssl_con) != 1) { | |
788 | + if (SSL_connect(ssl_con) != 1) | |
789 | + { | |
780 | 790 | /* |
781 | 791 | * No need to trace the error, it was already |
782 | 792 | * displayed. |
783 | 793 | */ |
784 | - host_disconnect(&h3270,True); | |
794 | + host_disconnect(session,True); | |
785 | 795 | return; |
786 | 796 | } |
787 | - h3270.secure_connection = True; | |
788 | - trace_dsn("TLS/SSL tunneled connection complete. " | |
789 | - "Connection is now secure.\n"); | |
797 | + session->secure_connection = True; | |
798 | + trace_dsn("TLS/SSL tunneled connection complete. Connection is now secure.\n"); | |
790 | 799 | |
791 | 800 | /* Tell everyone else again. */ |
792 | 801 | host_connected(); |
... | ... | @@ -827,12 +836,13 @@ net_connected(void) |
827 | 836 | check_linemode(True); |
828 | 837 | |
829 | 838 | /* write out the passthru hostname and port nubmer */ |
830 | - if (h3270.passthru_host) { | |
839 | + if (session->passthru_host) | |
840 | + { | |
831 | 841 | char *buf; |
832 | 842 | |
833 | - buf = Malloc(strlen(h3270.hostname) + 32); | |
834 | - (void) sprintf(buf, "%s %d\r\n", h3270.hostname, h3270.current_port); | |
835 | - (void) send(h3270.sock, buf, strlen(buf), 0); | |
843 | + buf = Malloc(strlen(session->hostname) + 32); | |
844 | + (void) sprintf(buf, "%s %d\r\n", session->hostname, session->current_port); | |
845 | + (void) send(session->sock, buf, strlen(buf), 0); | |
836 | 846 | Free(buf); |
837 | 847 | } |
838 | 848 | } |
... | ... | @@ -853,7 +863,7 @@ connection_complete(void) |
853 | 863 | } |
854 | 864 | #endif /*]*/ |
855 | 865 | host_connected(); |
856 | - net_connected(); | |
866 | + net_connected(&h3270); | |
857 | 867 | } |
858 | 868 | |
859 | 869 | #if !defined(_WIN32) /*[*/ |
... | ... | @@ -940,7 +950,7 @@ void net_input(H3270 *session) |
940 | 950 | #if defined(_WIN32) /*[*/ |
941 | 951 | if (HALF_CONNECTED) { |
942 | 952 | |
943 | - if (connect(h3270.sock, &haddr.sa, sizeof(haddr)) < 0) { | |
953 | + if (connect(session->sock, &haddr.sa, sizeof(haddr)) < 0) { | |
944 | 954 | int err = GetLastError(); |
945 | 955 | |
946 | 956 | switch (err) { |
... | ... | @@ -966,20 +976,21 @@ void net_input(H3270 *session) |
966 | 976 | #endif /*]*/ |
967 | 977 | |
968 | 978 | #if defined(_WIN32) /*[*/ |
969 | - (void) ResetEvent(h3270.sock_handle); | |
979 | + (void) ResetEvent(session->sock_handle); | |
970 | 980 | #endif /*]*/ |
971 | 981 | |
972 | -#if defined(HAVE_LIBSSL) /*[*/ | |
982 | +#if defined(HAVE_LIBSSL) | |
973 | 983 | if (ssl_con != NULL) |
974 | 984 | nr = SSL_read(ssl_con, (char *) netrbuf, BUFSZ); |
975 | 985 | else |
976 | -#else /*][*/ | |
977 | -#endif /*]*/ | |
978 | -#if defined(LOCAL_PROCESS) /*[*/ | |
986 | +#endif // HAVE_LIBSSL | |
987 | +/* | |
988 | +#if defined(LOCAL_PROCESS) | |
979 | 989 | if (local_process) |
980 | 990 | nr = read(sock, (char *) netrbuf, BUFSZ); |
981 | 991 | else |
982 | -#endif /*]*/ | |
992 | +#endif | |
993 | +*/ | |
983 | 994 | nr = recv(session->sock, (char *) netrbuf, BUFSZ, 0); |
984 | 995 | if (nr < 0) { |
985 | 996 | if (socket_errno() == SE_EWOULDBLOCK) { |
... | ... | @@ -999,7 +1010,7 @@ void net_input(H3270 *session) |
999 | 1010 | err_buf); |
1000 | 1011 | |
1001 | 1012 | popup_an_error("SSL_read:\n%s", err_buf); |
1002 | - host_disconnect(&h3270,True); | |
1013 | + host_disconnect(session,True); | |
1003 | 1014 | return; |
1004 | 1015 | } |
1005 | 1016 | #endif /*]*/ |
... | ... | @@ -1007,25 +1018,27 @@ void net_input(H3270 *session) |
1007 | 1018 | connection_complete(); |
1008 | 1019 | return; |
1009 | 1020 | } |
1010 | -#if defined(LOCAL_PROCESS) /*[*/ | |
1021 | +/* | |
1022 | +#if defined(LOCAL_PROCESS) / | |
1011 | 1023 | if (errno == EIO && local_process) { |
1012 | 1024 | trace_dsn("RCVD local process disconnect\n"); |
1013 | - host_disconnect(False); | |
1025 | + host_disconnect(session,False); | |
1014 | 1026 | return; |
1015 | 1027 | } |
1016 | -#endif /*]*/ | |
1028 | +#endif | |
1029 | +*/ | |
1017 | 1030 | trace_dsn("RCVD socket error %d\n", errno); |
1018 | 1031 | if (HALF_CONNECTED) { |
1019 | 1032 | popup_a_sockerr( N_( "%s:%d" ),h3270.hostname, h3270.current_port); |
1020 | 1033 | } else if (socket_errno() != SE_ECONNRESET) { |
1021 | 1034 | popup_a_sockerr( N_( "Socket read error" ) ); |
1022 | 1035 | } |
1023 | - host_disconnect(&h3270,True); | |
1036 | + host_disconnect(session,True); | |
1024 | 1037 | return; |
1025 | 1038 | } else if (nr == 0) { |
1026 | 1039 | /* Host disconnected. */ |
1027 | 1040 | trace_dsn("RCVD disconnect\n"); |
1028 | - host_disconnect(&h3270,False); | |
1041 | + host_disconnect(session,False); | |
1029 | 1042 | return; |
1030 | 1043 | } |
1031 | 1044 | |
... | ... | @@ -1035,11 +1048,11 @@ void net_input(H3270 *session) |
1035 | 1048 | { |
1036 | 1049 | if (non_blocking(False) < 0) |
1037 | 1050 | { |
1038 | - host_disconnect(&h3270,True); | |
1051 | + host_disconnect(session,True); | |
1039 | 1052 | return; |
1040 | 1053 | } |
1041 | 1054 | host_connected(); |
1042 | - net_connected(); | |
1055 | + net_connected(session); | |
1043 | 1056 | } |
1044 | 1057 | |
1045 | 1058 | #if defined(X3270_TRACE) /*[*/ |
... | ... | @@ -1067,9 +1080,11 @@ void net_input(H3270 *session) |
1067 | 1080 | host_disconnect(&h3270,True); |
1068 | 1081 | return; |
1069 | 1082 | } |
1070 | -#if defined(LOCAL_PROCESS) /*[*/ | |
1083 | +/* | |
1084 | +#if defined(LOCAL_PROCESS) | |
1071 | 1085 | } |
1072 | -#endif /*]*/ | |
1086 | +#endif | |
1087 | +*/ | |
1073 | 1088 | } |
1074 | 1089 | |
1075 | 1090 | #if defined(X3270_ANSI) /*[*/ | ... | ... |