Commit 69524ccb8f8fd810cb6fb485edf6a067b8cb0e3c

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

Ajustes para multi-sessao

Showing 2 changed files with 175 additions and 175 deletions   Show diff stats
src/lib3270/ansi.c
@@ -126,64 +126,64 @@ static enum state { @@ -126,64 +126,64 @@ static enum state {
126 MBPEND = 7 126 MBPEND = 7
127 } state = DATA; 127 } state = DATA;
128 128
129 -static enum state ansi_data_mode(int, int);  
130 -static enum state dec_save_cursor(int, int);  
131 -static enum state dec_restore_cursor(int, int);  
132 -static enum state ansi_newline(int, int);  
133 -static enum state ansi_cursor_up(int, int);  
134 -static enum state ansi_esc2(int, int);  
135 -static enum state ansi_reset(int, int);  
136 -static enum state ansi_insert_chars(int, int);  
137 -static enum state ansi_cursor_down(int, int);  
138 -static enum state ansi_cursor_right(int, int);  
139 -static enum state ansi_cursor_left(int, int);  
140 -static enum state ansi_cursor_motion(int, int);  
141 -static enum state ansi_erase_in_display(int, int);  
142 -static enum state ansi_erase_in_line(int, int);  
143 -static enum state ansi_insert_lines(int, int);  
144 -static enum state ansi_delete_lines(int, int);  
145 -static enum state ansi_delete_chars(int, int);  
146 -static enum state ansi_sgr(int, int);  
147 -static enum state ansi_bell(int, int);  
148 -static enum state ansi_newpage(int, int);  
149 -static enum state ansi_backspace(int, int);  
150 -static enum state ansi_cr(int, int);  
151 -static enum state ansi_lf(int, int);  
152 -static enum state ansi_htab(int, int);  
153 -static enum state ansi_escape(int, int);  
154 -static enum state ansi_nop(int, int);  
155 -static enum state ansi_printing(int, int);  
156 -static enum state ansi_semicolon(int, int);  
157 -static enum state ansi_digit(int, int);  
158 -static enum state ansi_reverse_index(int, int);  
159 -static enum state ansi_send_attributes(int, int);  
160 -static enum state ansi_set_mode(int, int);  
161 -static enum state ansi_reset_mode(int, int);  
162 -static enum state dec_return_terminal_id(int, int);  
163 -static enum state ansi_status_report(int, int);  
164 -static enum state ansi_cs_designate(int, int);  
165 -static enum state ansi_esc3(int, int);  
166 -static enum state dec_set(int, int);  
167 -static enum state dec_reset(int, int);  
168 -static enum state dec_save(int, int);  
169 -static enum state dec_restore(int, int);  
170 -static enum state dec_scrolling_region(int, int);  
171 -static enum state xterm_text_mode(int, int);  
172 -static enum state xterm_text_semicolon(int, int);  
173 -static enum state xterm_text(int, int);  
174 -static enum state xterm_text_do(int, int);  
175 -static enum state ansi_htab_set(int, int);  
176 -static enum state ansi_htab_clear(int, int);  
177 -static enum state ansi_cs_designate2(int, int);  
178 -static enum state ansi_select_g0(int, int);  
179 -static enum state ansi_select_g1(int, int);  
180 -static enum state ansi_select_g2(int, int);  
181 -static enum state ansi_select_g3(int, int);  
182 -static enum state ansi_one_g2(int, int);  
183 -static enum state ansi_one_g3(int, int);  
184 -static enum state ansi_multibyte(int, int);  
185 -  
186 -typedef enum state (*afn_t)(int, int); 129 +static enum state ansi_data_mode(H3270 *, int, int);
  130 +static enum state dec_save_cursor(H3270 *, int, int);
  131 +static enum state dec_restore_cursor(H3270 *, int, int);
  132 +static enum state ansi_newline(H3270 *, int, int);
  133 +static enum state ansi_cursor_up(H3270 *, int, int);
  134 +static enum state ansi_esc2(H3270 *, int, int);
  135 +static enum state ansi_reset(H3270 *, int, int);
  136 +static enum state ansi_insert_chars(H3270 *, int, int);
  137 +static enum state ansi_cursor_down(H3270 *, int, int);
  138 +static enum state ansi_cursor_right(H3270 *, int, int);
  139 +static enum state ansi_cursor_left(H3270 *, int, int);
  140 +static enum state ansi_cursor_motion(H3270 *, int, int);
  141 +static enum state ansi_erase_in_display(H3270 *, int, int);
  142 +static enum state ansi_erase_in_line(H3270 *, int, int);
  143 +static enum state ansi_insert_lines(H3270 *, int, int);
  144 +static enum state ansi_delete_lines(H3270 *, int, int);
  145 +static enum state ansi_delete_chars(H3270 *, int, int);
  146 +static enum state ansi_sgr(H3270 *, int, int);
  147 +static enum state ansi_bell(H3270 *, int, int);
  148 +static enum state ansi_newpage(H3270 *, int, int);
  149 +static enum state ansi_backspace(H3270 *, int, int);
  150 +static enum state ansi_cr(H3270 *, int, int);
  151 +static enum state ansi_lf(H3270 *, int, int);
  152 +static enum state ansi_htab(H3270 *, int, int);
  153 +static enum state ansi_escape(H3270 *, int, int);
  154 +static enum state ansi_nop(H3270 *, int, int);
  155 +static enum state ansi_printing(H3270 *, int, int);
  156 +static enum state ansi_semicolon(H3270 *, int, int);
  157 +static enum state ansi_digit(H3270 *, int, int);
  158 +static enum state ansi_reverse_index(H3270 *, int, int);
  159 +static enum state ansi_send_attributes(H3270 *, int, int);
  160 +static enum state ansi_set_mode(H3270 *, int, int);
  161 +static enum state ansi_reset_mode(H3270 *, int, int);
  162 +static enum state dec_return_terminal_id(H3270 *, int, int);
  163 +static enum state ansi_status_report(H3270 *, int, int);
  164 +static enum state ansi_cs_designate(H3270 *, int, int);
  165 +static enum state ansi_esc3(H3270 *, int, int);
  166 +static enum state dec_set(H3270 *, int, int);
  167 +static enum state dec_reset(H3270 *, int, int);
  168 +static enum state dec_save(H3270 *, int, int);
  169 +static enum state dec_restore(H3270 *, int, int);
  170 +static enum state dec_scrolling_region(H3270 *, int, int);
  171 +static enum state xterm_text_mode(H3270 *, int, int);
  172 +static enum state xterm_text_semicolon(H3270 *, int, int);
  173 +static enum state xterm_text(H3270 *, int, int);
  174 +static enum state xterm_text_do(H3270 *, int, int);
  175 +static enum state ansi_htab_set(H3270 *, int, int);
  176 +static enum state ansi_htab_clear(H3270 *, int, int);
  177 +static enum state ansi_cs_designate2(H3270 *, int, int);
  178 +static enum state ansi_select_g0(H3270 *, int, int);
  179 +static enum state ansi_select_g1(H3270 *, int, int);
  180 +static enum state ansi_select_g2(H3270 *, int, int);
  181 +static enum state ansi_select_g3(H3270 *, int, int);
  182 +static enum state ansi_one_g2(H3270 *, int, int);
  183 +static enum state ansi_one_g3(H3270 *, int, int);
  184 +static enum state ansi_multibyte(H3270 *, int, int);
  185 +
  186 +typedef enum state (*afn_t)(H3270 *, int, int);
187 static afn_t ansi_fn[] = { 187 static afn_t ansi_fn[] = {
188 /* 0 */ &ansi_data_mode, 188 /* 0 */ &ansi_data_mode,
189 /* 1 */ &dec_save_cursor, 189 /* 1 */ &dec_save_cursor,
@@ -489,13 +489,13 @@ static Boolean held_wrap = False; @@ -489,13 +489,13 @@ static Boolean held_wrap = False;
489 static void ansi_scroll(void); 489 static void ansi_scroll(void);
490 490
491 static enum state 491 static enum state
492 -ansi_data_mode(int ig1 unused, int ig2 unused) 492 +ansi_data_mode(H3270 *hSession, int ig1 unused, int ig2 unused)
493 { 493 {
494 return DATA; 494 return DATA;
495 } 495 }
496 496
497 static enum state 497 static enum state
498 -dec_save_cursor(int ig1 unused, int ig2 unused) 498 +dec_save_cursor(H3270 *hSession, int ig1 unused, int ig2 unused)
499 { 499 {
500 int i; 500 int i;
501 501
@@ -510,7 +510,7 @@ dec_save_cursor(int ig1 unused, int ig2 unused) @@ -510,7 +510,7 @@ dec_save_cursor(int ig1 unused, int ig2 unused)
510 } 510 }
511 511
512 static enum state 512 static enum state
513 -dec_restore_cursor(int ig1 unused, int ig2 unused) 513 +dec_restore_cursor(H3270 *hSession, int ig1 unused, int ig2 unused)
514 { 514 {
515 int i; 515 int i;
516 516
@@ -526,7 +526,7 @@ dec_restore_cursor(int ig1 unused, int ig2 unused) @@ -526,7 +526,7 @@ dec_restore_cursor(int ig1 unused, int ig2 unused)
526 } 526 }
527 527
528 static enum state 528 static enum state
529 -ansi_newline(int ig1 unused, int ig2 unused) 529 +ansi_newline(H3270 *hSession, int ig1 unused, int ig2 unused)
530 { 530 {
531 int nc; 531 int nc;
532 532
@@ -541,7 +541,7 @@ ansi_newline(int ig1 unused, int ig2 unused) @@ -541,7 +541,7 @@ ansi_newline(int ig1 unused, int ig2 unused)
541 } 541 }
542 542
543 static enum state 543 static enum state
544 -ansi_cursor_up(int nn, int ig2 unused) 544 +ansi_cursor_up(H3270 *hSession, int nn, int ig2 unused)
545 { 545 {
546 int rr; 546 int rr;
547 547
@@ -557,7 +557,7 @@ ansi_cursor_up(int nn, int ig2 unused) @@ -557,7 +557,7 @@ ansi_cursor_up(int nn, int ig2 unused)
557 } 557 }
558 558
559 static enum state 559 static enum state
560 -ansi_esc2(int ig1 unused, int ig2 unused) 560 +ansi_esc2(H3270 *hSession, int ig1 unused, int ig2 unused)
561 { 561 {
562 register int i; 562 register int i;
563 563
@@ -568,7 +568,7 @@ ansi_esc2(int ig1 unused, int ig2 unused) @@ -568,7 +568,7 @@ ansi_esc2(int ig1 unused, int ig2 unused)
568 } 568 }
569 569
570 static enum state 570 static enum state
571 -ansi_reset(int ig1 unused, int ig2 unused) 571 +ansi_reset(H3270 *hSession, int ig1 unused, int ig2 unused)
572 { 572 {
573 int i; 573 int i;
574 static Boolean first = True; 574 static Boolean first = True;
@@ -617,7 +617,7 @@ ansi_reset(int ig1 unused, int ig2 unused) @@ -617,7 +617,7 @@ ansi_reset(int ig1 unused, int ig2 unused)
617 } 617 }
618 618
619 static enum state 619 static enum state
620 -ansi_insert_chars(int nn, int ig2 unused) 620 +ansi_insert_chars(H3270 *hSession, int nn, int ig2 unused)
621 { 621 {
622 int cc = h3270.cursor_addr % h3270.cols; /* current col */ 622 int cc = h3270.cursor_addr % h3270.cols; /* current col */
623 int mc = h3270.cols - cc; /* max chars that can be inserted */ 623 int mc = h3270.cols - cc; /* max chars that can be inserted */
@@ -639,7 +639,7 @@ ansi_insert_chars(int nn, int ig2 unused) @@ -639,7 +639,7 @@ ansi_insert_chars(int nn, int ig2 unused)
639 } 639 }
640 640
641 static enum state 641 static enum state
642 -ansi_cursor_down(int nn, int ig2 unused) 642 +ansi_cursor_down(H3270 *hSession, int nn, int ig2 unused)
643 { 643 {
644 int rr; 644 int rr;
645 645
@@ -655,7 +655,7 @@ ansi_cursor_down(int nn, int ig2 unused) @@ -655,7 +655,7 @@ ansi_cursor_down(int nn, int ig2 unused)
655 } 655 }
656 656
657 static enum state 657 static enum state
658 -ansi_cursor_right(int nn, int ig2 unused) 658 +ansi_cursor_right(H3270 *hSession, int nn, int ig2 unused)
659 { 659 {
660 int cc; 660 int cc;
661 661
@@ -672,7 +672,7 @@ ansi_cursor_right(int nn, int ig2 unused) @@ -672,7 +672,7 @@ ansi_cursor_right(int nn, int ig2 unused)
672 } 672 }
673 673
674 static enum state 674 static enum state
675 -ansi_cursor_left(int nn, int ig2 unused) 675 +ansi_cursor_left(H3270 *hSession, int nn, int ig2 unused)
676 { 676 {
677 int cc; 677 int cc;
678 678
@@ -692,7 +692,7 @@ ansi_cursor_left(int nn, int ig2 unused) @@ -692,7 +692,7 @@ ansi_cursor_left(int nn, int ig2 unused)
692 } 692 }
693 693
694 static enum state 694 static enum state
695 -ansi_cursor_motion(int n1, int n2) 695 +ansi_cursor_motion(H3270 *hSession, int n1, int n2)
696 { 696 {
697 if (n1 < 1) n1 = 1; 697 if (n1 < 1) n1 = 1;
698 if (n1 > h3270.rows) n1 = h3270.rows; 698 if (n1 > h3270.rows) n1 = h3270.rows;
@@ -704,7 +704,7 @@ ansi_cursor_motion(int n1, int n2) @@ -704,7 +704,7 @@ ansi_cursor_motion(int n1, int n2)
704 } 704 }
705 705
706 static enum state 706 static enum state
707 -ansi_erase_in_display(int nn, int ig2 unused) 707 +ansi_erase_in_display(H3270 *hSession, int nn, int ig2 unused)
708 { 708 {
709 switch (nn) { 709 switch (nn) {
710 case 0: /* below */ 710 case 0: /* below */
@@ -722,7 +722,7 @@ ansi_erase_in_display(int nn, int ig2 unused) @@ -722,7 +722,7 @@ ansi_erase_in_display(int nn, int ig2 unused)
722 } 722 }
723 723
724 static enum state 724 static enum state
725 -ansi_erase_in_line(int nn, int ig2 unused) 725 +ansi_erase_in_line(H3270 *hSession, int nn, int ig2 unused)
726 { 726 {
727 int nc = h3270.cursor_addr % h3270.cols; 727 int nc = h3270.cursor_addr % h3270.cols;
728 728
@@ -741,7 +741,7 @@ ansi_erase_in_line(int nn, int ig2 unused) @@ -741,7 +741,7 @@ ansi_erase_in_line(int nn, int ig2 unused)
741 } 741 }
742 742
743 static enum state 743 static enum state
744 -ansi_insert_lines(int nn, int ig2 unused) 744 +ansi_insert_lines(H3270 *hSession, int nn, int ig2 unused)
745 { 745 {
746 int rr = h3270.cursor_addr / h3270.cols; /* current row */ 746 int rr = h3270.cursor_addr / h3270.cols; /* current row */
747 int mr = scroll_bottom - rr; /* rows left at and below this one */ 747 int mr = scroll_bottom - rr; /* rows left at and below this one */
@@ -767,7 +767,7 @@ ansi_insert_lines(int nn, int ig2 unused) @@ -767,7 +767,7 @@ ansi_insert_lines(int nn, int ig2 unused)
767 } 767 }
768 768
769 static enum state 769 static enum state
770 -ansi_delete_lines(int nn, int ig2 unused) 770 +ansi_delete_lines(H3270 *hSession, int nn, int ig2 unused)
771 { 771 {
772 int rr = h3270.cursor_addr / h3270.cols; /* current row */ 772 int rr = h3270.cursor_addr / h3270.cols; /* current row */
773 int mr = scroll_bottom - rr; /* max rows that can be deleted */ 773 int mr = scroll_bottom - rr; /* max rows that can be deleted */
@@ -793,7 +793,7 @@ ansi_delete_lines(int nn, int ig2 unused) @@ -793,7 +793,7 @@ ansi_delete_lines(int nn, int ig2 unused)
793 } 793 }
794 794
795 static enum state 795 static enum state
796 -ansi_delete_chars(int nn, int ig2 unused) 796 +ansi_delete_chars(H3270 *hSession, int nn, int ig2 unused)
797 { 797 {
798 int cc = h3270.cursor_addr % h3270.cols; /* current col */ 798 int cc = h3270.cursor_addr % h3270.cols; /* current col */
799 int mc = h3270.cols - cc; /* max chars that can be deleted */ 799 int mc = h3270.cols - cc; /* max chars that can be deleted */
@@ -815,7 +815,7 @@ ansi_delete_chars(int nn, int ig2 unused) @@ -815,7 +815,7 @@ ansi_delete_chars(int nn, int ig2 unused)
815 } 815 }
816 816
817 static enum state 817 static enum state
818 -ansi_sgr(int ig1 unused, int ig2 unused) 818 +ansi_sgr(H3270 *hSession, int ig1 unused, int ig2 unused)
819 { 819 {
820 int i; 820 int i;
821 821
@@ -914,21 +914,21 @@ ansi_sgr(int ig1 unused, int ig2 unused) @@ -914,21 +914,21 @@ ansi_sgr(int ig1 unused, int ig2 unused)
914 } 914 }
915 915
916 static enum state 916 static enum state
917 -ansi_bell(int ig1 unused, int ig2 unused) 917 +ansi_bell(H3270 *hSession, int ig1 unused, int ig2 unused)
918 { 918 {
919 - lib3270_ring_bell(NULL); 919 + lib3270_ring_bell(hSession);
920 return DATA; 920 return DATA;
921 } 921 }
922 922
923 static enum state 923 static enum state
924 -ansi_newpage(int ig1 unused, int ig2 unused) 924 +ansi_newpage(H3270 *hSession, int ig1 unused, int ig2 unused)
925 { 925 {
926 ctlr_clear(&h3270,False); 926 ctlr_clear(&h3270,False);
927 return DATA; 927 return DATA;
928 } 928 }
929 929
930 static enum state 930 static enum state
931 -ansi_backspace(int ig1 unused, int ig2 unused) 931 +ansi_backspace(H3270 *hSession, int ig1 unused, int ig2 unused)
932 { 932 {
933 if (held_wrap) { 933 if (held_wrap) {
934 held_wrap = False; 934 held_wrap = False;
@@ -945,18 +945,18 @@ ansi_backspace(int ig1 unused, int ig2 unused) @@ -945,18 +945,18 @@ ansi_backspace(int ig1 unused, int ig2 unused)
945 } 945 }
946 946
947 static enum state 947 static enum state
948 -ansi_cr(int ig1 unused, int ig2 unused) 948 +ansi_cr(H3270 *hSession, int ig1 unused, int ig2 unused)
949 { 949 {
950 if (h3270.cursor_addr % h3270.cols) 950 if (h3270.cursor_addr % h3270.cols)
951 cursor_move(&h3270,h3270.cursor_addr - (h3270.cursor_addr % h3270.cols)); 951 cursor_move(&h3270,h3270.cursor_addr - (h3270.cursor_addr % h3270.cols));
952 if (auto_newline_mode) 952 if (auto_newline_mode)
953 - (void) ansi_lf(0, 0); 953 + (void) ansi_lf(hSession, 0, 0);
954 held_wrap = False; 954 held_wrap = False;
955 return DATA; 955 return DATA;
956 } 956 }
957 957
958 static enum state 958 static enum state
959 -ansi_lf(int ig1 unused, int ig2 unused) 959 +ansi_lf(H3270 *hSession, int ig1 unused, int ig2 unused)
960 { 960 {
961 int nc = h3270.cursor_addr + h3270.cols; 961 int nc = h3270.cursor_addr + h3270.cols;
962 962
@@ -977,7 +977,7 @@ ansi_lf(int ig1 unused, int ig2 unused) @@ -977,7 +977,7 @@ ansi_lf(int ig1 unused, int ig2 unused)
977 } 977 }
978 978
979 static enum state 979 static enum state
980 -ansi_htab(int ig1 unused, int ig2 unused) 980 +ansi_htab(H3270 *hSession, int ig1 unused, int ig2 unused)
981 { 981 {
982 int col = h3270.cursor_addr % h3270.cols; 982 int col = h3270.cursor_addr % h3270.cols;
983 int i; 983 int i;
@@ -993,13 +993,13 @@ ansi_htab(int ig1 unused, int ig2 unused) @@ -993,13 +993,13 @@ ansi_htab(int ig1 unused, int ig2 unused)
993 } 993 }
994 994
995 static enum state 995 static enum state
996 -ansi_escape(int ig1 unused, int ig2 unused) 996 +ansi_escape(H3270 *hSession, int ig1 unused, int ig2 unused)
997 { 997 {
998 return ESC; 998 return ESC;
999 } 999 }
1000 1000
1001 static enum state 1001 static enum state
1002 -ansi_nop(int ig1 unused, int ig2 unused) 1002 +ansi_nop(H3270 *hSession, int ig1 unused, int ig2 unused)
1003 { 1003 {
1004 return DATA; 1004 return DATA;
1005 } 1005 }
@@ -1019,7 +1019,7 @@ ansi_nop(int ig1 unused, int ig2 unused) @@ -1019,7 +1019,7 @@ ansi_nop(int ig1 unused, int ig2 unused)
1019 } 1019 }
1020 1020
1021 static enum state 1021 static enum state
1022 -ansi_printing(int ig1 unused, int ig2 unused) 1022 +ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused)
1023 { 1023 {
1024 int nc; 1024 int nc;
1025 unsigned char ebc_ch; 1025 unsigned char ebc_ch;
@@ -1065,7 +1065,7 @@ ansi_printing(int ig1 unused, int ig2 unused) @@ -1065,7 +1065,7 @@ ansi_printing(int ig1 unused, int ig2 unused)
1065 } 1065 }
1066 1066
1067 if (insert_mode) 1067 if (insert_mode)
1068 - (void) ansi_insert_chars(1, 0); 1068 + (void) ansi_insert_chars(hSession,1, 0);
1069 switch (csd[(once_cset != -1) ? once_cset : cset]) { 1069 switch (csd[(once_cset != -1) ? once_cset : cset]) {
1070 case CSD_LD: /* line drawing "0" */ 1070 case CSD_LD: /* line drawing "0" */
1071 if (ansi_ch >= 0x5f && ansi_ch <= 0x7e) 1071 if (ansi_ch >= 0x5f && ansi_ch <= 0x7e)
@@ -1193,7 +1193,7 @@ ansi_printing(int ig1 unused, int ig2 unused) @@ -1193,7 +1193,7 @@ ansi_printing(int ig1 unused, int ig2 unused)
1193 } 1193 }
1194 1194
1195 static enum state 1195 static enum state
1196 -ansi_multibyte(int ig1, int ig2) 1196 +ansi_multibyte(H3270 *hSession, int ig1, int ig2)
1197 { 1197 {
1198 char mbs[MB_MAX]; 1198 char mbs[MB_MAX];
1199 unsigned char ch; 1199 unsigned char ch;
@@ -1204,7 +1204,7 @@ ansi_multibyte(int ig1, int ig2) @@ -1204,7 +1204,7 @@ ansi_multibyte(int ig1, int ig2)
1204 /* String too long. */ 1204 /* String too long. */
1205 pmi = 0; 1205 pmi = 0;
1206 ansi_ch = '?'; 1206 ansi_ch = '?';
1207 - return ansi_printing(ig1, ig2); 1207 + return ansi_printing(hSession,ig1, ig2);
1208 } 1208 }
1209 1209
1210 strncpy(mbs, pending_mbs, pmi); 1210 strncpy(mbs, pending_mbs, pmi);
@@ -1215,7 +1215,7 @@ ansi_multibyte(int ig1, int ig2) @@ -1215,7 +1215,7 @@ ansi_multibyte(int ig1, int ig2)
1215 if (ch != 0) { 1215 if (ch != 0) {
1216 // Success! 1216 // Success!
1217 ansi_ch = ch; 1217 ansi_ch = ch;
1218 - return ansi_printing(ig1, ig2); 1218 + return ansi_printing(hSession, ig1, ig2);
1219 } 1219 }
1220 if (fail == ULFAIL_INCOMPLETE) { 1220 if (fail == ULFAIL_INCOMPLETE) {
1221 // Go get more. 1221 // Go get more.
@@ -1229,17 +1229,17 @@ ansi_multibyte(int ig1, int ig2) @@ -1229,17 +1229,17 @@ ansi_multibyte(int ig1, int ig2)
1229 ch = ansi_ch; /* save for later */ 1229 ch = ansi_ch; /* save for later */
1230 pmi = 0; 1230 pmi = 0;
1231 ansi_ch = '?'; 1231 ansi_ch = '?';
1232 - (void) ansi_printing(ig1, ig2); 1232 + (void) ansi_printing(hSession, ig1, ig2);
1233 1233
1234 /* Reprocess whatever we choked on. */ 1234 /* Reprocess whatever we choked on. */
1235 ansi_ch = ch; 1235 ansi_ch = ch;
1236 state = DATA; 1236 state = DATA;
1237 fn = ansi_fn[st[(int)DATA][ansi_ch]]; 1237 fn = ansi_fn[st[(int)DATA][ansi_ch]];
1238 - return (*fn)(n[0], n[1]); 1238 + return (*fn)(hSession,n[0], n[1]);
1239 } 1239 }
1240 1240
1241 static enum state 1241 static enum state
1242 -ansi_semicolon(int ig1 unused, int ig2 unused) 1242 +ansi_semicolon(H3270 *hSession, int ig1 unused, int ig2 unused)
1243 { 1243 {
1244 if (nx >= NN) 1244 if (nx >= NN)
1245 return DATA; 1245 return DATA;
@@ -1248,14 +1248,14 @@ ansi_semicolon(int ig1 unused, int ig2 unused) @@ -1248,14 +1248,14 @@ ansi_semicolon(int ig1 unused, int ig2 unused)
1248 } 1248 }
1249 1249
1250 static enum state 1250 static enum state
1251 -ansi_digit(int ig1 unused, int ig2 unused) 1251 +ansi_digit(H3270 *hSession, int ig1 unused, int ig2 unused)
1252 { 1252 {
1253 n[nx] = (n[nx] * 10) + (ansi_ch - '0'); 1253 n[nx] = (n[nx] * 10) + (ansi_ch - '0');
1254 return state; 1254 return state;
1255 } 1255 }
1256 1256
1257 static enum state 1257 static enum state
1258 -ansi_reverse_index(int ig1 unused, int ig2 unused) 1258 +ansi_reverse_index(H3270 *hSession, int ig1 unused, int ig2 unused)
1259 { 1259 {
1260 int rr = h3270.cursor_addr / h3270.cols; /* current row */ 1260 int rr = h3270.cursor_addr / h3270.cols; /* current row */
1261 int np = (scroll_top - 1) - rr; /* number of rows in the scrolling 1261 int np = (scroll_top - 1) - rr; /* number of rows in the scrolling
@@ -1268,7 +1268,7 @@ ansi_reverse_index(int ig1 unused, int ig2 unused) @@ -1268,7 +1268,7 @@ ansi_reverse_index(int ig1 unused, int ig2 unused)
1268 /* If the cursor is above the scrolling region, do a simple margined 1268 /* If the cursor is above the scrolling region, do a simple margined
1269 cursor up. */ 1269 cursor up. */
1270 if (np < 0) { 1270 if (np < 0) {
1271 - (void) ansi_cursor_up(nn, 0); 1271 + (void) ansi_cursor_up(hSession, nn, 0);
1272 return DATA; 1272 return DATA;
1273 } 1273 }
1274 1274
@@ -1281,17 +1281,17 @@ ansi_reverse_index(int ig1 unused, int ig2 unused) @@ -1281,17 +1281,17 @@ ansi_reverse_index(int ig1 unused, int ig2 unused)
1281 1281
1282 /* Move the cursor up without scrolling */ 1282 /* Move the cursor up without scrolling */
1283 if (nn) 1283 if (nn)
1284 - (void) ansi_cursor_up(nn, 0); 1284 + (void) ansi_cursor_up(hSession,nn, 0);
1285 1285
1286 /* Insert lines at the top for backward scroll */ 1286 /* Insert lines at the top for backward scroll */
1287 if (ns) 1287 if (ns)
1288 - (void) ansi_insert_lines(ns, 0); 1288 + (void) ansi_insert_lines(hSession, ns, 0);
1289 1289
1290 return DATA; 1290 return DATA;
1291 } 1291 }
1292 1292
1293 static enum state 1293 static enum state
1294 -ansi_send_attributes(int nn, int ig2 unused) 1294 +ansi_send_attributes(H3270 *hSession, int nn, int ig2 unused)
1295 { 1295 {
1296 if (!nn) 1296 if (!nn)
1297 net_sends("\033[?1;2c"); 1297 net_sends("\033[?1;2c");
@@ -1299,13 +1299,13 @@ ansi_send_attributes(int nn, int ig2 unused) @@ -1299,13 +1299,13 @@ ansi_send_attributes(int nn, int ig2 unused)
1299 } 1299 }
1300 1300
1301 static enum state 1301 static enum state
1302 -dec_return_terminal_id(int ig1 unused, int ig2 unused) 1302 +dec_return_terminal_id(H3270 *hSession, int ig1 unused, int ig2 unused)
1303 { 1303 {
1304 - return ansi_send_attributes(0, 0); 1304 + return ansi_send_attributes(hSession, 0, 0);
1305 } 1305 }
1306 1306
1307 static enum state 1307 static enum state
1308 -ansi_set_mode(int nn, int ig2 unused) 1308 +ansi_set_mode(H3270 *hSession, int nn, int ig2 unused)
1309 { 1309 {
1310 switch (nn) { 1310 switch (nn) {
1311 case 4: 1311 case 4:
@@ -1319,7 +1319,7 @@ ansi_set_mode(int nn, int ig2 unused) @@ -1319,7 +1319,7 @@ ansi_set_mode(int nn, int ig2 unused)
1319 } 1319 }
1320 1320
1321 static enum state 1321 static enum state
1322 -ansi_reset_mode(int nn, int ig2 unused) 1322 +ansi_reset_mode(H3270 *hSession, int nn, int ig2 unused)
1323 { 1323 {
1324 switch (nn) { 1324 switch (nn) {
1325 case 4: 1325 case 4:
@@ -1333,7 +1333,7 @@ ansi_reset_mode(int nn, int ig2 unused) @@ -1333,7 +1333,7 @@ ansi_reset_mode(int nn, int ig2 unused)
1333 } 1333 }
1334 1334
1335 static enum state 1335 static enum state
1336 -ansi_status_report(int nn, int ig2 unused) 1336 +ansi_status_report(H3270 *hSession, int nn, int ig2 unused)
1337 { 1337 {
1338 static char cpr[11]; 1338 static char cpr[11];
1339 1339
@@ -1351,69 +1351,69 @@ ansi_status_report(int nn, int ig2 unused) @@ -1351,69 +1351,69 @@ ansi_status_report(int nn, int ig2 unused)
1351 } 1351 }
1352 1352
1353 static enum state 1353 static enum state
1354 -ansi_cs_designate(int ig1 unused, int ig2 unused) 1354 +ansi_cs_designate(H3270 *hSession, int ig1 unused, int ig2 unused)
1355 { 1355 {
1356 cs_to_change = strchr(gnnames, ansi_ch) - gnnames; 1356 cs_to_change = strchr(gnnames, ansi_ch) - gnnames;
1357 return CSDES; 1357 return CSDES;
1358 } 1358 }
1359 1359
1360 static enum state 1360 static enum state
1361 -ansi_cs_designate2(int ig1 unused, int ig2 unused) 1361 +ansi_cs_designate2(H3270 *hSession, int ig1 unused, int ig2 unused)
1362 { 1362 {
1363 csd[cs_to_change] = strchr(csnames, ansi_ch) - csnames; 1363 csd[cs_to_change] = strchr(csnames, ansi_ch) - csnames;
1364 return DATA; 1364 return DATA;
1365 } 1365 }
1366 1366
1367 static enum state 1367 static enum state
1368 -ansi_select_g0(int ig1 unused, int ig2 unused) 1368 +ansi_select_g0(H3270 *hSession, int ig1 unused, int ig2 unused)
1369 { 1369 {
1370 cset = CS_G0; 1370 cset = CS_G0;
1371 return DATA; 1371 return DATA;
1372 } 1372 }
1373 1373
1374 static enum state 1374 static enum state
1375 -ansi_select_g1(int ig1 unused, int ig2 unused) 1375 +ansi_select_g1(H3270 *hSession, int ig1 unused, int ig2 unused)
1376 { 1376 {
1377 cset = CS_G1; 1377 cset = CS_G1;
1378 return DATA; 1378 return DATA;
1379 } 1379 }
1380 1380
1381 static enum state 1381 static enum state
1382 -ansi_select_g2(int ig1 unused, int ig2 unused) 1382 +ansi_select_g2(H3270 *hSession, int ig1 unused, int ig2 unused)
1383 { 1383 {
1384 cset = CS_G2; 1384 cset = CS_G2;
1385 return DATA; 1385 return DATA;
1386 } 1386 }
1387 1387
1388 static enum state 1388 static enum state
1389 -ansi_select_g3(int ig1 unused, int ig2 unused) 1389 +ansi_select_g3(H3270 *hSession, int ig1 unused, int ig2 unused)
1390 { 1390 {
1391 cset = CS_G3; 1391 cset = CS_G3;
1392 return DATA; 1392 return DATA;
1393 } 1393 }
1394 1394
1395 static enum state 1395 static enum state
1396 -ansi_one_g2(int ig1 unused, int ig2 unused) 1396 +ansi_one_g2(H3270 *hSession, int ig1 unused, int ig2 unused)
1397 { 1397 {
1398 once_cset = CS_G2; 1398 once_cset = CS_G2;
1399 return DATA; 1399 return DATA;
1400 } 1400 }
1401 1401
1402 static enum state 1402 static enum state
1403 -ansi_one_g3(int ig1 unused, int ig2 unused) 1403 +ansi_one_g3(H3270 *hSession, int ig1 unused, int ig2 unused)
1404 { 1404 {
1405 once_cset = CS_G3; 1405 once_cset = CS_G3;
1406 return DATA; 1406 return DATA;
1407 } 1407 }
1408 1408
1409 static enum state 1409 static enum state
1410 -ansi_esc3(int ig1 unused, int ig2 unused) 1410 +ansi_esc3(H3270 *hSession, int ig1 unused, int ig2 unused)
1411 { 1411 {
1412 return DECP; 1412 return DECP;
1413 } 1413 }
1414 1414
1415 static enum state 1415 static enum state
1416 -dec_set(int ig1 unused, int ig2 unused) 1416 +dec_set(H3270 *hSession, int ig1 unused, int ig2 unused)
1417 { 1417 {
1418 int i; 1418 int i;
1419 1419
@@ -1448,7 +1448,7 @@ dec_set(int ig1 unused, int ig2 unused) @@ -1448,7 +1448,7 @@ dec_set(int ig1 unused, int ig2 unused)
1448 } 1448 }
1449 1449
1450 static enum state 1450 static enum state
1451 -dec_reset(int ig1 unused, int ig2 unused) 1451 +dec_reset(H3270 *hSession, int ig1 unused, int ig2 unused)
1452 { 1452 {
1453 int i; 1453 int i;
1454 1454
@@ -1480,7 +1480,7 @@ dec_reset(int ig1 unused, int ig2 unused) @@ -1480,7 +1480,7 @@ dec_reset(int ig1 unused, int ig2 unused)
1480 } 1480 }
1481 1481
1482 static enum state 1482 static enum state
1483 -dec_save(int ig1 unused, int ig2 unused) 1483 +dec_save(H3270 *hSession, int ig1 unused, int ig2 unused)
1484 { 1484 {
1485 int i; 1485 int i;
1486 1486
@@ -1509,7 +1509,7 @@ dec_save(int ig1 unused, int ig2 unused) @@ -1509,7 +1509,7 @@ dec_save(int ig1 unused, int ig2 unused)
1509 } 1509 }
1510 1510
1511 static enum state 1511 static enum state
1512 -dec_restore(int ig1 unused, int ig2 unused) 1512 +dec_restore(H3270 *hSession, int ig1 unused, int ig2 unused)
1513 { 1513 {
1514 int i; 1514 int i;
1515 1515
@@ -1544,7 +1544,7 @@ dec_restore(int ig1 unused, int ig2 unused) @@ -1544,7 +1544,7 @@ dec_restore(int ig1 unused, int ig2 unused)
1544 } 1544 }
1545 1545
1546 static enum state 1546 static enum state
1547 -dec_scrolling_region(int top, int bottom) 1547 +dec_scrolling_region(H3270 *hSession, int top, int bottom)
1548 { 1548 {
1549 if (top < 1) 1549 if (top < 1)
1550 top = 1; 1550 top = 1;
@@ -1562,7 +1562,7 @@ dec_scrolling_region(int top, int bottom) @@ -1562,7 +1562,7 @@ dec_scrolling_region(int top, int bottom)
1562 } 1562 }
1563 1563
1564 static enum state 1564 static enum state
1565 -xterm_text_mode(int ig1 unused, int ig2 unused) 1565 +xterm_text_mode(H3270 *hSession, int ig1 unused, int ig2 unused)
1566 { 1566 {
1567 nx = 0; 1567 nx = 0;
1568 n[0] = 0; 1568 n[0] = 0;
@@ -1570,14 +1570,14 @@ xterm_text_mode(int ig1 unused, int ig2 unused) @@ -1570,14 +1570,14 @@ xterm_text_mode(int ig1 unused, int ig2 unused)
1570 } 1570 }
1571 1571
1572 static enum state 1572 static enum state
1573 -xterm_text_semicolon(int ig1 unused, int ig2 unused) 1573 +xterm_text_semicolon(H3270 *hSession, int ig1 unused, int ig2 unused)
1574 { 1574 {
1575 tx = 0; 1575 tx = 0;
1576 return TEXT2; 1576 return TEXT2;
1577 } 1577 }
1578 1578
1579 static enum state 1579 static enum state
1580 -xterm_text(int ig1 unused, int ig2 unused) 1580 +xterm_text(H3270 *hSession, int ig1 unused, int ig2 unused)
1581 { 1581 {
1582 if (tx < NT) 1582 if (tx < NT)
1583 text[tx++] = ansi_ch; 1583 text[tx++] = ansi_ch;
@@ -1585,7 +1585,7 @@ xterm_text(int ig1 unused, int ig2 unused) @@ -1585,7 +1585,7 @@ xterm_text(int ig1 unused, int ig2 unused)
1585 } 1585 }
1586 1586
1587 static enum state 1587 static enum state
1588 -xterm_text_do(int ig1 unused, int ig2 unused) 1588 +xterm_text_do(H3270 *hSession, int ig1 unused, int ig2 unused)
1589 { 1589 {
1590 /* 1590 /*
1591 #if defined(X3270_DISPLAY) || defined(WC3270) 1591 #if defined(X3270_DISPLAY) || defined(WC3270)
@@ -1629,7 +1629,7 @@ xterm_text_do(int ig1 unused, int ig2 unused) @@ -1629,7 +1629,7 @@ xterm_text_do(int ig1 unused, int ig2 unused)
1629 } 1629 }
1630 1630
1631 static enum state 1631 static enum state
1632 -ansi_htab_set(int ig1 unused, int ig2 unused) 1632 +ansi_htab_set(H3270 *hSession, int ig1 unused, int ig2 unused)
1633 { 1633 {
1634 register int col = h3270.cursor_addr % h3270.cols; 1634 register int col = h3270.cursor_addr % h3270.cols;
1635 1635
@@ -1638,7 +1638,7 @@ ansi_htab_set(int ig1 unused, int ig2 unused) @@ -1638,7 +1638,7 @@ ansi_htab_set(int ig1 unused, int ig2 unused)
1638 } 1638 }
1639 1639
1640 static enum state 1640 static enum state
1641 -ansi_htab_clear(int nn, int ig2 unused) 1641 +ansi_htab_clear(H3270 *hSession, int nn, int ig2 unused)
1642 { 1642 {
1643 register int col, i; 1643 register int col, i;
1644 1644
@@ -1687,7 +1687,7 @@ ansi_scroll(void) @@ -1687,7 +1687,7 @@ ansi_scroll(void)
1687 void ansi_in3270(H3270 *session, int in3270, void *dunno) 1687 void ansi_in3270(H3270 *session, int in3270, void *dunno)
1688 { 1688 {
1689 if (!in3270) 1689 if (!in3270)
1690 - (void) ansi_reset(0, 0); 1690 + (void) ansi_reset(session, 0, 0);
1691 } 1691 }
1692 1692
1693 #if defined(X3270_DBCS) /*[*/ 1693 #if defined(X3270_DBCS) /*[*/
@@ -1730,7 +1730,7 @@ ansi_process(unsigned int c) @@ -1730,7 +1730,7 @@ ansi_process(unsigned int c)
1730 mb_pending = 0; 1730 mb_pending = 0;
1731 } 1731 }
1732 #endif /*]*/ 1732 #endif /*]*/
1733 - state = (*fn)(n[0], n[1]); 1733 + state = (*fn)(&h3270, n[0], n[1]);
1734 } 1734 }
1735 1735
1736 void 1736 void
src/lib3270/telnet.c
@@ -205,7 +205,7 @@ static char *proxy_portname = CN; @@ -205,7 +205,7 @@ static char *proxy_portname = CN;
205 static unsigned short proxy_port = 0; 205 static unsigned short proxy_port = 0;
206 206
207 static int telnet_fsm(H3270 *session, unsigned char c); 207 static int telnet_fsm(H3270 *session, unsigned char c);
208 -static void net_rawout(unsigned const char *buf, int len); 208 +static void net_rawout(H3270 *session, unsigned const char *buf, int len);
209 static void check_in3270(H3270 *session); 209 static void check_in3270(H3270 *session);
210 static void store3270in(unsigned char c); 210 static void store3270in(unsigned char c);
211 static void check_linemode(Boolean init); 211 static void check_linemode(Boolean init);
@@ -1147,7 +1147,7 @@ send_naws(void) @@ -1147,7 +1147,7 @@ send_naws(void)
1147 naws_len += set16(naws_msg + naws_len, XMIT_ROWS); 1147 naws_len += set16(naws_msg + naws_len, XMIT_ROWS);
1148 (void) sprintf(naws_msg + naws_len, "%c%c", IAC, SE); 1148 (void) sprintf(naws_msg + naws_len, "%c%c", IAC, SE);
1149 naws_len += 2; 1149 naws_len += 2;
1150 - net_rawout((unsigned char *)naws_msg, naws_len); 1150 + net_rawout(&h3270,(unsigned char *)naws_msg, naws_len);
1151 trace_dsn("SENT %s NAWS %d %d %s\n", cmd(SB), XMIT_COLS, XMIT_ROWS, cmd(SE)); 1151 trace_dsn("SENT %s NAWS %d %d %s\n", cmd(SB), XMIT_COLS, XMIT_ROWS, cmd(SE));
1152 } 1152 }
1153 1153
@@ -1310,7 +1310,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1310,7 +1310,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1310 if (!h3270.hisopts[c]) { 1310 if (!h3270.hisopts[c]) {
1311 h3270.hisopts[c] = 1; 1311 h3270.hisopts[c] = 1;
1312 do_opt[2] = c; 1312 do_opt[2] = c;
1313 - net_rawout(do_opt, sizeof(do_opt)); 1313 + net_rawout(&h3270,do_opt, sizeof(do_opt));
1314 trace_dsn("SENT %s %s\n", 1314 trace_dsn("SENT %s %s\n",
1315 cmd(DO), opt(c)); 1315 cmd(DO), opt(c));
1316 1316
@@ -1321,7 +1321,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1321,7 +1321,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1321 if (c == TELOPT_EOR && !h3270.myopts[c]) { 1321 if (c == TELOPT_EOR && !h3270.myopts[c]) {
1322 h3270.myopts[c] = 1; 1322 h3270.myopts[c] = 1;
1323 will_opt[2] = c; 1323 will_opt[2] = c;
1324 - net_rawout(will_opt, 1324 + net_rawout(&h3270,will_opt,
1325 sizeof(will_opt)); 1325 sizeof(will_opt));
1326 trace_dsn("SENT %s %s\n", 1326 trace_dsn("SENT %s %s\n",
1327 cmd(WILL), opt(c)); 1327 cmd(WILL), opt(c));
@@ -1334,7 +1334,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1334,7 +1334,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1334 } 1334 }
1335 default: 1335 default:
1336 dont_opt[2] = c; 1336 dont_opt[2] = c;
1337 - net_rawout(dont_opt, sizeof(dont_opt)); 1337 + net_rawout(&h3270,dont_opt, sizeof(dont_opt));
1338 trace_dsn("SENT %s %s\n", cmd(DONT), opt(c)); 1338 trace_dsn("SENT %s %s\n", cmd(DONT), opt(c));
1339 break; 1339 break;
1340 } 1340 }
@@ -1345,7 +1345,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1345,7 +1345,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1345 if (h3270.hisopts[c]) { 1345 if (h3270.hisopts[c]) {
1346 h3270.hisopts[c] = 0; 1346 h3270.hisopts[c] = 0;
1347 dont_opt[2] = c; 1347 dont_opt[2] = c;
1348 - net_rawout(dont_opt, sizeof(dont_opt)); 1348 + net_rawout(&h3270, dont_opt, sizeof(dont_opt));
1349 trace_dsn("SENT %s %s\n", cmd(DONT), opt(c)); 1349 trace_dsn("SENT %s %s\n", cmd(DONT), opt(c));
1350 check_in3270(&h3270); 1350 check_in3270(&h3270);
1351 check_linemode(False); 1351 check_linemode(False);
@@ -1376,7 +1376,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1376,7 +1376,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1376 if (c != TELOPT_TM) 1376 if (c != TELOPT_TM)
1377 h3270.myopts[c] = 1; 1377 h3270.myopts[c] = 1;
1378 will_opt[2] = c; 1378 will_opt[2] = c;
1379 - net_rawout(will_opt, sizeof(will_opt)); 1379 + net_rawout(&h3270, will_opt, sizeof(will_opt));
1380 trace_dsn("SENT %s %s\n", cmd(WILL), opt(c)); 1380 trace_dsn("SENT %s %s\n", cmd(WILL), opt(c));
1381 check_in3270(&h3270); 1381 check_in3270(&h3270);
1382 check_linemode(False); 1382 check_linemode(False);
@@ -1394,7 +1394,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1394,7 +1394,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1394 * Send IAC SB STARTTLS FOLLOWS IAC SE 1394 * Send IAC SB STARTTLS FOLLOWS IAC SE
1395 * to announce that what follows is TLS. 1395 * to announce that what follows is TLS.
1396 */ 1396 */
1397 - net_rawout(follows_msg, 1397 + net_rawout(&h3270, follows_msg,
1398 sizeof(follows_msg)); 1398 sizeof(follows_msg));
1399 trace_dsn("SENT %s %s FOLLOWS %s\n", 1399 trace_dsn("SENT %s %s FOLLOWS %s\n",
1400 cmd(SB), 1400 cmd(SB),
@@ -1407,7 +1407,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1407,7 +1407,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1407 default: 1407 default:
1408 wont: 1408 wont:
1409 wont_opt[2] = c; 1409 wont_opt[2] = c;
1410 - net_rawout(wont_opt, sizeof(wont_opt)); 1410 + net_rawout(&h3270, wont_opt, sizeof(wont_opt));
1411 trace_dsn("SENT %s %s\n", cmd(WONT), opt(c)); 1411 trace_dsn("SENT %s %s\n", cmd(WONT), opt(c));
1412 break; 1412 break;
1413 } 1413 }
@@ -1418,7 +1418,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1418,7 +1418,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1418 if (h3270.myopts[c]) { 1418 if (h3270.myopts[c]) {
1419 h3270.myopts[c] = 0; 1419 h3270.myopts[c] = 0;
1420 wont_opt[2] = c; 1420 wont_opt[2] = c;
1421 - net_rawout(wont_opt, sizeof(wont_opt)); 1421 + net_rawout(&h3270, wont_opt, sizeof(wont_opt));
1422 trace_dsn("SENT %s %s\n", cmd(WONT), opt(c)); 1422 trace_dsn("SENT %s %s\n", cmd(WONT), opt(c));
1423 check_in3270(&h3270); 1423 check_in3270(&h3270);
1424 check_linemode(False); 1424 check_linemode(False);
@@ -1464,7 +1464,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1464,7 +1464,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1464 (try_lu != CN && *try_lu) ? "@" : "", 1464 (try_lu != CN && *try_lu) ? "@" : "",
1465 (try_lu != CN && *try_lu) ? try_lu : "", 1465 (try_lu != CN && *try_lu) ? try_lu : "",
1466 IAC, SE); 1466 IAC, SE);
1467 - net_rawout((unsigned char *)tt_out, tb_len); 1467 + net_rawout(&h3270, (unsigned char *)tt_out, tb_len);
1468 1468
1469 trace_dsn("SENT %s %s %s %.*s %s\n", 1469 trace_dsn("SENT %s %s %s %.*s %s\n",
1470 cmd(SB), opt(TELOPT_TTYPE), 1470 cmd(SB), opt(TELOPT_TTYPE),
@@ -1528,7 +1528,7 @@ tn3270e_request(void) @@ -1528,7 +1528,7 @@ tn3270e_request(void)
1528 1528
1529 (void) sprintf(t, "%c%c", IAC, SE); 1529 (void) sprintf(t, "%c%c", IAC, SE);
1530 1530
1531 - net_rawout((unsigned char *)tt_out, tb_len); 1531 + net_rawout(&h3270, (unsigned char *)tt_out, tb_len);
1532 1532
1533 trace_dsn("SENT %s %s DEVICE-TYPE REQUEST %.*s%s%s %s\n", 1533 trace_dsn("SENT %s %s DEVICE-TYPE REQUEST %.*s%s%s %s\n",
1534 cmd(SB), opt(TELOPT_TN3270E), (int) strlen(h3270.termtype), tt_out + 5, 1534 cmd(SB), opt(TELOPT_TN3270E), (int) strlen(h3270.termtype), tt_out + 5,
@@ -1549,7 +1549,7 @@ backoff_tn3270e(const char *why) @@ -1549,7 +1549,7 @@ backoff_tn3270e(const char *why)
1549 1549
1550 /* Tell the host 'no'. */ 1550 /* Tell the host 'no'. */
1551 wont_opt[2] = TELOPT_TN3270E; 1551 wont_opt[2] = TELOPT_TN3270E;
1552 - net_rawout(wont_opt, sizeof(wont_opt)); 1552 + net_rawout(&h3270, wont_opt, sizeof(wont_opt));
1553 trace_dsn("SENT %s %s\n", cmd(WONT), opt(TELOPT_TN3270E)); 1553 trace_dsn("SENT %s %s\n", cmd(WONT), opt(TELOPT_TN3270E));
1554 1554
1555 /* Restore the LU list; we may need to run it again in TN3270 mode. */ 1555 /* Restore the LU list; we may need to run it again in TN3270 mode. */
@@ -1805,7 +1805,7 @@ tn3270e_subneg_send(unsigned char op, unsigned long funcs) @@ -1805,7 +1805,7 @@ tn3270e_subneg_send(unsigned char op, unsigned long funcs)
1805 /* Complete and send out the protocol message. */ 1805 /* Complete and send out the protocol message. */
1806 proto_buf[proto_len++] = IAC; 1806 proto_buf[proto_len++] = IAC;
1807 proto_buf[proto_len++] = SE; 1807 proto_buf[proto_len++] = SE;
1808 - net_rawout(proto_buf, proto_len); 1808 + net_rawout(&h3270, proto_buf, proto_len);
1809 1809
1810 /* Complete and send out the trace text. */ 1810 /* Complete and send out the trace text. */
1811 trace_dsn("SENT %s %s FUNCTIONS %s %s %s\n", 1811 trace_dsn("SENT %s %s FUNCTIONS %s %s %s\n",
@@ -1983,7 +1983,7 @@ void net_exception(H3270 *session) @@ -1983,7 +1983,7 @@ void net_exception(H3270 *session)
1983 * EWOULDBLOCK. 1983 * EWOULDBLOCK.
1984 */ 1984 */
1985 static void 1985 static void
1986 -net_rawout(unsigned const char *buf, int len) 1986 +net_rawout(H3270 *session, unsigned const char *buf, int len)
1987 { 1987 {
1988 int nw; 1988 int nw;
1989 1989
@@ -2002,8 +2002,8 @@ net_rawout(unsigned const char *buf, int len) @@ -2002,8 +2002,8 @@ net_rawout(unsigned const char *buf, int len)
2002 # define n2w len 2002 # define n2w len
2003 #endif 2003 #endif
2004 #if defined(HAVE_LIBSSL) /*[*/ 2004 #if defined(HAVE_LIBSSL) /*[*/
2005 - if(h3270.ssl_con != NULL)  
2006 - nw = SSL_write(h3270.ssl_con, (const char *) buf, n2w); 2005 + if(session->ssl_con != NULL)
  2006 + nw = SSL_write(session->ssl_con, (const char *) buf, n2w);
2007 else 2007 else
2008 #endif /*]*/ 2008 #endif /*]*/
2009 2009
@@ -2014,10 +2014,10 @@ net_rawout(unsigned const char *buf, int len) @@ -2014,10 +2014,10 @@ net_rawout(unsigned const char *buf, int len)
2014 else 2014 else
2015 #endif 2015 #endif
2016 */ 2016 */
2017 - nw = send(h3270.sock, (const char *) buf, n2w, 0); 2017 + nw = send(session->sock, (const char *) buf, n2w, 0);
2018 if (nw < 0) { 2018 if (nw < 0) {
2019 #if defined(HAVE_LIBSSL) /*[*/ 2019 #if defined(HAVE_LIBSSL) /*[*/
2020 - if (h3270.ssl_con != NULL) 2020 + if (session->ssl_con != NULL)
2021 { 2021 {
2022 unsigned long e; 2022 unsigned long e;
2023 char err_buf[120]; 2023 char err_buf[120];
@@ -2026,19 +2026,19 @@ net_rawout(unsigned const char *buf, int len) @@ -2026,19 +2026,19 @@ net_rawout(unsigned const char *buf, int len)
2026 (void) ERR_error_string(e, err_buf); 2026 (void) ERR_error_string(e, err_buf);
2027 trace_dsn("RCVD SSL_write error %ld (%s)\n", e,err_buf); 2027 trace_dsn("RCVD SSL_write error %ld (%s)\n", e,err_buf);
2028 popup_an_error(NULL,"SSL_write:\n%s", err_buf); 2028 popup_an_error(NULL,"SSL_write:\n%s", err_buf);
2029 - host_disconnect(&h3270,False); 2029 + host_disconnect(session,False);
2030 return; 2030 return;
2031 } 2031 }
2032 #endif /*]*/ 2032 #endif /*]*/
2033 trace_dsn("RCVD socket error %d\n", errno); 2033 trace_dsn("RCVD socket error %d\n", errno);
2034 if (socket_errno() == SE_EPIPE || socket_errno() == SE_ECONNRESET) { 2034 if (socket_errno() == SE_EPIPE || socket_errno() == SE_ECONNRESET) {
2035 - host_disconnect(&h3270,False); 2035 + host_disconnect(session,False);
2036 return; 2036 return;
2037 } else if (socket_errno() == SE_EINTR) { 2037 } else if (socket_errno() == SE_EINTR) {
2038 goto bot; 2038 goto bot;
2039 } else { 2039 } else {
2040 popup_a_sockerr(NULL, N_( "Socket write error" ) ); 2040 popup_a_sockerr(NULL, N_( "Socket write error" ) );
2041 - host_disconnect(&h3270,True); 2041 + host_disconnect(session,True);
2042 return; 2042 return;
2043 } 2043 }
2044 } 2044 }
@@ -2096,7 +2096,7 @@ net_hexansi_out(unsigned char *buf, int len) @@ -2096,7 +2096,7 @@ net_hexansi_out(unsigned char *buf, int len)
2096 } 2096 }
2097 2097
2098 /* Send it to the host. */ 2098 /* Send it to the host. */
2099 - net_rawout(xbuf, tbuf - xbuf); 2099 + net_rawout(&h3270,xbuf, tbuf - xbuf);
2100 lib3270_free(xbuf); 2100 lib3270_free(xbuf);
2101 } 2101 }
2102 2102
@@ -2105,10 +2105,11 @@ net_hexansi_out(unsigned char *buf, int len) @@ -2105,10 +2105,11 @@ net_hexansi_out(unsigned char *buf, int len)
2105 * Send user data out in ANSI mode, without cooked-mode processing. 2105 * Send user data out in ANSI mode, without cooked-mode processing.
2106 */ 2106 */
2107 static void 2107 static void
2108 -net_cookedout(const char *buf, int len) 2108 +net_cookedout(H3270 *hSession, const char *buf, int len)
2109 { 2109 {
2110 -#if defined(X3270_TRACE) /*[*/  
2111 - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_DS_TRACE)) { 2110 +#if defined(X3270_TRACE)
  2111 + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_DS_TRACE))
  2112 + {
2112 int i; 2113 int i;
2113 2114
2114 trace_dsn(">"); 2115 trace_dsn(">");
@@ -2116,8 +2117,8 @@ net_cookedout(const char *buf, int len) @@ -2116,8 +2117,8 @@ net_cookedout(const char *buf, int len)
2116 trace_dsn(" %s", ctl_see((int) *(buf+i))); 2117 trace_dsn(" %s", ctl_see((int) *(buf+i)));
2117 trace_dsn("\n"); 2118 trace_dsn("\n");
2118 } 2119 }
2119 -#endif /*]*/  
2120 - net_rawout((unsigned const char *) buf, len); 2120 +#endif
  2121 + net_rawout(hSession,(unsigned const char *) buf, len);
2121 } 2122 }
2122 2123
2123 2124
@@ -2126,11 +2127,10 @@ net_cookedout(const char *buf, int len) @@ -2126,11 +2127,10 @@ net_cookedout(const char *buf, int len)
2126 * Send output in ANSI mode, including cooked-mode processing if 2127 * Send output in ANSI mode, including cooked-mode processing if
2127 * appropriate. 2128 * appropriate.
2128 */ 2129 */
2129 -static void  
2130 -net_cookout(const char *buf, int len) 2130 +static void net_cookout(H3270 *hSession, const char *buf, int len)
2131 { 2131 {
2132 2132
2133 - if (!IN_ANSI || (h3270.kybdlock & KL_AWAITING_FIRST)) 2133 + if (!IN_ANSI || (hSession->kybdlock & KL_AWAITING_FIRST))
2134 return; 2134 return;
2135 2135
2136 if (linemode) { 2136 if (linemode) {
@@ -2141,9 +2141,9 @@ net_cookout(const char *buf, int len) @@ -2141,9 +2141,9 @@ net_cookout(const char *buf, int len)
2141 c = buf[i]; 2141 c = buf[i];
2142 2142
2143 /* Input conversions. */ 2143 /* Input conversions. */
2144 - if (!lnext && c == '\r' && h3270.icrnl) 2144 + if (!lnext && c == '\r' && hSession->icrnl)
2145 c = '\n'; 2145 c = '\n';
2146 - else if (!lnext && c == '\n' && h3270.inlcr) 2146 + else if (!lnext && c == '\n' && hSession->inlcr)
2147 c = '\r'; 2147 c = '\r';
2148 2148
2149 /* Backslashes. */ 2149 /* Backslashes. */
@@ -2178,7 +2178,7 @@ net_cookout(const char *buf, int len) @@ -2178,7 +2178,7 @@ net_cookout(const char *buf, int len)
2178 } 2178 }
2179 return; 2179 return;
2180 } else 2180 } else
2181 - net_cookedout(buf, len); 2181 + net_cookedout(&h3270, buf, len);
2182 } 2182 }
2183 2183
2184 2184
@@ -2206,7 +2206,7 @@ ansi_process_s(const char *data) @@ -2206,7 +2206,7 @@ ansi_process_s(const char *data)
2206 static void 2206 static void
2207 forward_data(void) 2207 forward_data(void)
2208 { 2208 {
2209 - net_cookedout((char *) lbuf, lbptr - lbuf); 2209 + net_cookedout(&h3270, (char *) lbuf, lbptr - lbuf);
2210 cooked_init(); 2210 cooked_init();
2211 } 2211 }
2212 2212
@@ -2721,7 +2721,7 @@ net_output(void) @@ -2721,7 +2721,7 @@ net_output(void)
2721 /* Append the IAC EOR and transmit. */ 2721 /* Append the IAC EOR and transmit. */
2722 *xoptr++ = IAC; 2722 *xoptr++ = IAC;
2723 *xoptr++ = EOR; 2723 *xoptr++ = EOR;
2724 - net_rawout(xobuf, xoptr - xobuf); 2724 + net_rawout(&h3270,xobuf, xoptr - xobuf);
2725 2725
2726 trace_dsn("SENT EOR\n"); 2726 trace_dsn("SENT EOR\n");
2727 ns_rsent++; 2727 ns_rsent++;
@@ -2753,7 +2753,7 @@ tn3270e_ack(void) @@ -2753,7 +2753,7 @@ tn3270e_ack(void)
2753 trace_dsn("SENT TN3270E(RESPONSE POSITIVE-RESPONSE " 2753 trace_dsn("SENT TN3270E(RESPONSE POSITIVE-RESPONSE "
2754 "%u) DEVICE-END\n", 2754 "%u) DEVICE-END\n",
2755 h_in->seq_number[0] << 8 | h_in->seq_number[1]); 2755 h_in->seq_number[0] << 8 | h_in->seq_number[1]);
2756 - net_rawout(rsp_buf, rsp_len); 2756 + net_rawout(&h3270, rsp_buf, rsp_len);
2757 } 2757 }
2758 2758
2759 /* Send a TN3270E negative response to the server. */ 2759 /* Send a TN3270E negative response to the server. */
@@ -2788,7 +2788,7 @@ tn3270e_nak(enum pds rv) @@ -2788,7 +2788,7 @@ tn3270e_nak(enum pds rv)
2788 rsp_buf[rsp_len++] = IAC; 2788 rsp_buf[rsp_len++] = IAC;
2789 rsp_buf[rsp_len++] = EOR; 2789 rsp_buf[rsp_len++] = EOR;
2790 trace_dsn("SENT TN3270E(RESPONSE NEGATIVE-RESPONSE %u) %s\n",h_in->seq_number[0] << 8 | h_in->seq_number[1], neg); 2790 trace_dsn("SENT TN3270E(RESPONSE NEGATIVE-RESPONSE %u) %s\n",h_in->seq_number[0] << 8 | h_in->seq_number[1], neg);
2791 - net_rawout(rsp_buf, rsp_len); 2791 + net_rawout(&h3270, rsp_buf, rsp_len);
2792 } 2792 }
2793 2793
2794 #if defined(X3270_TRACE) /*[*/ 2794 #if defined(X3270_TRACE) /*[*/
@@ -2856,9 +2856,9 @@ net_sendc(char c) @@ -2856,9 +2856,9 @@ net_sendc(char c)
2856 */ 2856 */
2857 ) { 2857 ) {
2858 /* CR must be quoted */ 2858 /* CR must be quoted */
2859 - net_cookout("\r"\r\0", 2);", 2); 2859 + net_cookout(&h3270,"\r"\r\0", 2);", 2);
2860 } else { 2860 } else {
2861 - net_cookout(&c, 1); 2861 + net_cookout(&h3270,&c, 1);
2862 } 2862 }
2863 } 2863 }
2864 2864
@@ -2870,7 +2870,7 @@ net_sendc(char c) @@ -2870,7 +2870,7 @@ net_sendc(char c)
2870 void 2870 void
2871 net_sends(const char *s) 2871 net_sends(const char *s)
2872 { 2872 {
2873 - net_cookout(s, strlen(s)); 2873 + net_cookout(&h3270, s, strlen(s));
2874 } 2874 }
2875 2875
2876 2876
@@ -2881,7 +2881,7 @@ net_sends(const char *s) @@ -2881,7 +2881,7 @@ net_sends(const char *s)
2881 void 2881 void
2882 net_send_erase(void) 2882 net_send_erase(void)
2883 { 2883 {
2884 - net_cookout(&verase, 1); 2884 + net_cookout(&h3270, &verase, 1);
2885 } 2885 }
2886 2886
2887 2887
@@ -2892,7 +2892,7 @@ net_send_erase(void) @@ -2892,7 +2892,7 @@ net_send_erase(void)
2892 void 2892 void
2893 net_send_kill(void) 2893 net_send_kill(void)
2894 { 2894 {
2895 - net_cookout(&vkill, 1); 2895 + net_cookout(&h3270, &vkill, 1);
2896 } 2896 }
2897 2897
2898 2898
@@ -2903,7 +2903,7 @@ net_send_kill(void) @@ -2903,7 +2903,7 @@ net_send_kill(void)
2903 void 2903 void
2904 net_send_werase(void) 2904 net_send_werase(void)
2905 { 2905 {
2906 - net_cookout(&vwerase, 1); 2906 + net_cookout(&h3270, &vwerase, 1);
2907 } 2907 }
2908 #endif /*]*/ 2908 #endif /*]*/
2909 2909
@@ -2959,7 +2959,7 @@ net_break(void) @@ -2959,7 +2959,7 @@ net_break(void)
2959 static unsigned char buf[] = { IAC, BREAK }; 2959 static unsigned char buf[] = { IAC, BREAK };
2960 2960
2961 /* I don't know if we should first send TELNET synch ? */ 2961 /* I don't know if we should first send TELNET synch ? */
2962 - net_rawout(buf, sizeof(buf)); 2962 + net_rawout(&h3270, buf, sizeof(buf));
2963 trace_dsn("SENT BREAK\n"); 2963 trace_dsn("SENT BREAK\n");
2964 } 2964 }
2965 2965
@@ -2974,7 +2974,7 @@ net_interrupt(void) @@ -2974,7 +2974,7 @@ net_interrupt(void)
2974 static unsigned char buf[] = { IAC, IP }; 2974 static unsigned char buf[] = { IAC, IP };
2975 2975
2976 /* I don't know if we should first send TELNET synch ? */ 2976 /* I don't know if we should first send TELNET synch ? */
2977 - net_rawout(buf, sizeof(buf)); 2977 + net_rawout(&h3270, buf, sizeof(buf));
2978 trace_dsn("SENT IP\n"); 2978 trace_dsn("SENT IP\n");
2979 } 2979 }
2980 2980
@@ -3001,7 +3001,7 @@ net_abort(void) @@ -3001,7 +3001,7 @@ net_abort(void)
3001 case E_NVT: 3001 case E_NVT:
3002 break; 3002 break;
3003 case E_SSCP: 3003 case E_SSCP:
3004 - net_rawout(buf, sizeof(buf)); 3004 + net_rawout(&h3270, buf, sizeof(buf));
3005 trace_dsn("SENT AO\n"); 3005 trace_dsn("SENT AO\n");
3006 if (tn3270e_bound || 3006 if (tn3270e_bound ||
3007 !(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) { 3007 !(e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) {
@@ -3010,7 +3010,7 @@ net_abort(void) @@ -3010,7 +3010,7 @@ net_abort(void)
3010 } 3010 }
3011 break; 3011 break;
3012 case E_3270: 3012 case E_3270:
3013 - net_rawout(buf, sizeof(buf)); 3013 + net_rawout(&h3270, buf, sizeof(buf));
3014 trace_dsn("SENT AO\n"); 3014 trace_dsn("SENT AO\n");
3015 tn3270e_submode = E_SSCP; 3015 tn3270e_submode = E_SSCP;
3016 check_in3270(&h3270); 3016 check_in3270(&h3270);