Commit 96256265e7c74ac8a821afd8ae6a9eab7d05c37f

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

Ajustes para multi-sessao

src/lib3270/globals.h
@@ -345,7 +345,7 @@ enum keytype @@ -345,7 +345,7 @@ enum keytype
345 345
346 346
347 /* Library internal calls */ 347 /* Library internal calls */
348 -LIB3270_INTERNAL void key_ACharacter(unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); 348 +LIB3270_INTERNAL void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped);
349 LIB3270_INTERNAL void lib3270_initialize(void); 349 LIB3270_INTERNAL void lib3270_initialize(void);
350 LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); 350 LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr);
351 351
src/lib3270/kybd.c
@@ -117,7 +117,7 @@ static unsigned char pa_xlate[] = @@ -117,7 +117,7 @@ static unsigned char pa_xlate[] =
117 // static void * unlock_id; 117 // static void * unlock_id;
118 // static time_t unlock_delay_time; 118 // static time_t unlock_delay_time;
119 #define UNLOCK_MS 350 /* 0.35s after last unlock */ 119 #define UNLOCK_MS 350 /* 0.35s after last unlock */
120 -static Boolean key_Character(int code, Boolean with_ge, Boolean pasting,Boolean *skipped); 120 +static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean pasting,Boolean *skipped);
121 static int flush_ta(H3270 *hSession); 121 static int flush_ta(H3270 *hSession);
122 static void key_AID(H3270 *session, unsigned char aid_code); 122 static void key_AID(H3270 *session, unsigned char aid_code);
123 static void kybdlock_set(H3270 *session, unsigned int bits); 123 static void kybdlock_set(H3270 *session, unsigned int bits);
@@ -197,35 +197,35 @@ static const char dxl[] = "0123456789abcdef"; @@ -197,35 +197,35 @@ static const char dxl[] = "0123456789abcdef";
197 /* 197 /*
198 * Check if the typeahead queue is available 198 * Check if the typeahead queue is available
199 */ 199 */
200 -static int enq_chk(H3270 *session) 200 +static int enq_chk(H3270 *hSession)
201 { 201 {
202 /* If no connection, forget it. */ 202 /* If no connection, forget it. */
203 - if (!lib3270_connected(session)) 203 + if (!lib3270_connected(hSession))
204 { 204 {
205 - trace_event(" dropped (not connected)\n"); 205 + lib3270_trace_event(hSession," dropped (not connected)\n");
206 return -1; 206 return -1;
207 } 207 }
208 208
209 /* If operator error, complain and drop it. */ 209 /* If operator error, complain and drop it. */
210 - if (session->kybdlock & KL_OERR_MASK) 210 + if (hSession->kybdlock & KL_OERR_MASK)
211 { 211 {
212 - lib3270_ring_bell(session);  
213 - trace_event(" dropped (operator error)\n"); 212 + lib3270_ring_bell(hSession);
  213 + lib3270_trace_event(hSession," dropped (operator error)\n");
214 return -1; 214 return -1;
215 } 215 }
216 216
217 /* If scroll lock, complain and drop it. */ 217 /* If scroll lock, complain and drop it. */
218 - if (session->kybdlock & KL_SCROLLED) 218 + if (hSession->kybdlock & KL_SCROLLED)
219 { 219 {
220 - lib3270_ring_bell(session);  
221 - trace_event(" dropped (scrolled)\n"); 220 + lib3270_ring_bell(hSession);
  221 + lib3270_trace_event(hSession," dropped (scrolled)\n");
222 return -1; 222 return -1;
223 } 223 }
224 224
225 /* If typeahead disabled, complain and drop it. */ 225 /* If typeahead disabled, complain and drop it. */
226 - if (!session->typeahead) 226 + if (!hSession->typeahead)
227 { 227 {
228 - trace_event(" dropped (no typeahead)\n"); 228 + lib3270_trace_event(hSession," dropped (no typeahead)\n");
229 return -1; 229 return -1;
230 } 230 }
231 231
@@ -612,11 +612,13 @@ LIB3270_ACTION(attn) @@ -612,11 +612,13 @@ LIB3270_ACTION(attn)
612 return 0; 612 return 0;
613 } 613 }
614 614
615 -/* 615 +/**
616 * Prepare for an insert of 'count' bytes. 616 * Prepare for an insert of 'count' bytes.
617 - * Returns True if the insert is legal, False otherwise. 617 + *
  618 + *
  619 + * @return True if the insert is legal, False otherwise.
618 */ 620 */
619 -static Boolean ins_prep(int faddr, int baddr, int count) 621 +static Boolean ins_prep(H3270 *hSession, int faddr, int baddr, int count)
620 { 622 {
621 int next_faddr; 623 int next_faddr;
622 int xaddr; 624 int xaddr;
@@ -626,13 +628,17 @@ static Boolean ins_prep(int faddr, int baddr, int count) @@ -626,13 +628,17 @@ static Boolean ins_prep(int faddr, int baddr, int count)
626 int copy_len; 628 int copy_len;
627 629
628 /* Find the end of the field. */ 630 /* Find the end of the field. */
629 - if (faddr == -1) { 631 + if (faddr == -1)
  632 + {
630 /* Unformatted. Use the end of the line. */ 633 /* Unformatted. Use the end of the line. */
631 - next_faddr = (((baddr / h3270.cols) + 1) * h3270.cols) % (h3270.rows*h3270.cols);  
632 - } else { 634 + next_faddr = (((baddr / hSession->cols) + 1) * hSession->cols) % (hSession->rows*hSession->cols);
  635 + }
  636 + else
  637 + {
633 next_faddr = faddr; 638 next_faddr = faddr;
634 INC_BA(next_faddr); 639 INC_BA(next_faddr);
635 - while (next_faddr != faddr && !h3270.ea_buf[next_faddr].fa) { 640 + while (next_faddr != faddr && !hSession->ea_buf[next_faddr].fa)
  641 + {
636 INC_BA(next_faddr); 642 INC_BA(next_faddr);
637 } 643 }
638 } 644 }
@@ -642,11 +648,11 @@ static Boolean ins_prep(int faddr, int baddr, int count) @@ -642,11 +648,11 @@ static Boolean ins_prep(int faddr, int baddr, int count)
642 need = count; 648 need = count;
643 ntb = 0; 649 ntb = 0;
644 while (need && (xaddr != next_faddr)) { 650 while (need && (xaddr != next_faddr)) {
645 - if (h3270.ea_buf[xaddr].cc == EBC_null) 651 + if (hSession->ea_buf[xaddr].cc == EBC_null)
646 need--; 652 need--;
647 - else if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_BLANK_FILL) &&  
648 - ((h3270.ea_buf[xaddr].cc == EBC_space) ||  
649 - (h3270.ea_buf[xaddr].cc == EBC_underscore))) { 653 + else if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_BLANK_FILL) &&
  654 + ((hSession->ea_buf[xaddr].cc == EBC_space) ||
  655 + (hSession->ea_buf[xaddr].cc == EBC_underscore))) {
650 if (tb_start == -1) 656 if (tb_start == -1)
651 tb_start = xaddr; 657 tb_start = xaddr;
652 ntb++; 658 ntb++;
@@ -659,8 +665,9 @@ static Boolean ins_prep(int faddr, int baddr, int count) @@ -659,8 +665,9 @@ static Boolean ins_prep(int faddr, int baddr, int count)
659 #if defined(_ST) /*[*/ 665 #if defined(_ST) /*[*/
660 printf("need %d at %d, tb_start at %d\n", count, baddr, tb_start); 666 printf("need %d at %d, tb_start at %d\n", count, baddr, tb_start);
661 #endif /*]*/ 667 #endif /*]*/
662 - if (need - ntb > 0) {  
663 - operator_error(&h3270,KL_OERR_OVERFLOW); 668 + if (need - ntb > 0)
  669 + {
  670 + operator_error(hSession,KL_OERR_OVERFLOW);
664 return False; 671 return False;
665 } 672 }
666 673
@@ -675,7 +682,7 @@ static Boolean ins_prep(int faddr, int baddr, int count) @@ -675,7 +682,7 @@ static Boolean ins_prep(int faddr, int baddr, int count)
675 int first_null = -1; 682 int first_null = -1;
676 683
677 while (need && 684 while (need &&
678 - ((h3270.ea_buf[xaddr].cc == EBC_null) || 685 + ((hSession->ea_buf[xaddr].cc == EBC_null) ||
679 (tb_start >= 0 && xaddr >= tb_start))) { 686 (tb_start >= 0 && xaddr >= tb_start))) {
680 need--; 687 need--;
681 n_nulls++; 688 n_nulls++;
@@ -689,15 +696,16 @@ static Boolean ins_prep(int faddr, int baddr, int count) @@ -689,15 +696,16 @@ static Boolean ins_prep(int faddr, int baddr, int count)
689 /* Shift right n_nulls worth. */ 696 /* Shift right n_nulls worth. */
690 copy_len = first_null - baddr; 697 copy_len = first_null - baddr;
691 if (copy_len < 0) 698 if (copy_len < 0)
692 - copy_len += h3270.rows*h3270.cols;  
693 - to = (baddr + n_nulls) % (h3270.rows*h3270.cols);  
694 -#if defined(_ST) /*[*/ 699 + copy_len += hSession->rows*hSession->cols;
  700 + to = (baddr + n_nulls) % (hSession->rows*hSession->cols);
  701 +/*
  702 +#if defined(_ST)
695 printf("found %d NULLs at %d\n", n_nulls, first_null); 703 printf("found %d NULLs at %d\n", n_nulls, first_null);
696 - printf("copying %d from %d to %d\n", copy_len, to,  
697 - first_null);  
698 -#endif /*]*/ 704 + printf("copying %d from %d to %d\n", copy_len, to,first_null);
  705 +#endif
  706 +*/
699 if (copy_len) 707 if (copy_len)
700 - ctlr_wrapping_memmove(&h3270,to, baddr, copy_len); 708 + ctlr_wrapping_memmove(hSession,to, baddr, copy_len);
701 } 709 }
702 INC_BA(xaddr); 710 INC_BA(xaddr);
703 } 711 }
@@ -709,7 +717,7 @@ static Boolean ins_prep(int faddr, int baddr, int count) @@ -709,7 +717,7 @@ static Boolean ins_prep(int faddr, int baddr, int count)
709 #define GE_WFLAG 0x100 717 #define GE_WFLAG 0x100
710 #define PASTE_WFLAG 0x200 718 #define PASTE_WFLAG 0x200
711 719
712 -static void key_Character_wrapper(H3270 *param, const char *param1, const char *param2) 720 +static void key_Character_wrapper(H3270 *hSession, const char *param1, const char *param2)
713 { 721 {
714 int code; 722 int code;
715 Boolean with_ge = False; 723 Boolean with_ge = False;
@@ -731,14 +739,14 @@ static void key_Character_wrapper(H3270 *param, const char *param1, const char * @@ -731,14 +739,14 @@ static void key_Character_wrapper(H3270 *param, const char *param1, const char *
731 739
732 // trace_event(" %s -> Key(%s\"%s\")\n",ia_name[(int) ia_cause],with_ge ? "GE " : "",ctl_see((int) ebc2asc[code])); 740 // trace_event(" %s -> Key(%s\"%s\")\n",ia_name[(int) ia_cause],with_ge ? "GE " : "",ctl_see((int) ebc2asc[code]));
733 741
734 - (void) key_Character(code, with_ge, pasting, NULL); 742 + (void) key_Character(hSession, code, with_ge, pasting, NULL);
735 } 743 }
736 744
737 /* 745 /*
738 * Handle an ordinary displayable character key. Lots of stuff to handle 746 * Handle an ordinary displayable character key. Lots of stuff to handle
739 * insert-mode, protected fields and etc. 747 * insert-mode, protected fields and etc.
740 */ 748 */
741 -static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) 749 +static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean pasting, Boolean *skipped)
742 { 750 {
743 register int baddr, faddr, xaddr; 751 register int baddr, faddr, xaddr;
744 register unsigned char fa; 752 register unsigned char fa;
@@ -747,56 +755,61 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -747,56 +755,61 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
747 if (skipped != NULL) 755 if (skipped != NULL)
748 *skipped = False; 756 *skipped = False;
749 757
750 - if (h3270.kybdlock) 758 + if (hSession->kybdlock)
751 { 759 {
752 char codename[64]; 760 char codename[64];
753 761
754 (void) sprintf(codename, "%d", code |(with_ge ? GE_WFLAG : 0) | (pasting ? PASTE_WFLAG : 0)); 762 (void) sprintf(codename, "%d", code |(with_ge ? GE_WFLAG : 0) | (pasting ? PASTE_WFLAG : 0));
755 763
756 #if defined(DEBUG) || defined(ANDROID) 764 #if defined(DEBUG) || defined(ANDROID)
757 - enq_ta(&h3270,key_Character_wrapper, codename, CN, "key_Character_wrapper"); 765 + enq_ta(hSession,key_Character_wrapper, codename, CN, "key_Character_wrapper");
758 #else 766 #else
759 - enq_ta(&h3270,key_Character_wrapper, codename, CN); 767 + enq_ta(hSession,key_Character_wrapper, codename, CN);
760 #endif // DEBUG 768 #endif // DEBUG
761 769
762 return False; 770 return False;
763 } 771 }
764 - baddr = h3270.cursor_addr;  
765 - faddr = find_field_attribute(&h3270,baddr);  
766 - fa = get_field_attribute(&h3270,baddr);  
767 - if (h3270.ea_buf[baddr].fa || FA_IS_PROTECTED(fa)) {  
768 - operator_error(&h3270,KL_OERR_PROTECTED); 772 + baddr = hSession->cursor_addr;
  773 + faddr = find_field_attribute(hSession,baddr);
  774 + fa = get_field_attribute(hSession,baddr);
  775 + if (hSession->ea_buf[baddr].fa || FA_IS_PROTECTED(fa))
  776 + {
  777 + operator_error(hSession,KL_OERR_PROTECTED);
769 return False; 778 return False;
770 } 779 }
771 - if (h3270.numeric_lock && FA_IS_NUMERIC(fa) && 780 + if (hSession->numeric_lock && FA_IS_NUMERIC(fa) &&
772 !((code >= EBC_0 && code <= EBC_9) || 781 !((code >= EBC_0 && code <= EBC_9) ||
773 code == EBC_minus || code == EBC_period)) { 782 code == EBC_minus || code == EBC_period)) {
774 - operator_error(&h3270,KL_OERR_NUMERIC); 783 + operator_error(hSession,KL_OERR_NUMERIC);
775 return False; 784 return False;
776 } 785 }
777 786
778 /* Can't put an SBCS in a DBCS field. */ 787 /* Can't put an SBCS in a DBCS field. */
779 - if (h3270.ea_buf[faddr].cs == CS_DBCS) {  
780 - operator_error(&h3270,KL_OERR_DBCS); 788 + if (hSession->ea_buf[faddr].cs == CS_DBCS) {
  789 + operator_error(hSession,KL_OERR_DBCS);
781 return False; 790 return False;
782 } 791 }
783 792
784 /* If it's an SI (end of DBCS subfield), move over one position. */ 793 /* If it's an SI (end of DBCS subfield), move over one position. */
785 - if (h3270.ea_buf[baddr].cc == EBC_si) { 794 + if (hSession->ea_buf[baddr].cc == EBC_si) {
786 INC_BA(baddr); 795 INC_BA(baddr);
787 - if (baddr == faddr) {  
788 - operator_error(&h3270,KL_OERR_OVERFLOW); 796 + if (baddr == faddr)
  797 + {
  798 + operator_error(hSession,KL_OERR_OVERFLOW);
789 return False; 799 return False;
790 } 800 }
791 } 801 }
792 802
793 /* Add the character. */ 803 /* Add the character. */
794 - if (h3270.ea_buf[baddr].cc == EBC_so) { 804 + if (hSession->ea_buf[baddr].cc == EBC_so) {
795 805
796 - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT)) {  
797 - if (!ins_prep(faddr, baddr, 1)) 806 + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_INSERT))
  807 + {
  808 + if (!ins_prep(hSession,faddr, baddr, 1))
798 return False; 809 return False;
799 - } else { 810 + }
  811 + else
  812 + {
800 Boolean was_si = False; 813 Boolean was_si = False;
801 814
802 /* 815 /*
@@ -808,18 +821,19 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -808,18 +821,19 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
808 */ 821 */
809 xaddr = baddr; 822 xaddr = baddr;
810 INC_BA(xaddr); 823 INC_BA(xaddr);
811 - was_si = (h3270.ea_buf[xaddr].cc == EBC_si);  
812 - ctlr_add(&h3270,xaddr, EBC_space, CS_BASE);  
813 - ctlr_add_fg(&h3270,xaddr, 0); 824 + was_si = (hSession->ea_buf[xaddr].cc == EBC_si);
  825 + ctlr_add(hSession,xaddr, EBC_space, CS_BASE);
  826 + ctlr_add_fg(hSession,xaddr, 0);
814 #if defined(X3270_ANSI) /*[*/ 827 #if defined(X3270_ANSI) /*[*/
815 - ctlr_add_bg(&h3270,xaddr, 0); 828 + ctlr_add_bg(hSession,xaddr, 0);
816 #endif /*]*/ 829 #endif /*]*/
817 - if (!was_si) { 830 + if (!was_si)
  831 + {
818 INC_BA(xaddr); 832 INC_BA(xaddr);
819 - ctlr_add(&h3270,xaddr, EBC_so, CS_BASE);  
820 - ctlr_add_fg(&h3270,xaddr, 0); 833 + ctlr_add(hSession,xaddr, EBC_so, CS_BASE);
  834 + ctlr_add_fg(hSession,xaddr, 0);
821 #if defined(X3270_ANSI) /*[*/ 835 #if defined(X3270_ANSI) /*[*/
822 - ctlr_add_bg(&h3270,xaddr, 0); 836 + ctlr_add_bg(hSession,xaddr, 0);
823 #endif /*]*/ 837 #endif /*]*/
824 } 838 }
825 } 839 }
@@ -830,8 +844,8 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -830,8 +844,8 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
830 /* fall through... */ 844 /* fall through... */
831 case DBCS_LEFT: 845 case DBCS_LEFT:
832 if (why == DBCS_ATTRIBUTE) { 846 if (why == DBCS_ATTRIBUTE) {
833 - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT)) {  
834 - if (!ins_prep(faddr, baddr, 1)) 847 + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_INSERT)) {
  848 + if (!ins_prep(hSession,faddr, baddr, 1))
835 return False; 849 return False;
836 } else { 850 } else {
837 /* 851 /*
@@ -840,14 +854,15 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -840,14 +854,15 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
840 */ 854 */
841 xaddr = baddr; 855 xaddr = baddr;
842 INC_BA(xaddr); 856 INC_BA(xaddr);
843 - ctlr_add(&h3270,xaddr, EBC_space, CS_BASE);  
844 - ctlr_add_fg(&h3270,xaddr, 0);  
845 - ctlr_add_gr(&h3270,xaddr, 0); 857 + ctlr_add(hSession,xaddr, EBC_space, CS_BASE);
  858 + ctlr_add_fg(hSession,xaddr, 0);
  859 + ctlr_add_gr(hSession,xaddr, 0);
846 } 860 }
847 } else { 861 } else {
848 Boolean was_si; 862 Boolean was_si;
849 863
850 - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT)) { 864 + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_INSERT))
  865 + {
851 /* 866 /*
852 * Inserting SBCS into a DBCS subfield. 867 * Inserting SBCS into a DBCS subfield.
853 * If this is the first position, we 868 * If this is the first position, we
@@ -859,66 +874,69 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -859,66 +874,69 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
859 */ 874 */
860 xaddr = baddr; 875 xaddr = baddr;
861 DEC_BA(xaddr); 876 DEC_BA(xaddr);
862 - if (h3270.ea_buf[xaddr].cc == EBC_so) { 877 + if (hSession->ea_buf[xaddr].cc == EBC_so) {
863 DEC_BA(baddr); 878 DEC_BA(baddr);
864 - if (!ins_prep(faddr, baddr, 1)) 879 + if (!ins_prep(hSession, faddr, baddr, 1))
865 return False; 880 return False;
866 } else { 881 } else {
867 - if (!ins_prep(faddr, baddr, 3)) 882 + if (!ins_prep(hSession, faddr, baddr, 3))
868 return False; 883 return False;
869 xaddr = baddr; 884 xaddr = baddr;
870 - ctlr_add(&h3270,xaddr, EBC_si,CS_BASE);  
871 - ctlr_add_fg(&h3270,xaddr, 0);  
872 - ctlr_add_gr(&h3270,xaddr, 0); 885 + ctlr_add(hSession,xaddr, EBC_si,CS_BASE);
  886 + ctlr_add_fg(hSession,xaddr, 0);
  887 + ctlr_add_gr(hSession,xaddr, 0);
873 INC_BA(xaddr); 888 INC_BA(xaddr);
874 INC_BA(baddr); 889 INC_BA(baddr);
875 INC_BA(xaddr); 890 INC_BA(xaddr);
876 - ctlr_add(&h3270,xaddr, EBC_so,CS_BASE);  
877 - ctlr_add_fg(&h3270,xaddr, 0);  
878 - ctlr_add_gr(&h3270,xaddr, 0); 891 + ctlr_add(hSession,xaddr, EBC_so,CS_BASE);
  892 + ctlr_add_fg(hSession,xaddr, 0);
  893 + ctlr_add_gr(hSession,xaddr, 0);
879 } 894 }
880 } else { 895 } else {
881 /* Overwriting part of a subfield. */ 896 /* Overwriting part of a subfield. */
882 xaddr = baddr; 897 xaddr = baddr;
883 - ctlr_add(&h3270,xaddr, EBC_si, CS_BASE);  
884 - ctlr_add_fg(&h3270,xaddr, 0);  
885 - ctlr_add_gr(&h3270,xaddr, 0); 898 + ctlr_add(hSession,xaddr, EBC_si, CS_BASE);
  899 + ctlr_add_fg(hSession,xaddr, 0);
  900 + ctlr_add_gr(hSession,xaddr, 0);
886 INC_BA(xaddr); 901 INC_BA(xaddr);
887 INC_BA(baddr); 902 INC_BA(baddr);
888 INC_BA(xaddr); 903 INC_BA(xaddr);
889 - was_si = (h3270.ea_buf[xaddr].cc == EBC_si);  
890 - ctlr_add(&h3270,xaddr, EBC_space, CS_BASE);  
891 - ctlr_add_fg(&h3270,xaddr, 0);  
892 - ctlr_add_gr(&h3270,xaddr, 0);  
893 - if (!was_si) { 904 + was_si = (hSession->ea_buf[xaddr].cc == EBC_si);
  905 + ctlr_add(hSession,xaddr, EBC_space, CS_BASE);
  906 + ctlr_add_fg(hSession,xaddr, 0);
  907 + ctlr_add_gr(hSession,xaddr, 0);
  908 + if (!was_si)
  909 + {
894 INC_BA(xaddr); 910 INC_BA(xaddr);
895 - ctlr_add(&h3270,xaddr, EBC_so,CS_BASE);  
896 - ctlr_add_fg(&h3270,xaddr, 0);  
897 - ctlr_add_gr(&h3270,xaddr, 0); 911 + ctlr_add(hSession,xaddr, EBC_so,CS_BASE);
  912 + ctlr_add_fg(hSession,xaddr, 0);
  913 + ctlr_add_gr(hSession,xaddr, 0);
898 } 914 }
899 } 915 }
900 } 916 }
901 break; 917 break;
902 default: 918 default:
903 case DBCS_NONE: 919 case DBCS_NONE:
904 - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_INSERT) && !ins_prep(faddr, baddr, 1)) 920 + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_INSERT) && !ins_prep(hSession, faddr, baddr, 1))
905 return False; 921 return False;
906 break; 922 break;
907 } 923 }
908 - ctlr_add(&h3270,baddr, (unsigned char)code,(unsigned char)(with_ge ? CS_GE : 0));  
909 - ctlr_add_fg(&h3270,baddr, 0);  
910 - ctlr_add_gr(&h3270,baddr, 0); 924 + ctlr_add(hSession,baddr, (unsigned char)code,(unsigned char)(with_ge ? CS_GE : 0));
  925 + ctlr_add_fg(hSession,baddr, 0);
  926 + ctlr_add_gr(hSession,baddr, 0);
911 INC_BA(baddr); 927 INC_BA(baddr);
912 928
913 /* Replace leading nulls with blanks, if desired. */ 929 /* Replace leading nulls with blanks, if desired. */
914 - if (h3270.formatted && lib3270_get_toggle(&h3270,LIB3270_TOGGLE_BLANK_FILL)) { 930 + if (hSession->formatted && lib3270_get_toggle(hSession,LIB3270_TOGGLE_BLANK_FILL))
  931 + {
915 register int baddr_fill = baddr; 932 register int baddr_fill = baddr;
916 933
917 DEC_BA(baddr_fill); 934 DEC_BA(baddr_fill);
918 while (baddr_fill != faddr) { 935 while (baddr_fill != faddr) {
919 936
920 /* Check for backward line wrap. */ 937 /* Check for backward line wrap. */
921 - if ((baddr_fill % h3270.cols) == h3270.cols - 1) { 938 + if ((baddr_fill % hSession->cols) == hSession->cols - 1)
  939 + {
922 Boolean aborted = True; 940 Boolean aborted = True;
923 register int baddr_scan = baddr_fill; 941 register int baddr_scan = baddr_fill;
924 942
@@ -927,11 +945,12 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -927,11 +945,12 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
927 * for NULLs. 945 * for NULLs.
928 */ 946 */
929 while (baddr_scan != faddr) { 947 while (baddr_scan != faddr) {
930 - if (h3270.ea_buf[baddr_scan].cc != EBC_null) { 948 + if (hSession->ea_buf[baddr_scan].cc != EBC_null)
  949 + {
931 aborted = False; 950 aborted = False;
932 break; 951 break;
933 } 952 }
934 - if (!(baddr_scan % h3270.cols)) 953 + if (!(baddr_scan % hSession->cols))
935 break; 954 break;
936 DEC_BA(baddr_scan); 955 DEC_BA(baddr_scan);
937 } 956 }
@@ -939,63 +958,66 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -939,63 +958,66 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
939 break; 958 break;
940 } 959 }
941 960
942 - if (h3270.ea_buf[baddr_fill].cc == EBC_null)  
943 - ctlr_add(&h3270,baddr_fill, EBC_space, 0); 961 + if (hSession->ea_buf[baddr_fill].cc == EBC_null)
  962 + ctlr_add(hSession,baddr_fill, EBC_space, 0);
944 DEC_BA(baddr_fill); 963 DEC_BA(baddr_fill);
945 } 964 }
946 } 965 }
947 966
948 - mdt_set(&h3270,h3270.cursor_addr); 967 + mdt_set(hSession,hSession->cursor_addr);
949 968
950 /* 969 /*
951 * Implement auto-skip, and don't land on attribute bytes. 970 * Implement auto-skip, and don't land on attribute bytes.
952 * This happens for all pasted data (even DUP), and for all 971 * This happens for all pasted data (even DUP), and for all
953 * keyboard-generated data except DUP. 972 * keyboard-generated data except DUP.
954 */ 973 */
955 - if (pasting || (code != EBC_dup)) {  
956 - while (h3270.ea_buf[baddr].fa) { 974 + if (pasting || (code != EBC_dup))
  975 + {
  976 + while (hSession->ea_buf[baddr].fa)
  977 + {
957 if (skipped != NULL) 978 if (skipped != NULL)
958 *skipped = True; 979 *skipped = True;
959 - if (FA_IS_SKIP(h3270.ea_buf[baddr].fa))  
960 - baddr = next_unprotected(&h3270,baddr); 980 + if (FA_IS_SKIP(hSession->ea_buf[baddr].fa))
  981 + baddr = next_unprotected(hSession,baddr);
961 else 982 else
962 INC_BA(baddr); 983 INC_BA(baddr);
963 } 984 }
964 - cursor_move(&h3270,baddr); 985 + cursor_move(hSession,baddr);
965 } 986 }
966 987
967 (void) ctlr_dbcs_postprocess(); 988 (void) ctlr_dbcs_postprocess();
968 return True; 989 return True;
969 } 990 }
970 991
971 -/* 992 +/**
972 * Handle an ordinary character key, given an ASCII code. 993 * Handle an ordinary character key, given an ASCII code.
  994 + *
973 */ 995 */
974 -void key_ACharacter(unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped) 996 +void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped)
975 { 997 {
976 if (skipped != NULL) 998 if (skipped != NULL)
977 *skipped = False; 999 *skipped = False;
978 1000
979 - trace_event(" %s -> Key(\"%s\")\n",ia_name[(int) cause], ctl_see((int) c)); 1001 + lib3270_trace_event(hSession," %s -> Key(\"%s\")\n",ia_name[(int) cause], ctl_see((int) c));
980 1002
981 if (IN_3270) 1003 if (IN_3270)
982 { 1004 {
983 if (c < ' ') 1005 if (c < ' ')
984 { 1006 {
985 - trace_event(" dropped (control char)\n"); 1007 + lib3270_trace_event(hSession," dropped (control char)\n");
986 return; 1008 return;
987 } 1009 }
988 - (void) key_Character((int) asc2ebc[c], keytype == KT_GE, False, skipped); 1010 + (void) key_Character(hSession, (int) asc2ebc[c], keytype == KT_GE, False, skipped);
989 } 1011 }
990 #if defined(X3270_ANSI) /*[*/ 1012 #if defined(X3270_ANSI) /*[*/
991 else if (IN_ANSI) 1013 else if (IN_ANSI)
992 { 1014 {
993 - net_sendc(&h3270,(char) c); 1015 + net_sendc(hSession,(char) c);
994 } 1016 }
995 #endif /*]*/ 1017 #endif /*]*/
996 else 1018 else
997 { 1019 {
998 - trace_event(" dropped (not connected)\n"); 1020 + lib3270_trace_event(hSession," dropped (not connected)\n");
999 } 1021 }
1000 } 1022 }
1001 1023
@@ -1847,7 +1869,7 @@ LIB3270_ACTION( dup ) @@ -1847,7 +1869,7 @@ LIB3270_ACTION( dup )
1847 if (IN_ANSI) 1869 if (IN_ANSI)
1848 return 0; 1870 return 0;
1849 #endif 1871 #endif
1850 - if (key_Character(EBC_dup, False, False, NULL)) 1872 + if (key_Character(hSession, EBC_dup, False, False, NULL))
1851 { 1873 {
1852 hSession->display(hSession); 1874 hSession->display(hSession);
1853 cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr)); 1875 cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr));
@@ -1870,7 +1892,7 @@ LIB3270_ACTION( fieldmark ) @@ -1870,7 +1892,7 @@ LIB3270_ACTION( fieldmark )
1870 if (IN_ANSI) 1892 if (IN_ANSI)
1871 return 0 ; 1893 return 0 ;
1872 #endif 1894 #endif
1873 - (void) key_Character(EBC_fm, False, False, NULL); 1895 + (void) key_Character(hSession, EBC_fm, False, False, NULL);
1874 1896
1875 return 0; 1897 return 0;
1876 } 1898 }
@@ -2511,8 +2533,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2511,8 +2533,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2511 break; 2533 break;
2512 case '\f': 2534 case '\f':
2513 if (pasting) { 2535 if (pasting) {
2514 - key_ACharacter((unsigned char) ' ',  
2515 - KT_STD, ia, &skipped); 2536 + key_ACharacter(session,(unsigned char) ' ',KT_STD, ia, &skipped);
2516 } else { 2537 } else {
2517 lib3270_clear(session); 2538 lib3270_clear(session);
2518 skipped = False; 2539 skipped = False;
@@ -2544,18 +2565,17 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2544,18 +2565,17 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2544 if (!pasting) 2565 if (!pasting)
2545 state = BACKSLASH; 2566 state = BACKSLASH;
2546 else 2567 else
2547 - key_ACharacter((unsigned char) c,  
2548 - KT_STD, ia, &skipped); 2568 + key_ACharacter(session,(unsigned char) c,KT_STD, ia, &skipped);
2549 break; 2569 break;
2550 case '\033': /* ESC is special only when pasting */ 2570 case '\033': /* ESC is special only when pasting */
2551 if (pasting) 2571 if (pasting)
2552 state = XGE; 2572 state = XGE;
2553 break; 2573 break;
2554 case '[': /* APL left bracket */ 2574 case '[': /* APL left bracket */
2555 - key_ACharacter((unsigned char) c, KT_STD, ia, &skipped); 2575 + key_ACharacter(session,(unsigned char) c, KT_STD, ia, &skipped);
2556 break; 2576 break;
2557 case ']': /* APL right bracket */ 2577 case ']': /* APL right bracket */
2558 - key_ACharacter((unsigned char) c, KT_STD, ia, &skipped); 2578 + key_ACharacter(session,(unsigned char) c, KT_STD, ia, &skipped);
2559 break; 2579 break;
2560 default: 2580 default:
2561 /* 2581 /*
@@ -2577,14 +2597,14 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2577,14 +2597,14 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2577 break; 2597 break;
2578 } 2598 }
2579 #endif */ 2599 #endif */
2580 - key_ACharacter((unsigned char) c, KT_STD, ia, &skipped); 2600 + key_ACharacter(session,(unsigned char) c, KT_STD, ia, &skipped);
2581 break; 2601 break;
2582 } 2602 }
2583 break; 2603 break;
2584 case BACKSLASH: /* last character was a backslash */ 2604 case BACKSLASH: /* last character was a backslash */
2585 switch (c) { 2605 switch (c) {
2586 case 'a': 2606 case 'a':
2587 - popup_an_error(NULL,"%s: Bell not supported",action_name(String_action)); 2607 + popup_an_error(session,"%s: Bell not supported",action_name(String_action));
2588 // cancel_if_idle_command(); 2608 // cancel_if_idle_command();
2589 state = BASE; 2609 state = BASE;
2590 break; 2610 break;
@@ -2640,7 +2660,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2640,7 +2660,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2640 state = BACKX; 2660 state = BACKX;
2641 break; 2661 break;
2642 case '\\': 2662 case '\\':
2643 - key_ACharacter((unsigned char) c, KT_STD, ia,&skipped); 2663 + key_ACharacter(session,(unsigned char) c, KT_STD, ia,&skipped);
2644 state = BASE; 2664 state = BASE;
2645 break; 2665 break;
2646 case '0': 2666 case '0':
@@ -2723,8 +2743,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2723,8 +2743,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2723 nc = 0; 2743 nc = 0;
2724 continue; 2744 continue;
2725 } else { 2745 } else {
2726 - popup_an_error(NULL,"%s: Missing hex digits after \\x",  
2727 - action_name(String_action)); 2746 + popup_an_error(session,_( "%s: Missing hex digits after \\x" ),action_name(String_action));
2728 // cancel_if_idle_command(); 2747 // cancel_if_idle_command();
2729 state = BASE; 2748 state = BASE;
2730 continue; 2749 continue;
@@ -2735,8 +2754,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2735,8 +2754,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2735 nc++; 2754 nc++;
2736 break; 2755 break;
2737 } else { 2756 } else {
2738 - key_ACharacter((unsigned char) literal, KT_STD,  
2739 - ia, &skipped); 2757 + key_ACharacter(session,(unsigned char) literal, KT_STD,ia, &skipped);
2740 state = BASE; 2758 state = BASE;
2741 continue; 2759 continue;
2742 } 2760 }
@@ -2746,22 +2764,20 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2746,22 +2764,20 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2746 nc++; 2764 nc++;
2747 break; 2765 break;
2748 } else { 2766 } else {
2749 - key_ACharacter((unsigned char) literal, KT_STD,  
2750 - ia, &skipped); 2767 + key_ACharacter(session,(unsigned char) literal, KT_STD, ia, &skipped);
2751 state = BASE; 2768 state = BASE;
2752 continue; 2769 continue;
2753 } 2770 }
2754 case XGE: /* have seen ESC */ 2771 case XGE: /* have seen ESC */
2755 switch (c) { 2772 switch (c) {
2756 case ';': /* FM */ 2773 case ';': /* FM */
2757 - key_Character(EBC_fm, False, True, &skipped); 2774 + key_Character(session, EBC_fm, False, True, &skipped);
2758 break; 2775 break;
2759 case '*': /* DUP */ 2776 case '*': /* DUP */
2760 - key_Character(EBC_dup, False, True, &skipped); 2777 + key_Character(session, EBC_dup, False, True, &skipped);
2761 break; 2778 break;
2762 default: 2779 default:
2763 - key_ACharacter((unsigned char) c, KT_GE, ia,  
2764 - &skipped); 2780 + key_ACharacter(session,(unsigned char) c, KT_GE, ia,&skipped);
2765 break; 2781 break;
2766 } 2782 }
2767 state = BASE; 2783 state = BASE;
@@ -2773,18 +2789,18 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p @@ -2773,18 +2789,18 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p
2773 2789
2774 switch (state) { 2790 switch (state) {
2775 case BASE: 2791 case BASE:
2776 - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE) && 2792 + if (lib3270_get_toggle(session,LIB3270_TOGGLE_MARGINED_PASTE) &&
2777 BA_TO_COL(session->cursor_addr) < orig_col) { 2793 BA_TO_COL(session->cursor_addr) < orig_col) {
2778 - (void) remargin(&h3270,orig_col); 2794 + (void) remargin(session,orig_col);
2779 } 2795 }
2780 break; 2796 break;
2781 case OCTAL: 2797 case OCTAL:
2782 case HEX: 2798 case HEX:
2783 - key_ACharacter((unsigned char) literal, KT_STD, ia, &skipped); 2799 + key_ACharacter(session,(unsigned char) literal, KT_STD, ia, &skipped);
2784 state = BASE; 2800 state = BASE;
2785 - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE) && 2801 + if (lib3270_get_toggle(session,LIB3270_TOGGLE_MARGINED_PASTE) &&
2786 BA_TO_COL(session->cursor_addr) < orig_col) { 2802 BA_TO_COL(session->cursor_addr) < orig_col) {
2787 - (void) remargin(&h3270,orig_col); 2803 + (void) remargin(session,orig_col);
2788 } 2804 }
2789 break; 2805 break;
2790 case BACKPF: 2806 case BACKPF:
src/lib3270/paste.c
@@ -143,11 +143,11 @@ @@ -143,11 +143,11 @@
143 if(FA_IS_PROTECTED(session->ea_buf[faddr].fa)) 143 if(FA_IS_PROTECTED(session->ea_buf[faddr].fa))
144 session->cursor_addr++; 144 session->cursor_addr++;
145 else 145 else
146 - key_ACharacter(c, KT_STD, IA_PASTE, NULL); 146 + key_ACharacter(session, c, KT_STD, IA_PASTE, NULL);
147 } 147 }
148 else 148 else
149 { 149 {
150 - key_ACharacter(c, KT_STD, IA_PASTE, NULL); 150 + key_ACharacter(session, c, KT_STD, IA_PASTE, NULL);
151 } 151 }
152 152
153 data->qtd++; 153 data->qtd++;