Commit e297096d75c0bdd1c2cdc946a910cc12d919d836
1 parent
320371b5
Exists in
master
and in
3 other branches
Migrando mais funções da API para a versão multi-sessão
Showing
6 changed files
with
259 additions
and
214 deletions
Show diff stats
ctlr.c
@@ -547,7 +547,7 @@ static void insert_sa1(H3270 *hSession, unsigned char attr, unsigned char value, | @@ -547,7 +547,7 @@ static void insert_sa1(H3270 *hSession, unsigned char attr, unsigned char value, | ||
547 | if (value == *currentp) | 547 | if (value == *currentp) |
548 | return; | 548 | return; |
549 | *currentp = value; | 549 | *currentp = value; |
550 | - space3270out(3); | 550 | + space3270out(hSession,3); |
551 | *hSession->obptr++ = ORDER_SA; | 551 | *hSession->obptr++ = ORDER_SA; |
552 | *hSession->obptr++ = attr; | 552 | *hSession->obptr++ = attr; |
553 | *hSession->obptr++ = value; | 553 | *hSession->obptr++ = value; |
@@ -633,7 +633,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | @@ -633,7 +633,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | ||
633 | switch (aid_byte) { | 633 | switch (aid_byte) { |
634 | 634 | ||
635 | case AID_SYSREQ: /* test request */ | 635 | case AID_SYSREQ: /* test request */ |
636 | - space3270out(4); | 636 | + space3270out(&h3270,4); |
637 | *h3270.obptr++ = 0x01; /* soh */ | 637 | *h3270.obptr++ = 0x01; /* soh */ |
638 | *h3270.obptr++ = 0x5b; /* % */ | 638 | *h3270.obptr++ = 0x5b; /* % */ |
639 | *h3270.obptr++ = 0x61; /* / */ | 639 | *h3270.obptr++ = 0x61; /* / */ |
@@ -656,7 +656,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | @@ -656,7 +656,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | ||
656 | 656 | ||
657 | default: /* ordinary AID */ | 657 | default: /* ordinary AID */ |
658 | if (!IN_SSCP) { | 658 | if (!IN_SSCP) { |
659 | - space3270out(3); | 659 | + space3270out(&h3270,3); |
660 | *h3270.obptr++ = aid_byte; | 660 | *h3270.obptr++ = aid_byte; |
661 | trace_ds("%s",see_aid(aid_byte)); | 661 | trace_ds("%s",see_aid(aid_byte)); |
662 | if (short_read) | 662 | if (short_read) |
@@ -664,7 +664,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | @@ -664,7 +664,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | ||
664 | ENCODE_BADDR(h3270.obptr, h3270.cursor_addr); | 664 | ENCODE_BADDR(h3270.obptr, h3270.cursor_addr); |
665 | trace_ds("%s",rcba(&h3270,h3270.cursor_addr)); | 665 | trace_ds("%s",rcba(&h3270,h3270.cursor_addr)); |
666 | } else { | 666 | } else { |
667 | - space3270out(1); /* just in case */ | 667 | + space3270out(&h3270,1); /* just in case */ |
668 | } | 668 | } |
669 | break; | 669 | break; |
670 | } | 670 | } |
@@ -683,7 +683,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | @@ -683,7 +683,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | ||
683 | Boolean any = False; | 683 | Boolean any = False; |
684 | 684 | ||
685 | INC_BA(baddr); | 685 | INC_BA(baddr); |
686 | - space3270out(3); | 686 | + space3270out(&h3270,3); |
687 | *h3270.obptr++ = ORDER_SBA; | 687 | *h3270.obptr++ = ORDER_SBA; |
688 | ENCODE_BADDR(h3270.obptr, baddr); | 688 | ENCODE_BADDR(h3270.obptr, baddr); |
689 | trace_ds(" SetBufferAddress%s (Cols: %d Rows: %d)", rcba(&h3270,baddr), h3270.cols, h3270.rows); | 689 | trace_ds(" SetBufferAddress%s (Cols: %d Rows: %d)", rcba(&h3270,baddr), h3270.cols, h3270.rows); |
@@ -693,14 +693,14 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | @@ -693,14 +693,14 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | ||
693 | h3270.ea_buf[baddr].cc) { | 693 | h3270.ea_buf[baddr].cc) { |
694 | insert_sa(&h3270,baddr,¤t_fg,¤t_bg,¤t_gr,¤t_cs,&any); | 694 | insert_sa(&h3270,baddr,¤t_fg,¤t_bg,¤t_gr,¤t_cs,&any); |
695 | if (h3270.ea_buf[baddr].cs & CS_GE) { | 695 | if (h3270.ea_buf[baddr].cs & CS_GE) { |
696 | - space3270out(1); | 696 | + space3270out(&h3270,1); |
697 | *h3270.obptr++ = ORDER_GE; | 697 | *h3270.obptr++ = ORDER_GE; |
698 | if (any) | 698 | if (any) |
699 | trace_ds("'"); | 699 | trace_ds("'"); |
700 | trace_ds(" GraphicEscape"); | 700 | trace_ds(" GraphicEscape"); |
701 | any = False; | 701 | any = False; |
702 | } | 702 | } |
703 | - space3270out(1); | 703 | + space3270out(&h3270,1); |
704 | *h3270.obptr++ = h3270.ea_buf[baddr].cc; | 704 | *h3270.obptr++ = h3270.ea_buf[baddr].cc; |
705 | if (!any) | 705 | if (!any) |
706 | trace_ds(" '"); | 706 | trace_ds(" '"); |
@@ -733,14 +733,14 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | @@ -733,14 +733,14 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | ||
733 | if (h3270.ea_buf[baddr].cc) { | 733 | if (h3270.ea_buf[baddr].cc) { |
734 | insert_sa(&h3270,baddr,¤t_fg,¤t_bg,¤t_gr,¤t_cs,&any); | 734 | insert_sa(&h3270,baddr,¤t_fg,¤t_bg,¤t_gr,¤t_cs,&any); |
735 | if (h3270.ea_buf[baddr].cs & CS_GE) { | 735 | if (h3270.ea_buf[baddr].cs & CS_GE) { |
736 | - space3270out(1); | 736 | + space3270out(&h3270,1); |
737 | *h3270.obptr++ = ORDER_GE; | 737 | *h3270.obptr++ = ORDER_GE; |
738 | if (any) | 738 | if (any) |
739 | trace_ds("' "); | 739 | trace_ds("' "); |
740 | trace_ds(" GraphicEscape "); | 740 | trace_ds(" GraphicEscape "); |
741 | any = False; | 741 | any = False; |
742 | } | 742 | } |
743 | - space3270out(1); | 743 | + space3270out(&h3270,1); |
744 | *h3270.obptr++ = h3270.ea_buf[baddr].cc; | 744 | *h3270.obptr++ = h3270.ea_buf[baddr].cc; |
745 | if (!any) | 745 | if (!any) |
746 | trace_ds("%s","'"); | 746 | trace_ds("%s","'"); |
@@ -763,7 +763,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | @@ -763,7 +763,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) | ||
763 | 763 | ||
764 | rm_done: | 764 | rm_done: |
765 | trace_ds("\n"); | 765 | trace_ds("\n"); |
766 | - net_output(); | 766 | + net_output(&h3270); |
767 | } | 767 | } |
768 | 768 | ||
769 | /* | 769 | /* |
@@ -791,7 +791,7 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | @@ -791,7 +791,7 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | ||
791 | trace_ds("> "); | 791 | trace_ds("> "); |
792 | hSession->obptr = hSession->obuf; | 792 | hSession->obptr = hSession->obuf; |
793 | 793 | ||
794 | - space3270out(3); | 794 | + space3270out(hSession,3); |
795 | *hSession->obptr++ = aid_byte; | 795 | *hSession->obptr++ = aid_byte; |
796 | ENCODE_BADDR(hSession->obptr, hSession->cursor_addr); | 796 | ENCODE_BADDR(hSession->obptr, hSession->cursor_addr); |
797 | trace_ds("%s%s", see_aid(aid_byte), rcba(hSession,hSession->cursor_addr)); | 797 | trace_ds("%s%s", see_aid(aid_byte), rcba(hSession,hSession->cursor_addr)); |
@@ -802,12 +802,12 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | @@ -802,12 +802,12 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | ||
802 | { | 802 | { |
803 | if (hSession->reply_mode == SF_SRM_FIELD) | 803 | if (hSession->reply_mode == SF_SRM_FIELD) |
804 | { | 804 | { |
805 | - space3270out(2); | 805 | + space3270out(hSession,2); |
806 | *hSession->obptr++ = ORDER_SF; | 806 | *hSession->obptr++ = ORDER_SF; |
807 | } | 807 | } |
808 | else | 808 | else |
809 | { | 809 | { |
810 | - space3270out(4); | 810 | + space3270out(hSession,4); |
811 | *hSession->obptr++ = ORDER_SFE; | 811 | *hSession->obptr++ = ORDER_SFE; |
812 | attr_count = hSession->obptr - hSession->obuf; | 812 | attr_count = hSession->obptr - hSession->obuf; |
813 | *hSession->obptr++ = 1; /* for now */ | 813 | *hSession->obptr++ = 1; /* for now */ |
@@ -825,21 +825,21 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | @@ -825,21 +825,21 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | ||
825 | if (hSession->reply_mode != SF_SRM_FIELD) | 825 | if (hSession->reply_mode != SF_SRM_FIELD) |
826 | { | 826 | { |
827 | if (hSession->ea_buf[baddr].fg) { | 827 | if (hSession->ea_buf[baddr].fg) { |
828 | - space3270out(2); | 828 | + space3270out(hSession,2); |
829 | *hSession->obptr++ = XA_FOREGROUND; | 829 | *hSession->obptr++ = XA_FOREGROUND; |
830 | *hSession->obptr++ = hSession->ea_buf[baddr].fg; | 830 | *hSession->obptr++ = hSession->ea_buf[baddr].fg; |
831 | trace_ds("%s", see_efa(XA_FOREGROUND, hSession->ea_buf[baddr].fg)); | 831 | trace_ds("%s", see_efa(XA_FOREGROUND, hSession->ea_buf[baddr].fg)); |
832 | (*(hSession->obuf + attr_count))++; | 832 | (*(hSession->obuf + attr_count))++; |
833 | } | 833 | } |
834 | if (hSession->ea_buf[baddr].bg) { | 834 | if (hSession->ea_buf[baddr].bg) { |
835 | - space3270out(2); | 835 | + space3270out(hSession,2); |
836 | *hSession->obptr++ = XA_BACKGROUND; | 836 | *hSession->obptr++ = XA_BACKGROUND; |
837 | *hSession->obptr++ = hSession->ea_buf[baddr].bg; | 837 | *hSession->obptr++ = hSession->ea_buf[baddr].bg; |
838 | trace_ds("%s", see_efa(XA_BACKGROUND, hSession->ea_buf[baddr].bg)); | 838 | trace_ds("%s", see_efa(XA_BACKGROUND, hSession->ea_buf[baddr].bg)); |
839 | (*(hSession->obuf + attr_count))++; | 839 | (*(hSession->obuf + attr_count))++; |
840 | } | 840 | } |
841 | if (hSession->ea_buf[baddr].gr) { | 841 | if (hSession->ea_buf[baddr].gr) { |
842 | - space3270out(2); | 842 | + space3270out(hSession,2); |
843 | *hSession->obptr++ = XA_HIGHLIGHTING; | 843 | *hSession->obptr++ = XA_HIGHLIGHTING; |
844 | *hSession->obptr++ = hSession->ea_buf[baddr].gr | 0xf0; | 844 | *hSession->obptr++ = hSession->ea_buf[baddr].gr | 0xf0; |
845 | trace_ds("%s", see_efa(XA_HIGHLIGHTING, | 845 | trace_ds("%s", see_efa(XA_HIGHLIGHTING, |
@@ -847,7 +847,7 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | @@ -847,7 +847,7 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | ||
847 | (*(hSession->obuf + attr_count))++; | 847 | (*(hSession->obuf + attr_count))++; |
848 | } | 848 | } |
849 | if (hSession->ea_buf[baddr].cs & CS_MASK) { | 849 | if (hSession->ea_buf[baddr].cs & CS_MASK) { |
850 | - space3270out(2); | 850 | + space3270out(hSession,2); |
851 | *hSession->obptr++ = XA_CHARSET; | 851 | *hSession->obptr++ = XA_CHARSET; |
852 | *hSession->obptr++ = host_cs(hSession->ea_buf[baddr].cs); | 852 | *hSession->obptr++ = host_cs(hSession->ea_buf[baddr].cs); |
853 | trace_ds("%s", see_efa(XA_CHARSET,host_cs(hSession->ea_buf[baddr].cs))); | 853 | trace_ds("%s", see_efa(XA_CHARSET,host_cs(hSession->ea_buf[baddr].cs))); |
@@ -858,14 +858,14 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | @@ -858,14 +858,14 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | ||
858 | } else { | 858 | } else { |
859 | insert_sa(hSession,baddr,¤t_fg,¤t_bg,¤t_gr,¤t_cs,&any); | 859 | insert_sa(hSession,baddr,¤t_fg,¤t_bg,¤t_gr,¤t_cs,&any); |
860 | if (hSession->ea_buf[baddr].cs & CS_GE) { | 860 | if (hSession->ea_buf[baddr].cs & CS_GE) { |
861 | - space3270out(1); | 861 | + space3270out(hSession,1); |
862 | *hSession->obptr++ = ORDER_GE; | 862 | *hSession->obptr++ = ORDER_GE; |
863 | if (any) | 863 | if (any) |
864 | trace_ds("'"); | 864 | trace_ds("'"); |
865 | trace_ds(" GraphicEscape"); | 865 | trace_ds(" GraphicEscape"); |
866 | any = False; | 866 | any = False; |
867 | } | 867 | } |
868 | - space3270out(1); | 868 | + space3270out(hSession,1); |
869 | *hSession->obptr++ = hSession->ea_buf[baddr].cc; | 869 | *hSession->obptr++ = hSession->ea_buf[baddr].cc; |
870 | if (hSession->ea_buf[baddr].cc <= 0x3f || | 870 | if (hSession->ea_buf[baddr].cc <= 0x3f || |
871 | hSession->ea_buf[baddr].cc == 0xff) { | 871 | hSession->ea_buf[baddr].cc == 0xff) { |
@@ -887,7 +887,7 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | @@ -887,7 +887,7 @@ void ctlr_read_buffer(H3270 *hSession, unsigned char aid_byte) | ||
887 | trace_ds("'"); | 887 | trace_ds("'"); |
888 | 888 | ||
889 | trace_ds("\n"); | 889 | trace_ds("\n"); |
890 | - net_output(); | 890 | + net_output(hSession); |
891 | } | 891 | } |
892 | 892 | ||
893 | #if defined(X3270_TRACE) /*[*/ | 893 | #if defined(X3270_TRACE) /*[*/ |
ft_dft.c
@@ -192,12 +192,12 @@ dft_open_request(unsigned short len, unsigned char *cp) | @@ -192,12 +192,12 @@ dft_open_request(unsigned short len, unsigned char *cp) | ||
192 | /* Acknowledge the Open. */ | 192 | /* Acknowledge the Open. */ |
193 | trace_ds("> WriteStructuredField FileTransferData OpenAck\n"); | 193 | trace_ds("> WriteStructuredField FileTransferData OpenAck\n"); |
194 | h3270.obptr = h3270.obuf; | 194 | h3270.obptr = h3270.obuf; |
195 | - space3270out(6); | 195 | + space3270out(&h3270,6); |
196 | *h3270.obptr++ = AID_SF; | 196 | *h3270.obptr++ = AID_SF; |
197 | SET16(h3270.obptr, 5); | 197 | SET16(h3270.obptr, 5); |
198 | *h3270.obptr++ = SF_TRANSFER_DATA; | 198 | *h3270.obptr++ = SF_TRANSFER_DATA; |
199 | SET16(h3270.obptr, 9); | 199 | SET16(h3270.obptr, 9); |
200 | - net_output(); | 200 | + net_output(&h3270); |
201 | } | 201 | } |
202 | 202 | ||
203 | /* Process an Insert request. */ | 203 | /* Process an Insert request. */ |
@@ -317,7 +317,7 @@ dft_data_insert(struct data_buffer *data_bufr) | @@ -317,7 +317,7 @@ dft_data_insert(struct data_buffer *data_bufr) | ||
317 | /* Send an acknowledgement frame back. */ | 317 | /* Send an acknowledgement frame back. */ |
318 | trace_ds("> WriteStructuredField FileTransferData DataAck(rec=%lu)\n", recnum); | 318 | trace_ds("> WriteStructuredField FileTransferData DataAck(rec=%lu)\n", recnum); |
319 | h3270.obptr = h3270.obuf; | 319 | h3270.obptr = h3270.obuf; |
320 | - space3270out(12); | 320 | + space3270out(&h3270,12); |
321 | *h3270.obptr++ = AID_SF; | 321 | *h3270.obptr++ = AID_SF; |
322 | SET16(h3270.obptr, 11); | 322 | SET16(h3270.obptr, 11); |
323 | *h3270.obptr++ = SF_TRANSFER_DATA; | 323 | *h3270.obptr++ = SF_TRANSFER_DATA; |
@@ -325,7 +325,7 @@ dft_data_insert(struct data_buffer *data_bufr) | @@ -325,7 +325,7 @@ dft_data_insert(struct data_buffer *data_bufr) | ||
325 | SET16(h3270.obptr, TR_RECNUM_HDR); | 325 | SET16(h3270.obptr, TR_RECNUM_HDR); |
326 | SET32(h3270.obptr, recnum); | 326 | SET32(h3270.obptr, recnum); |
327 | recnum++; | 327 | recnum++; |
328 | - net_output(); | 328 | + net_output(&h3270); |
329 | } | 329 | } |
330 | 330 | ||
331 | /* Process a Set Cursor request. */ | 331 | /* Process a Set Cursor request. */ |
@@ -354,7 +354,7 @@ dft_get_request(void) | @@ -354,7 +354,7 @@ dft_get_request(void) | ||
354 | 354 | ||
355 | /* Read a buffer's worth. */ | 355 | /* Read a buffer's worth. */ |
356 | set_dft_buffersize(); | 356 | set_dft_buffersize(); |
357 | - space3270out(dft_buffersize); | 357 | + space3270out(&h3270,dft_buffersize); |
358 | numbytes = dft_buffersize - 27; /* always read 5 bytes less than we're allowed */ | 358 | numbytes = dft_buffersize - 27; /* always read 5 bytes less than we're allowed */ |
359 | bufptr = h3270.obuf + 17; | 359 | bufptr = h3270.obuf + 17; |
360 | while (!dft_eof && numbytes) { | 360 | while (!dft_eof && numbytes) { |
@@ -464,7 +464,7 @@ dft_get_request(void) | @@ -464,7 +464,7 @@ dft_get_request(void) | ||
464 | h3270.aid = AID_SF; | 464 | h3270.aid = AID_SF; |
465 | 465 | ||
466 | /* Write the data. */ | 466 | /* Write the data. */ |
467 | - net_output(); | 467 | + net_output(&h3270); |
468 | ft_update_length((H3270FT *) h3270.ft); | 468 | ft_update_length((H3270FT *) h3270.ft); |
469 | } | 469 | } |
470 | 470 | ||
@@ -479,12 +479,12 @@ dft_close_request(void) | @@ -479,12 +479,12 @@ dft_close_request(void) | ||
479 | trace_ds(" Close\n"); | 479 | trace_ds(" Close\n"); |
480 | trace_ds("> WriteStructuredField FileTransferData CloseAck\n"); | 480 | trace_ds("> WriteStructuredField FileTransferData CloseAck\n"); |
481 | h3270.obptr = h3270.obuf; | 481 | h3270.obptr = h3270.obuf; |
482 | - space3270out(6); | 482 | + space3270out(&h3270,6); |
483 | *h3270.obptr++ = AID_SF; | 483 | *h3270.obptr++ = AID_SF; |
484 | SET16(h3270.obptr, 5); /* length */ | 484 | SET16(h3270.obptr, 5); /* length */ |
485 | *h3270.obptr++ = SF_TRANSFER_DATA; | 485 | *h3270.obptr++ = SF_TRANSFER_DATA; |
486 | SET16(h3270.obptr, TR_CLOSE_REPLY); | 486 | SET16(h3270.obptr, TR_CLOSE_REPLY); |
487 | - net_output(); | 487 | + net_output(&h3270); |
488 | } | 488 | } |
489 | 489 | ||
490 | /* Abort a transfer. */ | 490 | /* Abort a transfer. */ |
@@ -502,7 +502,7 @@ static void dft_abort(unsigned short code, const char *fmt, ...) | @@ -502,7 +502,7 @@ static void dft_abort(unsigned short code, const char *fmt, ...) | ||
502 | trace_ds("> WriteStructuredField FileTransferData Error\n"); | 502 | trace_ds("> WriteStructuredField FileTransferData Error\n"); |
503 | 503 | ||
504 | h3270.obptr = h3270.obuf; | 504 | h3270.obptr = h3270.obuf; |
505 | - space3270out(10); | 505 | + space3270out(&h3270,10); |
506 | *h3270.obptr++ = AID_SF; | 506 | *h3270.obptr++ = AID_SF; |
507 | SET16(h3270.obptr, 9); /* length */ | 507 | SET16(h3270.obptr, 9); /* length */ |
508 | *h3270.obptr++ = SF_TRANSFER_DATA; | 508 | *h3270.obptr++ = SF_TRANSFER_DATA; |
@@ -510,7 +510,7 @@ static void dft_abort(unsigned short code, const char *fmt, ...) | @@ -510,7 +510,7 @@ static void dft_abort(unsigned short code, const char *fmt, ...) | ||
510 | *h3270.obptr++ = TR_ERROR_REPLY; | 510 | *h3270.obptr++ = TR_ERROR_REPLY; |
511 | SET16(h3270.obptr, TR_ERROR_HDR); | 511 | SET16(h3270.obptr, TR_ERROR_HDR); |
512 | SET16(h3270.obptr, TR_ERR_CMDFAIL); | 512 | SET16(h3270.obptr, TR_ERR_CMDFAIL); |
513 | - net_output(); | 513 | + net_output(&h3270); |
514 | 514 | ||
515 | /* Update the pop-up and state. */ | 515 | /* Update the pop-up and state. */ |
516 | ft_aborting((H3270FT *) h3270.ft); | 516 | ft_aborting((H3270FT *) h3270.ft); |
@@ -533,13 +533,14 @@ filter_len(char *s, register int len) | @@ -533,13 +533,14 @@ filter_len(char *s, register int len) | ||
533 | void | 533 | void |
534 | dft_read_modified(void) | 534 | dft_read_modified(void) |
535 | { | 535 | { |
536 | - if (dft_savebuf_len) { | 536 | + if (dft_savebuf_len) |
537 | + { | ||
537 | trace_ds("> WriteStructuredField FileTransferData\n"); | 538 | trace_ds("> WriteStructuredField FileTransferData\n"); |
538 | h3270.obptr = h3270.obuf; | 539 | h3270.obptr = h3270.obuf; |
539 | - space3270out(dft_savebuf_len); | 540 | + space3270out(&h3270,dft_savebuf_len); |
540 | memcpy(h3270.obptr, dft_savebuf, dft_savebuf_len); | 541 | memcpy(h3270.obptr, dft_savebuf, dft_savebuf_len); |
541 | h3270.obptr += dft_savebuf_len; | 542 | h3270.obptr += dft_savebuf_len; |
542 | - net_output(); | 543 | + net_output(&h3270); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | 546 |
@@ -140,7 +140,7 @@ void do_qr_rpqnames(void) | @@ -140,7 +140,7 @@ void do_qr_rpqnames(void) | ||
140 | * By pre-allocating the space I don't have to worry about the | 140 | * By pre-allocating the space I don't have to worry about the |
141 | * possibility of addresses changing. | 141 | * possibility of addresses changing. |
142 | */ | 142 | */ |
143 | - space3270out(4+4+1+remaining); /* Maximum space for an RPQNAME item */ | 143 | + space3270out(&h3270,4+4+1+remaining); /* Maximum space for an RPQNAME item */ |
144 | 144 | ||
145 | SET32(h3270.obptr, 0); /* Device number, 0 = All */ | 145 | SET32(h3270.obptr, 0); /* Device number, 0 = All */ |
146 | SET32(h3270.obptr, 0); /* Model number, 0 = All */ | 146 | SET32(h3270.obptr, 0); /* Model number, 0 = All */ |
@@ -654,7 +654,7 @@ static void | @@ -654,7 +654,7 @@ static void | ||
654 | query_reply_start(void) | 654 | query_reply_start(void) |
655 | { | 655 | { |
656 | h3270.obptr = h3270.obuf; | 656 | h3270.obptr = h3270.obuf; |
657 | - space3270out(1); | 657 | + space3270out(&h3270,1); |
658 | *h3270.obptr++ = AID_SF; | 658 | *h3270.obptr++ = AID_SF; |
659 | qr_in_progress = True; | 659 | qr_in_progress = True; |
660 | } | 660 | } |
@@ -684,7 +684,7 @@ do_query_reply(unsigned char code) | @@ -684,7 +684,7 @@ do_query_reply(unsigned char code) | ||
684 | int obptr0 = h3270.obptr - h3270.obuf; | 684 | int obptr0 = h3270.obptr - h3270.obuf; |
685 | Boolean full = True; | 685 | Boolean full = True; |
686 | 686 | ||
687 | - space3270out(4); | 687 | + space3270out(&h3270,4); |
688 | h3270.obptr += 2; /* skip length for now */ | 688 | h3270.obptr += 2; /* skip length for now */ |
689 | *h3270.obptr++ = SFID_QREPLY; | 689 | *h3270.obptr++ = SFID_QREPLY; |
690 | *h3270.obptr++ = code; | 690 | *h3270.obptr++ = code; |
@@ -723,7 +723,7 @@ do_qr_summary(void) | @@ -723,7 +723,7 @@ do_qr_summary(void) | ||
723 | const char *comma = ""; | 723 | const char *comma = ""; |
724 | 724 | ||
725 | trace_ds("> QueryReply(Summary("); | 725 | trace_ds("> QueryReply(Summary("); |
726 | - space3270out(NSR); | 726 | + space3270out(&h3270,NSR); |
727 | for (i = 0; i < NSR; i++) { | 727 | for (i = 0; i < NSR; i++) { |
728 | #if defined(X3270_DBCS) /*[*/ | 728 | #if defined(X3270_DBCS) /*[*/ |
729 | if (dbcs || replies[i].code != QR_DBCS_ASIA) { | 729 | if (dbcs || replies[i].code != QR_DBCS_ASIA) { |
@@ -744,7 +744,7 @@ do_qr_usable_area(void) | @@ -744,7 +744,7 @@ do_qr_usable_area(void) | ||
744 | unsigned short num, denom; | 744 | unsigned short num, denom; |
745 | 745 | ||
746 | trace_ds("> QueryReply(UsableArea)\n"); | 746 | trace_ds("> QueryReply(UsableArea)\n"); |
747 | - space3270out(19); | 747 | + space3270out(&h3270,19); |
748 | *h3270.obptr++ = 0x01; /* 12/14-bit addressing */ | 748 | *h3270.obptr++ = 0x01; /* 12/14-bit addressing */ |
749 | *h3270.obptr++ = 0x00; /* no special character features */ | 749 | *h3270.obptr++ = 0x00; /* no special character features */ |
750 | SET16(h3270.obptr, h3270.maxCOLS); /* usable width */ | 750 | SET16(h3270.obptr, h3270.maxCOLS); /* usable width */ |
@@ -781,7 +781,7 @@ do_qr_color(void) | @@ -781,7 +781,7 @@ do_qr_color(void) | ||
781 | 781 | ||
782 | color_max = h3270.color8 ? 8: 16; /* report on 8 or 16 colors */ | 782 | color_max = h3270.color8 ? 8: 16; /* report on 8 or 16 colors */ |
783 | 783 | ||
784 | - space3270out(4 + 2*15); | 784 | + space3270out(&h3270,4 + 2*15); |
785 | *h3270.obptr++ = 0x00; /* no options */ | 785 | *h3270.obptr++ = 0x00; /* no options */ |
786 | *h3270.obptr++ = color_max; /* report on 8 or 16 colors */ | 786 | *h3270.obptr++ = color_max; /* report on 8 or 16 colors */ |
787 | *h3270.obptr++ = 0x00; /* default color: */ | 787 | *h3270.obptr++ = 0x00; /* default color: */ |
@@ -812,7 +812,7 @@ static void | @@ -812,7 +812,7 @@ static void | ||
812 | do_qr_highlighting(void) | 812 | do_qr_highlighting(void) |
813 | { | 813 | { |
814 | trace_ds("> QueryReply(Highlighting)\n"); | 814 | trace_ds("> QueryReply(Highlighting)\n"); |
815 | - space3270out(11); | 815 | + space3270out(&h3270,11); |
816 | *h3270.obptr++ = 5; /* report on 5 pairs */ | 816 | *h3270.obptr++ = 5; /* report on 5 pairs */ |
817 | *h3270.obptr++ = XAH_DEFAULT; /* default: */ | 817 | *h3270.obptr++ = XAH_DEFAULT; /* default: */ |
818 | *h3270.obptr++ = XAH_NORMAL; /* normal */ | 818 | *h3270.obptr++ = XAH_NORMAL; /* normal */ |
@@ -830,7 +830,7 @@ static void | @@ -830,7 +830,7 @@ static void | ||
830 | do_qr_reply_modes(void) | 830 | do_qr_reply_modes(void) |
831 | { | 831 | { |
832 | trace_ds("> QueryReply(ReplyModes)\n"); | 832 | trace_ds("> QueryReply(ReplyModes)\n"); |
833 | - space3270out(3); | 833 | + space3270out(&h3270,3); |
834 | *h3270.obptr++ = SF_SRM_FIELD; | 834 | *h3270.obptr++ = SF_SRM_FIELD; |
835 | *h3270.obptr++ = SF_SRM_XFIELD; | 835 | *h3270.obptr++ = SF_SRM_XFIELD; |
836 | *h3270.obptr++ = SF_SRM_CHAR; | 836 | *h3270.obptr++ = SF_SRM_CHAR; |
@@ -857,7 +857,7 @@ static void | @@ -857,7 +857,7 @@ static void | ||
857 | do_qr_alpha_part(void) | 857 | do_qr_alpha_part(void) |
858 | { | 858 | { |
859 | trace_ds("> QueryReply(AlphanumericPartitions)\n"); | 859 | trace_ds("> QueryReply(AlphanumericPartitions)\n"); |
860 | - space3270out(4); | 860 | + space3270out(&h3270,4); |
861 | *h3270.obptr++ = 0; /* 1 partition */ | 861 | *h3270.obptr++ = 0; /* 1 partition */ |
862 | SET16(h3270.obptr, h3270.maxROWS * h3270.maxCOLS); /* buffer space */ | 862 | SET16(h3270.obptr, h3270.maxROWS * h3270.maxCOLS); /* buffer space */ |
863 | *h3270.obptr++ = 0; /* no special features */ | 863 | *h3270.obptr++ = 0; /* no special features */ |
@@ -867,7 +867,7 @@ static void | @@ -867,7 +867,7 @@ static void | ||
867 | do_qr_charsets(void) | 867 | do_qr_charsets(void) |
868 | { | 868 | { |
869 | trace_ds("> QueryReply(CharacterSets)\n"); | 869 | trace_ds("> QueryReply(CharacterSets)\n"); |
870 | - space3270out(64); | 870 | + space3270out(&h3270,64); |
871 | #if defined(X3270_DBCS) /*[*/ | 871 | #if defined(X3270_DBCS) /*[*/ |
872 | if (dbcs) | 872 | if (dbcs) |
873 | *h3270.obptr++ = 0x8e; /* flags: GE, CGCSGID, DBCS */ | 873 | *h3270.obptr++ = 0x8e; /* flags: GE, CGCSGID, DBCS */ |
@@ -953,7 +953,7 @@ do_qr_ddm(void) | @@ -953,7 +953,7 @@ do_qr_ddm(void) | ||
953 | set_dft_buffersize(); | 953 | set_dft_buffersize(); |
954 | 954 | ||
955 | trace_ds("> QueryReply(DistributedDataManagement)\n"); | 955 | trace_ds("> QueryReply(DistributedDataManagement)\n"); |
956 | - space3270out(8); | 956 | + space3270out(&h3270,8); |
957 | SET16(h3270.obptr,0); /* set reserved field to 0 */ | 957 | SET16(h3270.obptr,0); /* set reserved field to 0 */ |
958 | SET16(h3270.obptr, dft_buffersize); /* set inbound length limit INLIM */ | 958 | SET16(h3270.obptr, dft_buffersize); /* set inbound length limit INLIM */ |
959 | SET16(h3270.obptr, dft_buffersize); /* set outbound length limit OUTLIM */ | 959 | SET16(h3270.obptr, dft_buffersize); /* set outbound length limit OUTLIM */ |
@@ -965,7 +965,7 @@ static void | @@ -965,7 +965,7 @@ static void | ||
965 | do_qr_imp_part(void) | 965 | do_qr_imp_part(void) |
966 | { | 966 | { |
967 | trace_ds("> QueryReply(ImplicitPartition)\n"); | 967 | trace_ds("> QueryReply(ImplicitPartition)\n"); |
968 | - space3270out(13); | 968 | + space3270out(&h3270,13); |
969 | *h3270.obptr++ = 0x0; /* reserved */ | 969 | *h3270.obptr++ = 0x0; /* reserved */ |
970 | *h3270.obptr++ = 0x0; | 970 | *h3270.obptr++ = 0x0; |
971 | *h3270.obptr++ = 0x0b; /* length of display size */ | 971 | *h3270.obptr++ = 0x0b; /* length of display size */ |
@@ -980,6 +980,6 @@ do_qr_imp_part(void) | @@ -980,6 +980,6 @@ do_qr_imp_part(void) | ||
980 | static void | 980 | static void |
981 | query_reply_end(void) | 981 | query_reply_end(void) |
982 | { | 982 | { |
983 | - net_output(); | 983 | + net_output(&h3270); |
984 | kybd_inhibit(&h3270,True); | 984 | kybd_inhibit(&h3270,True); |
985 | } | 985 | } |
telnet.c
@@ -231,7 +231,7 @@ static void tn3270e_nak(H3270 *hSession, enum pds); | @@ -231,7 +231,7 @@ static void tn3270e_nak(H3270 *hSession, enum pds); | ||
231 | #endif /*]*/ | 231 | #endif /*]*/ |
232 | 232 | ||
233 | #if defined(X3270_ANSI) /*[*/ | 233 | #if defined(X3270_ANSI) /*[*/ |
234 | -static void do_data(char c); | 234 | +static void do_data(H3270 *hSession, char c); |
235 | static void do_intr(H3270 *hSession, char c); | 235 | static void do_intr(H3270 *hSession, char c); |
236 | static void do_quit(H3270 *hSession, char c); | 236 | static void do_quit(H3270 *hSession, char c); |
237 | static void do_cerase(H3270 *hSession, char c); | 237 | static void do_cerase(H3270 *hSession, char c); |
@@ -756,21 +756,21 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | @@ -756,21 +756,21 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo | ||
756 | #undef close_fail | 756 | #undef close_fail |
757 | 757 | ||
758 | /* Set up the LU list. */ | 758 | /* Set up the LU list. */ |
759 | -static void | ||
760 | -setup_lus(void) | 759 | +static void setup_lus(H3270 *hSession) |
761 | { | 760 | { |
762 | char *lu; | 761 | char *lu; |
763 | char *comma; | 762 | char *comma; |
764 | int n_lus = 1; | 763 | int n_lus = 1; |
765 | int i; | 764 | int i; |
766 | 765 | ||
767 | - h3270.connected_lu = CN; | ||
768 | - h3270.connected_type = CN; | 766 | + hSession->connected_lu = CN; |
767 | + hSession->connected_type = CN; | ||
769 | 768 | ||
770 | - if (!h3270.luname[0]) { | ||
771 | - Replace(h3270.lus, NULL); | ||
772 | - h3270.curr_lu = (char **)NULL; | ||
773 | - h3270.try_lu = CN; | 769 | + if (!hSession->luname[0]) |
770 | + { | ||
771 | + Replace(hSession->lus, NULL); | ||
772 | + hSession->curr_lu = (char **)NULL; | ||
773 | + hSession->try_lu = CN; | ||
774 | return; | 774 | return; |
775 | } | 775 | } |
776 | 776 | ||
@@ -778,8 +778,9 @@ setup_lus(void) | @@ -778,8 +778,9 @@ setup_lus(void) | ||
778 | * Count the commas in the LU name. That plus one is the | 778 | * Count the commas in the LU name. That plus one is the |
779 | * number of LUs to try. | 779 | * number of LUs to try. |
780 | */ | 780 | */ |
781 | - lu = h3270.luname; | ||
782 | - while ((comma = strchr(lu, ',')) != CN) { | 781 | + lu = hSession->luname; |
782 | + while ((comma = strchr(lu, ',')) != CN) | ||
783 | + { | ||
783 | n_lus++; | 784 | n_lus++; |
784 | lu++; | 785 | lu++; |
785 | } | 786 | } |
@@ -788,23 +789,27 @@ setup_lus(void) | @@ -788,23 +789,27 @@ setup_lus(void) | ||
788 | * Allocate enough memory to construct an argv[] array for | 789 | * Allocate enough memory to construct an argv[] array for |
789 | * the LUs. | 790 | * the LUs. |
790 | */ | 791 | */ |
791 | - Replace(h3270.lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(h3270.luname) + 1)); | 792 | + Replace(hSession->lus,(char **)lib3270_malloc((n_lus+1) * sizeof(char *) + strlen(hSession->luname) + 1)); |
792 | 793 | ||
793 | /* Copy each LU into the array. */ | 794 | /* Copy each LU into the array. */ |
794 | - lu = (char *)(h3270.lus + n_lus + 1); | ||
795 | - (void) strcpy(lu, h3270.luname); | 795 | + lu = (char *)(hSession->lus + n_lus + 1); |
796 | + (void) strcpy(lu, hSession->luname); | ||
797 | + | ||
796 | i = 0; | 798 | i = 0; |
797 | - do { | ||
798 | - h3270.lus[i++] = lu; | 799 | + do |
800 | + { | ||
801 | + hSession->lus[i++] = lu; | ||
799 | comma = strchr(lu, ','); | 802 | comma = strchr(lu, ','); |
800 | - if (comma != CN) { | 803 | + if (comma != CN) |
804 | + { | ||
801 | *comma = '\0'; | 805 | *comma = '\0'; |
802 | lu = comma + 1; | 806 | lu = comma + 1; |
803 | } | 807 | } |
804 | } while (comma != CN); | 808 | } while (comma != CN); |
805 | - h3270.lus[i] = CN; | ||
806 | - h3270.curr_lu = h3270.lus; | ||
807 | - h3270.try_lu = *h3270.curr_lu; | 809 | + |
810 | + hSession->lus[i] = CN; | ||
811 | + hSession->curr_lu = hSession->lus; | ||
812 | + hSession->try_lu = *hSession->curr_lu; | ||
808 | } | 813 | } |
809 | 814 | ||
810 | static void net_connected(H3270 *session) | 815 | static void net_connected(H3270 *session) |
@@ -895,7 +900,7 @@ LIB3270_EXPORT void lib3270_setup_session(H3270 *session) | @@ -895,7 +900,7 @@ LIB3270_EXPORT void lib3270_setup_session(H3270 *session) | ||
895 | need_tls_follows = False; | 900 | need_tls_follows = False; |
896 | #endif /*]*/ | 901 | #endif /*]*/ |
897 | session->telnet_state = TNS_DATA; | 902 | session->telnet_state = TNS_DATA; |
898 | - session->ibptr = h3270.ibuf; | 903 | + session->ibptr = session->ibuf; |
899 | 904 | ||
900 | /* clear statistics and flags */ | 905 | /* clear statistics and flags */ |
901 | time(&session->ns_time); | 906 | time(&session->ns_time); |
@@ -908,7 +913,7 @@ LIB3270_EXPORT void lib3270_setup_session(H3270 *session) | @@ -908,7 +913,7 @@ LIB3270_EXPORT void lib3270_setup_session(H3270 *session) | ||
908 | session->tn3270e_submode = E_NONE; | 913 | session->tn3270e_submode = E_NONE; |
909 | session->tn3270e_bound = 0; | 914 | session->tn3270e_bound = 0; |
910 | 915 | ||
911 | - setup_lus(); | 916 | + setup_lus(session); |
912 | 917 | ||
913 | check_linemode(session,True); | 918 | check_linemode(session,True); |
914 | 919 | ||
@@ -1444,7 +1449,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1444,7 +1449,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1444 | check_linemode(session,False); | 1449 | check_linemode(session,False); |
1445 | } | 1450 | } |
1446 | if (c == TELOPT_NAWS) | 1451 | if (c == TELOPT_NAWS) |
1447 | - send_naws(&h3270); | 1452 | + send_naws(session); |
1448 | #if defined(HAVE_LIBSSL) /*[*/ | 1453 | #if defined(HAVE_LIBSSL) /*[*/ |
1449 | if (c == TELOPT_STARTTLS) { | 1454 | if (c == TELOPT_STARTTLS) { |
1450 | static unsigned char follows_msg[] = { | 1455 | static unsigned char follows_msg[] = { |
@@ -1456,8 +1461,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1456,8 +1461,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1456 | * Send IAC SB STARTTLS FOLLOWS IAC SE | 1461 | * Send IAC SB STARTTLS FOLLOWS IAC SE |
1457 | * to announce that what follows is TLS. | 1462 | * to announce that what follows is TLS. |
1458 | */ | 1463 | */ |
1459 | - net_rawout(&h3270, follows_msg, | ||
1460 | - sizeof(follows_msg)); | 1464 | + net_rawout(session, follows_msg, sizeof(follows_msg)); |
1461 | trace_dsn("SENT %s %s FOLLOWS %s\n", | 1465 | trace_dsn("SENT %s %s FOLLOWS %s\n", |
1462 | cmd(SB), | 1466 | cmd(SB), |
1463 | opt(TELOPT_STARTTLS), | 1467 | opt(TELOPT_STARTTLS), |
@@ -1469,53 +1473,57 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1469,53 +1473,57 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1469 | default: | 1473 | default: |
1470 | wont: | 1474 | wont: |
1471 | wont_opt[2] = c; | 1475 | wont_opt[2] = c; |
1472 | - net_rawout(&h3270, wont_opt, sizeof(wont_opt)); | 1476 | + net_rawout(session, wont_opt, sizeof(wont_opt)); |
1473 | trace_dsn("SENT %s %s\n", cmd(WONT), opt(c)); | 1477 | trace_dsn("SENT %s %s\n", cmd(WONT), opt(c)); |
1474 | break; | 1478 | break; |
1475 | } | 1479 | } |
1476 | - h3270.telnet_state = TNS_DATA; | 1480 | + session->telnet_state = TNS_DATA; |
1477 | break; | 1481 | break; |
1478 | case TNS_DONT: /* telnet PLEASE DON'T DO OPTION command */ | 1482 | case TNS_DONT: /* telnet PLEASE DON'T DO OPTION command */ |
1479 | trace_dsn("%s\n", opt(c)); | 1483 | trace_dsn("%s\n", opt(c)); |
1480 | - if (h3270.myopts[c]) { | ||
1481 | - h3270.myopts[c] = 0; | 1484 | + if (session->myopts[c]) { |
1485 | + session->myopts[c] = 0; | ||
1482 | wont_opt[2] = c; | 1486 | wont_opt[2] = c; |
1483 | - net_rawout(&h3270, wont_opt, sizeof(wont_opt)); | 1487 | + net_rawout(session, wont_opt, sizeof(wont_opt)); |
1484 | trace_dsn("SENT %s %s\n", cmd(WONT), opt(c)); | 1488 | trace_dsn("SENT %s %s\n", cmd(WONT), opt(c)); |
1485 | - check_in3270(&h3270); | ||
1486 | - check_linemode(&h3270,False); | 1489 | + check_in3270(session); |
1490 | + check_linemode(session,False); | ||
1487 | } | 1491 | } |
1488 | - h3270.telnet_state = TNS_DATA; | 1492 | + session->telnet_state = TNS_DATA; |
1489 | break; | 1493 | break; |
1490 | case TNS_SB: /* telnet sub-option string command */ | 1494 | case TNS_SB: /* telnet sub-option string command */ |
1491 | if (c == IAC) | 1495 | if (c == IAC) |
1492 | - h3270.telnet_state = TNS_SB_IAC; | 1496 | + session->telnet_state = TNS_SB_IAC; |
1493 | else | 1497 | else |
1494 | - *h3270.sbptr++ = c; | 1498 | + *session->sbptr++ = c; |
1495 | break; | 1499 | break; |
1496 | case TNS_SB_IAC: /* telnet sub-option string command */ | 1500 | case TNS_SB_IAC: /* telnet sub-option string command */ |
1497 | - *h3270.sbptr++ = c; | 1501 | + *session->sbptr++ = c; |
1498 | if (c == SE) { | 1502 | if (c == SE) { |
1499 | - h3270.telnet_state = TNS_DATA; | ||
1500 | - if (session->sbbuf[0] == TELOPT_TTYPE && | ||
1501 | - session->sbbuf[1] == TELQUAL_SEND) { | 1503 | + session->telnet_state = TNS_DATA; |
1504 | + if (session->sbbuf[0] == TELOPT_TTYPE && session->sbbuf[1] == TELQUAL_SEND) | ||
1505 | + { | ||
1502 | int tt_len, tb_len; | 1506 | int tt_len, tb_len; |
1503 | char *tt_out; | 1507 | char *tt_out; |
1504 | 1508 | ||
1505 | - trace_dsn("%s %s\n", opt(session->sbbuf[0]), | ||
1506 | - telquals[session->sbbuf[1]]); | ||
1507 | - if (session->lus != (char **)NULL && h3270.try_lu == CN) { | 1509 | + trace_dsn("%s %s\n", opt(session->sbbuf[0]),telquals[session->sbbuf[1]]); |
1510 | + | ||
1511 | + if (session->lus != (char **)NULL && session->try_lu == CN) | ||
1512 | + { | ||
1508 | /* None of the LUs worked. */ | 1513 | /* None of the LUs worked. */ |
1509 | popup_an_error(NULL,"Cannot connect to specified LU"); | 1514 | popup_an_error(NULL,"Cannot connect to specified LU"); |
1510 | return -1; | 1515 | return -1; |
1511 | } | 1516 | } |
1512 | 1517 | ||
1513 | tt_len = strlen(session->termtype); | 1518 | tt_len = strlen(session->termtype); |
1514 | - if (h3270.try_lu != CN && *h3270.try_lu) { | ||
1515 | - tt_len += strlen(h3270.try_lu) + 1; | ||
1516 | - session->connected_lu = h3270.try_lu; | ||
1517 | - } else | 1519 | + if (session->try_lu != CN && *session->try_lu) |
1520 | + { | ||
1521 | + tt_len += strlen(session->try_lu) + 1; | ||
1522 | + session->connected_lu = session->try_lu; | ||
1523 | + } | ||
1524 | + else | ||
1518 | session->connected_lu = CN; | 1525 | session->connected_lu = CN; |
1526 | + | ||
1519 | status_lu(session,session->connected_lu); | 1527 | status_lu(session,session->connected_lu); |
1520 | 1528 | ||
1521 | tb_len = 4 + tt_len + 2; | 1529 | tb_len = 4 + tt_len + 2; |
@@ -1523,10 +1531,10 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1523,10 +1531,10 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1523 | (void) sprintf(tt_out, "%c%c%c%c%s%s%s%c%c", | 1531 | (void) sprintf(tt_out, "%c%c%c%c%s%s%s%c%c", |
1524 | IAC, SB, TELOPT_TTYPE, TELQUAL_IS, | 1532 | IAC, SB, TELOPT_TTYPE, TELQUAL_IS, |
1525 | session->termtype, | 1533 | session->termtype, |
1526 | - (h3270.try_lu != CN && *h3270.try_lu) ? "@" : "", | ||
1527 | - (h3270.try_lu != CN && *h3270.try_lu) ? h3270.try_lu : "", | 1534 | + (session->try_lu != CN && *session->try_lu) ? "@" : "", |
1535 | + (session->try_lu != CN && *session->try_lu) ? session->try_lu : "", | ||
1528 | IAC, SE); | 1536 | IAC, SE); |
1529 | - net_rawout(&h3270, (unsigned char *)tt_out, tb_len); | 1537 | + net_rawout(session, (unsigned char *)tt_out, tb_len); |
1530 | 1538 | ||
1531 | trace_dsn("SENT %s %s %s %.*s %s\n", | 1539 | trace_dsn("SENT %s %s %s %.*s %s\n", |
1532 | cmd(SB), opt(TELOPT_TTYPE), | 1540 | cmd(SB), opt(TELOPT_TTYPE), |
@@ -1536,25 +1544,24 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1536,25 +1544,24 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1536 | lib3270_free(tt_out); | 1544 | lib3270_free(tt_out); |
1537 | 1545 | ||
1538 | /* Advance to the next LU name. */ | 1546 | /* Advance to the next LU name. */ |
1539 | - next_lu(&h3270); | 1547 | + next_lu(session); |
1540 | } | 1548 | } |
1541 | #if defined(X3270_TN3270E) /*[*/ | 1549 | #if defined(X3270_TN3270E) /*[*/ |
1542 | - else if (h3270.myopts[TELOPT_TN3270E] && | ||
1543 | - h3270.sbbuf[0] == TELOPT_TN3270E) { | ||
1544 | - if (tn3270e_negotiate(&h3270)) | 1550 | + else if (session->myopts[TELOPT_TN3270E] && session->sbbuf[0] == TELOPT_TN3270E) |
1551 | + { | ||
1552 | + if (tn3270e_negotiate(session)) | ||
1545 | return -1; | 1553 | return -1; |
1546 | } | 1554 | } |
1547 | #endif /*]*/ | 1555 | #endif /*]*/ |
1548 | #if defined(HAVE_LIBSSL) /*[*/ | 1556 | #if defined(HAVE_LIBSSL) /*[*/ |
1549 | - else if (need_tls_follows && | ||
1550 | - h3270.myopts[TELOPT_STARTTLS] && | ||
1551 | - h3270.sbbuf[0] == TELOPT_STARTTLS) { | ||
1552 | - continue_tls(h3270.sbbuf, h3270.sbptr - h3270.sbbuf); | 1557 | + else if (need_tls_follows && session->myopts[TELOPT_STARTTLS] && session->sbbuf[0] == TELOPT_STARTTLS) |
1558 | + { | ||
1559 | + continue_tls(session->sbbuf, session->sbptr - session->sbbuf); | ||
1553 | } | 1560 | } |
1554 | #endif /*]*/ | 1561 | #endif /*]*/ |
1555 | 1562 | ||
1556 | } else { | 1563 | } else { |
1557 | - h3270.telnet_state = TNS_SB; | 1564 | + session->telnet_state = TNS_SB; |
1558 | } | 1565 | } |
1559 | break; | 1566 | break; |
1560 | } | 1567 | } |
@@ -1563,39 +1570,38 @@ static int telnet_fsm(H3270 *session, unsigned char c) | @@ -1563,39 +1570,38 @@ static int telnet_fsm(H3270 *session, unsigned char c) | ||
1563 | 1570 | ||
1564 | #if defined(X3270_TN3270E) /*[*/ | 1571 | #if defined(X3270_TN3270E) /*[*/ |
1565 | /* Send a TN3270E terminal type request. */ | 1572 | /* Send a TN3270E terminal type request. */ |
1566 | -static void | ||
1567 | -tn3270e_request(void) | 1573 | +static void tn3270e_request(H3270 *hSession) |
1568 | { | 1574 | { |
1569 | int tt_len, tb_len; | 1575 | int tt_len, tb_len; |
1570 | char *tt_out; | 1576 | char *tt_out; |
1571 | char *t; | 1577 | char *t; |
1572 | 1578 | ||
1573 | - tt_len = strlen(h3270.termtype); | ||
1574 | - if (h3270.try_lu != CN && *h3270.try_lu) | ||
1575 | - tt_len += strlen(h3270.try_lu) + 1; | 1579 | + tt_len = strlen(hSession->termtype); |
1580 | + if (hSession->try_lu != CN && *hSession->try_lu) | ||
1581 | + tt_len += strlen(hSession->try_lu) + 1; | ||
1576 | 1582 | ||
1577 | tb_len = 5 + tt_len + 2; | 1583 | tb_len = 5 + tt_len + 2; |
1578 | tt_out = lib3270_malloc(tb_len + 1); | 1584 | tt_out = lib3270_malloc(tb_len + 1); |
1579 | t = tt_out; | 1585 | t = tt_out; |
1580 | t += sprintf(tt_out, "%c%c%c%c%c%s", | 1586 | t += sprintf(tt_out, "%c%c%c%c%c%s", |
1581 | IAC, SB, TELOPT_TN3270E, TN3270E_OP_DEVICE_TYPE, | 1587 | IAC, SB, TELOPT_TN3270E, TN3270E_OP_DEVICE_TYPE, |
1582 | - TN3270E_OP_REQUEST, h3270.termtype); | 1588 | + TN3270E_OP_REQUEST, hSession->termtype); |
1583 | 1589 | ||
1584 | /* Convert 3279 to 3278, per the RFC. */ | 1590 | /* Convert 3279 to 3278, per the RFC. */ |
1585 | if (tt_out[12] == '9') | 1591 | if (tt_out[12] == '9') |
1586 | tt_out[12] = '8'; | 1592 | tt_out[12] = '8'; |
1587 | 1593 | ||
1588 | - if (h3270.try_lu != CN && *h3270.try_lu) | ||
1589 | - t += sprintf(t, "%c%s", TN3270E_OP_CONNECT, h3270.try_lu); | 1594 | + if (hSession->try_lu != CN && *hSession->try_lu) |
1595 | + t += sprintf(t, "%c%s", TN3270E_OP_CONNECT, hSession->try_lu); | ||
1590 | 1596 | ||
1591 | (void) sprintf(t, "%c%c", IAC, SE); | 1597 | (void) sprintf(t, "%c%c", IAC, SE); |
1592 | 1598 | ||
1593 | - net_rawout(&h3270, (unsigned char *)tt_out, tb_len); | 1599 | + net_rawout(hSession, (unsigned char *)tt_out, tb_len); |
1594 | 1600 | ||
1595 | trace_dsn("SENT %s %s DEVICE-TYPE REQUEST %.*s%s%s %s\n", | 1601 | trace_dsn("SENT %s %s DEVICE-TYPE REQUEST %.*s%s%s %s\n", |
1596 | - cmd(SB), opt(TELOPT_TN3270E), (int) strlen(h3270.termtype), tt_out + 5, | ||
1597 | - (h3270.try_lu != CN && *h3270.try_lu) ? " CONNECT " : "", | ||
1598 | - (h3270.try_lu != CN && *h3270.try_lu) ? h3270.try_lu : "", | 1602 | + cmd(SB), opt(TELOPT_TN3270E), (int) strlen(hSession->termtype), tt_out + 5, |
1603 | + (hSession->try_lu != CN && *hSession->try_lu) ? " CONNECT " : "", | ||
1604 | + (hSession->try_lu != CN && *hSession->try_lu) ? hSession->try_lu : "", | ||
1599 | cmd(SE)); | 1605 | cmd(SE)); |
1600 | 1606 | ||
1601 | lib3270_free(tt_out); | 1607 | lib3270_free(tt_out); |
@@ -1604,22 +1610,21 @@ tn3270e_request(void) | @@ -1604,22 +1610,21 @@ tn3270e_request(void) | ||
1604 | /* | 1610 | /* |
1605 | * Back off of TN3270E. | 1611 | * Back off of TN3270E. |
1606 | */ | 1612 | */ |
1607 | -static void | ||
1608 | -backoff_tn3270e(const char *why) | 1613 | +static void backoff_tn3270e(H3270 *hSession, const char *why) |
1609 | { | 1614 | { |
1610 | trace_dsn("Aborting TN3270E: %s\n", why); | 1615 | trace_dsn("Aborting TN3270E: %s\n", why); |
1611 | 1616 | ||
1612 | /* Tell the host 'no'. */ | 1617 | /* Tell the host 'no'. */ |
1613 | wont_opt[2] = TELOPT_TN3270E; | 1618 | wont_opt[2] = TELOPT_TN3270E; |
1614 | - net_rawout(&h3270, wont_opt, sizeof(wont_opt)); | 1619 | + net_rawout(hSession, wont_opt, sizeof(wont_opt)); |
1615 | trace_dsn("SENT %s %s\n", cmd(WONT), opt(TELOPT_TN3270E)); | 1620 | trace_dsn("SENT %s %s\n", cmd(WONT), opt(TELOPT_TN3270E)); |
1616 | 1621 | ||
1617 | /* Restore the LU list; we may need to run it again in TN3270 mode. */ | 1622 | /* Restore the LU list; we may need to run it again in TN3270 mode. */ |
1618 | - setup_lus(); | 1623 | + setup_lus(hSession); |
1619 | 1624 | ||
1620 | /* Reset our internal state. */ | 1625 | /* Reset our internal state. */ |
1621 | - h3270.myopts[TELOPT_TN3270E] = 0; | ||
1622 | - check_in3270(&h3270); | 1626 | + hSession->myopts[TELOPT_TN3270E] = 0; |
1627 | + check_in3270(hSession); | ||
1623 | } | 1628 | } |
1624 | 1629 | ||
1625 | /* | 1630 | /* |
@@ -1652,7 +1657,7 @@ static int tn3270e_negotiate(H3270 *hSession) | @@ -1652,7 +1657,7 @@ static int tn3270e_negotiate(H3270 *hSession) | ||
1652 | /* Host wants us to send our device type. */ | 1657 | /* Host wants us to send our device type. */ |
1653 | trace_dsn("SEND DEVICE-TYPE SE\n"); | 1658 | trace_dsn("SEND DEVICE-TYPE SE\n"); |
1654 | 1659 | ||
1655 | - tn3270e_request(); | 1660 | + tn3270e_request(hSession); |
1656 | } else { | 1661 | } else { |
1657 | trace_dsn("SEND ??%u SE\n", hSession->sbbuf[2]); | 1662 | trace_dsn("SEND ??%u SE\n", hSession->sbbuf[2]); |
1658 | } | 1663 | } |
@@ -1711,19 +1716,24 @@ static int tn3270e_negotiate(H3270 *hSession) | @@ -1711,19 +1716,24 @@ static int tn3270e_negotiate(H3270 *hSession) | ||
1711 | trace_dsn("REJECT REASON %s SE\n", rsn(hSession->sbbuf[4])); | 1716 | trace_dsn("REJECT REASON %s SE\n", rsn(hSession->sbbuf[4])); |
1712 | if (hSession->sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE || | 1717 | if (hSession->sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE || |
1713 | hSession->sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) { | 1718 | hSession->sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) { |
1714 | - backoff_tn3270e(_( "Host rejected device type or request type" )); | 1719 | + backoff_tn3270e(hSession,_( "Host rejected device type or request type" )); |
1715 | break; | 1720 | break; |
1716 | } | 1721 | } |
1717 | 1722 | ||
1718 | next_lu(hSession); | 1723 | next_lu(hSession); |
1719 | - if (hSession->try_lu != CN) { | 1724 | + if (hSession->try_lu != CN) |
1725 | + { | ||
1720 | /* Try the next LU. */ | 1726 | /* Try the next LU. */ |
1721 | - tn3270e_request(); | ||
1722 | - } else if (hSession->lus != (char **)NULL) { | 1727 | + tn3270e_request(hSession); |
1728 | + } | ||
1729 | + else if (hSession->lus != (char **)NULL) | ||
1730 | + { | ||
1723 | /* No more LUs to try. Give up. */ | 1731 | /* No more LUs to try. Give up. */ |
1724 | - backoff_tn3270e(_("Host rejected resource(s)")); | ||
1725 | - } else { | ||
1726 | - backoff_tn3270e(_("Device type rejected")); | 1732 | + backoff_tn3270e(hSession,_("Host rejected resource(s)")); |
1733 | + } | ||
1734 | + else | ||
1735 | + { | ||
1736 | + backoff_tn3270e(hSession,_("Device type rejected")); | ||
1727 | } | 1737 | } |
1728 | 1738 | ||
1729 | break; | 1739 | break; |
@@ -1782,7 +1792,7 @@ static int tn3270e_negotiate(H3270 *hSession) | @@ -1782,7 +1792,7 @@ static int tn3270e_negotiate(H3270 *hSession) | ||
1782 | * They've added something. Abandon | 1792 | * They've added something. Abandon |
1783 | * TN3270E, they're brain dead. | 1793 | * TN3270E, they're brain dead. |
1784 | */ | 1794 | */ |
1785 | - backoff_tn3270e("Host illegally added function(s)"); | 1795 | + backoff_tn3270e(hSession,_( "Host illegally added function(s)" )); |
1786 | break; | 1796 | break; |
1787 | } | 1797 | } |
1788 | } | 1798 | } |
@@ -2191,11 +2201,11 @@ static void net_cookout(H3270 *hSession, const char *buf, int len) | @@ -2191,11 +2201,11 @@ static void net_cookout(H3270 *hSession, const char *buf, int len) | ||
2191 | else if (c == 0x08 || c == 0x7f) /* Yes, a hack. */ | 2201 | else if (c == 0x08 || c == 0x7f) /* Yes, a hack. */ |
2192 | do_cerase(hSession,c); | 2202 | do_cerase(hSession,c); |
2193 | else | 2203 | else |
2194 | - do_data(c); | 2204 | + do_data(hSession,c); |
2195 | } | 2205 | } |
2196 | return; | 2206 | return; |
2197 | } else | 2207 | } else |
2198 | - net_cookedout(&h3270, buf, len); | 2208 | + net_cookedout(hSession, buf, len); |
2199 | } | 2209 | } |
2200 | 2210 | ||
2201 | 2211 | ||
@@ -2219,35 +2229,36 @@ ansi_process_s(const char *data) | @@ -2219,35 +2229,36 @@ ansi_process_s(const char *data) | ||
2219 | ansi_process((unsigned int) *data++); | 2229 | ansi_process((unsigned int) *data++); |
2220 | } | 2230 | } |
2221 | 2231 | ||
2222 | -static void | ||
2223 | -forward_data(void) | 2232 | +static void forward_data(H3270 *hSession) |
2224 | { | 2233 | { |
2225 | - net_cookedout(&h3270, (char *) h3270.lbuf, h3270.lbptr - h3270.lbuf); | ||
2226 | - cooked_init(&h3270); | 2234 | + net_cookedout(hSession, (char *) hSession->lbuf, hSession->lbptr - hSession->lbuf); |
2235 | + cooked_init(hSession); | ||
2227 | } | 2236 | } |
2228 | 2237 | ||
2229 | -static void | ||
2230 | -do_data(char c) | 2238 | +static void do_data(H3270 *hSession, char c) |
2231 | { | 2239 | { |
2232 | - if (h3270.lbptr+1 < h3270.lbuf + BUFSZ) { | ||
2233 | - *h3270.lbptr++ = c; | 2240 | + if (hSession->lbptr+1 < hSession->lbuf + BUFSZ) |
2241 | + { | ||
2242 | + *hSession->lbptr++ = c; | ||
2234 | if (c == '\r') | 2243 | if (c == '\r') |
2235 | - *h3270.lbptr++ = 'lbptr++ = '\0';'; | 2244 | + *hSession->lbptr++ = 'lbptr++ = '\0';'; |
2236 | if (c == '\t') | 2245 | if (c == '\t') |
2237 | ansi_process((unsigned int) c); | 2246 | ansi_process((unsigned int) c); |
2238 | else | 2247 | else |
2239 | ansi_process_s(ctl_see((int) c)); | 2248 | ansi_process_s(ctl_see((int) c)); |
2240 | - } else | 2249 | + } |
2250 | + else | ||
2241 | ansi_process_s("\007"); | 2251 | ansi_process_s("\007"); |
2242 | - h3270.lnext = 0; | ||
2243 | - h3270.backslashed = 0; | 2252 | + |
2253 | + hSession->lnext = 0; | ||
2254 | + hSession->backslashed = 0; | ||
2244 | } | 2255 | } |
2245 | 2256 | ||
2246 | static void do_intr(H3270 *hSession, char c) | 2257 | static void do_intr(H3270 *hSession, char c) |
2247 | { | 2258 | { |
2248 | if (hSession->lnext) | 2259 | if (hSession->lnext) |
2249 | { | 2260 | { |
2250 | - do_data(c); | 2261 | + do_data(hSession,c); |
2251 | return; | 2262 | return; |
2252 | } | 2263 | } |
2253 | ansi_process_s(ctl_see((int) c)); | 2264 | ansi_process_s(ctl_see((int) c)); |
@@ -2259,7 +2270,7 @@ static void do_quit(H3270 *hSession, char c) | @@ -2259,7 +2270,7 @@ static void do_quit(H3270 *hSession, char c) | ||
2259 | { | 2270 | { |
2260 | if (hSession->lnext) | 2271 | if (hSession->lnext) |
2261 | { | 2272 | { |
2262 | - do_data(c); | 2273 | + do_data(hSession,c); |
2263 | return; | 2274 | return; |
2264 | } | 2275 | } |
2265 | ansi_process_s(ctl_see((int) c)); | 2276 | ansi_process_s(ctl_see((int) c)); |
@@ -2275,14 +2286,16 @@ static void do_cerase(H3270 *hSession, char c) | @@ -2275,14 +2286,16 @@ static void do_cerase(H3270 *hSession, char c) | ||
2275 | { | 2286 | { |
2276 | hSession->lbptr--; | 2287 | hSession->lbptr--; |
2277 | ansi_process_s("\b"); | 2288 | ansi_process_s("\b"); |
2278 | - do_data(c); | 2289 | + do_data(hSession,c); |
2279 | return; | 2290 | return; |
2280 | } | 2291 | } |
2292 | + | ||
2281 | if (hSession->lnext) | 2293 | if (hSession->lnext) |
2282 | { | 2294 | { |
2283 | - do_data(c); | 2295 | + do_data(hSession,c); |
2284 | return; | 2296 | return; |
2285 | } | 2297 | } |
2298 | + | ||
2286 | if (hSession->lbptr > hSession->lbuf) | 2299 | if (hSession->lbptr > hSession->lbuf) |
2287 | { | 2300 | { |
2288 | len = strlen(ctl_see((int) *--hSession->lbptr)); | 2301 | len = strlen(ctl_see((int) *--hSession->lbptr)); |
@@ -2297,10 +2310,12 @@ static void do_werase(H3270 *hSession, char c) | @@ -2297,10 +2310,12 @@ static void do_werase(H3270 *hSession, char c) | ||
2297 | int any = 0; | 2310 | int any = 0; |
2298 | int len; | 2311 | int len; |
2299 | 2312 | ||
2300 | - if (hSession->lnext) { | ||
2301 | - do_data(c); | 2313 | + if (hSession->lnext) |
2314 | + { | ||
2315 | + do_data(hSession,c); | ||
2302 | return; | 2316 | return; |
2303 | } | 2317 | } |
2318 | + | ||
2304 | while (hSession->lbptr > hSession->lbuf) { | 2319 | while (hSession->lbptr > hSession->lbuf) { |
2305 | char ch; | 2320 | char ch; |
2306 | 2321 | ||
@@ -2327,14 +2342,18 @@ static void do_kill(H3270 *hSession, char c) | @@ -2327,14 +2342,18 @@ static void do_kill(H3270 *hSession, char c) | ||
2327 | if (hSession->backslashed) { | 2342 | if (hSession->backslashed) { |
2328 | hSession->lbptr--; | 2343 | hSession->lbptr--; |
2329 | ansi_process_s("\b"); | 2344 | ansi_process_s("\b"); |
2330 | - do_data(c); | 2345 | + do_data(hSession,c); |
2331 | return; | 2346 | return; |
2332 | } | 2347 | } |
2333 | - if (hSession->lnext) { | ||
2334 | - do_data(c); | 2348 | + |
2349 | + if (hSession->lnext) | ||
2350 | + { | ||
2351 | + do_data(hSession,c); | ||
2335 | return; | 2352 | return; |
2336 | } | 2353 | } |
2337 | - while (hSession->lbptr > hSession->lbuf) { | 2354 | + |
2355 | + while (hSession->lbptr > hSession->lbuf) | ||
2356 | + { | ||
2338 | len = strlen(ctl_see((int) *--hSession->lbptr)); | 2357 | len = strlen(ctl_see((int) *--hSession->lbptr)); |
2339 | 2358 | ||
2340 | for (i = 0; i < len; i++) | 2359 | for (i = 0; i < len; i++) |
@@ -2346,10 +2365,12 @@ static void do_rprnt(H3270 *hSession, char c) | @@ -2346,10 +2365,12 @@ static void do_rprnt(H3270 *hSession, char c) | ||
2346 | { | 2365 | { |
2347 | unsigned char *p; | 2366 | unsigned char *p; |
2348 | 2367 | ||
2349 | - if (hSession->lnext) { | ||
2350 | - do_data(c); | 2368 | + if (hSession->lnext) |
2369 | + { | ||
2370 | + do_data(hSession,c); | ||
2351 | return; | 2371 | return; |
2352 | } | 2372 | } |
2373 | + | ||
2353 | ansi_process_s(ctl_see((int) c)); | 2374 | ansi_process_s(ctl_see((int) c)); |
2354 | ansi_process_s("\r\n"); | 2375 | ansi_process_s("\r\n"); |
2355 | for (p = hSession->lbuf; p < hSession->lbptr; p++) | 2376 | for (p = hSession->lbuf; p < hSession->lbptr; p++) |
@@ -2358,40 +2379,49 @@ static void do_rprnt(H3270 *hSession, char c) | @@ -2358,40 +2379,49 @@ static void do_rprnt(H3270 *hSession, char c) | ||
2358 | 2379 | ||
2359 | static void do_eof(H3270 *hSession, char c) | 2380 | static void do_eof(H3270 *hSession, char c) |
2360 | { | 2381 | { |
2361 | - if (hSession->backslashed) { | 2382 | + if (hSession->backslashed) |
2383 | + { | ||
2362 | hSession->lbptr--; | 2384 | hSession->lbptr--; |
2363 | ansi_process_s("\b"); | 2385 | ansi_process_s("\b"); |
2364 | - do_data(c); | 2386 | + do_data(hSession,c); |
2365 | return; | 2387 | return; |
2366 | } | 2388 | } |
2367 | - if (hSession->lnext) { | ||
2368 | - do_data(c); | 2389 | + |
2390 | + if (hSession->lnext) | ||
2391 | + { | ||
2392 | + do_data(hSession,c); | ||
2369 | return; | 2393 | return; |
2370 | } | 2394 | } |
2371 | - do_data(c); | ||
2372 | - forward_data(); | 2395 | + |
2396 | + do_data(hSession,c); | ||
2397 | + forward_data(hSession); | ||
2373 | } | 2398 | } |
2374 | 2399 | ||
2375 | static void do_eol(H3270 *hSession, char c) | 2400 | static void do_eol(H3270 *hSession, char c) |
2376 | { | 2401 | { |
2377 | - if (hSession->lnext) { | ||
2378 | - do_data(c); | 2402 | + if (hSession->lnext) |
2403 | + { | ||
2404 | + do_data(hSession,c); | ||
2379 | return; | 2405 | return; |
2380 | } | 2406 | } |
2381 | - if (hSession->lbptr+2 >= hSession->lbuf + BUFSZ) { | 2407 | + |
2408 | + if (hSession->lbptr+2 >= hSession->lbuf + BUFSZ) | ||
2409 | + { | ||
2382 | ansi_process_s("\007"); | 2410 | ansi_process_s("\007"); |
2383 | return; | 2411 | return; |
2384 | } | 2412 | } |
2413 | + | ||
2385 | *hSession->lbptr++ = '\r'; | 2414 | *hSession->lbptr++ = '\r'; |
2386 | *hSession->lbptr++ = '\n'; | 2415 | *hSession->lbptr++ = '\n'; |
2387 | ansi_process_s("\r\n"); | 2416 | ansi_process_s("\r\n"); |
2388 | - forward_data(); | 2417 | + forward_data(hSession); |
2389 | } | 2418 | } |
2390 | 2419 | ||
2391 | static void do_lnext(H3270 *hSession, char c) | 2420 | static void do_lnext(H3270 *hSession, char c) |
2392 | { | 2421 | { |
2393 | - if (hSession->lnext) { | ||
2394 | - do_data(c); | 2422 | + if (hSession->lnext) |
2423 | + { | ||
2424 | + do_data(hSession,c); | ||
2395 | return; | 2425 | return; |
2396 | } | 2426 | } |
2397 | hSession->lnext = 1; | 2427 | hSession->lnext = 1; |
@@ -2519,29 +2549,34 @@ static void store3270in(H3270 *hSession, unsigned char c) | @@ -2519,29 +2549,34 @@ static void store3270in(H3270 *hSession, unsigned char c) | ||
2519 | *hSession->ibptr++ = c; | 2549 | *hSession->ibptr++ = c; |
2520 | } | 2550 | } |
2521 | 2551 | ||
2522 | -/* | ||
2523 | - * space3270out | ||
2524 | - * Ensure that <n> more characters will fit in the 3270 output buffer. | ||
2525 | - * Allocates the buffer in BUFSIZ chunks. | ||
2526 | - * Allocates hidden space at the front of the buffer for TN3270E. | 2552 | +/** |
2553 | + * Ensure that <n> more characters will fit in the 3270 output buffer. | ||
2554 | + * | ||
2555 | + * Allocates the buffer in BUFSIZ chunks. | ||
2556 | + * Allocates hidden space at the front of the buffer for TN3270E. | ||
2557 | + * | ||
2558 | + * @param hSession 3270 session handle. | ||
2559 | + * @param n Number of characters to set. | ||
2527 | */ | 2560 | */ |
2528 | -void space3270out(int n) | 2561 | +void space3270out(H3270 *hSession, int n) |
2529 | { | 2562 | { |
2530 | unsigned nc = 0; /* amount of data currently in obuf */ | 2563 | unsigned nc = 0; /* amount of data currently in obuf */ |
2531 | unsigned more = 0; | 2564 | unsigned more = 0; |
2532 | 2565 | ||
2533 | - if (h3270.obuf_size) | ||
2534 | - nc = h3270.obptr - h3270.obuf; | 2566 | + if (hSession->obuf_size) |
2567 | + nc = hSession->obptr - hSession->obuf; | ||
2535 | 2568 | ||
2536 | - while ((nc + n + EH_SIZE) > (h3270.obuf_size + more)) { | 2569 | + while ((nc + n + EH_SIZE) > (hSession->obuf_size + more)) |
2570 | + { | ||
2537 | more += BUFSIZ; | 2571 | more += BUFSIZ; |
2538 | } | 2572 | } |
2539 | 2573 | ||
2540 | - if (more) { | ||
2541 | - h3270.obuf_size += more; | ||
2542 | - h3270.obuf_base = (unsigned char *)Realloc((char *) h3270.obuf_base,h3270.obuf_size); | ||
2543 | - h3270.obuf = h3270.obuf_base + EH_SIZE; | ||
2544 | - h3270.obptr = h3270.obuf + nc; | 2574 | + if (more) |
2575 | + { | ||
2576 | + hSession->obuf_size += more; | ||
2577 | + hSession->obuf_base = (unsigned char *)Realloc((char *) hSession->obuf_base,hSession->obuf_size); | ||
2578 | + hSession->obuf = hSession->obuf_base + EH_SIZE; | ||
2579 | + hSession->obptr = hSession->obuf + nc; | ||
2545 | } | 2580 | } |
2546 | } | 2581 | } |
2547 | 2582 | ||
@@ -2660,66 +2695,75 @@ void trace_netdata(char direction, unsigned const char *buf, int len) | @@ -2660,66 +2695,75 @@ void trace_netdata(char direction, unsigned const char *buf, int len) | ||
2660 | #endif // X3270_TRACE | 2695 | #endif // X3270_TRACE |
2661 | 2696 | ||
2662 | 2697 | ||
2663 | -/* | ||
2664 | - * net_output | ||
2665 | - * Send 3270 output over the network: | 2698 | +/** |
2699 | + * Send 3270 output over the network. | ||
2700 | + * | ||
2701 | + * Send 3270 output over the network: | ||
2666 | * - Prepend TN3270E header | 2702 | * - Prepend TN3270E header |
2667 | * - Expand IAC to IAC IAC | 2703 | * - Expand IAC to IAC IAC |
2668 | * - Append IAC EOR | 2704 | * - Append IAC EOR |
2705 | + * | ||
2706 | + * @param hSession Session handle | ||
2707 | + * | ||
2669 | */ | 2708 | */ |
2670 | -void | ||
2671 | -net_output(void) | 2709 | +void net_output(H3270 *hSession) |
2672 | { | 2710 | { |
2673 | static unsigned char *xobuf = NULL; | 2711 | static unsigned char *xobuf = NULL; |
2674 | static int xobuf_len = 0; | 2712 | static int xobuf_len = 0; |
2675 | int need_resize = 0; | 2713 | int need_resize = 0; |
2676 | unsigned char *nxoptr, *xoptr; | 2714 | unsigned char *nxoptr, *xoptr; |
2677 | 2715 | ||
2678 | -#if defined(X3270_TN3270E) /*[*/ | ||
2679 | -#define BSTART ((IN_TN3270E || IN_SSCP) ? h3270.obuf_base : h3270.obuf) | ||
2680 | -#else /*][*/ | ||
2681 | -#define BSTART obuf | ||
2682 | -#endif /*]*/ | 2716 | +#if defined(X3270_TN3270E) |
2717 | + #define BSTART ((IN_TN3270E || IN_SSCP) ? hSession->obuf_base : hSession->obuf) | ||
2718 | +#else | ||
2719 | + #define BSTART obuf | ||
2720 | +#endif | ||
2683 | 2721 | ||
2684 | #if defined(X3270_TN3270E) /*[*/ | 2722 | #if defined(X3270_TN3270E) /*[*/ |
2685 | /* Set the TN3720E header. */ | 2723 | /* Set the TN3720E header. */ |
2686 | - if (IN_TN3270E || IN_SSCP) { | ||
2687 | - tn3270e_header *h = (tn3270e_header *) h3270.obuf_base; | 2724 | + if (IN_TN3270E || IN_SSCP) |
2725 | + { | ||
2726 | + tn3270e_header *h = (tn3270e_header *) hSession->obuf_base; | ||
2688 | 2727 | ||
2689 | /* Check for sending a TN3270E response. */ | 2728 | /* Check for sending a TN3270E response. */ |
2690 | - if (h3270.response_required == TN3270E_RSF_ALWAYS_RESPONSE) { | ||
2691 | - tn3270e_ack(&h3270); | ||
2692 | - h3270.response_required = TN3270E_RSF_NO_RESPONSE; | 2729 | + if (hSession->response_required == TN3270E_RSF_ALWAYS_RESPONSE) |
2730 | + { | ||
2731 | + tn3270e_ack(hSession); | ||
2732 | + hSession->response_required = TN3270E_RSF_NO_RESPONSE; | ||
2693 | } | 2733 | } |
2694 | 2734 | ||
2695 | /* Set the outbound TN3270E header. */ | 2735 | /* Set the outbound TN3270E header. */ |
2696 | - h->data_type = IN_TN3270E ? | ||
2697 | - TN3270E_DT_3270_DATA : TN3270E_DT_SSCP_LU_DATA; | 2736 | + h->data_type = IN_TN3270E ? TN3270E_DT_3270_DATA : TN3270E_DT_SSCP_LU_DATA; |
2698 | h->request_flag = 0; | 2737 | h->request_flag = 0; |
2699 | h->response_flag = 0; | 2738 | h->response_flag = 0; |
2700 | - h->seq_number[0] = (h3270.e_xmit_seq >> 8) & 0xff; | ||
2701 | - h->seq_number[1] = h3270.e_xmit_seq & 0xff; | 2739 | + h->seq_number[0] = (hSession->e_xmit_seq >> 8) & 0xff; |
2740 | + h->seq_number[1] = hSession->e_xmit_seq & 0xff; | ||
2702 | 2741 | ||
2703 | - trace_dsn("SENT TN3270E(%s NO-RESPONSE %u)\n",IN_TN3270E ? "3270-DATA" : "SSCP-LU-DATA", h3270.e_xmit_seq); | ||
2704 | - if (h3270.e_funcs & E_OPT(TN3270E_FUNC_RESPONSES)) | ||
2705 | - h3270.e_xmit_seq = (h3270.e_xmit_seq + 1) & 0x7fff; | 2742 | + trace_dsn("SENT TN3270E(%s NO-RESPONSE %u)\n",IN_TN3270E ? "3270-DATA" : "SSCP-LU-DATA", hSession->e_xmit_seq); |
2743 | + if (hSession->e_funcs & E_OPT(TN3270E_FUNC_RESPONSES)) | ||
2744 | + hSession->e_xmit_seq = (hSession->e_xmit_seq + 1) & 0x7fff; | ||
2706 | } | 2745 | } |
2707 | #endif /*]*/ | 2746 | #endif /*]*/ |
2708 | 2747 | ||
2709 | /* Reallocate the expanded output buffer. */ | 2748 | /* Reallocate the expanded output buffer. */ |
2710 | - while (xobuf_len < (h3270.obptr - BSTART + 1) * 2) { | 2749 | + while (xobuf_len < (hSession->obptr - BSTART + 1) * 2) |
2750 | + { | ||
2711 | xobuf_len += BUFSZ; | 2751 | xobuf_len += BUFSZ; |
2712 | need_resize++; | 2752 | need_resize++; |
2713 | } | 2753 | } |
2714 | - if (need_resize) { | 2754 | + |
2755 | + if (need_resize) | ||
2756 | + { | ||
2715 | Replace(xobuf, (unsigned char *)lib3270_malloc(xobuf_len)); | 2757 | Replace(xobuf, (unsigned char *)lib3270_malloc(xobuf_len)); |
2716 | } | 2758 | } |
2717 | 2759 | ||
2718 | /* Copy and expand IACs. */ | 2760 | /* Copy and expand IACs. */ |
2719 | xoptr = xobuf; | 2761 | xoptr = xobuf; |
2720 | nxoptr = BSTART; | 2762 | nxoptr = BSTART; |
2721 | - while (nxoptr < h3270.obptr) { | ||
2722 | - if ((*xoptr++ = *nxoptr++) == IAC) { | 2763 | + while (nxoptr < hSession->obptr) |
2764 | + { | ||
2765 | + if ((*xoptr++ = *nxoptr++) == IAC) | ||
2766 | + { | ||
2723 | *xoptr++ = IAC; | 2767 | *xoptr++ = IAC; |
2724 | } | 2768 | } |
2725 | } | 2769 | } |
@@ -2727,10 +2771,10 @@ net_output(void) | @@ -2727,10 +2771,10 @@ net_output(void) | ||
2727 | /* Append the IAC EOR and transmit. */ | 2771 | /* Append the IAC EOR and transmit. */ |
2728 | *xoptr++ = IAC; | 2772 | *xoptr++ = IAC; |
2729 | *xoptr++ = EOR; | 2773 | *xoptr++ = EOR; |
2730 | - net_rawout(&h3270,xobuf, xoptr - xobuf); | 2774 | + net_rawout(hSession,xobuf, xoptr - xobuf); |
2731 | 2775 | ||
2732 | trace_dsn("SENT EOR\n"); | 2776 | trace_dsn("SENT EOR\n"); |
2733 | - h3270.ns_rsent++; | 2777 | + hSession->ns_rsent++; |
2734 | #undef BSTART | 2778 | #undef BSTART |
2735 | } | 2779 | } |
2736 | 2780 | ||
@@ -2808,7 +2852,7 @@ net_add_dummy_tn3270e(void) | @@ -2808,7 +2852,7 @@ net_add_dummy_tn3270e(void) | ||
2808 | if (!IN_E || h3270.tn3270e_submode == E_NONE) | 2852 | if (!IN_E || h3270.tn3270e_submode == E_NONE) |
2809 | return False; | 2853 | return False; |
2810 | 2854 | ||
2811 | - space3270out(EH_SIZE); | 2855 | + space3270out(&h3270,EH_SIZE); |
2812 | h = (tn3270e_header *)h3270.obptr; | 2856 | h = (tn3270e_header *)h3270.obptr; |
2813 | 2857 | ||
2814 | switch (h3270.tn3270e_submode) { | 2858 | switch (h3270.tn3270e_submode) { |
telnetc.h
@@ -42,7 +42,7 @@ LIB3270_INTERNAL void net_input(H3270 *session); | @@ -42,7 +42,7 @@ LIB3270_INTERNAL void net_input(H3270 *session); | ||
42 | LIB3270_INTERNAL void net_interrupt(void); | 42 | LIB3270_INTERNAL void net_interrupt(void); |
43 | // LIB3270_INTERNAL void net_linemode(void); | 43 | // LIB3270_INTERNAL void net_linemode(void); |
44 | // LIB3270_INTERNAL struct ctl_char *net_linemode_chars(void); | 44 | // LIB3270_INTERNAL struct ctl_char *net_linemode_chars(void); |
45 | -LIB3270_INTERNAL void net_output(void); | 45 | +LIB3270_INTERNAL void net_output(H3270 *hSession); |
46 | LIB3270_INTERNAL const char *net_query_bind_plu_name(void); | 46 | LIB3270_INTERNAL const char *net_query_bind_plu_name(void); |
47 | LIB3270_INTERNAL const char *net_query_connection_state(void); | 47 | LIB3270_INTERNAL const char *net_query_connection_state(void); |
48 | LIB3270_INTERNAL const char *net_query_host(void); | 48 | LIB3270_INTERNAL const char *net_query_host(void); |
@@ -53,7 +53,7 @@ LIB3270_INTERNAL void net_send_erase(void); | @@ -53,7 +53,7 @@ LIB3270_INTERNAL void net_send_erase(void); | ||
53 | LIB3270_INTERNAL void net_send_kill(void); | 53 | LIB3270_INTERNAL void net_send_kill(void); |
54 | LIB3270_INTERNAL void net_send_werase(void); | 54 | LIB3270_INTERNAL void net_send_werase(void); |
55 | // LIB3270_INTERNAL Boolean net_snap_options(void); | 55 | // LIB3270_INTERNAL Boolean net_snap_options(void); |
56 | -LIB3270_INTERNAL void space3270out(int n); | 56 | +LIB3270_INTERNAL void space3270out(H3270 *hSession, int n); |
57 | // LIB3270_INTERNAL const char *tn3270e_current_opts(void); | 57 | // LIB3270_INTERNAL const char *tn3270e_current_opts(void); |
58 | // LIB3270_INTERNAL char *net_proxy_type(void); | 58 | // LIB3270_INTERNAL char *net_proxy_type(void); |
59 | //LIB3270_INTERNAL char *net_proxy_host(void); | 59 | //LIB3270_INTERNAL char *net_proxy_host(void); |