Commit 01182c52f7ded8ee379ac90744406a14bb1a1ea4

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

Modificando métodos para multi-sessão

ansi.c
... ... @@ -640,7 +640,7 @@ ansi_insert_chars(H3270 *hSession, int nn, int ig2 unused)
640 640 /* Move the surviving chars right */
641 641 ns = mc - nn;
642 642 if (ns)
643   - ctlr_bcopy(hSession->cursor_addr, hSession->cursor_addr + nn, ns, 1);
  643 + ctlr_bcopy(hSession,hSession->cursor_addr, hSession->cursor_addr + nn, ns, 1);
644 644  
645 645 /* Clear the middle of the line */
646 646 ctlr_aclear(hSession, hSession->cursor_addr, nn, 1);
... ... @@ -769,7 +769,7 @@ ansi_insert_lines(H3270 *hSession, int nn, int ig2 unused)
769 769 /* Move the victims down */
770 770 ns = mr - nn;
771 771 if (ns)
772   - ctlr_bcopy(rr * hSession->cols, (rr + nn) * hSession->cols, ns * hSession->cols, 1);
  772 + ctlr_bcopy(hSession,rr * hSession->cols, (rr + nn) * hSession->cols, ns * hSession->cols, 1);
773 773  
774 774 /* Clear the middle of the screen */
775 775 ctlr_aclear(hSession, rr * hSession->cols, nn * hSession->cols, 1);
... ... @@ -795,7 +795,7 @@ ansi_delete_lines(H3270 *hSession, int nn, int ig2 unused)
795 795 /* Move the surviving rows up */
796 796 ns = mr - nn;
797 797 if (ns)
798   - ctlr_bcopy((rr + nn) * hSession->cols, rr * hSession->cols, ns * hSession->cols, 1);
  798 + ctlr_bcopy(hSession,(rr + nn) * hSession->cols, rr * hSession->cols, ns * hSession->cols, 1);
799 799  
800 800 /* Clear the rest of the screen */
801 801 ctlr_aclear(hSession, (rr + ns) * hSession->cols, nn * hSession->cols, 1);
... ... @@ -817,7 +817,7 @@ ansi_delete_chars(H3270 *hSession, int nn, int ig2 unused)
817 817 /* Move the surviving chars left */
818 818 ns = mc - nn;
819 819 if (ns)
820   - ctlr_bcopy(hSession->cursor_addr + nn, hSession->cursor_addr, ns, 1);
  820 + ctlr_bcopy(hSession,hSession->cursor_addr + nn, hSession->cursor_addr, ns, 1);
821 821  
822 822 /* Clear the end of the line */
823 823 ctlr_aclear(hSession, hSession->cursor_addr + ns, nn, 1);
... ... @@ -1705,7 +1705,7 @@ static void ansi_scroll(H3270 *hSession)
1705 1705  
1706 1706 /* Scroll all but the last line up */
1707 1707 if (hSession->scroll_bottom > hSession->scroll_top)
1708   - ctlr_bcopy(hSession->scroll_top * hSession->cols,
  1708 + ctlr_bcopy(hSession,hSession->scroll_top * hSession->cols,
1709 1709 (hSession->scroll_top - 1) * hSession->cols,
1710 1710 (hSession->scroll_bottom - hSession->scroll_top) * hSession->cols,
1711 1711 1);
... ...
ctlr.c
... ... @@ -264,7 +264,6 @@ static void ctlr_half_connect(H3270 *session, int ignored unused, void *dunno)
264 264 ticking_start(session,True);
265 265 }
266 266  
267   -
268 267 /*
269 268 * Called when a host connects, disconnects, or changes ANSI/3270 modes.
270 269 */
... ... @@ -437,8 +436,8 @@ enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen)
437 436 case CMD_EWA: /* erase/write alternate */
438 437 case SNA_CMD_EWA:
439 438 trace_ds(hSession,"EraseWriteAlternate");
440   - ctlr_erase(NULL,True);
441   - if ((rv = ctlr_write(buf, buflen, True)) < 0)
  439 + ctlr_erase(hSession,True);
  440 + if ((rv = ctlr_write(hSession,buf, buflen, True)) < 0)
442 441 return rv;
443 442 return PDS_OKAY_NO_OUTPUT;
444 443 break;
... ... @@ -446,8 +445,8 @@ enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen)
446 445 case CMD_EW: /* erase/write */
447 446 case SNA_CMD_EW:
448 447 trace_ds(hSession,"EraseWrite");
449   - ctlr_erase(NULL,False);
450   - if ((rv = ctlr_write(buf, buflen, True)) < 0)
  448 + ctlr_erase(hSession,False);
  449 + if ((rv = ctlr_write(hSession,buf, buflen, True)) < 0)
451 450 return rv;
452 451 return PDS_OKAY_NO_OUTPUT;
453 452 break;
... ... @@ -455,7 +454,7 @@ enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen)
455 454 case CMD_W: /* write */
456 455 case SNA_CMD_W:
457 456 trace_ds(hSession,"Write");
458   - if ((rv = ctlr_write(buf, buflen, False)) < 0)
  457 + if ((rv = ctlr_write(hSession,buf, buflen, False)) < 0)
459 458 return rv;
460 459 return PDS_OKAY_NO_OUTPUT;
461 460 break;
... ... @@ -568,8 +567,8 @@ static void insert_sa(H3270 *hSession, int baddr, unsigned char *current_fgp, un
568 567 void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all)
569 568 {
570 569 register int baddr, sbaddr;
571   - Boolean send_data = True;
572   - Boolean short_read = False;
  570 + Boolean send_data = True;
  571 + Boolean short_read = False;
573 572 unsigned char current_fg = 0x00;
574 573 unsigned char current_bg = 0x00;
575 574 unsigned char current_gr = 0x00;
... ... @@ -579,104 +578,123 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all)
579 578 return;
580 579  
581 580 #if defined(X3270_FT) /*[*/
582   - if (aid_byte == AID_SF) {
  581 + if (aid_byte == AID_SF)
  582 + {
583 583 dft_read_modified();
584 584 return;
585 585 }
586 586 #endif /*]*/
587 587  
588   - trace_ds(&h3270,"> ");
589   - h3270.obptr = h3270.obuf;
590   -
591   - switch (aid_byte) {
  588 + trace_ds(hSession,"> ");
  589 + hSession->obptr = hSession->obuf;
592 590  
593   - case AID_SYSREQ: /* test request */
594   - space3270out(&h3270,4);
595   - *h3270.obptr++ = 0x01; /* soh */
596   - *h3270.obptr++ = 0x5b; /* % */
597   - *h3270.obptr++ = 0x61; /* / */
598   - *h3270.obptr++ = 0x02; /* stx */
599   - trace_ds(&h3270,"SYSREQ");
  591 + switch (aid_byte)
  592 + {
  593 + case AID_SYSREQ: /* test request */
  594 + space3270out(hSession,4);
  595 + *hSession->obptr++ = 0x01; /* soh */
  596 + *hSession->obptr++ = 0x5b; /* % */
  597 + *hSession->obptr++ = 0x61; /* / */
  598 + *hSession->obptr++ = 0x02; /* stx */
  599 + trace_ds(hSession,"SYSREQ");
600 600 break;
601 601  
602   - case AID_PA1: /* short-read AIDs */
603   - case AID_PA2:
604   - case AID_PA3:
605   - case AID_CLEAR:
606   - if (!all)
607   - short_read = True;
608   - /* fall through... */
609   -
610   - case AID_SELECT: /* No data on READ MODIFIED */
611   - if (!all)
612   - send_data = False;
613   - /* fall through... */
614   -
615   - default: /* ordinary AID */
616   - if (!IN_SSCP) {
617   - space3270out(&h3270,3);
618   - *h3270.obptr++ = aid_byte;
619   - trace_ds(&h3270,"%s",see_aid(aid_byte));
  602 + case AID_PA1: /* short-read AIDs */
  603 + case AID_PA2:
  604 + case AID_PA3:
  605 + case AID_CLEAR:
  606 + if (!all)
  607 + short_read = True;
  608 + /* fall through... */
  609 +
  610 + case AID_SELECT: /* No data on READ MODIFIED */
  611 + if (!all)
  612 + send_data = False;
  613 + /* fall through... */
  614 +
  615 + default: /* ordinary AID */
  616 + if (!IN_SSCP)
  617 + {
  618 + space3270out(hSession,3);
  619 + *hSession->obptr++ = aid_byte;
  620 + trace_ds(hSession,"%s",see_aid(aid_byte));
  621 +
620 622 if (short_read)
621   - goto rm_done;
622   - ENCODE_BADDR(h3270.obptr, h3270.cursor_addr);
623   - trace_ds(&h3270,"%s",rcba(&h3270,h3270.cursor_addr));
624   - } else {
625   - space3270out(&h3270,1); /* just in case */
  623 + goto rm_done;
  624 +
  625 + ENCODE_BADDR(hSession->obptr, hSession->cursor_addr);
  626 + trace_ds(hSession,"%s",rcba(hSession,hSession->cursor_addr));
  627 + }
  628 + else
  629 + {
  630 + space3270out(hSession,1); /* just in case */
626 631 }
627 632 break;
628 633 }
629 634  
630 635 baddr = 0;
631   - if (h3270.formatted) {
  636 + if (hSession->formatted)
  637 + {
632 638 /* find first field attribute */
633   - do {
634   - if (h3270.ea_buf[baddr].fa)
  639 + do
  640 + {
  641 + if (hSession->ea_buf[baddr].fa)
635 642 break;
636 643 INC_BA(baddr);
637 644 } while (baddr != 0);
  645 +
638 646 sbaddr = baddr;
639   - do {
640   - if (FA_IS_MODIFIED(h3270.ea_buf[baddr].fa)) {
  647 + do
  648 + {
  649 + if (FA_IS_MODIFIED(hSession->ea_buf[baddr].fa))
  650 + {
641 651 Boolean any = False;
642 652  
643 653 INC_BA(baddr);
644   - space3270out(&h3270,3);
645   - *h3270.obptr++ = ORDER_SBA;
646   - ENCODE_BADDR(h3270.obptr, baddr);
647   - trace_ds(&h3270," SetBufferAddress%s (Cols: %d Rows: %d)", rcba(&h3270,baddr), h3270.cols, h3270.rows);
648   - while (!h3270.ea_buf[baddr].fa) {
649   -
650   - if (send_data &&
651   - h3270.ea_buf[baddr].cc) {
652   - insert_sa(&h3270,baddr,&current_fg,&current_bg,&current_gr,&current_cs,&any);
653   - if (h3270.ea_buf[baddr].cs & CS_GE) {
654   - space3270out(&h3270,1);
655   - *h3270.obptr++ = ORDER_GE;
  654 + space3270out(hSession,3);
  655 + *hSession->obptr++ = ORDER_SBA;
  656 + ENCODE_BADDR(hSession->obptr, baddr);
  657 + trace_ds(hSession," SetBufferAddress%s (Cols: %d Rows: %d)", rcba(hSession,baddr), hSession->cols, hSession->rows);
  658 + while (!hSession->ea_buf[baddr].fa)
  659 + {
  660 +
  661 + if (send_data && hSession->ea_buf[baddr].cc)
  662 + {
  663 + insert_sa(hSession,baddr,&current_fg,&current_bg,&current_gr,&current_cs,&any);
  664 + if (hSession->ea_buf[baddr].cs & CS_GE)
  665 + {
  666 + space3270out(hSession,1);
  667 + *hSession->obptr++ = ORDER_GE;
656 668 if (any)
657   - trace_ds(&h3270,"'");
658   - trace_ds(&h3270," GraphicEscape");
  669 + trace_ds(hSession,"'");
  670 + trace_ds(hSession," GraphicEscape");
659 671 any = False;
660 672 }
661   - space3270out(&h3270,1);
662   - *h3270.obptr++ = h3270.ea_buf[baddr].cc;
  673 + space3270out(hSession,1);
  674 + *hSession->obptr++ = hSession->ea_buf[baddr].cc;
663 675 if (!any)
664   - trace_ds(&h3270," '");
665   - trace_ds(&h3270,"%s",see_ebc(h3270.ea_buf[baddr].cc));
  676 + trace_ds(hSession," '");
  677 +
  678 + trace_ds(hSession,"%s",see_ebc(hSession->ea_buf[baddr].cc));
666 679 any = True;
667 680 }
668 681 INC_BA(baddr);
669 682 }
670 683 if (any)
671   - trace_ds(&h3270,"'");
  684 + trace_ds(hSession,"'");
672 685 }
673   - else { /* not modified - skip */
674   - do {
  686 + else
  687 + { /* not modified - skip */
  688 + do
  689 + {
675 690 INC_BA(baddr);
676   - } while (!h3270.ea_buf[baddr].fa);
  691 + } while (!hSession->ea_buf[baddr].fa);
677 692 }
678 693 } while (baddr != sbaddr);
679   - } else {
  694 +
  695 + }
  696 + else
  697 + {
680 698 Boolean any = False;
681 699 int nbytes = 0;
682 700  
... ... @@ -685,24 +703,28 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all)
685 703 * host left the cursor.
686 704 */
687 705 if (IN_SSCP)
688   - baddr = h3270.sscp_start;
  706 + baddr = hSession->sscp_start;
689 707  
690   - do {
691   - if (h3270.ea_buf[baddr].cc) {
692   - insert_sa(&h3270,baddr,&current_fg,&current_bg,&current_gr,&current_cs,&any);
693   - if (h3270.ea_buf[baddr].cs & CS_GE) {
694   - space3270out(&h3270,1);
695   - *h3270.obptr++ = ORDER_GE;
  708 + do
  709 + {
  710 + if (hSession->ea_buf[baddr].cc)
  711 + {
  712 + insert_sa(hSession,baddr,&current_fg,&current_bg,&current_gr,&current_cs,&any);
  713 + if (hSession->ea_buf[baddr].cs & CS_GE)
  714 + {
  715 + space3270out(hSession,1);
  716 + *hSession->obptr++ = ORDER_GE;
696 717 if (any)
697   - trace_ds(&h3270,"' ");
698   - trace_ds(&h3270," GraphicEscape ");
  718 + trace_ds(hSession,"' ");
  719 + trace_ds(hSession," GraphicEscape ");
699 720 any = False;
700 721 }
701   - space3270out(&h3270,1);
702   - *h3270.obptr++ = h3270.ea_buf[baddr].cc;
  722 +
  723 + space3270out(hSession,1);
  724 + *hSession->obptr++ = hSession->ea_buf[baddr].cc;
703 725 if (!any)
704   - trace_ds(&h3270,"%s","'");
705   - trace_ds(&h3270,"%s",see_ebc(h3270.ea_buf[baddr].cc));
  726 + trace_ds(hSession,"%s","'");
  727 + trace_ds(hSession,"%s",see_ebc(hSession->ea_buf[baddr].cc));
706 728 any = True;
707 729 nbytes++;
708 730 }
... ... @@ -714,14 +736,16 @@ void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all)
714 736 */
715 737 if (IN_SSCP && (nbytes >= 255 || !baddr))
716 738 break;
  739 +
717 740 } while (baddr != 0);
  741 +
718 742 if (any)
719   - trace_ds(&h3270,"'");
  743 + trace_ds(hSession,"'");
720 744 }
721 745  
722 746 rm_done:
723   - trace_ds(&h3270,"\n");
724   - net_output(&h3270);
  747 + trace_ds(hSession,"\n");
  748 + net_output(hSession);
725 749 }
726 750  
727 751 /*
... ... @@ -848,137 +872,6 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte)
848 872 net_output(hSession);
849 873 }
850 874  
851   -#if defined(X3270_TRACE) /*[*/
852   -/*
853   - * Construct a 3270 command to reproduce the current state of the display.
854   - */ /*
855   -void
856   -ctlr_snap_buffer(void)
857   -{
858   - register int baddr = 0;
859   - int attr_count;
860   - unsigned char current_fg = 0x00;
861   - unsigned char current_bg = 0x00;
862   - unsigned char current_gr = 0x00;
863   - unsigned char current_cs = 0x00;
864   - unsigned char av;
865   -
866   - space3270out(2);
867   - *obptr++ = h3270.screen_alt ? CMD_EWA : CMD_EW;
868   - *obptr++ = code_table[0];
869   -
870   - do {
871   - if (h3270.ea_buf[baddr].fa) {
872   - space3270out(4);
873   - *obptr++ = ORDER_SFE;
874   - attr_count = obptr - obuf;
875   - *obptr++ = 1; // for now
876   - *obptr++ = XA_3270;
877   - *obptr++ = code_table[h3270.ea_buf[baddr].fa & ~FA_PRINTABLE];
878   - if (h3270.ea_buf[baddr].fg) {
879   - space3270out(2);
880   - *obptr++ = XA_FOREGROUND;
881   - *obptr++ = h3270.ea_buf[baddr].fg;
882   - (*(obuf + attr_count))++;
883   - }
884   - if (h3270.ea_buf[baddr].bg) {
885   - space3270out(2);
886   - *obptr++ = XA_BACKGROUND;
887   - *obptr++ = h3270.ea_buf[baddr].fg;
888   - (*(obuf + attr_count))++;
889   - }
890   - if (h3270.ea_buf[baddr].gr) {
891   - space3270out(2);
892   - *obptr++ = XA_HIGHLIGHTING;
893   - *obptr++ = h3270.ea_buf[baddr].gr | 0xf0;
894   - (*(obuf + attr_count))++;
895   - }
896   - if (h3270.ea_buf[baddr].cs & CS_MASK) {
897   - space3270out(2);
898   - *obptr++ = XA_CHARSET;
899   - *obptr++ = host_cs(h3270.ea_buf[baddr].cs);
900   - (*(obuf + attr_count))++;
901   - }
902   - } else {
903   - av = h3270.ea_buf[baddr].fg;
904   - if (current_fg != av) {
905   - current_fg = av;
906   - space3270out(3);
907   - *obptr++ = ORDER_SA;
908   - *obptr++ = XA_FOREGROUND;
909   - *obptr++ = av;
910   - }
911   - av = h3270.ea_buf[baddr].bg;
912   - if (current_bg != av) {
913   - current_bg = av;
914   - space3270out(3);
915   - *obptr++ = ORDER_SA;
916   - *obptr++ = XA_BACKGROUND;
917   - *obptr++ = av;
918   - }
919   - av = h3270.ea_buf[baddr].gr;
920   - if (av)
921   - av |= 0xf0;
922   - if (current_gr != av) {
923   - current_gr = av;
924   - space3270out(3);
925   - *obptr++ = ORDER_SA;
926   - *obptr++ = XA_HIGHLIGHTING;
927   - *obptr++ = av;
928   - }
929   - av = h3270.ea_buf[baddr].cs & CS_MASK;
930   - if (av)
931   - av = host_cs(av);
932   - if (current_cs != av) {
933   - current_cs = av;
934   - space3270out(3);
935   - *obptr++ = ORDER_SA;
936   - *obptr++ = XA_CHARSET;
937   - *obptr++ = av;
938   - }
939   - if (h3270.ea_buf[baddr].cs & CS_GE) {
940   - space3270out(1);
941   - *obptr++ = ORDER_GE;
942   - }
943   - space3270out(1);
944   - *obptr++ = h3270.ea_buf[baddr].cc;
945   - }
946   - INC_BA(baddr);
947   - } while (baddr != 0);
948   -
949   - space3270out(4);
950   - *obptr++ = ORDER_SBA;
951   - ENCODE_BADDR(obptr, h3270.cursor_addr);
952   - *obptr++ = ORDER_IC;
953   -} */
954   -
955   -/*
956   - * Construct a 3270 command to reproduce the reply mode.
957   - * Returns a Boolean indicating if one is necessary.
958   - */ /*
959   -Boolean
960   -ctlr_snap_modes(void)
961   -{
962   - int i;
963   -
964   - if (!IN_3270 || h3270.reply_mode == SF_SRM_FIELD)
965   - return False;
966   -
967   - space3270out(6 + h3270.crm_nattr);
968   - *obptr++ = CMD_WSF;
969   - *obptr++ = 0x00; // implicit length
970   - *obptr++ = 0x00;
971   - *obptr++ = SF_SET_REPLY_MODE;
972   - *obptr++ = 0x00; // partition 0
973   - *obptr++ = h3270.reply_mode;
974   - if (h3270.reply_mode == SF_SRM_CHAR)
975   - for (i = 0; i < h3270.crm_nattr; i++)
976   - *obptr++ = h3270.crm_attr[i];
977   - return True;
978   -} */
979   -#endif
980   -
981   -
982 875 /*
983 876 * Process a 3270 Erase All Unprotected command.
984 877 */
... ... @@ -1003,7 +896,7 @@ void ctlr_erase_all_unprotected(H3270 *hSession)
1003 896 do {
1004 897 fa = hSession->ea_buf[baddr].fa;
1005 898 if (!FA_IS_PROTECTED(fa)) {
1006   - mdt_clear(baddr);
  899 + mdt_clear(hSession,baddr);
1007 900 do {
1008 901 INC_BA(baddr);
1009 902 if (!f) {
... ... @@ -1036,8 +929,7 @@ void ctlr_erase_all_unprotected(H3270 *hSession)
1036 929 /*
1037 930 * Process a 3270 Write command.
1038 931 */
1039   -enum pds
1040   -ctlr_write(unsigned char buf[], int buflen, Boolean erase)
  932 +enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean erase)
1041 933 {
1042 934 register unsigned char *cp;
1043 935 register int baddr;
... ... @@ -1067,73 +959,80 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1067 959 char mb[16];
1068 960 #endif /*]*/
1069 961  
1070   -#define END_TEXT0 { if (previous == TEXT) trace_ds(&h3270,"'"); }
1071   -#define END_TEXT(cmd) { END_TEXT0; trace_ds(&h3270," %s", cmd); }
  962 +#define END_TEXT0 { if (previous == TEXT) trace_ds(hSession,"'"); }
  963 +#define END_TEXT(cmd) { END_TEXT0; trace_ds(hSession," %s", cmd); }
1072 964  
1073 965 /* XXX: Should there be a ctlr_add_cs call here? */
1074 966 #define START_FIELD(fa) { \
1075 967 current_fa = fa; \
1076   - ctlr_add_fa(&h3270,h3270.buffer_addr, fa, 0); \
1077   - ctlr_add_cs(&h3270,h3270.buffer_addr, 0); \
1078   - ctlr_add_fg(&h3270,h3270.buffer_addr, 0); \
1079   - ctlr_add_bg(&h3270,h3270.buffer_addr, 0); \
1080   - ctlr_add_gr(&h3270,h3270.buffer_addr, 0); \
1081   - ctlr_add_ic(&h3270,h3270.buffer_addr, 0); \
1082   - trace_ds(&h3270,"%s",see_attr(fa)); \
1083   - h3270.formatted = True; \
  968 + ctlr_add_fa(hSession,hSession->buffer_addr, fa, 0); \
  969 + ctlr_add_cs(hSession,hSession->buffer_addr, 0); \
  970 + ctlr_add_fg(hSession,hSession->buffer_addr, 0); \
  971 + ctlr_add_bg(hSession,hSession->buffer_addr, 0); \
  972 + ctlr_add_gr(hSession,hSession->buffer_addr, 0); \
  973 + ctlr_add_ic(hSession,hSession->buffer_addr, 0); \
  974 + trace_ds(hSession,"%s",see_attr(fa)); \
  975 + hSession->formatted = True; \
1084 976 }
1085 977  
1086   - kybd_inhibit(&h3270,False);
  978 + kybd_inhibit(hSession,False);
1087 979  
1088 980 if (buflen < 2)
1089 981 return PDS_BAD_CMD;
1090 982  
1091   - h3270.default_fg = 0;
1092   - h3270.default_bg = 0;
1093   - h3270.default_gr = 0;
1094   - h3270.default_cs = 0;
1095   - h3270.default_ic = 0;
  983 + hSession->default_fg = 0;
  984 + hSession->default_bg = 0;
  985 + hSession->default_gr = 0;
  986 + hSession->default_cs = 0;
  987 + hSession->default_ic = 0;
1096 988  
1097   - h3270.trace_primed = 1;
1098   - h3270.buffer_addr = h3270.cursor_addr;
1099   - if (WCC_RESET(buf[1])) {
  989 + hSession->trace_primed = 1;
  990 + hSession->buffer_addr = hSession->cursor_addr;
  991 + if (WCC_RESET(buf[1]))
  992 + {
1100 993 if (erase)
1101   - h3270.reply_mode = SF_SRM_FIELD;
1102   - trace_ds(&h3270,"%sreset", paren);
  994 + hSession->reply_mode = SF_SRM_FIELD;
  995 + trace_ds(hSession,"%sreset", paren);
1103 996 paren = ",";
1104 997 }
1105 998 wcc_sound_alarm = WCC_SOUND_ALARM(buf[1]);
1106   - if (wcc_sound_alarm) {
1107   - trace_ds(&h3270,"%salarm", paren);
  999 + if (wcc_sound_alarm)
  1000 + {
  1001 + trace_ds(hSession,"%salarm", paren);
1108 1002 paren = ",";
1109 1003 }
1110 1004 wcc_keyboard_restore = WCC_KEYBOARD_RESTORE(buf[1]);
1111 1005 if (wcc_keyboard_restore)
1112   - ticking_stop(NULL);
1113   - if (wcc_keyboard_restore) {
1114   - trace_ds(&h3270,"%srestore", paren);
  1006 + ticking_stop(hSession);
  1007 +
  1008 + if (wcc_keyboard_restore)
  1009 + {
  1010 + trace_ds(hSession,"%srestore", paren);
1115 1011 paren = ",";
1116 1012 }
1117 1013  
1118   - if (WCC_RESET_MDT(buf[1])) {
1119   - trace_ds(&h3270,"%sresetMDT", paren);
  1014 + if (WCC_RESET_MDT(buf[1]))
  1015 + {
  1016 + trace_ds(hSession,"%sresetMDT", paren);
1120 1017 paren = ",";
1121 1018 baddr = 0;
1122   - if (h3270.modified_sel)
1123   - ALL_CHANGED(&h3270);
1124   - do {
1125   - if (h3270.ea_buf[baddr].fa) {
1126   - mdt_clear(baddr);
  1019 + if (hSession->modified_sel)
  1020 + ALL_CHANGED(hSession);
  1021 + do
  1022 + {
  1023 + if (hSession->ea_buf[baddr].fa)
  1024 + {
  1025 + mdt_clear(hSession,baddr);
1127 1026 }
1128 1027 INC_BA(baddr);
1129 1028 } while (baddr != 0);
1130 1029 }
1131 1030 if (strcmp(paren, "("))
1132   - trace_ds(&h3270,")");
  1031 + trace_ds(hSession,")");
1133 1032  
1134 1033 last_cmd = True;
1135 1034 last_zpt = False;
1136   - current_fa = get_field_attribute(&h3270,h3270.buffer_addr);
  1035 + current_fa = get_field_attribute(hSession,hSession->buffer_addr);
1137 1036  
1138 1037 #define ABORT_WRITEx { \
1139 1038 rv = PDS_BAD_ADDR; \
... ... @@ -1141,48 +1040,53 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1141 1040 break; \
1142 1041 }
1143 1042 #define ABORT_WRITE(s) { \
1144   - trace_ds(&h3270," [" s "; write aborted]\n"); \
  1043 + trace_ds(hSession," [" s "; write aborted]\n"); \
1145 1044 ABORT_WRITEx; \
1146 1045 } \
1147 1046  
1148   - for (cp = &buf[2]; !aborted && cp < (buf + buflen); cp++) {
1149   - switch (*cp) {
  1047 + for (cp = &buf[2]; !aborted && cp < (buf + buflen); cp++)
  1048 + {
  1049 + switch (*cp)
  1050 + {
1150 1051 case ORDER_SF: /* start field */
1151 1052 END_TEXT("StartField");
1152 1053 if (previous != SBA)
1153   - trace_ds(&h3270,"%s",rcba(&h3270,h3270.buffer_addr));
  1054 + trace_ds(hSession,"%s",rcba(hSession,hSession->buffer_addr));
1154 1055 previous = ORDER;
1155 1056 cp++; /* skip field attribute */
1156 1057 START_FIELD(*cp);
1157   - ctlr_add_fg(&h3270,h3270.buffer_addr, 0);
1158   - ctlr_add_bg(&h3270,h3270.buffer_addr, 0);
1159   - INC_BA(h3270.buffer_addr);
  1058 + ctlr_add_fg(hSession,hSession->buffer_addr, 0);
  1059 + ctlr_add_bg(hSession,hSession->buffer_addr, 0);
  1060 + INC_BA(hSession->buffer_addr);
1160 1061 last_cmd = True;
1161 1062 last_zpt = False;
1162 1063 break;
  1064 +
1163 1065 case ORDER_SBA: /* set buffer address */
1164 1066 cp += 2; /* skip buffer address */
1165   - h3270.buffer_addr = DECODE_BADDR(*(cp-1), *cp);
  1067 + hSession->buffer_addr = DECODE_BADDR(*(cp-1), *cp);
1166 1068 END_TEXT("SetBufferAddress");
1167 1069 previous = SBA;
1168   - trace_ds(&h3270,"%s",rcba(&h3270,h3270.buffer_addr));
1169   - if (h3270.buffer_addr >= h3270.cols * h3270.rows)
  1070 + trace_ds(hSession,"%s",rcba(hSession,hSession->buffer_addr));
  1071 + if(hSession->buffer_addr >= hSession->cols * hSession->rows)
1170 1072 {
1171 1073 ABORT_WRITE("invalid SBA address");
1172 1074 }
1173   - current_fa = get_field_attribute(&h3270,h3270.buffer_addr);
  1075 + current_fa = get_field_attribute(hSession,hSession->buffer_addr);
1174 1076 last_cmd = True;
1175 1077 last_zpt = False;
1176 1078 break;
  1079 +
1177 1080 case ORDER_IC: /* insert cursor */
1178 1081 END_TEXT("InsertCursor");
1179 1082 if (previous != SBA)
1180   - trace_ds(&h3270,"%s",rcba(&h3270,h3270.buffer_addr));
  1083 + trace_ds(hSession,"%s",rcba(hSession,hSession->buffer_addr));
1181 1084 previous = ORDER;
1182   - cursor_move(&h3270,h3270.buffer_addr);
  1085 + cursor_move(hSession,hSession->buffer_addr);
1183 1086 last_cmd = True;
1184 1087 last_zpt = False;
1185 1088 break;
  1089 +
1186 1090 case ORDER_PT: /* program tab */
1187 1091 END_TEXT("ProgramTab");
1188 1092 previous = ORDER;
... ... @@ -1191,9 +1095,9 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1191 1095 * of an unprotected field, simply advance one
1192 1096 * position.
1193 1097 */
1194   - if (h3270.ea_buf[h3270.buffer_addr].fa &&
1195   - !FA_IS_PROTECTED(h3270.ea_buf[h3270.buffer_addr].fa)) {
1196   - INC_BA(h3270.buffer_addr);
  1098 + if (hSession->ea_buf[hSession->buffer_addr].fa && !FA_IS_PROTECTED(hSession->ea_buf[hSession->buffer_addr].fa))
  1099 + {
  1100 + INC_BA(hSession->buffer_addr);
1197 1101 last_zpt = False;
1198 1102 last_cmd = True;
1199 1103 break;
... ... @@ -1202,8 +1106,8 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1202 1106 * Otherwise, advance to the first position of the
1203 1107 * next unprotected field.
1204 1108 */
1205   - baddr = next_unprotected(&h3270,h3270.buffer_addr);
1206   - if (baddr < h3270.buffer_addr)
  1109 + baddr = next_unprotected(hSession,hSession->buffer_addr);
  1110 + if (baddr < hSession->buffer_addr)
1207 1111 baddr = 0;
1208 1112 /*
1209 1113 * Null out the remainder of the current field -- even
... ... @@ -1212,56 +1116,69 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1212 1116 * a null-filling PT that left the buffer address at 0.
1213 1117 * XXX: There's some funky DBCS rule here.
1214 1118 */
1215   - if (!last_cmd || last_zpt) {
1216   - trace_ds(&h3270,"(nulling)");
1217   - while ((h3270.buffer_addr != baddr) &&
1218   - (!h3270.ea_buf[h3270.buffer_addr].fa)) {
1219   - ctlr_add(&h3270,h3270.buffer_addr, EBC_null, 0);
1220   - ctlr_add_cs(&h3270,h3270.buffer_addr, 0);
1221   - ctlr_add_fg(&h3270,h3270.buffer_addr, 0);
1222   - ctlr_add_bg(&h3270,h3270.buffer_addr, 0);
1223   - ctlr_add_gr(&h3270,h3270.buffer_addr, 0);
1224   - ctlr_add_ic(&h3270,h3270.buffer_addr, 0);
1225   - INC_BA(h3270.buffer_addr);
  1119 + if (!last_cmd || last_zpt)
  1120 + {
  1121 + trace_ds(hSession,"(nulling)");
  1122 +
  1123 + while((hSession->buffer_addr != baddr) && (!hSession->ea_buf[hSession->buffer_addr].fa))
  1124 + {
  1125 + ctlr_add(hSession,hSession->buffer_addr, EBC_null, 0);
  1126 + ctlr_add_cs(hSession,hSession->buffer_addr, 0);
  1127 + ctlr_add_fg(hSession,hSession->buffer_addr, 0);
  1128 + ctlr_add_bg(hSession,hSession->buffer_addr, 0);
  1129 + ctlr_add_gr(hSession,hSession->buffer_addr, 0);
  1130 + ctlr_add_ic(hSession,hSession->buffer_addr, 0);
  1131 + INC_BA(hSession->buffer_addr);
1226 1132 }
1227 1133 if (baddr == 0)
1228 1134 last_zpt = True;
1229   - } else
  1135 + }
  1136 + else
1230 1137 last_zpt = False;
1231   - h3270.buffer_addr = baddr;
  1138 +
  1139 + hSession->buffer_addr = baddr;
1232 1140 last_cmd = True;
1233 1141 break;
  1142 +
1234 1143 case ORDER_RA: /* repeat to address */
1235 1144 END_TEXT("RepeatToAddress");
1236 1145 cp += 2; /* skip buffer address */
1237 1146 baddr = DECODE_BADDR(*(cp-1), *cp);
1238   - trace_ds(&h3270,"%s",rcba(&h3270,baddr));
  1147 + trace_ds(hSession,"%s",rcba(hSession,baddr));
1239 1148 cp++; /* skip char to repeat */
1240 1149 add_dbcs = False;
1241 1150 ra_ge = False;
1242 1151 previous = ORDER;
1243 1152 #if defined(X3270_DBCS) /*[*/
1244   - if (dbcs) {
  1153 + if (dbcs)
  1154 + {
1245 1155 d = ctlr_lookleft_state(buffer_addr, &why);
1246   - if (d == DBCS_RIGHT) {
  1156 + if (d == DBCS_RIGHT)
  1157 + {
1247 1158 ABORT_WRITE("RA over right half of DBCS character");
1248 1159 }
1249   - if (default_cs == CS_DBCS || d == DBCS_LEFT) {
  1160 + if (default_cs == CS_DBCS || d == DBCS_LEFT)
  1161 + {
1250 1162 add_dbcs = True;
1251 1163 }
1252 1164 }
1253   - if (add_dbcs) {
1254   - if ((baddr - buffer_addr) % 2) {
  1165 + if (add_dbcs)
  1166 + {
  1167 + if ((baddr - buffer_addr) % 2)
  1168 + {
1255 1169 ABORT_WRITE("DBCS RA with odd length");
1256 1170 }
1257 1171 add_c1 = *cp;
1258 1172 cp++;
1259   - if (cp >= buf + buflen) {
  1173 + if (cp >= buf + buflen)
  1174 + {
1260 1175 ABORT_WRITE("missing second half of DBCS character");
1261 1176 }
1262 1177 add_c2 = *cp;
1263   - if (add_c1 == EBC_null) {
1264   - switch (add_c2) {
  1178 + if (add_c1 == EBC_null)
  1179 + {
  1180 + switch (add_c2)
  1181 + {
1265 1182 case EBC_null:
1266 1183 case EBC_nl:
1267 1184 case EBC_em:
... ... @@ -1270,173 +1187,217 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1270 1187 case EBC_dup:
1271 1188 case EBC_fm:
1272 1189 break;
  1190 +
1273 1191 default:
1274   - trace_ds(&h3270," [invalid DBCS RA control character X'%02x%02x'; write aborted]",add_c1, add_c2);
  1192 + trace_ds(hSession," [invalid DBCS RA control character X'%02x%02x'; write aborted]",add_c1, add_c2);
1275 1193 ABORT_WRITEx;
1276 1194 }
1277   - } else if (add_c1 < 0x40 || add_c1 > 0xfe ||
1278   - add_c2 < 0x40 || add_c2 > 0xfe) {
1279   - trace_ds(&h3270," [invalid DBCS RA character X'%02x%02x'; write aborted]",add_c1, add_c2);
  1195 + }
  1196 + else if (add_c1 < 0x40 || add_c1 > 0xfe || add_c2 < 0x40 || add_c2 > 0xfe)
  1197 + {
  1198 + trace_ds(hSession," [invalid DBCS RA character X'%02x%02x'; write aborted]",add_c1, add_c2);
1280 1199 ABORT_WRITEx;
1281   - }
1282   - dbcs_to_mb(add_c1, add_c2, mb);
1283   - trace_ds_nb(&h3270,"'%s'", mb);
1284   - } else
  1200 + }
  1201 + dbcs_to_mb(add_c1, add_c2, mb);
  1202 + trace_ds_nb(hSession,"'%s'", mb);
  1203 + }
  1204 + else
1285 1205 #endif /*]*/
1286 1206 {
1287   - if (*cp == ORDER_GE) {
  1207 + if (*cp == ORDER_GE)
  1208 + {
1288 1209 ra_ge = True;
1289   - trace_ds(&h3270,"GraphicEscape");
  1210 + trace_ds(hSession,"GraphicEscape");
1290 1211 cp++;
1291 1212 }
1292 1213 add_c1 = *cp;
1293 1214 if (add_c1)
1294 1215 trace_ds(&h3270,"'");
1295   - trace_ds(&h3270,"%s", see_ebc(add_c1));
  1216 +
  1217 + trace_ds(hSession,"%s", see_ebc(add_c1));
1296 1218 if (add_c1)
1297   - trace_ds(&h3270,"'");
  1219 + trace_ds(hSession,"'");
  1220 +
1298 1221 }
1299   - if (baddr >= h3270.cols * h3270.rows) {
  1222 + if (baddr >= hSession->cols * hSession->rows)
  1223 + {
1300 1224 ABORT_WRITE("invalid RA address");
1301 1225 }
1302   - do {
1303   - if (add_dbcs) {
1304   - ctlr_add(&h3270,h3270.buffer_addr, add_c1,h3270.default_cs);
1305   - } else {
  1226 + do
  1227 + {
  1228 + if (add_dbcs)
  1229 + {
  1230 + ctlr_add(hSession,hSession->buffer_addr, add_c1,hSession->default_cs);
  1231 + }
  1232 + else
  1233 + {
1306 1234 if (ra_ge)
1307   - ctlr_add(&h3270,h3270.buffer_addr, add_c1,CS_GE);
  1235 + ctlr_add(hSession,h3270.buffer_addr, add_c1,CS_GE);
1308 1236 else if (h3270.default_cs)
1309   - ctlr_add(&h3270,h3270.buffer_addr, add_c1,h3270.default_cs);
  1237 + ctlr_add(hSession,h3270.buffer_addr, add_c1,h3270.default_cs);
1310 1238 else
1311   - ctlr_add(&h3270,h3270.buffer_addr, add_c1,0);
  1239 + ctlr_add(hSession,h3270.buffer_addr, add_c1,0);
1312 1240 }
1313   - ctlr_add_fg(&h3270,h3270.buffer_addr, h3270.default_fg);
1314   - ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr);
1315   - ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic);
1316   - INC_BA(h3270.buffer_addr);
1317   - if (add_dbcs) {
1318   - ctlr_add(&h3270,h3270.buffer_addr, add_c2,h3270.default_cs);
1319   - ctlr_add_fg(&h3270,h3270.buffer_addr, h3270.default_fg);
1320   - ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg);
1321   - ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr);
1322   - ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic);
1323   - INC_BA(h3270.buffer_addr);
  1241 + ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg);
  1242 + ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr);
  1243 + ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic);
  1244 +
  1245 + INC_BA(hSession->buffer_addr);
  1246 + if (add_dbcs)
  1247 + {
  1248 + ctlr_add(hSession,h3270.buffer_addr, add_c2,h3270.default_cs);
  1249 + ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg);
  1250 + ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg);
  1251 + ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr);
  1252 + ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic);
  1253 + INC_BA(hSession->buffer_addr);
1324 1254 }
1325 1255 } while (h3270.buffer_addr != baddr);
  1256 +
1326 1257 current_fa = get_field_attribute(&h3270,h3270.buffer_addr);
1327 1258 last_cmd = True;
1328 1259 last_zpt = False;
1329 1260 break;
  1261 +
1330 1262 case ORDER_EUA: /* erase unprotected to address */
1331 1263 cp += 2; /* skip buffer address */
1332 1264 baddr = DECODE_BADDR(*(cp-1), *cp);
1333 1265 END_TEXT("EraseUnprotectedAll");
1334 1266 if (previous != SBA)
1335   - trace_ds(&h3270,"%s",rcba(&h3270,baddr));
  1267 + trace_ds(hSession,"%s",rcba(hSession,baddr));
  1268 +
1336 1269 previous = ORDER;
1337   - if (baddr >= h3270.cols * h3270.rows) {
  1270 + if (baddr >= h3270.cols * h3270.rows)
  1271 + {
1338 1272 ABORT_WRITE("invalid EUA address");
1339 1273 }
1340 1274 d = ctlr_lookleft_state(buffer_addr, &why);
1341   - if (d == DBCS_RIGHT) {
  1275 + if (d == DBCS_RIGHT)
  1276 + {
1342 1277 ABORT_WRITE("EUA overwriting right half of DBCS character");
1343 1278 }
1344 1279 d = ctlr_lookleft_state(baddr, &why);
1345   - if (d == DBCS_LEFT) {
  1280 + if (d == DBCS_LEFT)
  1281 + {
1346 1282 ABORT_WRITE("EUA overwriting left half of DBCS character");
1347 1283 }
1348   - do {
  1284 + do
  1285 + {
1349 1286 if (h3270.ea_buf[h3270.buffer_addr].fa)
1350 1287 current_fa = h3270.ea_buf[h3270.buffer_addr].fa;
1351   - else if (!FA_IS_PROTECTED(current_fa)) {
  1288 + else if (!FA_IS_PROTECTED(current_fa))
  1289 + {
1352 1290 ctlr_add(&h3270,h3270.buffer_addr, EBC_null,
1353 1291 CS_BASE);
1354 1292 }
1355 1293 INC_BA(h3270.buffer_addr);
1356 1294 } while (h3270.buffer_addr != baddr);
1357   - current_fa = get_field_attribute(&h3270,h3270.buffer_addr);
  1295 + current_fa = get_field_attribute(hSession,h3270.buffer_addr);
1358 1296 last_cmd = True;
1359 1297 last_zpt = False;
1360 1298 break;
  1299 +
1361 1300 case ORDER_GE: /* graphic escape */
1362 1301 /* XXX: DBCS? */
1363 1302 END_TEXT("GraphicEscape ");
1364 1303 cp++; /* skip char */
1365 1304 previous = ORDER;
1366 1305 if (*cp)
1367   - trace_ds(&h3270,"'");
1368   - trace_ds(&h3270,"%s", see_ebc(*cp));
  1306 + trace_ds(hSession,"'");
  1307 + trace_ds(hSession,"%s", see_ebc(*cp));
1369 1308 if (*cp)
1370   - trace_ds(&h3270,"'");
1371   - ctlr_add(&h3270,h3270.buffer_addr, *cp, CS_GE);
1372   - ctlr_add_fg(&h3270,h3270.buffer_addr, h3270.default_fg);
1373   - ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg);
1374   - ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr);
1375   - ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic);
  1309 + trace_ds(hSession,"'");
  1310 +
  1311 + ctlr_add(hSession,h3270.buffer_addr, *cp, CS_GE);
  1312 + ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg);
  1313 + ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg);
  1314 + ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr);
  1315 + ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic);
1376 1316 INC_BA(h3270.buffer_addr);
1377   - current_fa = get_field_attribute(&h3270,h3270.buffer_addr);
  1317 +
  1318 + current_fa = get_field_attribute(hSession,h3270.buffer_addr);
1378 1319 last_cmd = False;
1379 1320 last_zpt = False;
1380 1321 break;
  1322 +
1381 1323 case ORDER_MF: /* modify field */
1382 1324 END_TEXT("ModifyField");
1383 1325 if (previous != SBA)
1384   - trace_ds(&h3270,"%s",rcba(&h3270,h3270.buffer_addr));
  1326 + trace_ds(hSession,"%s",rcba(hSession,h3270.buffer_addr));
1385 1327 previous = ORDER;
1386 1328 cp++;
1387 1329 na = *cp;
1388   - if (h3270.ea_buf[h3270.buffer_addr].fa) {
1389   - for (i = 0; i < (int)na; i++) {
  1330 + if (h3270.ea_buf[h3270.buffer_addr].fa)
  1331 + {
  1332 + for (i = 0; i < (int)na; i++)
  1333 + {
1390 1334 cp++;
1391   - if (*cp == XA_3270) {
1392   - trace_ds(&h3270," 3270");
  1335 + if (*cp == XA_3270)
  1336 + {
  1337 + trace_ds(hSession," 3270");
1393 1338 cp++;
1394   - ctlr_add_fa(&h3270,h3270.buffer_addr, *cp,
  1339 + ctlr_add_fa(hSession,h3270.buffer_addr, *cp,
1395 1340 h3270.ea_buf[h3270.buffer_addr].cs);
1396   - trace_ds(&h3270,"%s",see_attr(*cp));
1397   - } else if (*cp == XA_FOREGROUND) {
1398   - trace_ds(&h3270,"%s",see_efa(*cp,*(cp + 1)));
  1341 + trace_ds(hSession,"%s",see_attr(*cp));
  1342 + }
  1343 + else if (*cp == XA_FOREGROUND)
  1344 + {
  1345 + trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
1399 1346 cp++;
1400   - if (h3270.m3279)
1401   - ctlr_add_fg(&h3270,h3270.buffer_addr, *cp);
1402   - } else if (*cp == XA_BACKGROUND) {
1403   - trace_ds(&h3270,"%s",see_efa(*cp,*(cp + 1)));
  1347 + if (hSession->m3279)
  1348 + ctlr_add_fg(hSession,h3270.buffer_addr, *cp);
  1349 + }
  1350 + else if (*cp == XA_BACKGROUND)
  1351 + {
  1352 + trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
1404 1353 cp++;
1405   - if (h3270.m3279)
1406   - ctlr_add_bg(&h3270,h3270.buffer_addr, *cp);
1407   - } else if (*cp == XA_HIGHLIGHTING) {
1408   - trace_ds(&h3270,"%s",see_efa(*cp,*(cp + 1)));
  1354 + if (hSession->m3279)
  1355 + ctlr_add_bg(hSession,hSession->buffer_addr, *cp);
  1356 + }
  1357 + else if (*cp == XA_HIGHLIGHTING)
  1358 + {
  1359 + trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
1409 1360 cp++;
1410   - ctlr_add_gr(&h3270,h3270.buffer_addr, *cp & 0x0f);
1411   - } else if (*cp == XA_CHARSET) {
  1361 + ctlr_add_gr(hSession,h3270.buffer_addr, *cp & 0x0f);
  1362 + }
  1363 + else if (*cp == XA_CHARSET)
  1364 + {
1412 1365 int cs = 0;
1413 1366  
1414   - trace_ds(&h3270,"%s",see_efa(*cp,*(cp + 1)));
  1367 + trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
1415 1368 cp++;
1416 1369 if (*cp == 0xf1)
1417 1370 cs = CS_APL;
1418 1371 else if (*cp == 0xf8)
1419 1372 cs = CS_DBCS;
1420   - ctlr_add_cs(&h3270,h3270.buffer_addr, cs);
1421   - } else if (*cp == XA_ALL) {
1422   - trace_ds(&h3270,"%s",see_efa(*cp,*(cp + 1)));
  1373 + ctlr_add_cs(hSession,hSession->buffer_addr, cs);
  1374 + }
  1375 + else if (*cp == XA_ALL)
  1376 + {
  1377 + trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
1423 1378 cp++;
1424   - } else if (*cp == XA_INPUT_CONTROL) {
1425   - trace_ds(&h3270,"%s",see_efa(*cp,*(cp + 1)));
1426   - ctlr_add_ic(&h3270,h3270.buffer_addr,
1427   - (*(cp + 1) == 1));
  1379 + }
  1380 + else if (*cp == XA_INPUT_CONTROL)
  1381 + {
  1382 + trace_ds(hSession,"%s",see_efa(*cp,*(cp + 1)));
  1383 + ctlr_add_ic(hSession,hSession->buffer_addr,(*(cp + 1) == 1));
1428 1384 cp++;
1429   - } else {
1430   - trace_ds(&h3270,"%s[unsupported]", see_efa(*cp, *(cp + 1)));
  1385 + }
  1386 + else
  1387 + {
  1388 + trace_ds(hSession,"%s[unsupported]", see_efa(*cp, *(cp + 1)));
1431 1389 cp++;
1432 1390 }
1433 1391 }
1434   - INC_BA(h3270.buffer_addr);
1435   - } else
  1392 + INC_BA(hSession->buffer_addr);
  1393 + }
  1394 + else
1436 1395 cp += na * 2;
  1396 +
1437 1397 last_cmd = True;
1438 1398 last_zpt = False;
1439 1399 break;
  1400 +
1440 1401 case ORDER_SFE: /* start field extended */
1441 1402 END_TEXT("StartFieldExtended");
1442 1403 if (previous != SBA)
... ... @@ -1758,7 +1719,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1758 1719 break;
1759 1720 }
1760 1721 }
1761   - set_formatted(&h3270);
  1722 + set_formatted(hSession);
1762 1723 END_TEXT0;
1763 1724 trace_ds(&h3270,"\n");
1764 1725 if (wcc_keyboard_restore) {
... ... @@ -1769,7 +1730,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1769 1730 status_changed(&h3270,LIB3270_STATUS_SYSWAIT);
1770 1731 }
1771 1732 if (wcc_sound_alarm)
1772   - lib3270_ring_bell(NULL);
  1733 + lib3270_ring_bell(hSession);
1773 1734  
1774 1735 /* Set up the DBCS state. */
1775 1736 if (ctlr_dbcs_postprocess() < 0 && rv == PDS_OKAY_NO_OUTPUT)
... ... @@ -1777,7 +1738,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1777 1738  
1778 1739 h3270.trace_primed = 0;
1779 1740  
1780   - ps_process();
  1741 + ps_process(hSession);
1781 1742  
1782 1743 /* Let a script go. */
1783 1744 // sms_host_output();
... ... @@ -2169,24 +2130,27 @@ ctlr_dbcs_postprocess(void)
2169 2130 }
2170 2131 #endif /*]*/
2171 2132  
2172   -/*
  2133 +/**
2173 2134 * Process pending input.
  2135 + *
  2136 + * @param hSession Session handle.
2174 2137 */
2175   -void
2176   -ps_process(void)
  2138 +void ps_process(H3270 *hSession)
2177 2139 {
2178   - while (run_ta(&h3270))
  2140 + while(run_ta(hSession))
2179 2141 ;
  2142 +
2180 2143 // sms_continue();
2181 2144  
2182 2145 #if defined(X3270_FT)
2183 2146 /* Process file transfers. */
2184   - if (lib3270_get_ft_state(&h3270) != LIB3270_FT_STATE_NONE && /* transfer in progress */
2185   - h3270.formatted && /* screen is formatted */
2186   - !h3270.screen_alt && /* 24x80 screen */
2187   - !h3270.kybdlock && /* keyboard not locked */
  2147 + if (lib3270_get_ft_state(hSession) != LIB3270_FT_STATE_NONE && /* transfer in progress */
  2148 + hSession->formatted && /* screen is formatted */
  2149 + !hSession->screen_alt && /* 24x80 screen */
  2150 + !hSession->kybdlock && /* keyboard not locked */
2188 2151 /* magic field */
2189   - h3270.ea_buf[1919].fa && FA_IS_SKIP(h3270.ea_buf[1919].fa)) {
  2152 + hSession->ea_buf[1919].fa && FA_IS_SKIP(hSession->ea_buf[1919].fa))
  2153 + {
2190 2154 ft_cut_data();
2191 2155 }
2192 2156 #endif
... ... @@ -2397,7 +2361,7 @@ void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int co
2397 2361 */
2398 2362 if (baddr_from + count <= hSession->rows*hSession->cols &&
2399 2363 baddr_to + count <= hSession->rows*hSession->cols) {
2400   - ctlr_bcopy(baddr_from, baddr_to, count, True);
  2364 + ctlr_bcopy(hSession,baddr_from, baddr_to, count, True);
2401 2365 } else {
2402 2366 int i, from, to;
2403 2367  
... ... @@ -2411,26 +2375,27 @@ void ctlr_wrapping_memmove(H3270 *hSession, int baddr_to, int baddr_from, int co
2411 2375 to = (baddr_to + i) % hSession->rows*hSession->cols;
2412 2376 from = (baddr_from + i) % hSession->rows*hSession->cols;
2413 2377 }
2414   - ctlr_bcopy(from, to, 1, True);
  2378 + ctlr_bcopy(hSession,from, to, 1, True);
2415 2379 }
2416 2380 }
2417 2381 }
2418 2382  
2419   -/*
  2383 +/**
  2384 + * Copy a block of characters in the 3270 buffer.
  2385 + *
2420 2386 * Copy a block of characters in the 3270 buffer, optionally including all of
2421 2387 * the extended attributes. (The character set, which is actually kept in the
2422 2388 * extended attributes, is considered part of the characters here.)
  2389 + *
  2390 + * @param hSession Session handle
2423 2391 */
2424   -void
2425   -ctlr_bcopy(int baddr_from, int baddr_to, int count, int move_ea)
  2392 +void ctlr_bcopy(H3270 *hSession, int baddr_from, int baddr_to, int count, int move_ea)
2426 2393 {
2427 2394 /* Move the characters. */
2428   - if (memcmp((char *) &h3270.ea_buf[baddr_from],
2429   - (char *) &h3270.ea_buf[baddr_to],
2430   - count * sizeof(struct lib3270_ea))) {
2431   - (void) memmove(&h3270.ea_buf[baddr_to], &h3270.ea_buf[baddr_from],
2432   - count * sizeof(struct lib3270_ea));
2433   - REGION_CHANGED(&h3270,baddr_to, baddr_to + count);
  2395 + if (memcmp((char *) &hSession->ea_buf[baddr_from],(char *) &hSession->ea_buf[baddr_to],count * sizeof(struct lib3270_ea)))
  2396 + {
  2397 + (void) memmove(&hSession->ea_buf[baddr_to], &hSession->ea_buf[baddr_from],count * sizeof(struct lib3270_ea));
  2398 + REGION_CHANGED(hSession,baddr_to, baddr_to + count);
2434 2399 }
2435 2400 /* XXX: What about move_ea? */
2436 2401 }
... ... @@ -2530,29 +2495,28 @@ void ctlr_altbuffer(H3270 *session, int alt)
2530 2495 /*
2531 2496 * Set or clear the MDT on an attribute
2532 2497 */
2533   -void
2534   -mdt_set(int baddr)
  2498 +void mdt_set(H3270 *hSession, int baddr)
2535 2499 {
2536 2500 int faddr;
2537 2501  
2538   - faddr = find_field_attribute(&h3270,baddr);
2539   - if (faddr >= 0 && !(h3270.ea_buf[faddr].fa & FA_MODIFY)) {
2540   - h3270.ea_buf[faddr].fa |= FA_MODIFY;
2541   - if (h3270.modified_sel)
2542   - ALL_CHANGED(&h3270);
  2502 + faddr = find_field_attribute(hSession,baddr);
  2503 + if (faddr >= 0 && !(hSession->ea_buf[faddr].fa & FA_MODIFY))
  2504 + {
  2505 + hSession->ea_buf[faddr].fa |= FA_MODIFY;
  2506 + if (hSession->modified_sel)
  2507 + ALL_CHANGED(hSession);
2543 2508 }
2544 2509 }
2545 2510  
2546   -void
2547   -mdt_clear(int baddr)
  2511 +void mdt_clear(H3270 *hSession, int baddr)
2548 2512 {
2549   - int faddr;
  2513 + int faddr = find_field_attribute(hSession,baddr);
2550 2514  
2551   - faddr = find_field_attribute(&h3270,baddr);
2552   - if (faddr >= 0 && (h3270.ea_buf[faddr].fa & FA_MODIFY)) {
2553   - h3270.ea_buf[faddr].fa &= ~FA_MODIFY;
2554   - if (h3270.modified_sel)
2555   - ALL_CHANGED(&h3270);
  2515 + if (faddr >= 0 && (hSession->ea_buf[faddr].fa & FA_MODIFY))
  2516 + {
  2517 + hSession->ea_buf[faddr].fa &= ~FA_MODIFY;
  2518 + if (hSession->modified_sel)
  2519 + ALL_CHANGED(hSession);
2556 2520 }
2557 2521 }
2558 2522  
... ...
ctlrc.h
... ... @@ -48,8 +48,7 @@ LIB3270_INTERNAL void ctlr_add_fg(H3270 *hSession, int baddr, unsigned char colo
48 48 LIB3270_INTERNAL void ctlr_add_gr(H3270 *hSession, int baddr, unsigned char gr);
49 49 LIB3270_INTERNAL void ctlr_altbuffer(H3270 *session, int alt);
50 50 LIB3270_INTERNAL int ctlr_any_data(H3270 *session);
51   -LIB3270_INTERNAL void ctlr_bcopy(int baddr_from, int baddr_to, int count, int move_ea);
52   -// LIB3270_INTERNAL void ctlr_changed(int bstart, int bend);
  51 +LIB3270_INTERNAL void ctlr_bcopy(H3270 *hSession, int baddr_from, int baddr_to, int count, int move_ea);
53 52 LIB3270_INTERNAL void ctlr_clear(H3270 *hSession, Boolean can_snap);
54 53 LIB3270_INTERNAL void ctlr_erase_all_unprotected(H3270 *hSession);
55 54 LIB3270_INTERNAL void ctlr_init(H3270 *session, unsigned cmask);
... ... @@ -57,28 +56,20 @@ LIB3270_INTERNAL void ctlr_read_buffer(H3270 *session, unsigned char aid_byte);
57 56 LIB3270_INTERNAL void ctlr_read_modified(H3270 *hSession, unsigned char aid_byte, Boolean all);
58 57 LIB3270_INTERNAL void ctlr_reinit(H3270 *session, unsigned cmask);
59 58 LIB3270_INTERNAL void ctlr_scroll(H3270 *hSession);
60   -// LIB3270_INTERNAL void ctlr_shrink(void);
61   -// LIB3270_INTERNAL void ctlr_snap_buffer(void);
62   -// LIB3270_INTERNAL Boolean ctlr_snap_modes(void);
63 59 LIB3270_INTERNAL void ctlr_wrapping_memmove(H3270 *session, int baddr_to, int baddr_from, int count);
64   -LIB3270_INTERNAL enum pds ctlr_write(unsigned char buf[], int buflen, Boolean erase);
  60 +LIB3270_INTERNAL enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean erase);
65 61 LIB3270_INTERNAL void ctlr_write_sscp_lu(H3270 *session, unsigned char buf[], int buflen);
66   -// LIB3270_INTERNAL struct ea *fa2ea(int baddr);
67   -
68   -// LIB3270_INTERNAL Boolean get_bounded_field_attribute(register int baddr, register int bound, unsigned char *fa_out);
69   -LIB3270_INTERNAL void mdt_clear(int baddr);
70   -LIB3270_INTERNAL void mdt_set(int baddr);
  62 +LIB3270_INTERNAL void mdt_clear(H3270 *hSession, int baddr);
  63 +LIB3270_INTERNAL void mdt_set(H3270 *hSession, int baddr);
71 64 LIB3270_INTERNAL int next_unprotected(H3270 *session, int baddr0);
72 65 LIB3270_INTERNAL enum pds process_ds(H3270 *hSession, unsigned char *buf, int buflen);
73   -LIB3270_INTERNAL void ps_process(void);
  66 +LIB3270_INTERNAL void ps_process(H3270 *hSession);
74 67  
75 68 LIB3270_INTERNAL void update_model_info(H3270 *session, int model, int cols, int rows);
76 69 LIB3270_INTERNAL void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr);
77 70 LIB3270_INTERNAL void ctlr_erase(H3270 *session, int alt);
78 71  
79 72 LIB3270_INTERNAL void ticking_start(H3270 *session, Boolean anyway);
80   -// LIB3270_INTERNAL void toggle_nop(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt);
81   -// LIB3270_INTERNAL void toggle_showTiming(struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt);
82 73  
83 74 enum dbcs_state {
84 75 DBCS_NONE = 0, /* position is not DBCS */
... ... @@ -93,30 +84,14 @@ enum dbcs_state {
93 84 #define IS_LEFT(d) ((d) == DBCS_LEFT || (d) == DBCS_LEFT_WRAP)
94 85 #define IS_RIGHT(d) ((d) == DBCS_RIGHT || (d) == DBCS_RIGHT_WRAP)
95 86 #define IS_DBCS(d) (IS_LEFT(d) || IS_RIGHT(d))
96   -
97   -/*
98   -#define MAKE_LEFT(b) { \
99   - if (((b) % COLS) == ((ROWS * COLS) - 1)) \
100   - ea_buf[(b)].db = DBCS_LEFT_WRAP; \
101   - else \
102   - ea_buf[(b)].db = DBCS_LEFT; \
103   -}
104   -#define MAKE_RIGHT(b) { \
105   - if (!((b) % COLS)) \
106   - ea_buf[(b)].db = DBCS_RIGHT_WRAP; \
107   - else \
108   - ea_buf[(b)].db = DBCS_RIGHT; \
109   -}
110   -*/
111   -
112 87 #define SOSI(c) (((c) == EBC_so)? EBC_si: EBC_so)
113 88  
114 89 enum dbcs_why { DBCS_FIELD, DBCS_SUBFIELD, DBCS_ATTRIBUTE };
115 90  
116 91 #if defined(X3270_DBCS) /*[*/
117   -LIB3270_INTERNAL enum dbcs_state ctlr_dbcs_state(int baddr);
118   -LIB3270_INTERNAL enum dbcs_state ctlr_lookleft_state(int baddr, enum dbcs_why *why);
119   -LIB3270_INTERNAL int ctlr_dbcs_postprocess(void);
  92 + LIB3270_INTERNAL enum dbcs_state ctlr_dbcs_state(int baddr);
  93 + LIB3270_INTERNAL enum dbcs_state ctlr_lookleft_state(int baddr, enum dbcs_why *why);
  94 + LIB3270_INTERNAL int ctlr_dbcs_postprocess(void);
120 95 #else /*][*/
121 96 #define ctlr_dbcs_state(b) DBCS_NONE
122 97 #define ctlr_lookleft_state(b, w) DBCS_NONE
... ...
kybd.c
... ... @@ -467,7 +467,7 @@ void kybd_in3270(H3270 *session, int in3270 unused, void *dunno)
467 467  
468 468 /* There might be a macro pending. */
469 469 if (CONNECTED)
470   - ps_process();
  470 + ps_process(session);
471 471 }
472 472  
473 473 /*
... ... @@ -945,7 +945,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
945 945 }
946 946 }
947 947  
948   - mdt_set(h3270.cursor_addr);
  948 + mdt_set(&h3270,h3270.cursor_addr);
949 949  
950 950 /*
951 951 * Implement auto-skip, and don't land on attribute bytes.
... ... @@ -1101,7 +1101,7 @@ static void defer_unlock(H3270 *session)
1101 1101 lib3270_kybdlock_clear(session,KL_DEFERRED_UNLOCK);
1102 1102 status_reset(session);
1103 1103 if(CONNECTED)
1104   - ps_process();
  1104 + ps_process(session);
1105 1105 }
1106 1106  
1107 1107 /*
... ... @@ -1257,12 +1257,14 @@ LIB3270_CURSOR_ACTION( left )
1257 1257 }
1258 1258  
1259 1259  
1260   -/*
  1260 +/**
1261 1261 * Delete char key.
1262   - * Returns "True" if succeeds, "False" otherwise.
  1262 + *
  1263 + * @param hSession Session handle
  1264 + *
  1265 + * @Return "True" if succeeds, "False" otherwise.
1263 1266 */
1264   -static Boolean
1265   -do_delete(void)
  1267 +static Boolean do_delete(H3270 *hSession)
1266 1268 {
1267 1269 register int baddr, end_baddr;
1268 1270 int xaddr;
... ... @@ -1270,67 +1272,81 @@ do_delete(void)
1270 1272 int ndel;
1271 1273 register int i;
1272 1274  
1273   - baddr = h3270.cursor_addr;
  1275 + baddr = hSession->cursor_addr;
1274 1276  
1275 1277 /* Can't delete a field attribute. */
1276   - fa = get_field_attribute(&h3270,baddr);
1277   - if (FA_IS_PROTECTED(fa) || h3270.ea_buf[baddr].fa) {
1278   - operator_error(&h3270,KL_OERR_PROTECTED);
  1278 + fa = get_field_attribute(hSession,baddr);
  1279 + if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa)
  1280 + {
  1281 + operator_error(hSession,KL_OERR_PROTECTED);
1279 1282 return False;
1280 1283 }
1281   - if (h3270.ea_buf[baddr].cc == EBC_so || h3270.ea_buf[baddr].cc == EBC_si) {
  1284 +
  1285 + if (hSession->ea_buf[baddr].cc == EBC_so || hSession->ea_buf[baddr].cc == EBC_si)
  1286 + {
1282 1287 /*
1283 1288 * Can't delete SO or SI, unless it's adjacent to its
1284 1289 * opposite.
1285 1290 */
1286 1291 xaddr = baddr;
1287 1292 INC_BA(xaddr);
1288   - if (h3270.ea_buf[xaddr].cc == SOSI(h3270.ea_buf[baddr].cc)) {
  1293 + if (hSession->ea_buf[xaddr].cc == SOSI(hSession->ea_buf[baddr].cc))
  1294 + {
1289 1295 ndel = 2;
1290   - } else {
1291   - operator_error(&h3270,KL_OERR_PROTECTED);
  1296 + }
  1297 + else
  1298 + {
  1299 + operator_error(hSession,KL_OERR_PROTECTED);
1292 1300 return False;
1293 1301 }
1294   - } else if (IS_DBCS(h3270.ea_buf[baddr].db)) {
1295   - if (IS_RIGHT(h3270.ea_buf[baddr].db))
  1302 + }
  1303 + else if (IS_DBCS(hSession->ea_buf[baddr].db))
  1304 + {
  1305 + if (IS_RIGHT(hSession->ea_buf[baddr].db))
1296 1306 DEC_BA(baddr);
1297 1307 ndel = 2;
1298   - } else
  1308 + }
  1309 + else
1299 1310 ndel = 1;
1300 1311  
1301 1312 /* find next fa */
1302   - if (h3270.formatted) {
  1313 + if (hSession->formatted)
  1314 + {
1303 1315 end_baddr = baddr;
1304   - do {
  1316 + do
  1317 + {
1305 1318 INC_BA(end_baddr);
1306   - if (h3270.ea_buf[end_baddr].fa)
  1319 + if (hSession->ea_buf[end_baddr].fa)
1307 1320 break;
1308 1321 } while (end_baddr != baddr);
1309 1322 DEC_BA(end_baddr);
1310   - } else {
1311   - if ((baddr % h3270.cols) == h3270.cols - ndel)
  1323 + }
  1324 + else
  1325 + {
  1326 + if ((baddr % hSession->cols) == hSession->cols - ndel)
1312 1327 return True;
1313   - end_baddr = baddr + (h3270.cols - (baddr % h3270.cols)) - 1;
  1328 + end_baddr = baddr + (hSession->cols - (baddr % hSession->cols)) - 1;
1314 1329 }
1315 1330  
1316 1331 /* Shift the remainder of the field left. */
1317   - if (end_baddr > baddr) {
1318   - ctlr_bcopy(baddr + ndel, baddr, end_baddr - (baddr + ndel) + 1,
1319   - 0);
1320   - } else if (end_baddr != baddr) {
  1332 + if (end_baddr > baddr)
  1333 + {
  1334 + ctlr_bcopy(hSession,baddr + ndel, baddr, end_baddr - (baddr + ndel) + 1, 0);
  1335 + }
  1336 + else if (end_baddr != baddr)
  1337 + {
1321 1338 /* XXX: Need to verify this. */
1322   - ctlr_bcopy(baddr + ndel, baddr,
1323   - ((h3270.rows * h3270.cols) - 1) - (baddr + ndel) + 1, 0);
1324   - ctlr_bcopy(0, (h3270.rows * h3270.cols) - ndel, ndel, 0);
1325   - ctlr_bcopy(ndel, 0, end_baddr - ndel + 1, 0);
  1339 + ctlr_bcopy(hSession,baddr + ndel, baddr,((hSession->rows * hSession->cols) - 1) - (baddr + ndel) + 1, 0);
  1340 + ctlr_bcopy(hSession,0, (hSession->rows * hSession->cols) - ndel, ndel, 0);
  1341 + ctlr_bcopy(hSession,ndel, 0, end_baddr - ndel + 1, 0);
1326 1342 }
1327 1343  
1328 1344 /* NULL fill at the end. */
1329 1345 for (i = 0; i < ndel; i++)
1330   - ctlr_add(&h3270,end_baddr - i, EBC_null, 0);
  1346 + ctlr_add(hSession,end_baddr - i, EBC_null, 0);
1331 1347  
1332 1348 /* Set the MDT for this field. */
1333   - mdt_set(h3270.cursor_addr);
  1349 + mdt_set(hSession,hSession->cursor_addr);
1334 1350  
1335 1351 /* Patch up the DBCS state for display. */
1336 1352 (void) ctlr_dbcs_postprocess();
... ... @@ -1351,7 +1367,7 @@ LIB3270_ACTION( delete )
1351 1367 return 0;
1352 1368 }
1353 1369 #endif /*]*/
1354   - if (!do_delete())
  1370 + if (!do_delete(hSession))
1355 1371 return 0;
1356 1372 if (hSession->reverse)
1357 1373 {
... ... @@ -1383,7 +1399,7 @@ LIB3270_ACTION( backspace )
1383 1399 }
1384 1400 #endif /*]*/
1385 1401 if (hSession->reverse)
1386   - (void) do_delete();
  1402 + (void) do_delete(hSession);
1387 1403 else if (!hSession->flipped)
1388 1404 do_left(hSession);
1389 1405 else {
... ... @@ -1446,7 +1462,7 @@ static void do_erase(H3270 *hSession)
1446 1462 /*
1447 1463 * Try to delete this character.
1448 1464 */
1449   - if (!do_delete())
  1465 + if (!do_delete(hSession))
1450 1466 return;
1451 1467  
1452 1468 /*
... ... @@ -1458,7 +1474,7 @@ static void do_erase(H3270 *hSession)
1458 1474 if (hSession->ea_buf[baddr].cc == EBC_so && hSession->ea_buf[hSession->cursor_addr].cc == EBC_si)
1459 1475 {
1460 1476 cursor_move(hSession,baddr);
1461   - (void) do_delete();
  1477 + (void) do_delete(hSession);
1462 1478 }
1463 1479 hSession->display(hSession);
1464 1480 }
... ... @@ -1595,19 +1611,19 @@ LIB3270_ACTION( previousword )
1595 1611  
1596 1612  
1597 1613 /* Find the next unprotected word, or -1 */
1598   -static int
1599   -nu_word(int baddr)
  1614 +static int nu_word(H3270 *hSession, int baddr)
1600 1615 {
1601 1616 int baddr0 = baddr;
1602 1617 unsigned char c;
1603 1618 Boolean prot;
1604 1619  
1605   - prot = FA_IS_PROTECTED(get_field_attribute(&h3270,baddr));
  1620 + prot = FA_IS_PROTECTED(get_field_attribute(hSession,baddr));
1606 1621  
1607   - do {
1608   - c = h3270.ea_buf[baddr].cc;
1609   - if (h3270.ea_buf[baddr].fa)
1610   - prot = FA_IS_PROTECTED(h3270.ea_buf[baddr].fa);
  1622 + do
  1623 + {
  1624 + c = hSession->ea_buf[baddr].cc;
  1625 + if (hSession->ea_buf[baddr].fa)
  1626 + prot = FA_IS_PROTECTED(hSession->ea_buf[baddr].fa);
1611 1627 else if (!prot && c != EBC_space && c != EBC_null)
1612 1628 return baddr;
1613 1629 INC_BA(baddr);
... ... @@ -1666,7 +1682,7 @@ LIB3270_ACTION( nextword )
1666 1682 /* If not in an unprotected field, go to the next unprotected word. */
1667 1683 if (hSession->ea_buf[hSession->cursor_addr].fa ||
1668 1684 FA_IS_PROTECTED(get_field_attribute(hSession,hSession->cursor_addr))) {
1669   - baddr = nu_word(hSession->cursor_addr);
  1685 + baddr = nu_word(hSession,hSession->cursor_addr);
1670 1686 if (baddr != -1)
1671 1687 cursor_move(hSession,baddr);
1672 1688 return 0;
... ... @@ -1689,7 +1705,7 @@ LIB3270_ACTION( nextword )
1689 1705 cursor_move(hSession,baddr);
1690 1706 return 0;
1691 1707 } else if (hSession->ea_buf[baddr].fa) {
1692   - baddr = nu_word(baddr);
  1708 + baddr = nu_word(hSession,baddr);
1693 1709 if (baddr != -1)
1694 1710 cursor_move(hSession,baddr);
1695 1711 return 0;
... ... @@ -1699,7 +1715,7 @@ LIB3270_ACTION( nextword )
1699 1715 }
1700 1716 /* Otherwise, go to the next unprotected word. */
1701 1717 else {
1702   - baddr = nu_word(hSession->cursor_addr);
  1718 + baddr = nu_word(hSession,hSession->cursor_addr);
1703 1719 if (baddr != -1)
1704 1720 cursor_move(hSession,baddr);
1705 1721 }
... ... @@ -1968,7 +1984,7 @@ LIB3270_ACTION( eraseeol )
1968 1984 INC_BA(baddr);
1969 1985 } while (!h3270.ea_buf[baddr].fa && BA_TO_COL(baddr) > 0);
1970 1986  
1971   - mdt_set(h3270.cursor_addr);
  1987 + mdt_set(hSession,hSession->cursor_addr);
1972 1988 }
1973 1989 else
1974 1990 {
... ... @@ -2027,7 +2043,7 @@ LIB3270_ACTION( eraseeof )
2027 2043 ctlr_add(&h3270,baddr, EBC_null, 0);
2028 2044 INC_BA(baddr);
2029 2045 } while (!h3270.ea_buf[baddr].fa);
2030   - mdt_set(hSession->cursor_addr);
  2046 + mdt_set(hSession,hSession->cursor_addr);
2031 2047 } else { /* erase to end of screen */
2032 2048 do {
2033 2049 ctlr_add(&h3270,baddr, EBC_null, 0);
... ... @@ -2078,7 +2094,7 @@ LIB3270_ACTION( eraseinput )
2078 2094 do {
2079 2095 fa = hSession->ea_buf[baddr].fa;
2080 2096 if (!FA_IS_PROTECTED(fa)) {
2081   - mdt_clear(baddr);
  2097 + mdt_clear(hSession,baddr);
2082 2098 do {
2083 2099 INC_BA(baddr);
2084 2100 if (!f) {
... ... @@ -2211,7 +2227,7 @@ LIB3270_ACTION( deletefield )
2211 2227 while (!hSession->ea_buf[baddr].fa)
2212 2228 DEC_BA(baddr);
2213 2229 INC_BA(baddr);
2214   - mdt_set(hSession->cursor_addr);
  2230 + mdt_set(hSession,hSession->cursor_addr);
2215 2231 cursor_move(hSession,baddr);
2216 2232 while (!hSession->ea_buf[baddr].fa) {
2217 2233 ctlr_add(hSession,baddr, EBC_null, 0);
... ...
sf.c
... ... @@ -387,21 +387,25 @@ sf_read_part(unsigned char buf[], unsigned buflen)
387 387 static enum pds
388 388 sf_erase_reset(unsigned char buf[], int buflen)
389 389 {
390   - if (buflen != 4) {
  390 + if (buflen != 4)
  391 + {
391 392 trace_ds(&h3270," error: wrong field length %d\n", buflen);
392 393 return PDS_BAD_CMD;
393 394 }
394 395  
395   - switch (buf[3]) {
396   - case SF_ER_DEFAULT:
  396 + switch (buf[3])
  397 + {
  398 + case SF_ER_DEFAULT:
397 399 trace_ds(&h3270," Default\n");
398   - ctlr_erase(NULL,False);
  400 + ctlr_erase(&h3270,False);
399 401 break;
400   - case SF_ER_ALT:
  402 +
  403 + case SF_ER_ALT:
401 404 trace_ds(&h3270," Alternate\n");
402   - ctlr_erase(NULL,True);
  405 + ctlr_erase(&h3270,True);
403 406 break;
404   - default:
  407 +
  408 + default:
405 409 trace_ds(&h3270," unknown type 0x%02x\n", buf[3]);
406 410 return PDS_BAD_CMD;
407 411 }
... ... @@ -613,7 +617,7 @@ sf_outbound_ds(unsigned char buf[], int buflen)
613 617 case SNA_CMD_W:
614 618 trace_ds(&h3270," Write");
615 619 if (buflen > 5) {
616   - if ((rv = ctlr_write(&buf[4], buflen-4, False)) < 0)
  620 + if ((rv = ctlr_write(&h3270,&buf[4], buflen-4, False)) < 0)
617 621 return rv;
618 622 } else
619 623 trace_ds(&h3270,"\n");
... ... @@ -622,7 +626,7 @@ sf_outbound_ds(unsigned char buf[], int buflen)
622 626 trace_ds(&h3270," EraseWrite");
623 627 ctlr_erase(&h3270,h3270.screen_alt);
624 628 if (buflen > 5) {
625   - if ((rv = ctlr_write(&buf[4], buflen-4, True)) < 0)
  629 + if ((rv = ctlr_write(&h3270,&buf[4], buflen-4, True)) < 0)
626 630 return rv;
627 631 } else
628 632 trace_ds(&h3270,"\n");
... ... @@ -631,7 +635,7 @@ sf_outbound_ds(unsigned char buf[], int buflen)
631 635 trace_ds(&h3270," EraseWriteAlternate");
632 636 ctlr_erase(&h3270,h3270.screen_alt);
633 637 if (buflen > 5) {
634   - if ((rv = ctlr_write(&buf[4], buflen-4, True)) < 0)
  638 + if ((rv = ctlr_write(&h3270,&buf[4], buflen-4, True)) < 0)
635 639 return rv;
636 640 } else
637 641 trace_ds(&h3270,"\n");
... ...
telnet.c
... ... @@ -1241,7 +1241,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1241 1241 host_in3270(session,CONNECTED_ANSI);
1242 1242 lib3270_kybdlock_clear(session,KL_AWAITING_FIRST);
1243 1243 status_reset(session);
1244   - ps_process();
  1244 + ps_process(session);
1245 1245 }
1246 1246 if (IN_ANSI && !IN_E) {
1247 1247 #if defined(X3270_ANSI) /*[*/
... ... @@ -3213,9 +3213,9 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3213 3213  
3214 3214 if(e != 0)
3215 3215 {
3216   - if(e == h3270.last_ssl_error)
  3216 + if(e == hSession->last_ssl_error)
3217 3217 return;
3218   - h3270.last_ssl_error = e;
  3218 + hSession->last_ssl_error = e;
3219 3219 (void) ERR_error_string_n(e, err_buf, 1023);
3220 3220 }
3221 3221 #if defined(_WIN32)
... ...