Commit 9a120c29c39c52ec0f3df0f86cf33541cd1c2cc0

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

Mudando processo de trace para um único callback

@@ -407,10 +407,10 @@ @@ -407,10 +407,10 @@
407 #define register_schange(tx,func) lib3270_register_schange(NULL,tx,func,NULL) 407 #define register_schange(tx,func) lib3270_register_schange(NULL,tx,func,NULL)
408 408
409 /* Console/Trace window */ 409 /* Console/Trace window */
410 - LOCAL_EXTERN HCONSOLE console_window_new(const char *title, const char *label);  
411 - LOCAL_EXTERN void console_window_delete(HCONSOLE hwnd);  
412 - LOCAL_EXTERN int console_window_append(HCONSOLE hwnd, const char *fmt, ...);  
413 - LOCAL_EXTERN char * console_window_wait_for_user_entry(HCONSOLE hwnd); 410 +// LOCAL_EXTERN HCONSOLE console_window_new(const char *title, const char *label);
  411 +// LOCAL_EXTERN void console_window_delete(HCONSOLE hwnd);
  412 +// LOCAL_EXTERN int console_window_append(HCONSOLE hwnd, const char *fmt, ...);
  413 +// LOCAL_EXTERN char * console_window_wait_for_user_entry(HCONSOLE hwnd);
414 414
415 #ifdef __cplusplus 415 #ifdef __cplusplus
416 } 416 }
@@ -737,8 +737,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) @@ -737,8 +737,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all)
737 *obptr++ = h3270.ea_buf[baddr].cc; 737 *obptr++ = h3270.ea_buf[baddr].cc;
738 if (!any) 738 if (!any)
739 trace_ds(" '"); 739 trace_ds(" '");
740 - trace_ds("%s",  
741 - see_ebc(ea_buf[baddr].cc)); 740 + trace_ds("%s",see_ebc(h3270.ea_buf[baddr].cc));
742 any = True; 741 any = True;
743 } 742 }
744 INC_BA(baddr); 743 INC_BA(baddr);
@@ -783,7 +782,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) @@ -783,7 +782,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all)
783 *obptr++ = h3270.ea_buf[baddr].cc; 782 *obptr++ = h3270.ea_buf[baddr].cc;
784 if (!any) 783 if (!any)
785 trace_ds("%s","'"); 784 trace_ds("%s","'");
786 - trace_ds("%s",see_ebc(ea_buf[baddr].cc)); 785 + trace_ds("%s",see_ebc(h3270.ea_buf[baddr].cc));
787 any = True; 786 any = True;
788 nbytes++; 787 nbytes++;
789 } 788 }
@@ -861,16 +860,14 @@ ctlr_read_buffer(unsigned char aid_byte) @@ -861,16 +860,14 @@ ctlr_read_buffer(unsigned char aid_byte)
861 space3270out(2); 860 space3270out(2);
862 *obptr++ = XA_FOREGROUND; 861 *obptr++ = XA_FOREGROUND;
863 *obptr++ = h3270.ea_buf[baddr].fg; 862 *obptr++ = h3270.ea_buf[baddr].fg;
864 - trace_ds("%s", see_efa(XA_FOREGROUND,  
865 - ea_buf[baddr].fg)); 863 + trace_ds("%s", see_efa(XA_FOREGROUND, h3270.ea_buf[baddr].fg));
866 (*(obuf + attr_count))++; 864 (*(obuf + attr_count))++;
867 } 865 }
868 if (h3270.ea_buf[baddr].bg) { 866 if (h3270.ea_buf[baddr].bg) {
869 space3270out(2); 867 space3270out(2);
870 *obptr++ = XA_BACKGROUND; 868 *obptr++ = XA_BACKGROUND;
871 *obptr++ = h3270.ea_buf[baddr].bg; 869 *obptr++ = h3270.ea_buf[baddr].bg;
872 - trace_ds("%s", see_efa(XA_BACKGROUND,  
873 - ea_buf[baddr].bg)); 870 + trace_ds("%s", see_efa(XA_BACKGROUND, h3270.ea_buf[baddr].bg));
874 (*(obuf + attr_count))++; 871 (*(obuf + attr_count))++;
875 } 872 }
876 if (h3270.ea_buf[baddr].gr) { 873 if (h3270.ea_buf[baddr].gr) {
@@ -885,8 +882,7 @@ ctlr_read_buffer(unsigned char aid_byte) @@ -885,8 +882,7 @@ ctlr_read_buffer(unsigned char aid_byte)
885 space3270out(2); 882 space3270out(2);
886 *obptr++ = XA_CHARSET; 883 *obptr++ = XA_CHARSET;
887 *obptr++ = host_cs(h3270.ea_buf[baddr].cs); 884 *obptr++ = host_cs(h3270.ea_buf[baddr].cs);
888 - trace_ds("%s", see_efa(XA_CHARSET,  
889 - host_cs(ea_buf[baddr].cs))); 885 + trace_ds("%s", see_efa(XA_CHARSET,host_cs(h3270.ea_buf[baddr].cs)));
890 (*(obuf + attr_count))++; 886 (*(obuf + attr_count))++;
891 } 887 }
892 } 888 }
@@ -913,12 +909,12 @@ ctlr_read_buffer(unsigned char aid_byte) @@ -913,12 +909,12 @@ ctlr_read_buffer(unsigned char aid_byte)
913 if (any) 909 if (any)
914 trace_ds("'"); 910 trace_ds("'");
915 911
916 - trace_ds(" %s", see_ebc(ea_buf[baddr].cc)); 912 + trace_ds(" %s", see_ebc(h3270.ea_buf[baddr].cc));
917 any = False; 913 any = False;
918 } else { 914 } else {
919 if (!any) 915 if (!any)
920 trace_ds(" '"); 916 trace_ds(" '");
921 - trace_ds("%s", see_ebc(ea_buf[baddr].cc)); 917 + trace_ds("%s", see_ebc(h3270.ea_buf[baddr].cc));
922 any = True; 918 any = True;
923 } 919 }
924 } 920 }
@@ -951,39 +947,39 @@ ctlr_snap_buffer(void) @@ -951,39 +947,39 @@ ctlr_snap_buffer(void)
951 *obptr++ = code_table[0]; 947 *obptr++ = code_table[0];
952 948
953 do { 949 do {
954 - if (ea_buf[baddr].fa) { 950 + if (h3270.ea_buf[baddr].fa) {
955 space3270out(4); 951 space3270out(4);
956 *obptr++ = ORDER_SFE; 952 *obptr++ = ORDER_SFE;
957 attr_count = obptr - obuf; 953 attr_count = obptr - obuf;
958 *obptr++ = 1; /* for now */ 954 *obptr++ = 1; /* for now */
959 *obptr++ = XA_3270; 955 *obptr++ = XA_3270;
960 - *obptr++ = code_table[ea_buf[baddr].fa & ~FA_PRINTABLE];  
961 - if (ea_buf[baddr].fg) { 956 + *obptr++ = code_table[h3270.ea_buf[baddr].fa & ~FA_PRINTABLE];
  957 + if (h3270.ea_buf[baddr].fg) {
962 space3270out(2); 958 space3270out(2);
963 *obptr++ = XA_FOREGROUND; 959 *obptr++ = XA_FOREGROUND;
964 - *obptr++ = ea_buf[baddr].fg; 960 + *obptr++ = h3270.ea_buf[baddr].fg;
965 (*(obuf + attr_count))++; 961 (*(obuf + attr_count))++;
966 } 962 }
967 - if (ea_buf[baddr].bg) { 963 + if (h3270.ea_buf[baddr].bg) {
968 space3270out(2); 964 space3270out(2);
969 *obptr++ = XA_BACKGROUND; 965 *obptr++ = XA_BACKGROUND;
970 - *obptr++ = ea_buf[baddr].fg; 966 + *obptr++ = h3270.ea_buf[baddr].fg;
971 (*(obuf + attr_count))++; 967 (*(obuf + attr_count))++;
972 } 968 }
973 - if (ea_buf[baddr].gr) { 969 + if (h3270.ea_buf[baddr].gr) {
974 space3270out(2); 970 space3270out(2);
975 *obptr++ = XA_HIGHLIGHTING; 971 *obptr++ = XA_HIGHLIGHTING;
976 - *obptr++ = ea_buf[baddr].gr | 0xf0; 972 + *obptr++ = h3270.ea_buf[baddr].gr | 0xf0;
977 (*(obuf + attr_count))++; 973 (*(obuf + attr_count))++;
978 } 974 }
979 - if (ea_buf[baddr].cs & CS_MASK) { 975 + if (h3270.ea_buf[baddr].cs & CS_MASK) {
980 space3270out(2); 976 space3270out(2);
981 *obptr++ = XA_CHARSET; 977 *obptr++ = XA_CHARSET;
982 - *obptr++ = host_cs(ea_buf[baddr].cs); 978 + *obptr++ = host_cs(h3270.ea_buf[baddr].cs);
983 (*(obuf + attr_count))++; 979 (*(obuf + attr_count))++;
984 } 980 }
985 } else { 981 } else {
986 - av = ea_buf[baddr].fg; 982 + av = h3270.ea_buf[baddr].fg;
987 if (current_fg != av) { 983 if (current_fg != av) {
988 current_fg = av; 984 current_fg = av;
989 space3270out(3); 985 space3270out(3);
@@ -991,7 +987,7 @@ ctlr_snap_buffer(void) @@ -991,7 +987,7 @@ ctlr_snap_buffer(void)
991 *obptr++ = XA_FOREGROUND; 987 *obptr++ = XA_FOREGROUND;
992 *obptr++ = av; 988 *obptr++ = av;
993 } 989 }
994 - av = ea_buf[baddr].bg; 990 + av = h3270.ea_buf[baddr].bg;
995 if (current_bg != av) { 991 if (current_bg != av) {
996 current_bg = av; 992 current_bg = av;
997 space3270out(3); 993 space3270out(3);
@@ -999,7 +995,7 @@ ctlr_snap_buffer(void) @@ -999,7 +995,7 @@ ctlr_snap_buffer(void)
999 *obptr++ = XA_BACKGROUND; 995 *obptr++ = XA_BACKGROUND;
1000 *obptr++ = av; 996 *obptr++ = av;
1001 } 997 }
1002 - av = ea_buf[baddr].gr; 998 + av = h3270.ea_buf[baddr].gr;
1003 if (av) 999 if (av)
1004 av |= 0xf0; 1000 av |= 0xf0;
1005 if (current_gr != av) { 1001 if (current_gr != av) {
@@ -1009,7 +1005,7 @@ ctlr_snap_buffer(void) @@ -1009,7 +1005,7 @@ ctlr_snap_buffer(void)
1009 *obptr++ = XA_HIGHLIGHTING; 1005 *obptr++ = XA_HIGHLIGHTING;
1010 *obptr++ = av; 1006 *obptr++ = av;
1011 } 1007 }
1012 - av = ea_buf[baddr].cs & CS_MASK; 1008 + av = h3270.ea_buf[baddr].cs & CS_MASK;
1013 if (av) 1009 if (av)
1014 av = host_cs(av); 1010 av = host_cs(av);
1015 if (current_cs != av) { 1011 if (current_cs != av) {
@@ -1019,12 +1015,12 @@ ctlr_snap_buffer(void) @@ -1019,12 +1015,12 @@ ctlr_snap_buffer(void)
1019 *obptr++ = XA_CHARSET; 1015 *obptr++ = XA_CHARSET;
1020 *obptr++ = av; 1016 *obptr++ = av;
1021 } 1017 }
1022 - if (ea_buf[baddr].cs & CS_GE) { 1018 + if (h3270.ea_buf[baddr].cs & CS_GE) {
1023 space3270out(1); 1019 space3270out(1);
1024 *obptr++ = ORDER_GE; 1020 *obptr++ = ORDER_GE;
1025 } 1021 }
1026 space3270out(1); 1022 space3270out(1);
1027 - *obptr++ = ea_buf[baddr].cc; 1023 + *obptr++ = h3270.ea_buf[baddr].cc;
1028 } 1024 }
1029 INC_BA(baddr); 1025 INC_BA(baddr);
1030 } while (baddr != 0); 1026 } while (baddr != 0);
@@ -1233,7 +1229,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) @@ -1233,7 +1229,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1233 case ORDER_SF: /* start field */ 1229 case ORDER_SF: /* start field */
1234 END_TEXT("StartField"); 1230 END_TEXT("StartField");
1235 if (previous != SBA) 1231 if (previous != SBA)
1236 - trace_ds("%s",rcba(buffer_addr)); 1232 + trace_ds("%s",rcba(h3270.buffer_addr));
1237 previous = ORDER; 1233 previous = ORDER;
1238 cp++; /* skip field attribute */ 1234 cp++; /* skip field attribute */
1239 START_FIELD(*cp); 1235 START_FIELD(*cp);
@@ -1260,7 +1256,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) @@ -1260,7 +1256,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1260 case ORDER_IC: /* insert cursor */ 1256 case ORDER_IC: /* insert cursor */
1261 END_TEXT("InsertCursor"); 1257 END_TEXT("InsertCursor");
1262 if (previous != SBA) 1258 if (previous != SBA)
1263 - trace_ds("%s",rcba(buffer_addr)); 1259 + trace_ds("%s",rcba(h3270.buffer_addr));
1264 previous = ORDER; 1260 previous = ORDER;
1265 cursor_move(&h3270,h3270.buffer_addr); 1261 cursor_move(&h3270,h3270.buffer_addr);
1266 last_cmd = True; 1262 last_cmd = True;
@@ -1471,7 +1467,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) @@ -1471,7 +1467,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1471 case ORDER_MF: /* modify field */ 1467 case ORDER_MF: /* modify field */
1472 END_TEXT("ModifyField"); 1468 END_TEXT("ModifyField");
1473 if (previous != SBA) 1469 if (previous != SBA)
1474 - trace_ds("%s",rcba(buffer_addr)); 1470 + trace_ds("%s",rcba(h3270.buffer_addr));
1475 previous = ORDER; 1471 previous = ORDER;
1476 cp++; 1472 cp++;
1477 na = *cp; 1473 na = *cp;
@@ -1542,7 +1538,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) @@ -1542,7 +1538,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1542 case ORDER_SFE: /* start field extended */ 1538 case ORDER_SFE: /* start field extended */
1543 END_TEXT("StartFieldExtended"); 1539 END_TEXT("StartFieldExtended");
1544 if (previous != SBA) 1540 if (previous != SBA)
1545 - trace_ds("%s",rcba(buffer_addr)); 1541 + trace_ds("%s",rcba(h3270.buffer_addr));
1546 previous = ORDER; 1542 previous = ORDER;
1547 cp++; /* skip order */ 1543 cp++; /* skip order */
1548 na = *cp; 1544 na = *cp;
@@ -288,7 +288,7 @@ ft_cut_data(void) @@ -288,7 +288,7 @@ ft_cut_data(void)
288 cut_data(); 288 cut_data();
289 break; 289 break;
290 default: 290 default:
291 - trace_ds("< FT unknown 0x%02x\n", ea_buf[O_FRAME_TYPE].cc); 291 + trace_ds("< FT unknown 0x%02x\n", h3270.ea_buf[O_FRAME_TYPE].cc);
292 cut_abort(_(" Unknown frame type from host"), SC_ABORT_XMIT); 292 cut_abort(_(" Unknown frame type from host"), SC_ABORT_XMIT);
293 break; 293 break;
294 } 294 }
@@ -311,9 +311,9 @@ static const struct lib3270_option options[] = @@ -311,9 +311,9 @@ static const struct lib3270_option options[] =
311 { OptCharset, OPT_STRING, False, ResCharset, offset(charset), NULL }, 311 { OptCharset, OPT_STRING, False, ResCharset, offset(charset), NULL },
312 { OptClear, OPT_SKIP2, False, NULL, NULL, NULL }, 312 { OptClear, OPT_SKIP2, False, NULL, NULL, NULL },
313 // { OptDefScreen,OPT_STRING, False, ResDefScreen, offset(defscreen), NULL }, 313 // { OptDefScreen,OPT_STRING, False, ResDefScreen, offset(defscreen), NULL },
314 -#if defined(X3270_TRACE) /*[*/  
315 - { OptDsTrace, OPT_BOOLEAN, True, ResDsTrace, toggle_offset(DS_TRACE), NULL },  
316 -#endif /*]*/ 314 +//#if defined(X3270_TRACE)
  315 +// { OptDsTrace, OPT_BOOLEAN, True, ResDsTrace, toggle_offset(DS_TRACE), NULL },
  316 +//#endif /*]*/
317 // { OptHostsFile,OPT_STRING, False, ResHostsFile, offset(hostsfile), NULL }, 317 // { OptHostsFile,OPT_STRING, False, ResHostsFile, offset(hostsfile), NULL },
318 //#if defined(C3270) 318 //#if defined(C3270)
319 // { OptKeymap, OPT_STRING, False, ResKeymap, offset(key_map), N_( "Specifies a keymap name and optional modifiers." ) }, 319 // { OptKeymap, OPT_STRING, False, ResKeymap, offset(key_map), N_( "Specifies a keymap name and optional modifiers." ) },
@@ -74,9 +74,9 @@ @@ -74,9 +74,9 @@
74 74
75 /*--[ Implement ]------------------------------------------------------------------------------------*/ 75 /*--[ Implement ]------------------------------------------------------------------------------------*/
76 76
77 -static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); 77 +static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg);
78 78
79 -static int (*popup_handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list) = logpopup; 79 +static int (*popup_handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list) = logpopup;
80 80
81 enum ts { TS_AUTO, TS_ON, TS_OFF }; 81 enum ts { TS_AUTO, TS_ON, TS_OFF };
82 82
@@ -601,12 +601,12 @@ void show_3270_popup_dialog(H3270 *session, LIB3270_NOTIFY type, const char *tit @@ -601,12 +601,12 @@ void show_3270_popup_dialog(H3270 *session, LIB3270_NOTIFY type, const char *tit
601 601
602 va_list arg_ptr; 602 va_list arg_ptr;
603 va_start(arg_ptr, fmt); 603 va_start(arg_ptr, fmt);
604 - popup_handler(session,type,title,msg,fmt,arg_ptr); 604 + popup_handler(session,session->widget,type,title,msg,fmt,arg_ptr);
605 va_end(arg_ptr); 605 va_end(arg_ptr);
606 606
607 } 607 }
608 608
609 -static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) 609 +static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg)
610 { 610 {
611 lib3270_write_va_log(session,"lib3270",fmt,arg); 611 lib3270_write_va_log(session,"lib3270",fmt,arg);
612 return 0; 612 return 0;
@@ -619,7 +619,7 @@ void Error(H3270 *session, const char *fmt, ...) @@ -619,7 +619,7 @@ void Error(H3270 *session, const char *fmt, ...)
619 CHECK_SESSION_HANDLE(session); 619 CHECK_SESSION_HANDLE(session);
620 620
621 va_start(arg_ptr, fmt); 621 va_start(arg_ptr, fmt);
622 - popup_handler(session,LIB3270_NOTIFY_ERROR, _( "3270 Error" ),NULL,fmt,arg_ptr); 622 + popup_handler(session,session->widget,LIB3270_NOTIFY_ERROR, _( "3270 Error" ),NULL,fmt,arg_ptr);
623 va_end(arg_ptr); 623 va_end(arg_ptr);
624 624
625 } 625 }
@@ -631,7 +631,7 @@ void Warning(H3270 *session, const char *fmt, ...) @@ -631,7 +631,7 @@ void Warning(H3270 *session, const char *fmt, ...)
631 CHECK_SESSION_HANDLE(session); 631 CHECK_SESSION_HANDLE(session);
632 632
633 va_start(arg_ptr, fmt); 633 va_start(arg_ptr, fmt);
634 - popup_handler(session,LIB3270_NOTIFY_WARNING, _( "3270 Warning" ),NULL,fmt,arg_ptr); 634 + popup_handler(session,session->widget,LIB3270_NOTIFY_WARNING, _( "3270 Warning" ),NULL,fmt,arg_ptr);
635 va_end(arg_ptr); 635 va_end(arg_ptr);
636 636
637 } 637 }
@@ -644,7 +644,7 @@ extern void popup_an_error(H3270 *session, const char *fmt, ...) @@ -644,7 +644,7 @@ extern void popup_an_error(H3270 *session, const char *fmt, ...)
644 CHECK_SESSION_HANDLE(session); 644 CHECK_SESSION_HANDLE(session);
645 645
646 va_start(args, fmt); 646 va_start(args, fmt);
647 - popup_handler(session,LIB3270_NOTIFY_ERROR,_( "3270 Error" ),NULL,fmt,args); 647 + popup_handler(session,session->widget,LIB3270_NOTIFY_ERROR,_( "3270 Error" ),NULL,fmt,args);
648 va_end(args); 648 va_end(args);
649 649
650 } 650 }
@@ -656,7 +656,7 @@ void popup_system_error(H3270 *session, const char *title, const char *message, @@ -656,7 +656,7 @@ void popup_system_error(H3270 *session, const char *title, const char *message,
656 CHECK_SESSION_HANDLE(session); 656 CHECK_SESSION_HANDLE(session);
657 657
658 va_start(args, fmt); 658 va_start(args, fmt);
659 - popup_handler(session,LIB3270_NOTIFY_ERROR,title ? title : _( "3270 Error" ), message,fmt,args); 659 + popup_handler(session,session->widget,LIB3270_NOTIFY_ERROR,title ? title : _( "3270 Error" ), message,fmt,args);
660 va_end(args); 660 va_end(args);
661 } 661 }
662 662
@@ -753,7 +753,7 @@ LIB3270_ACTION( testpattern ) @@ -753,7 +753,7 @@ LIB3270_ACTION( testpattern )
753 return 0; 753 return 0;
754 } 754 }
755 755
756 -LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list)) 756 +LIB3270_EXPORT void lib3270_set_popup_handler(int (*handler)(H3270 *, void *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list))
757 { 757 {
758 popup_handler = handler ? handler : logpopup; 758 popup_handler = handler ? handler : logpopup;
759 } 759 }
@@ -765,7 +765,7 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con @@ -765,7 +765,7 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con
765 CHECK_SESSION_HANDLE(session); 765 CHECK_SESSION_HANDLE(session);
766 766
767 va_start(args, fmt); 767 va_start(args, fmt);
768 - popup_handler(session,id,title ? title : _( "3270 Error" ), message,fmt,args); 768 + popup_handler(session,session->widget,id,title ? title : _( "3270 Error" ), message,fmt,args);
769 va_end(args); 769 va_end(args);
770 } 770 }
771 771
@@ -1110,11 +1110,6 @@ void net_input(H3270 *session) @@ -1110,11 +1110,6 @@ void net_input(H3270 *session)
1110 } 1110 }
1111 #endif /*]*/ 1111 #endif /*]*/
1112 1112
1113 -#if defined(X3270_TRACE) /*[*/  
1114 - /* See if it's time to roll over the trace file. */  
1115 - trace_rollover_check();  
1116 -#endif /*]*/  
1117 -  
1118 } 1113 }
1119 1114
1120 } 1115 }
@@ -155,11 +155,13 @@ void initialize_toggles(H3270 *session) @@ -155,11 +155,13 @@ void initialize_toggles(H3270 *session)
155 session->toggle[LIB3270_TOGGLE_RECTANGLE_SELECT].upcall = toggle_rectselect; 155 session->toggle[LIB3270_TOGGLE_RECTANGLE_SELECT].upcall = toggle_rectselect;
156 session->toggle[LIB3270_TOGGLE_MONOCASE].upcall = toggle_monocase; 156 session->toggle[LIB3270_TOGGLE_MONOCASE].upcall = toggle_monocase;
157 157
  158 +/*
158 #if defined(X3270_TRACE) 159 #if defined(X3270_TRACE)
159 session->toggle[LIB3270_TOGGLE_DS_TRACE].upcall = toggle_dsTrace; 160 session->toggle[LIB3270_TOGGLE_DS_TRACE].upcall = toggle_dsTrace;
160 session->toggle[LIB3270_TOGGLE_SCREEN_TRACE].upcall = toggle_screenTrace; 161 session->toggle[LIB3270_TOGGLE_SCREEN_TRACE].upcall = toggle_screenTrace;
161 session->toggle[LIB3270_TOGGLE_EVENT_TRACE].upcall = toggle_eventTrace; 162 session->toggle[LIB3270_TOGGLE_EVENT_TRACE].upcall = toggle_eventTrace;
162 #endif 163 #endif
  164 +*/
163 165
164 #if defined(X3270_ANSI) 166 #if defined(X3270_ANSI)
165 session->toggle[LIB3270_TOGGLE_LINE_WRAP].upcall = toggle_lineWrap; 167 session->toggle[LIB3270_TOGGLE_LINE_WRAP].upcall = toggle_lineWrap;
@@ -197,19 +199,8 @@ void shutdown_toggles(H3270 *session) @@ -197,19 +199,8 @@ void shutdown_toggles(H3270 *session)
197 int f; 199 int f;
198 200
199 for(f=0;f< (sizeof(disable_on_shutdown)/sizeof(disable_on_shutdown[0])); f++) 201 for(f=0;f< (sizeof(disable_on_shutdown)/sizeof(disable_on_shutdown[0])); f++)
200 - {  
201 - LIB3270_TOGGLE ix = disable_on_shutdown[f];  
202 - struct toggle * t = &session->toggle[ix];  
203 -  
204 - if(t->value)  
205 - {  
206 - t->value = False;  
207 - t->upcall(session,&toggle[f],TT_FINAL); 202 + lib3270_set_toggle(session,disable_on_shutdown[f],0);
208 203
209 - if(session->update_toggle)  
210 - session->update_toggle(session,ix,t->value,TT_FINAL,toggle_names[ix]);  
211 - }  
212 - }  
213 #endif 204 #endif
214 } 205 }
215 206
@@ -83,33 +83,37 @@ @@ -83,33 +83,37 @@
83 #define ftello(s) (off_t)ftell(s) 83 #define ftello(s) (off_t)ftell(s)
84 #endif /*]*/ 84 #endif /*]*/
85 85
86 -#include <lib3270/api.h> 86 +// #include <lib3270/api.h>
87 87
88 /* Statics */ 88 /* Statics */
89 static int dscnt = 0; 89 static int dscnt = 0;
90 90
  91 +/*
91 #if defined (LIB3270) 92 #if defined (LIB3270)
92 HCONSOLE tracewindow_handle = 0; 93 HCONSOLE tracewindow_handle = 0;
93 -#elif defined(_WIN32) /*[*/ 94 +#elif defined(_WIN32)
94 static HANDLE tracewindow_handle = NULL; 95 static HANDLE tracewindow_handle = NULL;
95 -#else /*][*/ 96 +#else
96 static int tracewindow_pid = -1; 97 static int tracewindow_pid = -1;
97 -#endif /*]*/ 98 +#endif
  99 +*/
98 100
99 -static FILE *tracef = NULL;  
100 -static FILE *tracef_pipe = NULL;  
101 -static char *tracef_bufptr = CN;  
102 -static off_t tracef_size = 0;  
103 -static off_t tracef_max = 0;  
104 -static char *tracef_midpoint_header = CN;  
105 -static off_t tracef_midpoint = 0;  
106 -static void vwtrace(const char *fmt, va_list args); 101 +// static FILE *tracef = NULL;
  102 +// static FILE *tracef_pipe = NULL;
  103 +// static char *tracef_bufptr = CN;
  104 +// static off_t tracef_size = 0;
  105 +// static off_t tracef_max = 0;
  106 +// static char *tracef_midpoint_header = CN;
  107 +// static off_t tracef_midpoint = 0;
  108 +
  109 +static void __vwtrace(const char *fmt, va_list args);
107 static void wtrace(const char *fmt, ...); 110 static void wtrace(const char *fmt, ...);
108 -static char *create_tracefile_header(const char *mode); 111 +// static char *create_tracefile_header(const char *mode);
109 static void stop_tracing(void); 112 static void stop_tracing(void);
110 113
111 /* Globals */ 114 /* Globals */
112 struct timeval ds_ts; 115 struct timeval ds_ts;
  116 +static void (*vwtrace)(const char *fmt, va_list args) = __vwtrace;
113 Boolean trace_skipping = False; 117 Boolean trace_skipping = False;
114 118
115 /* display a (row,col) */ 119 /* display a (row,col) */
@@ -133,7 +137,7 @@ trace_ds_s(char *s, Boolean can_break) @@ -133,7 +137,7 @@ trace_ds_s(char *s, Boolean can_break)
133 int len = strlen(s); 137 int len = strlen(s);
134 Boolean nl = False; 138 Boolean nl = False;
135 139
136 - if (!toggled(DS_TRACE) || tracef == NULL || !len) 140 + if (!toggled(DS_TRACE) || !len)
137 return; 141 return;
138 142
139 if (s && s[len-1] == '\n') { 143 if (s && s[len-1] == '\n') {
@@ -167,7 +171,7 @@ trace_ds(const char *fmt, ...) @@ -167,7 +171,7 @@ trace_ds(const char *fmt, ...)
167 { 171 {
168 va_list args; 172 va_list args;
169 173
170 - if (!toggled(DS_TRACE) || tracef == NULL) 174 + if (!toggled(DS_TRACE))
171 return; 175 return;
172 176
173 va_start(args, fmt); 177 va_start(args, fmt);
@@ -187,7 +191,7 @@ trace_ds_nb(const char *fmt, ...) @@ -187,7 +191,7 @@ trace_ds_nb(const char *fmt, ...)
187 { 191 {
188 va_list args; 192 va_list args;
189 193
190 - if (!toggled(DS_TRACE) || tracef == NULL) 194 + if (!toggled(DS_TRACE))
191 return; 195 return;
192 196
193 va_start(args, fmt); 197 va_start(args, fmt);
@@ -208,7 +212,7 @@ trace_event(const char *fmt, ...) @@ -208,7 +212,7 @@ trace_event(const char *fmt, ...)
208 { 212 {
209 va_list args; 213 va_list args;
210 214
211 - if (!toggled(EVENT_TRACE) || tracef == NULL) 215 + if (!toggled(EVENT_TRACE))
212 return; 216 return;
213 217
214 /* print out message */ 218 /* print out message */
@@ -223,7 +227,7 @@ trace_dsn(const char *fmt, ...) @@ -223,7 +227,7 @@ trace_dsn(const char *fmt, ...)
223 { 227 {
224 va_list args; 228 va_list args;
225 229
226 - if (!toggled(DS_TRACE) || tracef == NULL) 230 + if (!toggled(DS_TRACE))
227 return; 231 return;
228 232
229 /* print out message */ 233 /* print out message */
@@ -237,6 +241,12 @@ trace_dsn(const char *fmt, ...) @@ -237,6 +241,12 @@ trace_dsn(const char *fmt, ...)
237 * This is the only function that actually does output to the trace file -- 241 * This is the only function that actually does output to the trace file --
238 * all others are wrappers around this function. 242 * all others are wrappers around this function.
239 */ 243 */
  244 +static void __vwtrace(const char *fmt, va_list args)
  245 +{
  246 + vfprintf(stdout,fmt,args);
  247 +}
  248 +
  249 +/*
240 static void vwtrace(const char *fmt, va_list args) 250 static void vwtrace(const char *fmt, va_list args)
241 { 251 {
242 char buf[16384]; 252 char buf[16384];
@@ -255,20 +265,18 @@ static void vwtrace(const char *fmt, va_list args) @@ -255,20 +265,18 @@ static void vwtrace(const char *fmt, va_list args)
255 popup_an_errno(errno,_( "Write to trace file failed\n%s" ),strerror(errno)); 265 popup_an_errno(errno,_( "Write to trace file failed\n%s" ),strerror(errno));
256 } 266 }
257 } 267 }
  268 +*/
258 269
259 /* Write to the trace file. */ 270 /* Write to the trace file. */
260 -static void  
261 -wtrace(const char *fmt, ...) 271 +static void wtrace(const char *fmt, ...)
262 { 272 {
263 - if (tracef != NULL) {  
264 - va_list args;  
265 -  
266 - va_start(args, fmt);  
267 - vwtrace(fmt, args);  
268 - va_end(args);  
269 - } 273 + va_list args;
  274 + va_start(args, fmt);
  275 + vwtrace(fmt, args);
  276 + va_end(args);
270 } 277 }
271 278
  279 +/*
272 static void stop_tracing(void) 280 static void stop_tracing(void)
273 { 281 {
274 if (tracef != NULL && tracef != stdout) 282 if (tracef != NULL && tracef != stdout)
@@ -282,39 +290,30 @@ static void stop_tracing(void) @@ -282,39 +290,30 @@ static void stop_tracing(void)
282 lib3270_set_toggle(&h3270,DS_TRACE,0); 290 lib3270_set_toggle(&h3270,DS_TRACE,0);
283 lib3270_set_toggle(&h3270,EVENT_TRACE,0); 291 lib3270_set_toggle(&h3270,EVENT_TRACE,0);
284 292
285 -/*  
286 - if (toggled(DS_TRACE)) {  
287 - toggle_toggle(&appres.toggle[DS_TRACE]);  
288 -// menubar_retoggle(&appres.toggle[DS_TRACE]);  
289 - }  
290 - if (toggled(EVENT_TRACE)) {  
291 - toggle_toggle(&appres.toggle[EVENT_TRACE]);  
292 -// menubar_retoggle(&appres.toggle[EVENT_TRACE]);  
293 - }  
294 -*/  
295 } 293 }
  294 +*/
296 295
297 -/* Check for a trace file rollover event. */ 296 +/* Check for a trace file rollover event.
298 void 297 void
299 trace_rollover_check(void) 298 trace_rollover_check(void)
300 { 299 {
301 if (tracef == NULL || tracef_max == 0) 300 if (tracef == NULL || tracef_max == 0)
302 return; 301 return;
303 302
304 - /* See if we've reached the midpoint. */ 303 + // See if we've reached the midpoint.
305 if (!tracef_midpoint) { 304 if (!tracef_midpoint) {
306 if (tracef_size >= tracef_max / 2) { 305 if (tracef_size >= tracef_max / 2) {
307 tracef_midpoint = ftello(tracef); 306 tracef_midpoint = ftello(tracef);
308 -#if defined(ROLLOVER_DEBUG) /*[*/ 307 +#if defined(ROLLOVER_DEBUG)
309 printf("midpoint is %lld\n", tracef_midpoint); 308 printf("midpoint is %lld\n", tracef_midpoint);
310 -#endif /*]*/ 309 +#endif
311 tracef_midpoint_header = 310 tracef_midpoint_header =
312 create_tracefile_header("rolled over"); 311 create_tracefile_header("rolled over");
313 } 312 }
314 return; 313 return;
315 } 314 }
316 315
317 - /* See if we've reached a rollover point. */ 316 + // See if we've reached a rollover point.
318 if (tracef_size >= tracef_max) { 317 if (tracef_size >= tracef_max) {
319 char buf[8*1024]; 318 char buf[8*1024];
320 int nr; 319 int nr;
@@ -322,13 +321,13 @@ trace_rollover_check(void) @@ -322,13 +321,13 @@ trace_rollover_check(void)
322 321
323 if (!tracef_midpoint) 322 if (!tracef_midpoint)
324 Error("Tracefile rollover logic error"); 323 Error("Tracefile rollover logic error");
325 -#if defined(ROLLOVER_DEBUG) /*[*/ 324 +#if defined(ROLLOVER_DEBUG)
326 printf("rolling over at %lld\n", tracef_size); 325 printf("rolling over at %lld\n", tracef_size);
327 -#endif /*]*/  
328 - /*  
329 - * Overwrite the file with the midpoint header, and the data  
330 - * which follows the midpoint.  
331 - */ 326 +#endif
  327 + //
  328 + // Overwrite the file with the midpoint header, and the data
  329 + // which follows the midpoint.
  330 + //
332 if (fseeko(tracef, 0, SEEK_SET) < 0) { 331 if (fseeko(tracef, 0, SEEK_SET) < 0) {
333 popup_an_errno(errno, "trace file fseeko(0) failed"); 332 popup_an_errno(errno, "trace file fseeko(0) failed");
334 stop_tracing(); 333 stop_tracing();
@@ -347,9 +346,9 @@ trace_rollover_check(void) @@ -347,9 +346,9 @@ trace_rollover_check(void)
347 stop_tracing(); 346 stop_tracing();
348 return; 347 return;
349 } 348 }
350 -#if defined(ROLLOVER_DEBUG) /*[*/ 349 +#if defined(ROLLOVER_DEBUG)
351 printf("rpos = %lld, wpos = %lld\n", rpos, wpos); 350 printf("rpos = %lld, wpos = %lld\n", rpos, wpos);
352 -#endif /*]*/ 351 +#endif
353 while ((nr = fread(buf, 1, sizeof(buf), tracef)) > 0) { 352 while ((nr = fread(buf, 1, sizeof(buf), tracef)) > 0) {
354 rpos = ftello(tracef); 353 rpos = ftello(tracef);
355 if (fseeko(tracef, wpos, SEEK_SET) < 0) { 354 if (fseeko(tracef, wpos, SEEK_SET) < 0) {
@@ -380,9 +379,9 @@ trace_rollover_check(void) @@ -380,9 +379,9 @@ trace_rollover_check(void)
380 stop_tracing(); 379 stop_tracing();
381 return; 380 return;
382 } 381 }
383 -#if defined(ROLLOVER_DEBUG) /*[*/ 382 +#if defined(ROLLOVER_DEBUG)
384 printf("final wpos = %lld\n", wpos); 383 printf("final wpos = %lld\n", wpos);
385 -#endif /*]*/ 384 +#endif
386 if (ftruncate(fileno(tracef), wpos) < 0) { 385 if (ftruncate(fileno(tracef), wpos) < 0) {
387 popup_an_errno(errno, "trace file ftruncate(%ld) " 386 popup_an_errno(errno, "trace file ftruncate(%ld) "
388 "failed", (long)wpos); 387 "failed", (long)wpos);
@@ -401,29 +400,29 @@ trace_rollover_check(void) @@ -401,29 +400,29 @@ trace_rollover_check(void)
401 create_tracefile_header("rolled over")); 400 create_tracefile_header("rolled over"));
402 } 401 }
403 } 402 }
  403 +*/
404 404
405 -#if defined(X3270_DISPLAY) /*[*/ 405 +/*
  406 +#if defined(X3270_DISPLAY)
406 static Widget trace_shell = (Widget)NULL; 407 static Widget trace_shell = (Widget)NULL;
407 -#endif /*]*/ 408 +#endif
408 static int trace_reason; 409 static int trace_reason;
  410 +*/
409 411
410 -/* Create a trace file header. */  
411 -static char *  
412 -create_tracefile_header(const char *mode) 412 +/* Create a trace file header. */ /*
  413 +static char * create_tracefile_header(const char *mode)
413 { 414 {
414 char *buf; 415 char *buf;
415 time_t clk; 416 time_t clk;
416 417
417 - /* Create a buffer and redirect output. */ 418 + // Create a buffer and redirect output.
418 buf = Malloc(MAX_HEADER_SIZE); 419 buf = Malloc(MAX_HEADER_SIZE);
419 tracef_bufptr = buf; 420 tracef_bufptr = buf;
420 421
421 - /* Display current status */ 422 + // Display current status
422 clk = time((time_t *)0); 423 clk = time((time_t *)0);
423 wtrace("Trace %s %s", mode, ctime(&clk)); 424 wtrace("Trace %s %s", mode, ctime(&clk));
424 wtrace(" Version: %s\n", build); 425 wtrace(" Version: %s\n", build);
425 -// save_yourself();  
426 -// wtrace(" Command: %s\n", command_string);  
427 wtrace(" Model %s", h3270.model_name); 426 wtrace(" Model %s", h3270.model_name);
428 wtrace(", %s display", appres.mono ? "monochrome" : "color"); 427 wtrace(", %s display", appres.mono ? "monochrome" : "color");
429 if (appres.extended) 428 if (appres.extended)
@@ -436,27 +435,27 @@ create_tracefile_header(const char *mode) @@ -436,27 +435,27 @@ create_tracefile_header(const char *mode)
436 if (CONNECTED) 435 if (CONNECTED)
437 wtrace(" Connected to %s, port %u\n",h3270.current_host, h3270.current_port); 436 wtrace(" Connected to %s, port %u\n",h3270.current_host, h3270.current_port);
438 437
439 - /* Snap the current TELNET options. */ 438 + // Snap the current TELNET options.
440 if (net_snap_options()) { 439 if (net_snap_options()) {
441 wtrace(" TELNET state:\n"); 440 wtrace(" TELNET state:\n");
442 trace_netdata('<', obuf, obptr - obuf); 441 trace_netdata('<', obuf, obptr - obuf);
443 } 442 }
444 443
445 - /* Dump the screen contents and modes into the trace file. */ 444 + // Dump the screen contents and modes into the trace file.
446 if (CONNECTED) { 445 if (CONNECTED) {
447 - /*  
448 - * Note that if the screen is not formatted, we do not  
449 - * attempt to save what's on it. However, if we're in  
450 - * 3270 SSCP-LU or NVT mode, we'll do a dummy, empty  
451 - * write to ensure that the display is in the right  
452 - * mode.  
453 - */ 446 + //
  447 + // Note that if the screen is not formatted, we do not
  448 + // attempt to save what's on it. However, if we're in
  449 + // 3270 SSCP-LU or NVT mode, we'll do a dummy, empty
  450 + // write to ensure that the display is in the right
  451 + // mode.
  452 + //
454 if (h3270.formatted) { 453 if (h3270.formatted) {
455 wtrace(" Screen contents:\n"); 454 wtrace(" Screen contents:\n");
456 obptr = obuf; 455 obptr = obuf;
457 -#if defined(X3270_TN3270E) /*[*/ 456 +#if defined(X3270_TN3270E)
458 (void) net_add_dummy_tn3270e(); 457 (void) net_add_dummy_tn3270e();
459 -#endif /*]*/ 458 +#endif
460 ctlr_snap_buffer(); 459 ctlr_snap_buffer();
461 space3270out(2); 460 space3270out(2);
462 net_add_eor(obuf, obptr - obuf); 461 net_add_eor(obuf, obptr - obuf);
@@ -464,9 +463,9 @@ create_tracefile_header(const char *mode) @@ -464,9 +463,9 @@ create_tracefile_header(const char *mode)
464 trace_netdata('<', obuf, obptr - obuf); 463 trace_netdata('<', obuf, obptr - obuf);
465 464
466 obptr = obuf; 465 obptr = obuf;
467 -#if defined(X3270_TN3270E) /*[*/ 466 +#if defined(X3270_TN3270E)
468 (void) net_add_dummy_tn3270e(); 467 (void) net_add_dummy_tn3270e();
469 -#endif /*]*/ 468 +#endif
470 if (ctlr_snap_modes()) { 469 if (ctlr_snap_modes()) {
471 wtrace(" 3270 modes:\n"); 470 wtrace(" 3270 modes:\n");
472 space3270out(2); 471 space3270out(2);
@@ -475,7 +474,7 @@ create_tracefile_header(const char *mode) @@ -475,7 +474,7 @@ create_tracefile_header(const char *mode)
475 trace_netdata('<', obuf, obptr - obuf); 474 trace_netdata('<', obuf, obptr - obuf);
476 } 475 }
477 } 476 }
478 -#if defined(X3270_TN3270E) /*[*/ 477 +#if defined(X3270_TN3270E)
479 else if (IN_E) { 478 else if (IN_E) {
480 obptr = obuf; 479 obptr = obuf;
481 if (net_add_dummy_tn3270e()) { 480 if (net_add_dummy_tn3270e()) {
@@ -486,17 +485,18 @@ create_tracefile_header(const char *mode) @@ -486,17 +485,18 @@ create_tracefile_header(const char *mode)
486 trace_netdata('<', obuf, obptr - obuf); 485 trace_netdata('<', obuf, obptr - obuf);
487 } 486 }
488 } 487 }
489 -#endif /*]*/ 488 +#endif
490 } 489 }
491 490
492 wtrace(" Data stream:\n"); 491 wtrace(" Data stream:\n");
493 492
494 - /* Return the buffer. */ 493 + // Return the buffer.
495 tracef_bufptr = CN; 494 tracef_bufptr = CN;
496 return buf; 495 return buf;
497 } 496 }
  497 +*/
498 498
499 -/* Calculate the tracefile maximum size. */ 499 +/* Calculate the tracefile maximum size. */ /*
500 static void 500 static void
501 get_tracef_max(void) 501 get_tracef_max(void)
502 { 502 {
@@ -538,16 +538,17 @@ get_tracef_max(void) @@ -538,16 +538,17 @@ get_tracef_max(void)
538 538
539 if (bad) { 539 if (bad) {
540 tracef_max = MIN_TRACEFILE_SIZE; 540 tracef_max = MIN_TRACEFILE_SIZE;
541 -#if defined(X3270_DISPLAY) /*[*/ 541 +#if defined(X3270_DISPLAY)
542 popup_an_info("Invalid %s '%s', assuming " 542 popup_an_info("Invalid %s '%s', assuming "
543 MIN_TRACEFILE_SIZE_NAME, 543 MIN_TRACEFILE_SIZE_NAME,
544 ResTraceFileSize, 544 ResTraceFileSize,
545 appres.trace_file_size); 545 appres.trace_file_size);
546 -#endif /*]*/ 546 +#endif
547 } else if (tracef_max < MIN_TRACEFILE_SIZE) { 547 } else if (tracef_max < MIN_TRACEFILE_SIZE) {
548 tracef_max = MIN_TRACEFILE_SIZE; 548 tracef_max = MIN_TRACEFILE_SIZE;
549 } 549 }
550 } 550 }
  551 +*/
551 552
552 /* Parse the name '/dev/fd<n>', so we can simulate it. */ 553 /* Parse the name '/dev/fd<n>', so we can simulate it. */
553 static int 554 static int
@@ -564,7 +565,7 @@ get_devfd(const char *pathname) @@ -564,7 +565,7 @@ get_devfd(const char *pathname)
564 return fd; 565 return fd;
565 } 566 }
566 567
567 -/* Callback for "OK" button on trace popup */ 568 +/* Callback for "OK" button on trace popup */ /*
568 static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_data unused) 569 static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_data unused)
569 { 570 {
570 char *tfn = CN; 571 char *tfn = CN;
@@ -590,10 +591,10 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d @@ -590,10 +591,10 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
590 } 591 }
591 else 592 else
592 { 593 {
593 - /* Get the trace file maximum. */ 594 + // Get the trace file maximum.
594 get_tracef_max(); 595 get_tracef_max();
595 596
596 - /* If there's a limit, the file can't exist. */ 597 + // If there's a limit, the file can't exist.
597 if (tracef_max && !access(tfn, R_OK)) 598 if (tracef_max && !access(tfn, R_OK))
598 { 599 {
599 popup_an_error("Trace file '%s' already exists",tfn); 600 popup_an_error("Trace file '%s' already exists",tfn);
@@ -601,7 +602,7 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d @@ -601,7 +602,7 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
601 return; 602 return;
602 } 603 }
603 604
604 - /* Open and configure the file. */ 605 + // Open and configure the file.
605 if ((devfd = get_devfd(tfn)) >= 0) 606 if ((devfd = get_devfd(tfn)) >= 0)
606 tracef = fdopen(dup(devfd), "a"); 607 tracef = fdopen(dup(devfd), "a");
607 else 608 else
@@ -613,31 +614,31 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d @@ -613,31 +614,31 @@ static void tracefile_callback(Widget w, XtPointer client_data, XtPointer call_d
613 return; 614 return;
614 } 615 }
615 (void) SETLINEBUF(tracef); 616 (void) SETLINEBUF(tracef);
616 -#if !defined(_WIN32) /*[*/ 617 +#if !defined(_WIN32)
617 (void) fcntl(fileno(tracef), F_SETFD, 1); 618 (void) fcntl(fileno(tracef), F_SETFD, 1);
618 -#endif /*]*/ 619 +#endif
619 } 620 }
620 621
621 - /* Open pw3270's console window */ 622 + // Open pw3270's console window
622 if(!tracewindow_handle) 623 if(!tracewindow_handle)
623 tracewindow_handle = console_window_new( tfn, NULL ); 624 tracewindow_handle = console_window_new( tfn, NULL );
624 625
625 Free(tfn); 626 Free(tfn);
626 627
627 - /* We're really tracing, turn the flag on. */ 628 + // We're really tracing, turn the flag on.
628 appres.toggle[trace_reason].value = True; 629 appres.toggle[trace_reason].value = True;
629 // appres.toggle[trace_reason].changed = True; 630 // appres.toggle[trace_reason].changed = True;
630 // menubar_retoggle(&appres.toggle[trace_reason]); 631 // menubar_retoggle(&appres.toggle[trace_reason]);
631 632
632 - /* Display current status. */ 633 + // Display current status
633 buf = create_tracefile_header("started"); 634 buf = create_tracefile_header("started");
634 wtrace("%s", buf); 635 wtrace("%s", buf);
635 Free(buf); 636 Free(buf);
636 637
637 } 638 }
638 639
639 -#if defined(X3270_DISPLAY) /*[*/  
640 -/* Callback for "No File" button on trace popup */ 640 +#if defined(X3270_DISPLAY)
  641 +// Callback for "No File" button on trace popup
641 static void 642 static void
642 no_tracefile_callback(Widget w, XtPointer client_data, 643 no_tracefile_callback(Widget w, XtPointer client_data,
643 XtPointer call_data unused) 644 XtPointer call_data unused)
@@ -645,9 +646,10 @@ no_tracefile_callback(Widget w, XtPointer client_data, @@ -645,9 +646,10 @@ no_tracefile_callback(Widget w, XtPointer client_data,
645 tracefile_callback((Widget)NULL, "", PN); 646 tracefile_callback((Widget)NULL, "", PN);
646 XtPopdown(trace_shell); 647 XtPopdown(trace_shell);
647 } 648 }
648 -#endif /*]*/ 649 +#endif
  650 +*/
649 651
650 -/* Open the trace file. */ 652 +/* Open the trace file.
651 static void 653 static void
652 tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt) 654 tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt)
653 { 655 {
@@ -668,30 +670,30 @@ tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt) @@ -668,30 +670,30 @@ tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt)
668 } 670 }
669 else 671 else
670 { 672 {
671 -#if defined(_WIN32) /*[*/ 673 +#if defined(_WIN32)
672 tracefile_buf = xs_buffer("%sx3trc.%u.txt", PROGRAM_DATA,getpid()); 674 tracefile_buf = xs_buffer("%sx3trc.%u.txt", PROGRAM_DATA,getpid());
673 -#else /*][*/ 675 +#else
674 676
675 if(appres.trace_dir) 677 if(appres.trace_dir)
676 tracefile_buf = xs_buffer("%s/x3trc.%u", appres.trace_dir,getpid()); 678 tracefile_buf = xs_buffer("%s/x3trc.%u", appres.trace_dir,getpid());
677 else 679 else
678 tracefile_buf = xs_buffer("%s/x3trc.%u", ".",getpid()); 680 tracefile_buf = xs_buffer("%s/x3trc.%u", ".",getpid());
679 681
680 -#endif /*]*/ 682 +#endif
681 tracefile = tracefile_buf; 683 tracefile = tracefile_buf;
682 } 684 }
683 685
684 686
685 -#if defined(X3270_DISPLAY) /*[*/ 687 +#if defined(X3270_DISPLAY)
686 if (tt == TT_INITIAL || tt == TT_ACTION) 688 if (tt == TT_INITIAL || tt == TT_ACTION)
687 -#endif /*]*/ 689 +#endif
688 { 690 {
689 tracefile_callback((Widget)NULL, tracefile, PN); 691 tracefile_callback((Widget)NULL, tracefile, PN);
690 if (tracefile_buf != NULL) 692 if (tracefile_buf != NULL)
691 Free(tracefile_buf); 693 Free(tracefile_buf);
692 return; 694 return;
693 } 695 }
694 -#if defined(X3270_DISPLAY) /*[*/ 696 +#if defined(X3270_DISPLAY)
695 if (trace_shell == NULL) { 697 if (trace_shell == NULL) {
696 trace_shell = create_form_popup("trace", 698 trace_shell = create_form_popup("trace",
697 tracefile_callback, 699 tracefile_callback,
@@ -702,18 +704,18 @@ tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt) @@ -702,18 +704,18 @@ tracefile_on(int reason, LIB3270_TOGGLE_TYPE tt)
702 NULL); 704 NULL);
703 } 705 }
704 706
705 - /* Turn the toggle _off_ until the popup succeeds. */ 707 + // Turn the toggle _off_ until the popup succeeds.
706 appres.toggle[reason].value = False; 708 appres.toggle[reason].value = False;
707 appres.toggle[reason].changed = True; 709 appres.toggle[reason].changed = True;
708 710
709 popup_popup(trace_shell, XtGrabExclusive); 711 popup_popup(trace_shell, XtGrabExclusive);
710 -#endif /*]*/ 712 +#endif
711 713
712 if (tracefile_buf != NULL) 714 if (tracefile_buf != NULL)
713 Free(tracefile_buf); 715 Free(tracefile_buf);
714 } 716 }
715 717
716 -/* Close the trace file. */ 718 +// Close the trace file.
717 static void tracefile_off(void) 719 static void tracefile_off(void)
718 { 720 {
719 time_t clk; 721 time_t clk;
@@ -729,13 +731,13 @@ static void tracefile_off(void) @@ -729,13 +731,13 @@ static void tracefile_off(void)
729 tracewindow_handle = NULL; 731 tracewindow_handle = NULL;
730 } 732 }
731 733
732 -#elif !defined(_WIN32) /*[*/ 734 +#elif !defined(_WIN32)
733 735
734 if (tracewindow_pid != -1) 736 if (tracewindow_pid != -1)
735 (void) kill(tracewindow_pid, SIGKILL); 737 (void) kill(tracewindow_pid, SIGKILL);
736 tracewindow_pid = -1; 738 tracewindow_pid = -1;
737 739
738 -#else /*][*/ 740 +#else
739 741
740 if (tracewindow_handle != NULL) 742 if (tracewindow_handle != NULL)
741 { 743 {
@@ -744,56 +746,57 @@ static void tracefile_off(void) @@ -744,56 +746,57 @@ static void tracefile_off(void)
744 tracewindow_handle = NULL; 746 tracewindow_handle = NULL;
745 } 747 }
746 748
747 -#endif /*]*/ 749 +#endif
748 750
749 stop_tracing(); 751 stop_tracing();
750 } 752 }
751 753
  754 +
752 void toggle_dsTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt) 755 void toggle_dsTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt)
753 { 756 {
754 - /* If turning on trace and no trace file, open one. */  
755 -  
756 if (toggled(DS_TRACE) && tracef == NULL) 757 if (toggled(DS_TRACE) && tracef == NULL)
757 tracefile_on(DS_TRACE, tt); 758 tracefile_on(DS_TRACE, tt);
758 759
759 - /* If turning off trace and not still tracing events, close the  
760 - trace file. */ 760 + // If turning off trace and not still tracing events, close the trace file.
761 else if (!toggled(DS_TRACE) && !toggled(EVENT_TRACE)) 761 else if (!toggled(DS_TRACE) && !toggled(EVENT_TRACE))
762 tracefile_off(); 762 tracefile_off();
763 763
764 if (toggled(DS_TRACE)) 764 if (toggled(DS_TRACE))
765 (void) gettimeofday(&ds_ts, (struct timezone *)NULL); 765 (void) gettimeofday(&ds_ts, (struct timezone *)NULL);
766 } 766 }
  767 +*/
767 768
  769 +/*
768 void toggle_eventTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt) 770 void toggle_eventTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt)
769 { 771 {
770 - /* If turning on event debug, and no trace file, open one. */ 772 + // If turning on event debug, and no trace file, open one.
771 773
772 if (toggled(EVENT_TRACE) && tracef == NULL) 774 if (toggled(EVENT_TRACE) && tracef == NULL)
773 tracefile_on(EVENT_TRACE, tt); 775 tracefile_on(EVENT_TRACE, tt);
774 776
775 - /* If turning off event debug, and not tracing the data stream,  
776 - close the trace file. */ 777 + // If turning off event debug, and not tracing the data stream, close the trace file.
777 else if (!toggled(EVENT_TRACE) && !toggled(DS_TRACE)) 778 else if (!toggled(EVENT_TRACE) && !toggled(DS_TRACE))
778 tracefile_off(); 779 tracefile_off();
779 } 780 }
  781 +*/
780 782
781 /* Screen trace file support. */ 783 /* Screen trace file support. */
782 784
783 -#if defined(X3270_DISPLAY) /*[*/ 785 +/*
  786 +#if defined(X3270_DISPLAY)
784 static Widget screentrace_shell = (Widget)NULL; 787 static Widget screentrace_shell = (Widget)NULL;
785 -#endif /*]*/ 788 +#endif
786 static FILE *screentracef = (FILE *)0; 789 static FILE *screentracef = (FILE *)0;
787 - 790 +*/
788 /* 791 /*
789 * Screen trace function, called when the host clears the screen. 792 * Screen trace function, called when the host clears the screen.
790 */ 793 */
791 -static void  
792 -do_screentrace(void) 794 +static void do_screentrace(void)
793 { 795 {
  796 + wtrace("\n%s - Not implemented\n",__FUNCTION__);
  797 +/*
794 register int i; 798 register int i;
795 799
796 -/*  
797 if (fprint_screen(screentracef, False, False)) { 800 if (fprint_screen(screentracef, False, False)) {
798 for (i = 0; i < h3270.cols; i++) 801 for (i = 0; i < h3270.cols; i++)
799 (void) fputc('=', screentracef); 802 (void) fputc('=', screentracef);
@@ -802,23 +805,20 @@ do_screentrace(void) @@ -802,23 +805,20 @@ do_screentrace(void)
802 */ 805 */
803 } 806 }
804 807
805 -void  
806 -trace_screen(void) 808 +void trace_screen(void)
807 { 809 {
808 trace_skipping = False; 810 trace_skipping = False;
809 811
810 - if (!toggled(SCREEN_TRACE) || !screentracef)  
811 - return;  
812 - do_screentrace(); 812 + if (!toggled(SCREEN_TRACE))
  813 + do_screentrace();
813 } 814 }
814 815
815 /* Called from ANSI emulation code to log a single character. */ 816 /* Called from ANSI emulation code to log a single character. */
816 -void  
817 -trace_char(char c) 817 +void trace_char(char c)
818 { 818 {
819 - if (!toggled(SCREEN_TRACE) || !screentracef)  
820 - return;  
821 - (void) fputc(c, screentracef); 819 + if (toggled(SCREEN_TRACE))
  820 + wtrace("%c",c);
  821 + return;
822 } 822 }
823 823
824 /* 824 /*
@@ -827,15 +827,14 @@ trace_char(char c) @@ -827,15 +827,14 @@ trace_char(char c)
827 * (In a gross violation of data hiding and modularity, trace_skipping is 827 * (In a gross violation of data hiding and modularity, trace_skipping is
828 * manipulated directly in ctlr_clear()). 828 * manipulated directly in ctlr_clear()).
829 */ 829 */
830 -void  
831 -trace_ansi_disc(void) 830 +void trace_ansi_disc(void)
832 { 831 {
833 int i; 832 int i;
834 833
835 - (void) fputc('\n', screentracef); 834 + wtrace("%c",'\n');
836 for (i = 0; i < h3270.cols; i++) 835 for (i = 0; i < h3270.cols; i++)
837 - (void) fputc('=', screentracef);  
838 - (void) fputc('\n', screentracef); 836 + wtrace("%c",'=');
  837 + wtrace("%c",'\n');
839 838
840 trace_skipping = True; 839 trace_skipping = True;
841 } 840 }
@@ -843,7 +842,7 @@ trace_ansi_disc(void) @@ -843,7 +842,7 @@ trace_ansi_disc(void)
843 /* 842 /*
844 * Screen tracing callback. 843 * Screen tracing callback.
845 * Returns True for success, False for failure. 844 * Returns True for success, False for failure.
846 - */ 845 + */ /*
847 static Boolean 846 static Boolean
848 screentrace_cb(char *tfn) 847 screentrace_cb(char *tfn)
849 { 848 {
@@ -856,16 +855,17 @@ screentrace_cb(char *tfn) @@ -856,16 +855,17 @@ screentrace_cb(char *tfn)
856 } 855 }
857 Free(tfn); 856 Free(tfn);
858 (void) SETLINEBUF(screentracef); 857 (void) SETLINEBUF(screentracef);
859 -#if !defined(_WIN32) /*[*/ 858 +#if !defined(_WIN32)
860 (void) fcntl(fileno(screentracef), F_SETFD, 1); 859 (void) fcntl(fileno(screentracef), F_SETFD, 1);
861 -#endif /*]*/ 860 +#endif
862 861
863 - /* We're really tracing, turn the flag on. */ 862 + // We're really tracing, turn the flag on.
864 appres.toggle[SCREEN_TRACE].value = True; 863 appres.toggle[SCREEN_TRACE].value = True;
865 // appres.toggle[SCREEN_TRACE].changed = True; 864 // appres.toggle[SCREEN_TRACE].changed = True;
866 // menubar_retoggle(&appres.toggle[SCREEN_TRACE]); 865 // menubar_retoggle(&appres.toggle[SCREEN_TRACE]);
867 return True; 866 return True;
868 } 867 }
  868 +*/
869 869
870 /* 870 /*
871 #if defined(X3270_DISPLAY) 871 #if defined(X3270_DISPLAY)
@@ -910,8 +910,11 @@ onescreen_callback(Widget w, XtPointer client_data, XtPointer call_data unused) @@ -910,8 +910,11 @@ onescreen_callback(Widget w, XtPointer client_data, XtPointer call_data unused)
910 } 910 }
911 #endif */ 911 #endif */
912 912
  913 +/*
913 void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt) 914 void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE tt)
914 { 915 {
  916 + wtrace("Screen trace is %s\n",toggled(SCREEN_TRACE),"Enabled" : "Disabled");
  917 +
915 char *tracefile_buf = NULL; 918 char *tracefile_buf = NULL;
916 char *tracefile; 919 char *tracefile;
917 920
@@ -919,14 +922,14 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_ @@ -919,14 +922,14 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_
919 if (appres.screentrace_file) 922 if (appres.screentrace_file)
920 tracefile = appres.screentrace_file; 923 tracefile = appres.screentrace_file;
921 else { 924 else {
922 -#if defined(_WIN32) /*[*/ 925 +#if defined(_WIN32)
923 tracefile_buf = xs_buffer("%sx3scr.%u.txt",PROGRAM_DATA, getpid()); 926 tracefile_buf = xs_buffer("%sx3scr.%u.txt",PROGRAM_DATA, getpid());
924 -#else /*][*/ 927 +#else
925 if(appres.trace_dir) 928 if(appres.trace_dir)
926 tracefile_buf = xs_buffer("%s/x3scr.%u",appres.trace_dir, getpid()); 929 tracefile_buf = xs_buffer("%s/x3scr.%u",appres.trace_dir, getpid());
927 else 930 else
928 tracefile_buf = xs_buffer("%s/x3scr.%u",".", getpid()); 931 tracefile_buf = xs_buffer("%s/x3scr.%u",".", getpid());
929 -#endif /*]*/ 932 +#endif
930 tracefile = tracefile_buf; 933 tracefile = tracefile_buf;
931 } 934 }
932 if (tt == TT_INITIAL || tt == TT_ACTION) { 935 if (tt == TT_INITIAL || tt == TT_ACTION) {
@@ -935,7 +938,7 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_ @@ -935,7 +938,7 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_
935 Free(tracefile_buf); 938 Free(tracefile_buf);
936 return; 939 return;
937 } 940 }
938 -#if defined(X3270_DISPLAY) /*[*/ 941 +#if defined(X3270_DISPLAY)
939 if (screentrace_shell == NULL) { 942 if (screentrace_shell == NULL) {
940 screentrace_shell = create_form_popup("screentrace", 943 screentrace_shell = create_form_popup("screentrace",
941 screentrace_callback, onescreen_callback, 944 screentrace_callback, onescreen_callback,
@@ -948,7 +951,7 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_ @@ -948,7 +951,7 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_
948 appres.toggle[SCREEN_TRACE].value = False; 951 appres.toggle[SCREEN_TRACE].value = False;
949 appres.toggle[SCREEN_TRACE].changed = True; 952 appres.toggle[SCREEN_TRACE].changed = True;
950 popup_popup(screentrace_shell, XtGrabExclusive); 953 popup_popup(screentrace_shell, XtGrabExclusive);
951 -#endif /*]*/ 954 +#endif
952 } else { 955 } else {
953 if (ctlr_any_data() && !trace_skipping) 956 if (ctlr_any_data() && !trace_skipping)
954 do_screentrace(); 957 do_screentrace();
@@ -958,5 +961,6 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_ @@ -958,5 +961,6 @@ void toggle_screenTrace(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_
958 if (tracefile_buf != NULL) 961 if (tracefile_buf != NULL)
959 Free(tracefile_buf); 962 Free(tracefile_buf);
960 } 963 }
  964 +*/
961 965
962 #endif /*]*/ 966 #endif /*]*/
@@ -32,37 +32,38 @@ @@ -32,37 +32,38 @@
32 * Global declarations for trace_ds.c. 32 * Global declarations for trace_ds.c.
33 */ 33 */
34 34
35 -#if defined(X3270_TRACE) /*[*/ 35 +#if defined(X3270_TRACE)
36 36
37 -LIB3270_INTERNAL Boolean trace_skipping; 37 + LIB3270_INTERNAL Boolean trace_skipping;
38 38
39 -const char *rcba(int baddr);  
40 -void toggle_dsTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);  
41 -void toggle_eventTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);  
42 -void toggle_screenTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);  
43 -void trace_ansi_disc(void);  
44 -void trace_char(char c);  
45 -void trace_ds(const char *fmt, ...) printflike(1, 2);  
46 -void trace_ds_nb(const char *fmt, ...) printflike(1, 2);  
47 -void trace_dsn(const char *fmt, ...) printflike(1, 2);  
48 -void trace_event(const char *fmt, ...) printflike(1, 2);  
49 -void trace_screen(void);  
50 -void trace_rollover_check(void); 39 + const char *rcba(int baddr);
51 40
52 -#else /*][*/ 41 +// void toggle_dsTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);
  42 +// void toggle_eventTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);
  43 +// void toggle_screenTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);
53 44
54 -#define rcba 0 &&  
55 -#if defined(__GNUC__) /*[*/  
56 -#define trace_ds(format, args...)  
57 -#define trace_dsn(format, args...)  
58 -#define trace_ds_nb(format, args...)  
59 -#define trace_event(format, args...)  
60 -#else /*][*/  
61 -#define trace_ds 0 &&  
62 -#define trace_ds_nb 0 &&  
63 -#define trace_dsn 0 &&  
64 -#define trace_event 0 &&  
65 -#define rcba 0 &&  
66 -#endif /*]*/ 45 + void trace_ansi_disc(void);
  46 + void trace_char(char c);
  47 + void trace_ds(const char *fmt, ...) printflike(1, 2);
  48 + void trace_ds_nb(const char *fmt, ...) printflike(1, 2);
  49 + void trace_dsn(const char *fmt, ...) printflike(1, 2);
  50 + void trace_event(const char *fmt, ...) printflike(1, 2);
  51 + void trace_screen(void);
  52 +// void trace_rollover_check(void);
67 53
68 -#endif /*]*/ 54 +#elif defined(__GNUC__)
  55 +
  56 + #define trace_ds(format, args...)
  57 + #define trace_dsn(format, args...)
  58 + #define trace_ds_nb(format, args...)
  59 + #define trace_event(format, args...)
  60 +
  61 +#else
  62 +
  63 + #define trace_ds 0 &&
  64 + #define trace_ds_nb 0 &&
  65 + #define trace_dsn 0 &&
  66 + #define trace_event 0 &&
  67 + #define rcba 0 &&
  68 +
  69 +#endif