Commit 001dc51b2057db2e571b6e0dc9fdbba922a3494f

Authored by perry.werneck@gmail.com
1 parent 445bdbc2

Funções de trace passam a usar o handle de sessão

ansi.c
... ... @@ -1718,7 +1718,7 @@ ansi_process(unsigned int c)
1718 1718  
1719 1719 #if defined(X3270_TRACE) /*[*/
1720 1720 if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_SCREEN_TRACE))
1721   - trace_char((char)c);
  1721 + trace_char(&h3270,(char)c);
1722 1722 #endif /*]*/
1723 1723  
1724 1724 fn = ansi_fn[st[(int)state][c]];
... ...
ctlr.c
... ... @@ -1771,7 +1771,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1771 1771 }
1772 1772 add_dbcs = True;
1773 1773 dbcs_to_mb(add_c1, add_c2, mb);
1774   - trace_ds_nb("%s", mb);
  1774 + trace_ds_nb(&h3270,"%s", mb);
1775 1775 } else {
1776 1776 #endif /*]*/
1777 1777 add_c1 = *cp;
... ... @@ -2257,15 +2257,16 @@ void
2257 2257 ctlr_clear(H3270 *session, Boolean can_snap)
2258 2258 {
2259 2259 /* Snap any data that is about to be lost into the trace file. */
2260   - if (ctlr_any_data(session)) {
  2260 + if (ctlr_any_data(session))
  2261 + {
2261 2262 #if defined(X3270_TRACE) /*[*/
2262   - if (can_snap && !trace_skipping && lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE))
  2263 + if (can_snap && !session->trace_skipping && lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE))
2263 2264 trace_screen(session);
2264 2265 #endif /*]*/
2265 2266 // scroll_save(session->maxROWS, ever_3270 ? False : True);
2266 2267 }
2267 2268 #if defined(X3270_TRACE) /*[*/
2268   - trace_skipping = False;
  2269 + session->trace_skipping = 0;
2269 2270 #endif /*]*/
2270 2271  
2271 2272 /* Clear the screen. */
... ...
host.c
... ... @@ -685,7 +685,7 @@ void host_disconnect(H3270 *h, int failed)
685 685 */
686 686 #if defined(X3270_TRACE) /*[*/
687 687 if (IN_ANSI && lib3270_get_toggle(h,LIB3270_TOGGLE_SCREEN_TRACE))
688   - trace_ansi_disc();
  688 + trace_ansi_disc(h);
689 689 #endif /*]*/
690 690  
691 691 lib3270_set_disconnected(h);
... ...
proxy.c
... ... @@ -349,13 +349,13 @@ static int proxy_passthru(int fd, char *host, unsigned short port)
349 349 (void) sprintf(buf, "%s %u\r\n", host, port);
350 350  
351 351 #if defined(X3270_TRACE) /*[*/
352   - trace_dsn("Passthru Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf);
  352 + trace_dsn(&h3270,"Passthru Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf);
353 353 trace_netdata(&h3270,'>', (unsigned char *)buf, (int) strlen(buf));
354 354 #endif /*]*/
355 355  
356 356 if (send(fd, buf, strlen(buf), 0) < 0)
357 357 {
358   - popup_a_sockerr(NULL,"Passthru Proxy: send error");
  358 + popup_a_sockerr(&h3270,"Passthru Proxy: send error");
359 359 lib3270_free(buf);
360 360 return -1;
361 361 }
... ... @@ -385,7 +385,7 @@ proxy_http(int fd, char *host, unsigned short port)
385 385 port);
386 386  
387 387 #if defined(X3270_TRACE) /*[*/
388   - trace_dsn("HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf);
  388 + trace_dsn(&h3270,"HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf);
389 389 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf));
390 390 #endif /*]*/
391 391  
... ... @@ -402,7 +402,7 @@ proxy_http(int fd, char *host, unsigned short port)
402 402 port);
403 403  
404 404 #if defined(X3270_TRACE) /*[*/
405   - trace_dsn("HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf);
  405 + trace_dsn(&h3270,"HTTP Proxy: xmit '%.*s'\n", (int) (strlen(buf) - 2), buf);
406 406 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf));
407 407 #endif /*]*/
408 408  
... ... @@ -414,7 +414,7 @@ proxy_http(int fd, char *host, unsigned short port)
414 414  
415 415 strcpy(buf, "\r\n");
416 416 #if defined(X3270_TRACE) /*[*/
417   - trace_dsn("HTTP Proxy: xmit ''\n");
  417 + trace_dsn(&h3270,"HTTP Proxy: xmit ''\n");
418 418 trace_netdata(&h3270, '>', (unsigned char *)buf, strlen(buf));
419 419 #endif /*]*/
420 420  
... ... @@ -476,19 +476,21 @@ proxy_http(int fd, char *host, unsigned short port)
476 476  
477 477 #if defined(X3270_TRACE) /*[*/
478 478 trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread);
479   - trace_dsn("HTTP Proxy: recv '%s'\n", rbuf);
  479 + trace_dsn(&h3270,"HTTP Proxy: recv '%s'\n", rbuf);
480 480 #endif /*]*/
481 481  
482   - if (strncmp(rbuf, "HTTP/", 5) || (space = strchr(rbuf, ' ')) == CN) {
483   - popup_an_error(NULL,"HTTP Proxy: unrecognized reply");
  482 + if (strncmp(rbuf, "HTTP/", 5) || (space = strchr(rbuf, ' ')) == CN)
  483 + {
  484 + popup_an_error(&h3270,"HTTP Proxy: unrecognized reply");
484 485 return -1;
485 486 }
486   - if (*(space + 1) != '2') {
487   - popup_an_error(NULL,"HTTP Proxy: CONNECT failed:\n%s", rbuf);
  487 + if (*(space + 1) != '2')
  488 + {
  489 + popup_an_error(&h3270,"HTTP Proxy: CONNECT failed:\n%s", rbuf);
488 490 return -1;
489 491 }
490 492  
491   - return 0;
  493 + return 0;
492 494 }
493 495  
494 496 /* TELNET proxy. */
... ... @@ -501,12 +503,13 @@ proxy_telnet(int fd, char *host, unsigned short port)
501 503 (void) sprintf(buf, "connect %s %u\r\n", host, port);
502 504  
503 505 #if defined(X3270_TRACE) /*[*/
504   - trace_dsn("TELNET Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf);
  506 + trace_dsn(&h3270,"TELNET Proxy: xmit '%.*s'", (int) (strlen(buf) - 2), buf);
505 507 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf));
506 508 #endif /*]*/
507 509  
508   - if (send(fd, buf, strlen(buf), 0) < 0) {
509   - popup_a_sockerr(NULL,"TELNET Proxy: send error");
  510 + if (send(fd, buf, strlen(buf), 0) < 0)
  511 + {
  512 + popup_a_sockerr(&h3270,"TELNET Proxy: send error");
510 513 lib3270_free(buf);
511 514 return -1;
512 515 }
... ... @@ -575,12 +578,13 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
575 578 s += strlen(host) + 1;
576 579  
577 580 #if defined(X3270_TRACE) /*[*/
578   - trace_dsn("SOCKS4 Proxy: version 4 connect port %u address 0.0.0.1 user '%s' host '%s'\n",port, user, host);
  581 + trace_dsn(&h3270,"SOCKS4 Proxy: version 4 connect port %u address 0.0.0.1 user '%s' host '%s'\n",port, user, host);
579 582 trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf);
580 583 #endif /*]*/
581 584  
582   - if (send(fd, buf, s - buf, 0) < 0) {
583   - popup_a_sockerr(NULL,"SOCKS4 Proxy: send error");
  585 + if (send(fd, buf, s - buf, 0) < 0)
  586 + {
  587 + popup_a_sockerr(&h3270,"SOCKS4 Proxy: send error");
584 588 lib3270_free(buf);
585 589 return -1;
586 590 }
... ... @@ -599,15 +603,14 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
599 603 s += strlen(user) + 1;
600 604  
601 605 #if defined(X3270_TRACE) /*[*/
602   - trace_dsn("SOCKS4 Proxy: xmit version 4 connect port %u "
603   - "address %s user '%s'\n",
604   - port, inet_ntoa(ipaddr), user);
  606 + trace_dsn(&h3270,"SOCKS4 Proxy: xmit version 4 connect port %u address %s user '%s'\n",port, inet_ntoa(ipaddr), user);
605 607 trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf);
606 608 #endif /*]*/
607 609  
608   - if (send(fd, buf, s - buf, 0) < 0) {
  610 + if (send(fd, buf, s - buf, 0) < 0)
  611 + {
609 612 lib3270_free(buf);
610   - popup_a_sockerr(NULL,"SOCKS4 Proxy: send error");
  613 + popup_a_sockerr(&h3270,"SOCKS4 Proxy: send error");
611 614 return -1;
612 615 }
613 616 lib3270_free(buf);
... ... @@ -643,35 +646,32 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
643 646  
644 647 #if defined(X3270_TRACE) /*[*/
645 648 trace_netdata(&h3270,'<', (unsigned char *)rbuf, nread);
646   - if (use_4a) {
647   - struct in_addr a;
648   -
649   - rport = (rbuf[2] << 8) | rbuf[3];
650   - memcpy(&a, &rbuf[4], 4);
651   - trace_dsn("SOCKS4 Proxy: recv status 0x%02x port %u "
652   - "address %s\n",
653   - rbuf[1],
654   - rport,
655   - inet_ntoa(a));
  649 + if (use_4a)
  650 + {
  651 + struct in_addr a;
  652 +
  653 + rport = (rbuf[2] << 8) | rbuf[3];
  654 + memcpy(&a, &rbuf[4], 4);
  655 + trace_dsn(&h3270,"SOCKS4 Proxy: recv status 0x%02x port %u address %s\n",rbuf[1],rport,inet_ntoa(a));
  656 +
656 657 } else
657   - trace_dsn("SOCKS4 Proxy: recv status 0x%02x\n", rbuf[1]);
  658 + trace_dsn(&h3270,"SOCKS4 Proxy: recv status 0x%02x\n", rbuf[1]);
658 659 #endif /*]*/
659 660  
660 661 switch (rbuf[1]) {
661 662 case 0x5a:
662 663 break;
663 664 case 0x5b:
664   - popup_an_error(NULL,"SOCKS4 Proxy: request rejected or failed");
  665 + popup_an_error(&h3270,"SOCKS4 Proxy: request rejected or failed");
665 666 return -1;
666 667 case 0x5c:
667   - popup_an_error(NULL,"SOCKS4 Proxy: client is not reachable");
  668 + popup_an_error(&h3270,"SOCKS4 Proxy: client is not reachable");
668 669 return -1;
669 670 case 0x5d:
670   - popup_an_error(NULL,"SOCKS4 Proxy: userid error");
  671 + popup_an_error(&h3270,"SOCKS4 Proxy: userid error");
671 672 return -1;
672 673 default:
673   - popup_an_error(NULL,"SOCKS4 Proxy: unknown status 0x%02x",
674   - rbuf[1]);
  674 + popup_an_error(&h3270,"SOCKS4 Proxy: unknown status 0x%02x",rbuf[1]);
675 675 return -1;
676 676 }
677 677  
... ... @@ -732,7 +732,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
732 732 /* Send the authentication request to the server. */
733 733 strcpy((char *)rbuf, "\005\001\000");
734 734 #if defined(X3270_TRACE) /*[*/
735   - trace_dsn("SOCKS5 Proxy: xmit version 5 nmethods 1 (no auth)\n");
  735 + trace_dsn(&h3270,"SOCKS5 Proxy: xmit version 5 nmethods 1 (no auth)\n");
736 736 trace_netdata(&h3270, '>', rbuf, 3);
737 737 #endif /*]*/
738 738 if (send(fd, (const char *) rbuf, 3, 0) < 0) {
... ... @@ -792,16 +792,16 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
792 792  
793 793 if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff))
794 794 {
795   - popup_an_error(NULL,"SOCKS5 Proxy: bad authentication response");
  795 + popup_an_error(&h3270,"SOCKS5 Proxy: bad authentication response");
796 796 return -1;
797 797 }
798 798  
799 799 #if defined(X3270_TRACE) /*[*/
800   - trace_dsn("SOCKS5 Proxy: recv version %d method %d\n", rbuf[0],rbuf[1]);
  800 + trace_dsn(&h3270,"SOCKS5 Proxy: recv version %d method %d\n", rbuf[0],rbuf[1]);
801 801 #endif /*]*/
802 802  
803 803 if (rbuf[1] == 0xff) {
804   - popup_an_error(NULL,"SOCKS5 Proxy: authentication failure");
  804 + popup_an_error(&h3270,"SOCKS5 Proxy: authentication failure");
805 805 return -1;
806 806 }
807 807  
... ... @@ -832,7 +832,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
832 832 SET16(s, port);
833 833  
834 834 #if defined(X3270_TRACE) /*[*/
835   - trace_dsn("SOCKS5 Proxy: xmit version 5 connect %s %s port %u\n",
  835 + trace_dsn(&h3270,"SOCKS5 Proxy: xmit version 5 connect %s %s port %u\n",
836 836 use_name? "domainname":
837 837 ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"),
838 838 use_name? host: nbuf,
... ... @@ -1008,7 +1008,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
1008 1008 break;
1009 1009 }
1010 1010 rport = (*portp << 8) + *(portp + 1);
1011   - trace_dsn("SOCKS5 Proxy: recv version %d status 0x%02x address %s %s "
  1011 + trace_dsn(&h3270,"SOCKS5 Proxy: recv version %d status 0x%02x address %s %s "
1012 1012 "port %u\n",
1013 1013 buf[0], buf[1],
1014 1014 atype_name[(unsigned char)buf[3]],
... ...
telnet.c
... ... @@ -376,7 +376,7 @@ static void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state)
376 376 if(state == session->secure)
377 377 return;
378 378  
379   - trace_dsn("SSL state changes to %d\n",(int) state);
  379 + trace_dsn(session,"SSL state changes to %d\n",(int) state);
380 380  
381 381 session->update_ssl(session,session->secure = state);
382 382 }
... ... @@ -690,7 +690,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
690 690  
691 691 if(!rc)
692 692 {
693   - trace_dsn("Connected.\n");
  693 + trace_dsn(session,"Connected.\n");
694 694 net_connected(session);
695 695 }
696 696 else
... ... @@ -817,7 +817,7 @@ static void net_connected(H3270 *session)
817 817 if(session->proxy_type > 0)
818 818 {
819 819 /* Negotiate with the proxy. */
820   - trace_dsn("Connected to proxy server %s, port %u.\n",session->proxy_host, session->proxy_port);
  820 + trace_dsn(session,"Connected to proxy server %s, port %u.\n",session->proxy_host, session->proxy_port);
821 821  
822 822 if (proxy_negotiate(session->proxy_type, session->sock, session->hostname,session->current_port) < 0)
823 823 {
... ... @@ -826,7 +826,7 @@ static void net_connected(H3270 *session)
826 826 }
827 827 }
828 828  
829   - trace_dsn("Connected to %s, port %u%s.\n", session->hostname, session->current_port,session->ssl_host? " via SSL": "");
  829 + trace_dsn(session,"Connected to %s, port %u%s.\n", session->hostname, session->current_port,session->ssl_host? " via SSL": "");
830 830  
831 831 #if defined(HAVE_LIBSSL) /*[*/
832 832 /* Set up SSL. */
... ... @@ -838,7 +838,7 @@ static void net_connected(H3270 *session)
838 838  
839 839 if (SSL_set_fd(session->ssl_con, session->sock) != 1)
840 840 {
841   - trace_dsn("Can't set fd!\n");
  841 + trace_dsn(session,"Can't set fd!\n");
842 842 popup_system_error(session,_( "Connection failed" ), _( "Can't set SSL socket file descriptor" ), "%s", SSL_state_string_long(session->ssl_con));
843 843 set_ssl_state(session,LIB3270_SSL_UNSECURE);
844 844 }
... ... @@ -851,7 +851,7 @@ static void net_connected(H3270 *session)
851 851 unsigned long e = ERR_get_error();
852 852 const char * state = SSL_state_string_long(session->ssl_con);
853 853  
854   - trace_dsn("TLS/SSL tunneled connection failed with error %ld, rc=%d and state=%s",e,rc,state);
  854 + trace_dsn(session,"TLS/SSL tunneled connection failed with error %ld, rc=%d and state=%s",e,rc,state);
855 855  
856 856 host_disconnect(session,True);
857 857  
... ... @@ -866,7 +866,7 @@ static void net_connected(H3270 *session)
866 866 }
867 867  
868 868 // session->secure_connection = True;
869   - trace_dsn("TLS/SSL tunneled connection complete. Connection is now secure.\n");
  869 + trace_dsn(session,"TLS/SSL tunneled connection complete. Connection is now secure.\n");
870 870  
871 871 /* Tell everyone else again. */
872 872 lib3270_set_connected(session);
... ... @@ -976,7 +976,7 @@ void net_disconnect(H3270 *session)
976 976  
977 977 session->disconnect(session);
978 978  
979   - trace_dsn("SENT disconnect\n");
  979 + trace_dsn(session,"SENT disconnect\n");
980 980  
981 981 /* Restore terminal type to its default. */
982 982 if (session->termname == CN)
... ... @@ -1015,7 +1015,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned
1015 1015  
1016 1016 if (hSession->ansi_data)
1017 1017 {
1018   - trace_dsn("\n");
  1018 + trace_dsn(hSession,"\n");
1019 1019 hSession->ansi_data = 0;
1020 1020 }
1021 1021 #endif // X3270_ANSI
... ... @@ -1077,7 +1077,7 @@ void net_input(H3270 *session)
1077 1077 else
1078 1078 strcpy(err_buf, _( "unknown error" ) );
1079 1079  
1080   - trace_dsn("RCVD SSL_read error %ld (%s)\n", e,err_buf);
  1080 + trace_dsn(session,"RCVD SSL_read error %ld (%s)\n", e,err_buf);
1081 1081  
1082 1082 session->message( session,LIB3270_NOTIFY_ERROR,_( "SSL Error" ),_( "SSL Read error" ),err_buf );
1083 1083  
... ... @@ -1092,7 +1092,7 @@ void net_input(H3270 *session)
1092 1092 return;
1093 1093 }
1094 1094  
1095   - trace_dsn("RCVD socket error %d\n", errno);
  1095 + trace_dsn(session,"RCVD socket error %d\n", errno);
1096 1096  
1097 1097 if (HALF_CONNECTED)
1098 1098 {
... ... @@ -1108,7 +1108,7 @@ void net_input(H3270 *session)
1108 1108 } else if (nr == 0)
1109 1109 {
1110 1110 /* Host disconnected. */
1111   - trace_dsn("RCVD disconnect\n");
  1111 + trace_dsn(session,"RCVD disconnect\n");
1112 1112 host_disconnect(session,False);
1113 1113 return;
1114 1114 }
... ... @@ -1149,7 +1149,7 @@ void net_input(H3270 *session)
1149 1149  
1150 1150 if (session->ansi_data)
1151 1151 {
1152   - trace_dsn("\n");
  1152 + trace_dsn(session,"\n");
1153 1153 session->ansi_data = 0;
1154 1154 }
1155 1155 #endif // X3270_ANSI
... ... @@ -1196,7 +1196,7 @@ static void send_naws(H3270 *hSession)
1196 1196 (void) sprintf(naws_msg + naws_len, "%c%c", IAC, SE);
1197 1197 naws_len += 2;
1198 1198 net_rawout(hSession,(unsigned char *)naws_msg, naws_len);
1199   - trace_dsn("SENT %s NAWS %d %d %s\n", cmd(SB), XMIT_COLS, XMIT_ROWS, cmd(SE));
  1199 + trace_dsn(hSession,"SENT %s NAWS %d %d %s\n", cmd(SB), XMIT_COLS, XMIT_ROWS, cmd(SE));
1200 1200 }
1201 1201  
1202 1202  
... ... @@ -1227,7 +1227,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1227 1227 session->telnet_state = TNS_IAC;
1228 1228 #if defined(X3270_ANSI) /*[*/
1229 1229 if (session->ansi_data) {
1230   - trace_dsn("\n");
  1230 + trace_dsn(session,"\n");
1231 1231 session->ansi_data = 0;
1232 1232 }
1233 1233 #endif /*]*/
... ... @@ -1246,16 +1246,16 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1246 1246 if (IN_ANSI && !IN_E) {
1247 1247 #if defined(X3270_ANSI) /*[*/
1248 1248 if (!session->ansi_data) {
1249   - trace_dsn("<.. ");
  1249 + trace_dsn(session,"<.. ");
1250 1250 session->ansi_data = 4;
1251 1251 }
1252 1252 see_chr = ctl_see((int) c);
1253 1253 session->ansi_data += (sl = strlen(see_chr));
1254 1254 if (session->ansi_data >= TRACELINE) {
1255   - trace_dsn(" ...\n... ");
  1255 + trace_dsn(session," ...\n... ");
1256 1256 session->ansi_data = 4 + sl;
1257 1257 }
1258   - trace_dsn("%s",see_chr);
  1258 + trace_dsn(session,"%s",see_chr);
1259 1259 if (!session->syncing)
1260 1260 {
1261 1261 if (session->linemode && session->onlcr && c == '\n')
... ... @@ -1271,7 +1271,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1271 1271 case TNS_IAC: /* process a telnet command */
1272 1272 if (c != EOR && c != IAC)
1273 1273 {
1274   - trace_dsn("RCVD %s ", cmd(c));
  1274 + trace_dsn(session,"RCVD %s ", cmd(c));
1275 1275 }
1276 1276  
1277 1277 switch (c)
... ... @@ -1282,16 +1282,17 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1282 1282 #if defined(X3270_ANSI) /*[*/
1283 1283 if (!session->ansi_data)
1284 1284 {
1285   - trace_dsn("<.. ");
  1285 + trace_dsn(session,"<.. ");
1286 1286 session->ansi_data = 4;
1287 1287 }
1288 1288 see_chr = ctl_see((int) c);
1289 1289 session->ansi_data += (sl = strlen(see_chr));
1290   - if (session->ansi_data >= TRACELINE) {
1291   - trace_dsn(" ...\n ...");
  1290 + if (session->ansi_data >= TRACELINE)
  1291 + {
  1292 + trace_dsn(session," ...\n ...");
1292 1293 session->ansi_data = 4 + sl;
1293 1294 }
1294   - trace_dsn("%s",see_chr);
  1295 + trace_dsn(session,"%s",see_chr);
1295 1296 ansi_process((unsigned int) c);
1296 1297 #endif /*]*/
1297 1298 }
... ... @@ -1312,7 +1313,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1312 1313 } else
1313 1314 Warning(session, _( "EOR received when not in 3270 mode, ignored." ));
1314 1315  
1315   - trace_dsn("RCVD EOR\n");
  1316 + trace_dsn(session,"RCVD EOR\n");
1316 1317 session->ibptr = session->ibuf;
1317 1318 session->telnet_state = TNS_DATA;
1318 1319 break;
... ... @@ -1341,7 +1342,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1341 1342 break;
1342 1343  
1343 1344 case DM:
1344   - trace_dsn("\n");
  1345 + trace_dsn(session,"\n");
1345 1346 if (session->syncing)
1346 1347 {
1347 1348 session->syncing = 0;
... ... @@ -1352,18 +1353,18 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1352 1353  
1353 1354 case GA:
1354 1355 case NOP:
1355   - trace_dsn("\n");
  1356 + trace_dsn(session,"\n");
1356 1357 session->telnet_state = TNS_DATA;
1357 1358 break;
1358 1359  
1359 1360 default:
1360   - trace_dsn("???\n");
  1361 + trace_dsn(session,"???\n");
1361 1362 session->telnet_state = TNS_DATA;
1362 1363 break;
1363 1364 }
1364 1365 break;
1365 1366 case TNS_WILL: /* telnet WILL DO OPTION command */
1366   - trace_dsn("%s\n", opt(c));
  1367 + trace_dsn(session,"%s\n", opt(c));
1367 1368 switch (c) {
1368 1369 case TELOPT_SGA:
1369 1370 case TELOPT_BINARY:
... ... @@ -1378,7 +1379,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1378 1379 session->hisopts[c] = 1;
1379 1380 do_opt[2] = c;
1380 1381 net_rawout(session,do_opt, sizeof(do_opt));
1381   - trace_dsn("SENT %s %s\n",
  1382 + trace_dsn(session,"SENT %s %s\n",
1382 1383 cmd(DO), opt(c));
1383 1384  
1384 1385 /*
... ... @@ -1389,7 +1390,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1389 1390 session->myopts[c] = 1;
1390 1391 will_opt[2] = c;
1391 1392 net_rawout(session,will_opt,sizeof(will_opt));
1392   - trace_dsn("SENT %s %s\n",cmd(WILL), opt(c));
  1393 + trace_dsn(session,"SENT %s %s\n",cmd(WILL), opt(c));
1393 1394 }
1394 1395  
1395 1396 check_in3270(session);
... ... @@ -1400,19 +1401,19 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1400 1401 default:
1401 1402 dont_opt[2] = c;
1402 1403 net_rawout(session,dont_opt, sizeof(dont_opt));
1403   - trace_dsn("SENT %s %s\n", cmd(DONT), opt(c));
  1404 + trace_dsn(session,"SENT %s %s\n", cmd(DONT), opt(c));
1404 1405 break;
1405 1406 }
1406 1407 session->telnet_state = TNS_DATA;
1407 1408 break;
1408 1409 case TNS_WONT: /* telnet WONT DO OPTION command */
1409   - trace_dsn("%s\n", opt(c));
  1410 + trace_dsn(session,"%s\n", opt(c));
1410 1411 if (session->hisopts[c])
1411 1412 {
1412 1413 session->hisopts[c] = 0;
1413 1414 dont_opt[2] = c;
1414 1415 net_rawout(session, dont_opt, sizeof(dont_opt));
1415   - trace_dsn("SENT %s %s\n", cmd(DONT), opt(c));
  1416 + trace_dsn(session,"SENT %s %s\n", cmd(DONT), opt(c));
1416 1417 check_in3270(session);
1417 1418 check_linemode(session,False);
1418 1419 }
... ... @@ -1420,7 +1421,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1420 1421 session->telnet_state = TNS_DATA;
1421 1422 break;
1422 1423 case TNS_DO: /* telnet PLEASE DO OPTION command */
1423   - trace_dsn("%s\n", opt(c));
  1424 + trace_dsn(session,"%s\n", opt(c));
1424 1425 switch (c) {
1425 1426 case TELOPT_BINARY:
1426 1427 case TELOPT_EOR:
... ... @@ -1446,7 +1447,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1446 1447 session->myopts[c] = 1;
1447 1448 will_opt[2] = c;
1448 1449 net_rawout(session, will_opt, sizeof(will_opt));
1449   - trace_dsn("SENT %s %s\n", cmd(WILL), opt(c));
  1450 + trace_dsn(session,"SENT %s %s\n", cmd(WILL), opt(c));
1450 1451 check_in3270(session);
1451 1452 check_linemode(session,False);
1452 1453 }
... ... @@ -1464,7 +1465,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1464 1465 * to announce that what follows is TLS.
1465 1466 */
1466 1467 net_rawout(session, follows_msg, sizeof(follows_msg));
1467   - trace_dsn("SENT %s %s FOLLOWS %s\n",
  1468 + trace_dsn(session,"SENT %s %s FOLLOWS %s\n",
1468 1469 cmd(SB),
1469 1470 opt(TELOPT_STARTTLS),
1470 1471 cmd(SE));
... ... @@ -1476,18 +1477,18 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1476 1477 wont:
1477 1478 wont_opt[2] = c;
1478 1479 net_rawout(session, wont_opt, sizeof(wont_opt));
1479   - trace_dsn("SENT %s %s\n", cmd(WONT), opt(c));
  1480 + trace_dsn(session,"SENT %s %s\n", cmd(WONT), opt(c));
1480 1481 break;
1481 1482 }
1482 1483 session->telnet_state = TNS_DATA;
1483 1484 break;
1484 1485 case TNS_DONT: /* telnet PLEASE DON'T DO OPTION command */
1485   - trace_dsn("%s\n", opt(c));
  1486 + trace_dsn(session,"%s\n", opt(c));
1486 1487 if (session->myopts[c]) {
1487 1488 session->myopts[c] = 0;
1488 1489 wont_opt[2] = c;
1489 1490 net_rawout(session, wont_opt, sizeof(wont_opt));
1490   - trace_dsn("SENT %s %s\n", cmd(WONT), opt(c));
  1491 + trace_dsn(session,"SENT %s %s\n", cmd(WONT), opt(c));
1491 1492 check_in3270(session);
1492 1493 check_linemode(session,False);
1493 1494 }
... ... @@ -1508,7 +1509,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1508 1509 int tt_len, tb_len;
1509 1510 char *tt_out;
1510 1511  
1511   - trace_dsn("%s %s\n", opt(session->sbbuf[0]),telquals[session->sbbuf[1]]);
  1512 + trace_dsn(session,"%s %s\n", opt(session->sbbuf[0]),telquals[session->sbbuf[1]]);
1512 1513  
1513 1514 if (session->lus != (char **)NULL && session->try_lu == CN)
1514 1515 {
... ... @@ -1538,7 +1539,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1538 1539 IAC, SE);
1539 1540 net_rawout(session, (unsigned char *)tt_out, tb_len);
1540 1541  
1541   - trace_dsn("SENT %s %s %s %.*s %s\n",
  1542 + trace_dsn(session,"SENT %s %s %s %.*s %s\n",
1542 1543 cmd(SB), opt(TELOPT_TTYPE),
1543 1544 telquals[TELQUAL_IS],
1544 1545 tt_len, tt_out + 4,
... ... @@ -1600,7 +1601,7 @@ static void tn3270e_request(H3270 *hSession)
1600 1601  
1601 1602 net_rawout(hSession, (unsigned char *)tt_out, tb_len);
1602 1603  
1603   - trace_dsn("SENT %s %s DEVICE-TYPE REQUEST %.*s%s%s %s\n",
  1604 + trace_dsn(hSession,"SENT %s %s DEVICE-TYPE REQUEST %.*s%s%s %s\n",
1604 1605 cmd(SB), opt(TELOPT_TN3270E), (int) strlen(hSession->termtype), tt_out + 5,
1605 1606 (hSession->try_lu != CN && *hSession->try_lu) ? " CONNECT " : "",
1606 1607 (hSession->try_lu != CN && *hSession->try_lu) ? hSession->try_lu : "",
... ... @@ -1614,12 +1615,12 @@ static void tn3270e_request(H3270 *hSession)
1614 1615 */
1615 1616 static void backoff_tn3270e(H3270 *hSession, const char *why)
1616 1617 {
1617   - trace_dsn("Aborting TN3270E: %s\n", why);
  1618 + trace_dsn(hSession,"Aborting TN3270E: %s\n", why);
1618 1619  
1619 1620 /* Tell the host 'no'. */
1620 1621 wont_opt[2] = TELOPT_TN3270E;
1621 1622 net_rawout(hSession, wont_opt, sizeof(wont_opt));
1622   - trace_dsn("SENT %s %s\n", cmd(WONT), opt(TELOPT_TN3270E));
  1623 + trace_dsn(hSession,"SENT %s %s\n", cmd(WONT), opt(TELOPT_TN3270E));
1623 1624  
1624 1625 /* Restore the LU list; we may need to run it again in TN3270 mode. */
1625 1626 setup_lus(hSession);
... ... @@ -1648,7 +1649,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1648 1649 break;
1649 1650 }
1650 1651  
1651   - trace_dsn("TN3270E ");
  1652 + trace_dsn(hSession,"TN3270E ");
1652 1653  
1653 1654 switch (hSession->sbbuf[1]) {
1654 1655  
... ... @@ -1657,18 +1658,18 @@ static int tn3270e_negotiate(H3270 *hSession)
1657 1658 if (hSession->sbbuf[2] == TN3270E_OP_DEVICE_TYPE) {
1658 1659  
1659 1660 /* Host wants us to send our device type. */
1660   - trace_dsn("SEND DEVICE-TYPE SE\n");
  1661 + trace_dsn(hSession,"SEND DEVICE-TYPE SE\n");
1661 1662  
1662 1663 tn3270e_request(hSession);
1663 1664 } else {
1664   - trace_dsn("SEND ??%u SE\n", hSession->sbbuf[2]);
  1665 + trace_dsn(hSession,"SEND ??%u SE\n", hSession->sbbuf[2]);
1665 1666 }
1666 1667 break;
1667 1668  
1668 1669 case TN3270E_OP_DEVICE_TYPE:
1669 1670  
1670 1671 /* Device type negotiation. */
1671   - trace_dsn("DEVICE-TYPE ");
  1672 + trace_dsn(hSession,"DEVICE-TYPE ");
1672 1673  
1673 1674 switch (hSession->sbbuf[2]) {
1674 1675 case TN3270E_OP_IS: {
... ... @@ -1686,7 +1687,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1686 1687 while(hSession->sbbuf[3+tnlen+1+snlen] != SE)
1687 1688 snlen++;
1688 1689 }
1689   - trace_dsn("IS %.*s CONNECT %.*s SE\n",
  1690 + trace_dsn(hSession,"IS %.*s CONNECT %.*s SE\n",
1690 1691 tnlen, &hSession->sbbuf[3],
1691 1692 snlen, &hSession->sbbuf[3+tnlen+1]);
1692 1693  
... ... @@ -1715,7 +1716,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1715 1716  
1716 1717 /* Device type failure. */
1717 1718  
1718   - trace_dsn("REJECT REASON %s SE\n", rsn(hSession->sbbuf[4]));
  1719 + trace_dsn(hSession,"REJECT REASON %s SE\n", rsn(hSession->sbbuf[4]));
1719 1720 if (hSession->sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE ||
1720 1721 hSession->sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) {
1721 1722 backoff_tn3270e(hSession,_( "Host rejected device type or request type" ));
... ... @@ -1740,7 +1741,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1740 1741  
1741 1742 break;
1742 1743 default:
1743   - trace_dsn("??%u SE\n", hSession->sbbuf[2]);
  1744 + trace_dsn(hSession,"??%u SE\n", hSession->sbbuf[2]);
1744 1745 break;
1745 1746 }
1746 1747 break;
... ... @@ -1748,15 +1749,14 @@ static int tn3270e_negotiate(H3270 *hSession)
1748 1749 case TN3270E_OP_FUNCTIONS:
1749 1750  
1750 1751 /* Functions negotiation. */
1751   - trace_dsn("FUNCTIONS ");
  1752 + trace_dsn(hSession,"FUNCTIONS ");
1752 1753  
1753 1754 switch (hSession->sbbuf[2]) {
1754 1755  
1755 1756 case TN3270E_OP_REQUEST:
1756 1757  
1757 1758 /* Host is telling us what functions they want. */
1758   - trace_dsn("REQUEST %s SE\n",
1759   - tn3270e_function_names(hSession->sbbuf+3, sblen-3));
  1759 + trace_dsn(hSession,"REQUEST %s SE\n",tn3270e_function_names(hSession->sbbuf+3, sblen-3));
1760 1760  
1761 1761 e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3);
1762 1762 if ((e_rcvd == hSession->e_funcs) || (hSession->e_funcs & ~e_rcvd)) {
... ... @@ -1764,7 +1764,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1764 1764 hSession->e_funcs = e_rcvd;
1765 1765 tn3270e_subneg_send(hSession, TN3270E_OP_IS, hSession->e_funcs);
1766 1766 hSession->tn3270e_negotiated = 1;
1767   - trace_dsn("TN3270E option negotiation complete.\n");
  1767 + trace_dsn(hSession,"TN3270E option negotiation complete.\n");
1768 1768 check_in3270(hSession);
1769 1769 } else {
1770 1770 /*
... ... @@ -1779,7 +1779,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1779 1779 case TN3270E_OP_IS:
1780 1780  
1781 1781 /* They accept our last request, or a subset thereof. */
1782   - trace_dsn("IS %s SE\n",tn3270e_function_names(hSession->sbbuf+3, sblen-3));
  1782 + trace_dsn(hSession,"IS %s SE\n",tn3270e_function_names(hSession->sbbuf+3, sblen-3));
1783 1783 e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3);
1784 1784 if (e_rcvd != hSession->e_funcs) {
1785 1785 if (hSession->e_funcs & ~e_rcvd) {
... ... @@ -1799,18 +1799,18 @@ static int tn3270e_negotiate(H3270 *hSession)
1799 1799 }
1800 1800 }
1801 1801 hSession->tn3270e_negotiated = 1;
1802   - trace_dsn("TN3270E option negotiation complete.\n");
  1802 + trace_dsn(hSession,"TN3270E option negotiation complete.\n");
1803 1803 check_in3270(hSession);
1804 1804 break;
1805 1805  
1806 1806 default:
1807   - trace_dsn("??%u SE\n", hSession->sbbuf[2]);
  1807 + trace_dsn(hSession,"??%u SE\n", hSession->sbbuf[2]);
1808 1808 break;
1809 1809 }
1810 1810 break;
1811 1811  
1812 1812 default:
1813   - trace_dsn("??%u SE\n", hSession->sbbuf[1]);
  1813 + trace_dsn(hSession,"??%u SE\n", hSession->sbbuf[1]);
1814 1814 }
1815 1815  
1816 1816 /* Good enough for now. */
... ... @@ -1877,7 +1877,7 @@ static void tn3270e_subneg_send(H3270 *hSession, unsigned char op, unsigned long
1877 1877 net_rawout(hSession, proto_buf, proto_len);
1878 1878  
1879 1879 /* Complete and send out the trace text. */
1880   - trace_dsn("SENT %s %s FUNCTIONS %s %s %s\n",
  1880 + trace_dsn(hSession,"SENT %s %s FUNCTIONS %s %s %s\n",
1881 1881 cmd(SB), opt(TELOPT_TN3270E),
1882 1882 (op == TN3270E_OP_REQUEST)? "REQUEST": "IS",
1883 1883 tn3270e_function_names(proto_buf + 5, proto_len - 7),
... ... @@ -1938,7 +1938,7 @@ process_eor(H3270 *hSession)
1938 1938 unsigned char *s;
1939 1939 enum pds rv;
1940 1940  
1941   - trace_dsn("RCVD TN3270E(%s%s %s %u)\n",
  1941 + trace_dsn(hSession,"RCVD TN3270E(%s%s %s %u)\n",
1942 1942 e_dt(h->data_type),
1943 1943 e_rq(h->data_type, h->request_flag),
1944 1944 e_rsp(h->data_type, h->response_flag),
... ... @@ -1966,7 +1966,7 @@ process_eor(H3270 *hSession)
1966 1966 if (!(hSession->e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1967 1967 return 0;
1968 1968 process_bind(hSession, hSession->ibuf + EH_SIZE, (hSession->ibptr - hSession->ibuf) - EH_SIZE);
1969   - trace_dsn("< BIND PLU-name '%s'\n", hSession->plu_name);
  1969 + trace_dsn(hSession,"< BIND PLU-name '%s'\n", hSession->plu_name);
1970 1970 hSession->tn3270e_bound = 1;
1971 1971 check_in3270(hSession);
1972 1972 return 0;
... ... @@ -2014,7 +2014,7 @@ void net_exception(H3270 *session)
2014 2014 {
2015 2015 CHECK_SESSION_HANDLE(session);
2016 2016  
2017   - trace_dsn("RCVD urgent data indication\n");
  2017 + trace_dsn(session,"RCVD urgent data indication\n");
2018 2018 if (!session->syncing)
2019 2019 {
2020 2020 session->syncing = 1;
... ... @@ -2069,13 +2069,13 @@ LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf
2069 2069  
2070 2070 e = ERR_get_error();
2071 2071 (void) ERR_error_string(e, err_buf);
2072   - trace_dsn("RCVD SSL_write error %ld (%s)\n", e,err_buf);
  2072 + trace_dsn(hSession,"RCVD SSL_write error %ld (%s)\n", e,err_buf);
2073 2073 popup_an_error(hSession,_( "SSL_write:\n%s" ), err_buf);
2074 2074 return -1;
2075 2075 }
2076 2076 #endif // HAVE_LIBSSL
2077 2077  
2078   - trace_dsn("RCVD socket error %d\n", socket_errno());
  2078 + trace_dsn(hSession,"RCVD socket error %d\n", socket_errno());
2079 2079  
2080 2080 switch(socket_errno())
2081 2081 {
... ... @@ -2146,10 +2146,10 @@ net_cookedout(H3270 *hSession, const char *buf, int len)
2146 2146 {
2147 2147 int i;
2148 2148  
2149   - trace_dsn(">");
  2149 + trace_dsn(hSession,">");
2150 2150 for (i = 0; i < len; i++)
2151   - trace_dsn(" %s", ctl_see((int) *(buf+i)));
2152   - trace_dsn("\n");
  2151 + trace_dsn(hSession," %s", ctl_see((int) *(buf+i)));
  2152 + trace_dsn(hSession,"\n");
2153 2153 }
2154 2154 #endif
2155 2155 net_rawout(hSession,(unsigned const char *) buf, len);
... ... @@ -2535,7 +2535,7 @@ check_in3270(H3270 *session)
2535 2535 session->tn3270e_bound = 0;
2536 2536 }
2537 2537 #endif /*]*/
2538   - trace_dsn("Now operating in %s mode.\n",state_name[new_cstate]);
  2538 + trace_dsn(session,"Now operating in %s mode.\n",state_name[new_cstate]);
2539 2539 host_in3270(session,new_cstate);
2540 2540 }
2541 2541 }
... ... @@ -2617,7 +2617,7 @@ static void check_linemode(H3270 *hSession, Boolean init)
2617 2617 lib3270_st_changed(hSession,LIB3270_STATE_LINE_MODE, hSession->linemode);
2618 2618 if (!init)
2619 2619 {
2620   - trace_dsn("Operating in %s mode.\n",hSession->linemode ? "line" : "character-at-a-time");
  2620 + trace_dsn(hSession,"Operating in %s mode.\n",hSession->linemode ? "line" : "character-at-a-time");
2621 2621 }
2622 2622 #if defined(X3270_ANSI) /*[*/
2623 2623 if (IN_ANSI && hSession->linemode)
... ... @@ -2690,18 +2690,17 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in
2690 2690 {
2691 2691 tdiff = ((1.0e6 * (double)(ts.tv_sec - h3270.ds_ts.tv_sec)) +
2692 2692 (double)(ts.tv_usec - h3270.ds_ts.tv_usec)) / 1.0e6;
2693   - trace_dsn("%c +%gs\n", direction, tdiff);
  2693 + trace_dsn(hSession,"%c +%gs\n", direction, tdiff);
2694 2694 }
2695 2695  
2696 2696 hSession->ds_ts = ts;
2697 2697 for (offset = 0; offset < len; offset++)
2698 2698 {
2699 2699 if (!(offset % LINEDUMP_MAX))
2700   - trace_dsn("%s%c 0x%-3x ",
2701   - (offset ? "\n" : ""), direction, offset);
2702   - trace_dsn("%02x", buf[offset]);
  2700 + trace_dsn(hSession,"%s%c 0x%-3x ",(offset ? "\n" : ""), direction, offset);
  2701 + trace_dsn(hSession,"%02x", buf[offset]);
2703 2702 }
2704   - trace_dsn("\n");
  2703 + trace_dsn(hSession,"\n");
2705 2704 }
2706 2705 #endif // X3270_TRACE
2707 2706  
... ... @@ -2750,7 +2749,7 @@ void net_output(H3270 *hSession)
2750 2749 h->seq_number[0] = (hSession->e_xmit_seq >> 8) & 0xff;
2751 2750 h->seq_number[1] = hSession->e_xmit_seq & 0xff;
2752 2751  
2753   - trace_dsn("SENT TN3270E(%s NO-RESPONSE %u)\n",IN_TN3270E ? "3270-DATA" : "SSCP-LU-DATA", hSession->e_xmit_seq);
  2752 + trace_dsn(hSession,"SENT TN3270E(%s NO-RESPONSE %u)\n",IN_TN3270E ? "3270-DATA" : "SSCP-LU-DATA", hSession->e_xmit_seq);
2754 2753 if (hSession->e_funcs & E_OPT(TN3270E_FUNC_RESPONSES))
2755 2754 hSession->e_xmit_seq = (hSession->e_xmit_seq + 1) & 0x7fff;
2756 2755 }
... ... @@ -2784,7 +2783,7 @@ void net_output(H3270 *hSession)
2784 2783 *xoptr++ = EOR;
2785 2784 net_rawout(hSession,xobuf, xoptr - xobuf);
2786 2785  
2787   - trace_dsn("SENT EOR\n");
  2786 + trace_dsn(hSession,"SENT EOR\n");
2788 2787 hSession->ns_rsent++;
2789 2788 #undef BSTART
2790 2789 }
... ... @@ -2814,8 +2813,7 @@ static void tn3270e_ack(H3270 *hSession)
2814 2813 rsp_buf[rsp_len++] = TN3270E_POS_DEVICE_END;
2815 2814 rsp_buf[rsp_len++] = IAC;
2816 2815 rsp_buf[rsp_len++] = EOR;
2817   - trace_dsn("SENT TN3270E(RESPONSE POSITIVE-RESPONSE %u) DEVICE-END\n",
2818   - h_in->seq_number[0] << 8 | h_in->seq_number[1]);
  2816 + trace_dsn(hSession,"SENT TN3270E(RESPONSE POSITIVE-RESPONSE %u) DEVICE-END\n",h_in->seq_number[0] << 8 | h_in->seq_number[1]);
2819 2817 net_rawout(hSession, rsp_buf, rsp_len);
2820 2818 }
2821 2819  
... ... @@ -2849,7 +2847,7 @@ static void tn3270e_nak(H3270 *hSession, enum pds rv)
2849 2847 }
2850 2848 rsp_buf[rsp_len++] = IAC;
2851 2849 rsp_buf[rsp_len++] = EOR;
2852   - trace_dsn("SENT TN3270E(RESPONSE NEGATIVE-RESPONSE %u) %s\n",h_in->seq_number[0] << 8 | h_in->seq_number[1], neg);
  2850 + trace_dsn(hSession,"SENT TN3270E(RESPONSE NEGATIVE-RESPONSE %u) %s\n",h_in->seq_number[0] << 8 | h_in->seq_number[1], neg);
2853 2851 net_rawout(hSession, rsp_buf, rsp_len);
2854 2852 }
2855 2853  
... ... @@ -2982,12 +2980,12 @@ net_linemode(void)
2982 2980 if (hisopts[TELOPT_ECHO]) {
2983 2981 dont_opt[2] = TELOPT_ECHO;
2984 2982 net_rawout(dont_opt, sizeof(dont_opt));
2985   - trace_dsn("SENT %s %s\n", cmd(DONT), opt(TELOPT_ECHO));
  2983 + trace_dsn(&h3270,"SENT %s %s\n", cmd(DONT), opt(TELOPT_ECHO));
2986 2984 }
2987 2985 if (hisopts[TELOPT_SGA]) {
2988 2986 dont_opt[2] = TELOPT_SGA;
2989 2987 net_rawout(dont_opt, sizeof(dont_opt));
2990   - trace_dsn("SENT %s %s\n", cmd(DONT), opt(TELOPT_SGA));
  2988 + trace_dsn(&h3270,"SENT %s %s\n", cmd(DONT), opt(TELOPT_SGA));
2991 2989 }
2992 2990 }
2993 2991 */
... ... @@ -3000,12 +2998,12 @@ net_charmode(void)
3000 2998 if (!hisopts[TELOPT_ECHO]) {
3001 2999 do_opt[2] = TELOPT_ECHO;
3002 3000 net_rawout(do_opt, sizeof(do_opt));
3003   - trace_dsn("SENT %s %s\n", cmd(DO), opt(TELOPT_ECHO));
  3001 + trace_dsn(&h3270,"SENT %s %s\n", cmd(DO), opt(TELOPT_ECHO));
3004 3002 }
3005 3003 if (!hisopts[TELOPT_SGA]) {
3006 3004 do_opt[2] = TELOPT_SGA;
3007 3005 net_rawout(do_opt, sizeof(do_opt));
3008   - trace_dsn("SENT %s %s\n", cmd(DO), opt(TELOPT_SGA));
  3006 + trace_dsn(&h3270,"SENT %s %s\n", cmd(DO), opt(TELOPT_SGA));
3009 3007 }
3010 3008 }
3011 3009 #endif /*]*/
... ... @@ -3023,7 +3021,7 @@ net_break(void)
3023 3021  
3024 3022 /* I don't know if we should first send TELNET synch ? */
3025 3023 net_rawout(&h3270, buf, sizeof(buf));
3026   - trace_dsn("SENT BREAK\n");
  3024 + trace_dsn(&h3270,"SENT BREAK\n");
3027 3025 }
3028 3026  
3029 3027 /*
... ... @@ -3038,7 +3036,7 @@ net_interrupt(void)
3038 3036  
3039 3037 /* I don't know if we should first send TELNET synch ? */
3040 3038 net_rawout(&h3270, buf, sizeof(buf));
3041   - trace_dsn("SENT IP\n");
  3039 + trace_dsn(&h3270,"SENT IP\n");
3042 3040 }
3043 3041  
3044 3042 /*
... ... @@ -3065,7 +3063,7 @@ net_abort(void)
3065 3063 break;
3066 3064 case E_SSCP:
3067 3065 net_rawout(&h3270, buf, sizeof(buf));
3068   - trace_dsn("SENT AO\n");
  3066 + trace_dsn(&h3270,"SENT AO\n");
3069 3067 if (h3270.tn3270e_bound ||
3070 3068 !(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) {
3071 3069 h3270.tn3270e_submode = E_3270;
... ... @@ -3074,7 +3072,7 @@ net_abort(void)
3074 3072 break;
3075 3073 case E_3270:
3076 3074 net_rawout(&h3270, buf, sizeof(buf));
3077   - trace_dsn("SENT AO\n");
  3075 + trace_dsn(&h3270,"SENT AO\n");
3078 3076 h3270.tn3270e_submode = E_SSCP;
3079 3077 check_in3270(&h3270);
3080 3078 break;
... ... @@ -3349,16 +3347,16 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3349 3347 switch(where)
3350 3348 {
3351 3349 case SSL_CB_CONNECT_LOOP:
3352   - trace_dsn("SSL_connect: %s %s\n",SSL_state_string(s), SSL_state_string_long(s));
  3350 + trace_dsn(hSession,"SSL_connect: %s %s\n",SSL_state_string(s), SSL_state_string_long(s));
3353 3351 break;
3354 3352  
3355 3353 case SSL_CB_CONNECT_EXIT:
3356 3354  
3357   - trace_dsn("%s: SSL_CB_CONNECT_EXIT\n",__FUNCTION__);
  3355 + trace_dsn(hSession,"%s: SSL_CB_CONNECT_EXIT\n",__FUNCTION__);
3358 3356  
3359 3357 if (ret == 0)
3360 3358 {
3361   - trace_dsn("SSL_connect: failed in %s\n",SSL_state_string_long(s));
  3359 + trace_dsn(hSession,"SSL_connect: failed in %s\n",SSL_state_string_long(s));
3362 3360 }
3363 3361 else if (ret < 0)
3364 3362 {
... ... @@ -3391,7 +3389,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3391 3389 err_buf[0] = '\0';
3392 3390 }
3393 3391  
3394   - trace_dsn("SSL Connect error in %s\nState: %s\nAlert: %s\n",err_buf,SSL_state_string_long(s),SSL_alert_type_string_long(ret));
  3392 + trace_dsn(hSession,"SSL Connect error in %s\nState: %s\nAlert: %s\n",err_buf,SSL_state_string_long(s),SSL_alert_type_string_long(ret));
3395 3393  
3396 3394 show_3270_popup_dialog( hSession, // H3270 *session,
3397 3395 PW3270_DIALOG_CRITICAL, // PW3270_DIALOG type,
... ... @@ -3406,7 +3404,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3406 3404  
3407 3405  
3408 3406 default:
3409   - trace_dsn("SSL Current state is \"%s\"\n",SSL_state_string_long(s));
  3407 + trace_dsn(hSession,"SSL Current state is \"%s\"\n",SSL_state_string_long(s));
3410 3408 }
3411 3409  
3412 3410 // trace("%s: state=%04x where=%04x ret=%d",__FUNCTION__,SSL_state(s),where,ret);
... ... @@ -3419,11 +3417,11 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3419 3417 #endif
3420 3418  
3421 3419 if(where & SSL_CB_ALERT)
3422   - trace_dsn("SSL ALERT: %s\n",SSL_alert_type_string_long(ret));
  3420 + trace_dsn(hSession,"SSL ALERT: %s\n",SSL_alert_type_string_long(ret));
3423 3421  
3424 3422 if(where & SSL_CB_HANDSHAKE_DONE)
3425 3423 {
3426   - trace_dsn("%s: SSL_CB_HANDSHAKE_DONE state=%04x\n",__FUNCTION__,SSL_state(s));
  3424 + trace_dsn(hSession,"%s: SSL_CB_HANDSHAKE_DONE state=%04x\n",__FUNCTION__,SSL_state(s));
3427 3425 if(SSL_state(s) == 0x03)
3428 3426 set_ssl_state(hSession,LIB3270_SSL_SECURE);
3429 3427 else
... ... @@ -3442,14 +3440,14 @@ static void continue_tls(unsigned char *sbbuf, int len)
3442 3440 /* Make sure the option is FOLLOWS. */
3443 3441 if (len < 2 || sbbuf[1] != TLS_FOLLOWS) {
3444 3442 /* Trace the junk. */
3445   - trace_dsn("%s ? %s\n", opt(TELOPT_STARTTLS), cmd(SE));
  3443 + trace_dsn(&h3270,"%s ? %s\n", opt(TELOPT_STARTTLS), cmd(SE));
3446 3444 popup_an_error(NULL,"TLS negotiation failure");
3447 3445 net_disconnect(&h3270);
3448 3446 return;
3449 3447 }
3450 3448  
3451 3449 /* Trace what we got. */
3452   - trace_dsn("%s FOLLOWS %s\n", opt(TELOPT_STARTTLS), cmd(SE));
  3450 + trace_dsn(&h3270,"%s FOLLOWS %s\n", opt(TELOPT_STARTTLS), cmd(SE));
3453 3451  
3454 3452 /* Initialize the SSL library. */
3455 3453 ssl_init(&h3270);
... ... @@ -3463,7 +3461,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3463 3461 /* Set up the TLS/SSL connection. */
3464 3462 if(SSL_set_fd(h3270.ssl_con, h3270.sock) != 1)
3465 3463 {
3466   - trace_dsn("SSL_set_fd failed!\n");
  3464 + trace_dsn(&h3270,"SSL_set_fd failed!\n");
3467 3465 }
3468 3466  
3469 3467 //#if defined(_WIN32)
... ... @@ -3481,7 +3479,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3481 3479  
3482 3480 if (rv != 1)
3483 3481 {
3484   - trace_dsn("continue_tls: SSL_connect failed\n");
  3482 + trace_dsn(&h3270,"continue_tls: SSL_connect failed\n");
3485 3483 net_disconnect(&h3270);
3486 3484 return;
3487 3485 }
... ... @@ -3489,7 +3487,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3489 3487 // h3270.secure_connection = True;
3490 3488  
3491 3489 /* Success. */
3492   -// trace_dsn("TLS/SSL negotiated connection complete. Connection is now secure.\n");
  3490 +// trace_dsn(&h3270,"TLS/SSL negotiated connection complete. Connection is now secure.\n");
3493 3491  
3494 3492 /* Tell the world that we are (still) connected, now in secure mode. */
3495 3493 lib3270_set_connected(&h3270);
... ...
trace_ds.c
... ... @@ -108,7 +108,7 @@
108 108 // static off_t tracef_midpoint = 0;
109 109  
110 110 static void __vwtrace(H3270 *session, const char *fmt, va_list args);
111   -static void wtrace(const char *fmt, ...);
  111 +static void wtrace(H3270 *session, const char *fmt, ...);
112 112 // static char *create_tracefile_header(const char *mode);
113 113 // static void stop_tracing(void);
114 114  
... ... @@ -116,7 +116,7 @@ static void wtrace(const char *fmt, ...);
116 116 // struct timeval ds_ts;
117 117  
118 118 static void (*vwtrace)(H3270 *session, const char *fmt, va_list args) = __vwtrace;
119   -Boolean trace_skipping = False;
  119 +// Boolean trace_skipping = False;
120 120  
121 121  
122 122 LIB3270_EXPORT void lib3270_set_trace_handler( void (*handler)(H3270 *session, const char *fmt, va_list args) )
... ... @@ -137,38 +137,46 @@ const char * rcba(H3270 *hSession, int baddr)
137 137 // static char *tdsbuf = CN;
138 138 // #define TDS_LEN 75
139 139  
140   -static void
141   -trace_ds_s(char *s, Boolean can_break)
  140 +static void trace_ds_s(H3270 *hSession, char *s, Boolean can_break)
142 141 {
143 142 static int dscnt = 0;
144 143 int len = strlen(s);
145 144 Boolean nl = False;
146 145  
147   - if (!lib3270_get_toggle(&h3270,DS_TRACE) || !len)
  146 + if (!lib3270_get_toggle(hSession,DS_TRACE) || !len)
148 147 return;
149 148  
150   - if (s && s[len-1] == '\n') {
  149 + if (s && s[len-1] == '\n')
  150 + {
151 151 len--;
152 152 nl = True;
153 153 }
154   - if (!can_break && dscnt + len >= 75) {
155   - wtrace("...\n... ");
  154 +
  155 + if (!can_break && dscnt + len >= 75)
  156 + {
  157 + wtrace(hSession,"...\n... ");
156 158 dscnt = 0;
157 159 }
158   - while (dscnt + len >= 75) {
  160 +
  161 + while (dscnt + len >= 75)
  162 + {
159 163 int plen = 75-dscnt;
160 164  
161   - wtrace("%.*s ...\n... ", plen, s);
  165 + wtrace(hSession,"%.*s ...\n... ", plen, s);
162 166 dscnt = 4;
163 167 s += plen;
164 168 len -= plen;
165 169 }
166   - if (len) {
167   - wtrace("%.*s", len, s);
  170 +
  171 + if (len)
  172 + {
  173 + wtrace(hSession,"%.*s", len, s);
168 174 dscnt += len;
169 175 }
170   - if (nl) {
171   - wtrace("\n");
  176 +
  177 + if (nl)
  178 + {
  179 + wtrace(hSession,"\n");
172 180 dscnt = 0;
173 181 }
174 182 }
... ... @@ -185,25 +193,25 @@ void trace_ds(H3270 *hSession, const char *fmt, ...)
185 193  
186 194 /* print out remainder of message */
187 195 text = lib3270_vsprintf(fmt,args);
188   - trace_ds_s(text, True);
  196 + trace_ds_s(hSession,text, True);
189 197 va_end(args);
190 198 lib3270_free(text);
191 199 }
192 200  
193   -void trace_ds_nb(const char *fmt, ...)
  201 +void trace_ds_nb(H3270 *hSession, const char *fmt, ...)
194 202 {
195   - char tdsbuf[4096];
  203 + char *text;
196 204 va_list args;
197 205  
198   - if (!lib3270_get_toggle(&h3270,DS_TRACE))
  206 + if (!lib3270_get_toggle(hSession,DS_TRACE))
199 207 return;
200 208  
201 209 va_start(args, fmt);
202 210  
203 211 /* print out remainder of message */
204   - (void) vsprintf(tdsbuf, fmt, args);
205   - trace_ds_s(tdsbuf, False);
206   - va_end(args);
  212 + text = lib3270_vsprintf(fmt,args);
  213 + trace_ds_s(hSession, text, False);
  214 + lib3270_free(text);
207 215 }
208 216  
209 217 /* Conditional event trace. */ /*
... ... @@ -222,16 +230,16 @@ void trace_event(const char *fmt, ...)
222 230 */
223 231  
224 232 /* Conditional data stream trace, without line splitting. */
225   -void trace_dsn(const char *fmt, ...)
  233 +void trace_dsn(H3270 *hSession, const char *fmt, ...)
226 234 {
227 235 va_list args;
228 236  
229   - if (!lib3270_get_toggle(&h3270,DS_TRACE))
  237 + if (!lib3270_get_toggle(hSession,DS_TRACE))
230 238 return;
231 239  
232 240 /* print out message */
233 241 va_start(args, fmt);
234   - vwtrace(&h3270,fmt, args);
  242 + vwtrace(hSession,fmt, args);
235 243 va_end(args);
236 244 }
237 245  
... ... @@ -247,11 +255,11 @@ static void __vwtrace(H3270 *session, const char *fmt, va_list args)
247 255 }
248 256  
249 257 /* Write to the trace file. */
250   -static void wtrace(const char *fmt, ...)
  258 +static void wtrace(H3270 *hSession, const char *fmt, ...)
251 259 {
252 260 va_list args;
253 261 va_start(args, fmt);
254   - vwtrace(&h3270,fmt, args);
  262 + vwtrace(hSession,fmt, args);
255 263 va_end(args);
256 264 }
257 265  
... ... @@ -286,7 +294,7 @@ LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...)
286 294 */
287 295 void trace_screen(H3270 *session)
288 296 {
289   - trace_skipping = False;
  297 + session->trace_skipping = 0;
290 298  
291 299 if (lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE))
292 300 {
... ... @@ -295,47 +303,51 @@ void trace_screen(H3270 *session)
295 303 for(row=baddr=0;row < session->rows;row++)
296 304 {
297 305 int col;
298   - wtrace("%02d ",row+1);
  306 + wtrace(session,"%02d ",row+1);
299 307  
300 308 for(col = 0; col < session->cols;col++)
301 309 {
302 310 if(session->text[baddr].attr & LIB3270_ATTR_CG)
303   - wtrace("%c",'.');
  311 + wtrace(session,"%c",'.');
304 312 else if(session->text[baddr].chr)
305   - wtrace("%c",session->text[baddr].chr);
  313 + wtrace(session,"%c",session->text[baddr].chr);
306 314 else
307   - wtrace("%c",'.');
  315 + wtrace(session,"%c",'.');
308 316 baddr++;
309 317 }
310   - wtrace("%s\n","");
  318 + wtrace(session,"%s\n","");
311 319 }
312 320 }
313 321 }
314 322  
315 323 /* Called from ANSI emulation code to log a single character. */
316   -void trace_char(char c)
  324 +void trace_char(H3270 *hSession, char c)
317 325 {
318   - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_SCREEN_TRACE))
319   - wtrace("%c",c);
  326 + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE))
  327 + wtrace(hSession,"%c",c);
320 328 return;
321 329 }
322 330  
323   -/*
324   - * Called when disconnecting in ANSI mode, to finish off the trace file
  331 +/**
  332 + * Called when disconnecting in ANSI modeto finish off the trace file.
  333 + *
  334 + * Called when disconnecting in ANSI mode to finish off the trace file
325 335 * and keep the next screen clear from re-recording the screen image.
326 336 * (In a gross violation of data hiding and modularity, trace_skipping is
327 337 * manipulated directly in ctlr_clear()).
  338 + *
  339 + *
328 340 */
329   -void trace_ansi_disc(void)
  341 +void trace_ansi_disc(H3270 *hSession)
330 342 {
331 343 int i;
332 344  
333   - wtrace("%c",'\n');
334   - for (i = 0; i < h3270.cols; i++)
335   - wtrace("%c",'=');
336   - wtrace("%c",'\n');
  345 + wtrace(hSession,"%c",'\n');
  346 + for (i = 0; i < hSession->cols; i++)
  347 + wtrace(hSession,"%c",'=');
  348 + wtrace(hSession,"%c",'\n');
337 349  
338   - trace_skipping = True;
  350 + hSession->trace_skipping = 1;
339 351 }
340 352  
341 353  
... ...
trace_dsc.h
... ... @@ -34,7 +34,7 @@
34 34  
35 35 #if defined(X3270_TRACE)
36 36  
37   - LIB3270_INTERNAL Boolean trace_skipping;
  37 +// LIB3270_INTERNAL Boolean trace_skipping;
38 38  
39 39 const char *rcba(H3270 *session, int baddr);
40 40  
... ... @@ -42,11 +42,11 @@
42 42 // void toggle_eventTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);
43 43 // void toggle_screenTrace(H3270 *h, struct toggle *t, LIB3270_TOGGLE_TYPE tt);
44 44  
45   - void trace_ansi_disc(void);
46   - void trace_char(char c);
  45 + void trace_ansi_disc(H3270 *hSession);
  46 + void trace_char(H3270 *hSession, char c);
47 47 void trace_ds(H3270 *hSession, const char *fmt, ...) printflike(2, 3);
48   - void trace_ds_nb(const char *fmt, ...) printflike(1, 2);
49   - void trace_dsn(const char *fmt, ...) printflike(1, 2);
  48 + void trace_ds_nb(H3270 *hSession, const char *fmt, ...) printflike(2, 3);
  49 + void trace_dsn(H3270 *hSession, const char *fmt, ...) printflike(2, 3);
50 50 // void trace_event(const char *fmt, ...) printflike(1, 2);
51 51 void trace_screen(H3270 *session);
52 52 // void trace_rollover_check(void);
... ... @@ -55,10 +55,10 @@
55 55  
56 56 #elif defined(__GNUC__)
57 57  
58   - #define trace_ds(format, args...)
59   - #define trace_dsn(format, args...)
60   - #define trace_ds_nb(format, args...)
61   - #define trace_event(format, args...)
  58 + #define trace_ds(session, format, args...)
  59 + #define trace_dsn(session, format, args...)
  60 + #define trace_ds_nb(session, format, args...)
  61 + #define trace_event(session, format, args...)
62 62  
63 63 #else
64 64  
... ...