Commit 001dc51b2057db2e571b6e0dc9fdbba922a3494f

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

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

@@ -1718,7 +1718,7 @@ ansi_process(unsigned int c) @@ -1718,7 +1718,7 @@ ansi_process(unsigned int c)
1718 1718
1719 #if defined(X3270_TRACE) /*[*/ 1719 #if defined(X3270_TRACE) /*[*/
1720 if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_SCREEN_TRACE)) 1720 if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_SCREEN_TRACE))
1721 - trace_char((char)c); 1721 + trace_char(&h3270,(char)c);
1722 #endif /*]*/ 1722 #endif /*]*/
1723 1723
1724 fn = ansi_fn[st[(int)state][c]]; 1724 fn = ansi_fn[st[(int)state][c]];
@@ -1771,7 +1771,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) @@ -1771,7 +1771,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1771 } 1771 }
1772 add_dbcs = True; 1772 add_dbcs = True;
1773 dbcs_to_mb(add_c1, add_c2, mb); 1773 dbcs_to_mb(add_c1, add_c2, mb);
1774 - trace_ds_nb("%s", mb); 1774 + trace_ds_nb(&h3270,"%s", mb);
1775 } else { 1775 } else {
1776 #endif /*]*/ 1776 #endif /*]*/
1777 add_c1 = *cp; 1777 add_c1 = *cp;
@@ -2257,15 +2257,16 @@ void @@ -2257,15 +2257,16 @@ void
2257 ctlr_clear(H3270 *session, Boolean can_snap) 2257 ctlr_clear(H3270 *session, Boolean can_snap)
2258 { 2258 {
2259 /* Snap any data that is about to be lost into the trace file. */ 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 #if defined(X3270_TRACE) /*[*/ 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 trace_screen(session); 2264 trace_screen(session);
2264 #endif /*]*/ 2265 #endif /*]*/
2265 // scroll_save(session->maxROWS, ever_3270 ? False : True); 2266 // scroll_save(session->maxROWS, ever_3270 ? False : True);
2266 } 2267 }
2267 #if defined(X3270_TRACE) /*[*/ 2268 #if defined(X3270_TRACE) /*[*/
2268 - trace_skipping = False; 2269 + session->trace_skipping = 0;
2269 #endif /*]*/ 2270 #endif /*]*/
2270 2271
2271 /* Clear the screen. */ 2272 /* Clear the screen. */
@@ -685,7 +685,7 @@ void host_disconnect(H3270 *h, int failed) @@ -685,7 +685,7 @@ void host_disconnect(H3270 *h, int failed)
685 */ 685 */
686 #if defined(X3270_TRACE) /*[*/ 686 #if defined(X3270_TRACE) /*[*/
687 if (IN_ANSI && lib3270_get_toggle(h,LIB3270_TOGGLE_SCREEN_TRACE)) 687 if (IN_ANSI && lib3270_get_toggle(h,LIB3270_TOGGLE_SCREEN_TRACE))
688 - trace_ansi_disc(); 688 + trace_ansi_disc(h);
689 #endif /*]*/ 689 #endif /*]*/
690 690
691 lib3270_set_disconnected(h); 691 lib3270_set_disconnected(h);
@@ -349,13 +349,13 @@ static int proxy_passthru(int fd, char *host, unsigned short port) @@ -349,13 +349,13 @@ static int proxy_passthru(int fd, char *host, unsigned short port)
349 (void) sprintf(buf, "%s %u\r\n", host, port); 349 (void) sprintf(buf, "%s %u\r\n", host, port);
350 350
351 #if defined(X3270_TRACE) /*[*/ 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 trace_netdata(&h3270,'>', (unsigned char *)buf, (int) strlen(buf)); 353 trace_netdata(&h3270,'>', (unsigned char *)buf, (int) strlen(buf));
354 #endif /*]*/ 354 #endif /*]*/
355 355
356 if (send(fd, buf, strlen(buf), 0) < 0) 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 lib3270_free(buf); 359 lib3270_free(buf);
360 return -1; 360 return -1;
361 } 361 }
@@ -385,7 +385,7 @@ proxy_http(int fd, char *host, unsigned short port) @@ -385,7 +385,7 @@ proxy_http(int fd, char *host, unsigned short port)
385 port); 385 port);
386 386
387 #if defined(X3270_TRACE) /*[*/ 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 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); 389 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf));
390 #endif /*]*/ 390 #endif /*]*/
391 391
@@ -402,7 +402,7 @@ proxy_http(int fd, char *host, unsigned short port) @@ -402,7 +402,7 @@ proxy_http(int fd, char *host, unsigned short port)
402 port); 402 port);
403 403
404 #if defined(X3270_TRACE) /*[*/ 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 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); 406 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf));
407 #endif /*]*/ 407 #endif /*]*/
408 408
@@ -414,7 +414,7 @@ proxy_http(int fd, char *host, unsigned short port) @@ -414,7 +414,7 @@ proxy_http(int fd, char *host, unsigned short port)
414 414
415 strcpy(buf, "\r\n"); 415 strcpy(buf, "\r\n");
416 #if defined(X3270_TRACE) /*[*/ 416 #if defined(X3270_TRACE) /*[*/
417 - trace_dsn("HTTP Proxy: xmit ''\n"); 417 + trace_dsn(&h3270,"HTTP Proxy: xmit ''\n");
418 trace_netdata(&h3270, '>', (unsigned char *)buf, strlen(buf)); 418 trace_netdata(&h3270, '>', (unsigned char *)buf, strlen(buf));
419 #endif /*]*/ 419 #endif /*]*/
420 420
@@ -476,19 +476,21 @@ proxy_http(int fd, char *host, unsigned short port) @@ -476,19 +476,21 @@ proxy_http(int fd, char *host, unsigned short port)
476 476
477 #if defined(X3270_TRACE) /*[*/ 477 #if defined(X3270_TRACE) /*[*/
478 trace_netdata(&h3270, '<', (unsigned char *)rbuf, nread); 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 #endif /*]*/ 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 return -1; 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 return -1; 490 return -1;
489 } 491 }
490 492
491 - return 0; 493 + return 0;
492 } 494 }
493 495
494 /* TELNET proxy. */ 496 /* TELNET proxy. */
@@ -501,12 +503,13 @@ proxy_telnet(int fd, char *host, unsigned short port) @@ -501,12 +503,13 @@ proxy_telnet(int fd, char *host, unsigned short port)
501 (void) sprintf(buf, "connect %s %u\r\n", host, port); 503 (void) sprintf(buf, "connect %s %u\r\n", host, port);
502 504
503 #if defined(X3270_TRACE) /*[*/ 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 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf)); 507 trace_netdata(&h3270, '>', (unsigned char *)buf, (int) strlen(buf));
506 #endif /*]*/ 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 lib3270_free(buf); 513 lib3270_free(buf);
511 return -1; 514 return -1;
512 } 515 }
@@ -575,12 +578,13 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) @@ -575,12 +578,13 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
575 s += strlen(host) + 1; 578 s += strlen(host) + 1;
576 579
577 #if defined(X3270_TRACE) /*[*/ 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 trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf); 582 trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf);
580 #endif /*]*/ 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 lib3270_free(buf); 588 lib3270_free(buf);
585 return -1; 589 return -1;
586 } 590 }
@@ -599,15 +603,14 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) @@ -599,15 +603,14 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
599 s += strlen(user) + 1; 603 s += strlen(user) + 1;
600 604
601 #if defined(X3270_TRACE) /*[*/ 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 trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf); 607 trace_netdata(&h3270,'>', (unsigned char *)buf, s - buf);
606 #endif /*]*/ 608 #endif /*]*/
607 609
608 - if (send(fd, buf, s - buf, 0) < 0) { 610 + if (send(fd, buf, s - buf, 0) < 0)
  611 + {
609 lib3270_free(buf); 612 lib3270_free(buf);
610 - popup_a_sockerr(NULL,"SOCKS4 Proxy: send error"); 613 + popup_a_sockerr(&h3270,"SOCKS4 Proxy: send error");
611 return -1; 614 return -1;
612 } 615 }
613 lib3270_free(buf); 616 lib3270_free(buf);
@@ -643,35 +646,32 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a) @@ -643,35 +646,32 @@ static int proxy_socks4(int fd, char *host, unsigned short port, int force_a)
643 646
644 #if defined(X3270_TRACE) /*[*/ 647 #if defined(X3270_TRACE) /*[*/
645 trace_netdata(&h3270,'<', (unsigned char *)rbuf, nread); 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 } else 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 #endif /*]*/ 659 #endif /*]*/
659 660
660 switch (rbuf[1]) { 661 switch (rbuf[1]) {
661 case 0x5a: 662 case 0x5a:
662 break; 663 break;
663 case 0x5b: 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 return -1; 666 return -1;
666 case 0x5c: 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 return -1; 669 return -1;
669 case 0x5d: 670 case 0x5d:
670 - popup_an_error(NULL,"SOCKS4 Proxy: userid error"); 671 + popup_an_error(&h3270,"SOCKS4 Proxy: userid error");
671 return -1; 672 return -1;
672 default: 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 return -1; 675 return -1;
676 } 676 }
677 677
@@ -732,7 +732,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) @@ -732,7 +732,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
732 /* Send the authentication request to the server. */ 732 /* Send the authentication request to the server. */
733 strcpy((char *)rbuf, "\005\001\000"); 733 strcpy((char *)rbuf, "\005\001\000");
734 #if defined(X3270_TRACE) /*[*/ 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 trace_netdata(&h3270, '>', rbuf, 3); 736 trace_netdata(&h3270, '>', rbuf, 3);
737 #endif /*]*/ 737 #endif /*]*/
738 if (send(fd, (const char *) rbuf, 3, 0) < 0) { 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,16 +792,16 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
792 792
793 if (rbuf[0] != 0x05 || (rbuf[1] != 0 && rbuf[1] != 0xff)) 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 return -1; 796 return -1;
797 } 797 }
798 798
799 #if defined(X3270_TRACE) /*[*/ 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 #endif /*]*/ 801 #endif /*]*/
802 802
803 if (rbuf[1] == 0xff) { 803 if (rbuf[1] == 0xff) {
804 - popup_an_error(NULL,"SOCKS5 Proxy: authentication failure"); 804 + popup_an_error(&h3270,"SOCKS5 Proxy: authentication failure");
805 return -1; 805 return -1;
806 } 806 }
807 807
@@ -832,7 +832,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) @@ -832,7 +832,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
832 SET16(s, port); 832 SET16(s, port);
833 833
834 #if defined(X3270_TRACE) /*[*/ 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 use_name? "domainname": 836 use_name? "domainname":
837 ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"), 837 ((ha.sa.sa_family == AF_INET)? "IPv4": "IPv6"),
838 use_name? host: nbuf, 838 use_name? host: nbuf,
@@ -1008,7 +1008,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d) @@ -1008,7 +1008,7 @@ proxy_socks5(int fd, char *host, unsigned short port, int force_d)
1008 break; 1008 break;
1009 } 1009 }
1010 rport = (*portp << 8) + *(portp + 1); 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 "port %u\n", 1012 "port %u\n",
1013 buf[0], buf[1], 1013 buf[0], buf[1],
1014 atype_name[(unsigned char)buf[3]], 1014 atype_name[(unsigned char)buf[3]],
@@ -376,7 +376,7 @@ static void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state) @@ -376,7 +376,7 @@ static void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state)
376 if(state == session->secure) 376 if(state == session->secure)
377 return; 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 session->update_ssl(session,session->secure = state); 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,7 +690,7 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
690 690
691 if(!rc) 691 if(!rc)
692 { 692 {
693 - trace_dsn("Connected.\n"); 693 + trace_dsn(session,"Connected.\n");
694 net_connected(session); 694 net_connected(session);
695 } 695 }
696 else 696 else
@@ -817,7 +817,7 @@ static void net_connected(H3270 *session) @@ -817,7 +817,7 @@ static void net_connected(H3270 *session)
817 if(session->proxy_type > 0) 817 if(session->proxy_type > 0)
818 { 818 {
819 /* Negotiate with the proxy. */ 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 if (proxy_negotiate(session->proxy_type, session->sock, session->hostname,session->current_port) < 0) 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,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 #if defined(HAVE_LIBSSL) /*[*/ 831 #if defined(HAVE_LIBSSL) /*[*/
832 /* Set up SSL. */ 832 /* Set up SSL. */
@@ -838,7 +838,7 @@ static void net_connected(H3270 *session) @@ -838,7 +838,7 @@ static void net_connected(H3270 *session)
838 838
839 if (SSL_set_fd(session->ssl_con, session->sock) != 1) 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 popup_system_error(session,_( "Connection failed" ), _( "Can't set SSL socket file descriptor" ), "%s", SSL_state_string_long(session->ssl_con)); 842 popup_system_error(session,_( "Connection failed" ), _( "Can't set SSL socket file descriptor" ), "%s", SSL_state_string_long(session->ssl_con));
843 set_ssl_state(session,LIB3270_SSL_UNSECURE); 843 set_ssl_state(session,LIB3270_SSL_UNSECURE);
844 } 844 }
@@ -851,7 +851,7 @@ static void net_connected(H3270 *session) @@ -851,7 +851,7 @@ static void net_connected(H3270 *session)
851 unsigned long e = ERR_get_error(); 851 unsigned long e = ERR_get_error();
852 const char * state = SSL_state_string_long(session->ssl_con); 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 host_disconnect(session,True); 856 host_disconnect(session,True);
857 857
@@ -866,7 +866,7 @@ static void net_connected(H3270 *session) @@ -866,7 +866,7 @@ static void net_connected(H3270 *session)
866 } 866 }
867 867
868 // session->secure_connection = True; 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 /* Tell everyone else again. */ 871 /* Tell everyone else again. */
872 lib3270_set_connected(session); 872 lib3270_set_connected(session);
@@ -976,7 +976,7 @@ void net_disconnect(H3270 *session) @@ -976,7 +976,7 @@ void net_disconnect(H3270 *session)
976 976
977 session->disconnect(session); 977 session->disconnect(session);
978 978
979 - trace_dsn("SENT disconnect\n"); 979 + trace_dsn(session,"SENT disconnect\n");
980 980
981 /* Restore terminal type to its default. */ 981 /* Restore terminal type to its default. */
982 if (session->termname == CN) 982 if (session->termname == CN)
@@ -1015,7 +1015,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned @@ -1015,7 +1015,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned
1015 1015
1016 if (hSession->ansi_data) 1016 if (hSession->ansi_data)
1017 { 1017 {
1018 - trace_dsn("\n"); 1018 + trace_dsn(hSession,"\n");
1019 hSession->ansi_data = 0; 1019 hSession->ansi_data = 0;
1020 } 1020 }
1021 #endif // X3270_ANSI 1021 #endif // X3270_ANSI
@@ -1077,7 +1077,7 @@ void net_input(H3270 *session) @@ -1077,7 +1077,7 @@ void net_input(H3270 *session)
1077 else 1077 else
1078 strcpy(err_buf, _( "unknown error" ) ); 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 session->message( session,LIB3270_NOTIFY_ERROR,_( "SSL Error" ),_( "SSL Read error" ),err_buf ); 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,7 +1092,7 @@ void net_input(H3270 *session)
1092 return; 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 if (HALF_CONNECTED) 1097 if (HALF_CONNECTED)
1098 { 1098 {
@@ -1108,7 +1108,7 @@ void net_input(H3270 *session) @@ -1108,7 +1108,7 @@ void net_input(H3270 *session)
1108 } else if (nr == 0) 1108 } else if (nr == 0)
1109 { 1109 {
1110 /* Host disconnected. */ 1110 /* Host disconnected. */
1111 - trace_dsn("RCVD disconnect\n"); 1111 + trace_dsn(session,"RCVD disconnect\n");
1112 host_disconnect(session,False); 1112 host_disconnect(session,False);
1113 return; 1113 return;
1114 } 1114 }
@@ -1149,7 +1149,7 @@ void net_input(H3270 *session) @@ -1149,7 +1149,7 @@ void net_input(H3270 *session)
1149 1149
1150 if (session->ansi_data) 1150 if (session->ansi_data)
1151 { 1151 {
1152 - trace_dsn("\n"); 1152 + trace_dsn(session,"\n");
1153 session->ansi_data = 0; 1153 session->ansi_data = 0;
1154 } 1154 }
1155 #endif // X3270_ANSI 1155 #endif // X3270_ANSI
@@ -1196,7 +1196,7 @@ static void send_naws(H3270 *hSession) @@ -1196,7 +1196,7 @@ static void send_naws(H3270 *hSession)
1196 (void) sprintf(naws_msg + naws_len, "%c%c", IAC, SE); 1196 (void) sprintf(naws_msg + naws_len, "%c%c", IAC, SE);
1197 naws_len += 2; 1197 naws_len += 2;
1198 net_rawout(hSession,(unsigned char *)naws_msg, naws_len); 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,7 +1227,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1227 session->telnet_state = TNS_IAC; 1227 session->telnet_state = TNS_IAC;
1228 #if defined(X3270_ANSI) /*[*/ 1228 #if defined(X3270_ANSI) /*[*/
1229 if (session->ansi_data) { 1229 if (session->ansi_data) {
1230 - trace_dsn("\n"); 1230 + trace_dsn(session,"\n");
1231 session->ansi_data = 0; 1231 session->ansi_data = 0;
1232 } 1232 }
1233 #endif /*]*/ 1233 #endif /*]*/
@@ -1246,16 +1246,16 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1246,16 +1246,16 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1246 if (IN_ANSI && !IN_E) { 1246 if (IN_ANSI && !IN_E) {
1247 #if defined(X3270_ANSI) /*[*/ 1247 #if defined(X3270_ANSI) /*[*/
1248 if (!session->ansi_data) { 1248 if (!session->ansi_data) {
1249 - trace_dsn("<.. "); 1249 + trace_dsn(session,"<.. ");
1250 session->ansi_data = 4; 1250 session->ansi_data = 4;
1251 } 1251 }
1252 see_chr = ctl_see((int) c); 1252 see_chr = ctl_see((int) c);
1253 session->ansi_data += (sl = strlen(see_chr)); 1253 session->ansi_data += (sl = strlen(see_chr));
1254 if (session->ansi_data >= TRACELINE) { 1254 if (session->ansi_data >= TRACELINE) {
1255 - trace_dsn(" ...\n... "); 1255 + trace_dsn(session," ...\n... ");
1256 session->ansi_data = 4 + sl; 1256 session->ansi_data = 4 + sl;
1257 } 1257 }
1258 - trace_dsn("%s",see_chr); 1258 + trace_dsn(session,"%s",see_chr);
1259 if (!session->syncing) 1259 if (!session->syncing)
1260 { 1260 {
1261 if (session->linemode && session->onlcr && c == '\n') 1261 if (session->linemode && session->onlcr && c == '\n')
@@ -1271,7 +1271,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1271,7 +1271,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1271 case TNS_IAC: /* process a telnet command */ 1271 case TNS_IAC: /* process a telnet command */
1272 if (c != EOR && c != IAC) 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 switch (c) 1277 switch (c)
@@ -1282,16 +1282,17 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1282,16 +1282,17 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1282 #if defined(X3270_ANSI) /*[*/ 1282 #if defined(X3270_ANSI) /*[*/
1283 if (!session->ansi_data) 1283 if (!session->ansi_data)
1284 { 1284 {
1285 - trace_dsn("<.. "); 1285 + trace_dsn(session,"<.. ");
1286 session->ansi_data = 4; 1286 session->ansi_data = 4;
1287 } 1287 }
1288 see_chr = ctl_see((int) c); 1288 see_chr = ctl_see((int) c);
1289 session->ansi_data += (sl = strlen(see_chr)); 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 session->ansi_data = 4 + sl; 1293 session->ansi_data = 4 + sl;
1293 } 1294 }
1294 - trace_dsn("%s",see_chr); 1295 + trace_dsn(session,"%s",see_chr);
1295 ansi_process((unsigned int) c); 1296 ansi_process((unsigned int) c);
1296 #endif /*]*/ 1297 #endif /*]*/
1297 } 1298 }
@@ -1312,7 +1313,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1312,7 +1313,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1312 } else 1313 } else
1313 Warning(session, _( "EOR received when not in 3270 mode, ignored." )); 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 session->ibptr = session->ibuf; 1317 session->ibptr = session->ibuf;
1317 session->telnet_state = TNS_DATA; 1318 session->telnet_state = TNS_DATA;
1318 break; 1319 break;
@@ -1341,7 +1342,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1341,7 +1342,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1341 break; 1342 break;
1342 1343
1343 case DM: 1344 case DM:
1344 - trace_dsn("\n"); 1345 + trace_dsn(session,"\n");
1345 if (session->syncing) 1346 if (session->syncing)
1346 { 1347 {
1347 session->syncing = 0; 1348 session->syncing = 0;
@@ -1352,18 +1353,18 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1352,18 +1353,18 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1352 1353
1353 case GA: 1354 case GA:
1354 case NOP: 1355 case NOP:
1355 - trace_dsn("\n"); 1356 + trace_dsn(session,"\n");
1356 session->telnet_state = TNS_DATA; 1357 session->telnet_state = TNS_DATA;
1357 break; 1358 break;
1358 1359
1359 default: 1360 default:
1360 - trace_dsn("???\n"); 1361 + trace_dsn(session,"???\n");
1361 session->telnet_state = TNS_DATA; 1362 session->telnet_state = TNS_DATA;
1362 break; 1363 break;
1363 } 1364 }
1364 break; 1365 break;
1365 case TNS_WILL: /* telnet WILL DO OPTION command */ 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 switch (c) { 1368 switch (c) {
1368 case TELOPT_SGA: 1369 case TELOPT_SGA:
1369 case TELOPT_BINARY: 1370 case TELOPT_BINARY:
@@ -1378,7 +1379,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1378,7 +1379,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1378 session->hisopts[c] = 1; 1379 session->hisopts[c] = 1;
1379 do_opt[2] = c; 1380 do_opt[2] = c;
1380 net_rawout(session,do_opt, sizeof(do_opt)); 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 cmd(DO), opt(c)); 1383 cmd(DO), opt(c));
1383 1384
1384 /* 1385 /*
@@ -1389,7 +1390,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1389,7 +1390,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1389 session->myopts[c] = 1; 1390 session->myopts[c] = 1;
1390 will_opt[2] = c; 1391 will_opt[2] = c;
1391 net_rawout(session,will_opt,sizeof(will_opt)); 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 check_in3270(session); 1396 check_in3270(session);
@@ -1400,19 +1401,19 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1400,19 +1401,19 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1400 default: 1401 default:
1401 dont_opt[2] = c; 1402 dont_opt[2] = c;
1402 net_rawout(session,dont_opt, sizeof(dont_opt)); 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 break; 1405 break;
1405 } 1406 }
1406 session->telnet_state = TNS_DATA; 1407 session->telnet_state = TNS_DATA;
1407 break; 1408 break;
1408 case TNS_WONT: /* telnet WONT DO OPTION command */ 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 if (session->hisopts[c]) 1411 if (session->hisopts[c])
1411 { 1412 {
1412 session->hisopts[c] = 0; 1413 session->hisopts[c] = 0;
1413 dont_opt[2] = c; 1414 dont_opt[2] = c;
1414 net_rawout(session, dont_opt, sizeof(dont_opt)); 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 check_in3270(session); 1417 check_in3270(session);
1417 check_linemode(session,False); 1418 check_linemode(session,False);
1418 } 1419 }
@@ -1420,7 +1421,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1420,7 +1421,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1420 session->telnet_state = TNS_DATA; 1421 session->telnet_state = TNS_DATA;
1421 break; 1422 break;
1422 case TNS_DO: /* telnet PLEASE DO OPTION command */ 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 switch (c) { 1425 switch (c) {
1425 case TELOPT_BINARY: 1426 case TELOPT_BINARY:
1426 case TELOPT_EOR: 1427 case TELOPT_EOR:
@@ -1446,7 +1447,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1446,7 +1447,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1446 session->myopts[c] = 1; 1447 session->myopts[c] = 1;
1447 will_opt[2] = c; 1448 will_opt[2] = c;
1448 net_rawout(session, will_opt, sizeof(will_opt)); 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 check_in3270(session); 1451 check_in3270(session);
1451 check_linemode(session,False); 1452 check_linemode(session,False);
1452 } 1453 }
@@ -1464,7 +1465,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1464,7 +1465,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1464 * to announce that what follows is TLS. 1465 * to announce that what follows is TLS.
1465 */ 1466 */
1466 net_rawout(session, follows_msg, sizeof(follows_msg)); 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 cmd(SB), 1469 cmd(SB),
1469 opt(TELOPT_STARTTLS), 1470 opt(TELOPT_STARTTLS),
1470 cmd(SE)); 1471 cmd(SE));
@@ -1476,18 +1477,18 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1476,18 +1477,18 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1476 wont: 1477 wont:
1477 wont_opt[2] = c; 1478 wont_opt[2] = c;
1478 net_rawout(session, wont_opt, sizeof(wont_opt)); 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 break; 1481 break;
1481 } 1482 }
1482 session->telnet_state = TNS_DATA; 1483 session->telnet_state = TNS_DATA;
1483 break; 1484 break;
1484 case TNS_DONT: /* telnet PLEASE DON'T DO OPTION command */ 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 if (session->myopts[c]) { 1487 if (session->myopts[c]) {
1487 session->myopts[c] = 0; 1488 session->myopts[c] = 0;
1488 wont_opt[2] = c; 1489 wont_opt[2] = c;
1489 net_rawout(session, wont_opt, sizeof(wont_opt)); 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 check_in3270(session); 1492 check_in3270(session);
1492 check_linemode(session,False); 1493 check_linemode(session,False);
1493 } 1494 }
@@ -1508,7 +1509,7 @@ static int telnet_fsm(H3270 *session, unsigned char c) @@ -1508,7 +1509,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1508 int tt_len, tb_len; 1509 int tt_len, tb_len;
1509 char *tt_out; 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 if (session->lus != (char **)NULL && session->try_lu == CN) 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,7 +1539,7 @@ static int telnet_fsm(H3270 *session, unsigned char c)
1538 IAC, SE); 1539 IAC, SE);
1539 net_rawout(session, (unsigned char *)tt_out, tb_len); 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 cmd(SB), opt(TELOPT_TTYPE), 1543 cmd(SB), opt(TELOPT_TTYPE),
1543 telquals[TELQUAL_IS], 1544 telquals[TELQUAL_IS],
1544 tt_len, tt_out + 4, 1545 tt_len, tt_out + 4,
@@ -1600,7 +1601,7 @@ static void tn3270e_request(H3270 *hSession) @@ -1600,7 +1601,7 @@ static void tn3270e_request(H3270 *hSession)
1600 1601
1601 net_rawout(hSession, (unsigned char *)tt_out, tb_len); 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 cmd(SB), opt(TELOPT_TN3270E), (int) strlen(hSession->termtype), tt_out + 5, 1605 cmd(SB), opt(TELOPT_TN3270E), (int) strlen(hSession->termtype), tt_out + 5,
1605 (hSession->try_lu != CN && *hSession->try_lu) ? " CONNECT " : "", 1606 (hSession->try_lu != CN && *hSession->try_lu) ? " CONNECT " : "",
1606 (hSession->try_lu != CN && *hSession->try_lu) ? hSession->try_lu : "", 1607 (hSession->try_lu != CN && *hSession->try_lu) ? hSession->try_lu : "",
@@ -1614,12 +1615,12 @@ static void tn3270e_request(H3270 *hSession) @@ -1614,12 +1615,12 @@ static void tn3270e_request(H3270 *hSession)
1614 */ 1615 */
1615 static void backoff_tn3270e(H3270 *hSession, const char *why) 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 /* Tell the host 'no'. */ 1620 /* Tell the host 'no'. */
1620 wont_opt[2] = TELOPT_TN3270E; 1621 wont_opt[2] = TELOPT_TN3270E;
1621 net_rawout(hSession, wont_opt, sizeof(wont_opt)); 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 /* Restore the LU list; we may need to run it again in TN3270 mode. */ 1625 /* Restore the LU list; we may need to run it again in TN3270 mode. */
1625 setup_lus(hSession); 1626 setup_lus(hSession);
@@ -1648,7 +1649,7 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1648,7 +1649,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1648 break; 1649 break;
1649 } 1650 }
1650 1651
1651 - trace_dsn("TN3270E "); 1652 + trace_dsn(hSession,"TN3270E ");
1652 1653
1653 switch (hSession->sbbuf[1]) { 1654 switch (hSession->sbbuf[1]) {
1654 1655
@@ -1657,18 +1658,18 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1657,18 +1658,18 @@ static int tn3270e_negotiate(H3270 *hSession)
1657 if (hSession->sbbuf[2] == TN3270E_OP_DEVICE_TYPE) { 1658 if (hSession->sbbuf[2] == TN3270E_OP_DEVICE_TYPE) {
1658 1659
1659 /* Host wants us to send our device type. */ 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 tn3270e_request(hSession); 1663 tn3270e_request(hSession);
1663 } else { 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 break; 1667 break;
1667 1668
1668 case TN3270E_OP_DEVICE_TYPE: 1669 case TN3270E_OP_DEVICE_TYPE:
1669 1670
1670 /* Device type negotiation. */ 1671 /* Device type negotiation. */
1671 - trace_dsn("DEVICE-TYPE "); 1672 + trace_dsn(hSession,"DEVICE-TYPE ");
1672 1673
1673 switch (hSession->sbbuf[2]) { 1674 switch (hSession->sbbuf[2]) {
1674 case TN3270E_OP_IS: { 1675 case TN3270E_OP_IS: {
@@ -1686,7 +1687,7 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1686,7 +1687,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1686 while(hSession->sbbuf[3+tnlen+1+snlen] != SE) 1687 while(hSession->sbbuf[3+tnlen+1+snlen] != SE)
1687 snlen++; 1688 snlen++;
1688 } 1689 }
1689 - trace_dsn("IS %.*s CONNECT %.*s SE\n", 1690 + trace_dsn(hSession,"IS %.*s CONNECT %.*s SE\n",
1690 tnlen, &hSession->sbbuf[3], 1691 tnlen, &hSession->sbbuf[3],
1691 snlen, &hSession->sbbuf[3+tnlen+1]); 1692 snlen, &hSession->sbbuf[3+tnlen+1]);
1692 1693
@@ -1715,7 +1716,7 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1715,7 +1716,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1715 1716
1716 /* Device type failure. */ 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 if (hSession->sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE || 1720 if (hSession->sbbuf[4] == TN3270E_REASON_INV_DEVICE_TYPE ||
1720 hSession->sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) { 1721 hSession->sbbuf[4] == TN3270E_REASON_UNSUPPORTED_REQ) {
1721 backoff_tn3270e(hSession,_( "Host rejected device type or request type" )); 1722 backoff_tn3270e(hSession,_( "Host rejected device type or request type" ));
@@ -1740,7 +1741,7 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1740,7 +1741,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1740 1741
1741 break; 1742 break;
1742 default: 1743 default:
1743 - trace_dsn("??%u SE\n", hSession->sbbuf[2]); 1744 + trace_dsn(hSession,"??%u SE\n", hSession->sbbuf[2]);
1744 break; 1745 break;
1745 } 1746 }
1746 break; 1747 break;
@@ -1748,15 +1749,14 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1748,15 +1749,14 @@ static int tn3270e_negotiate(H3270 *hSession)
1748 case TN3270E_OP_FUNCTIONS: 1749 case TN3270E_OP_FUNCTIONS:
1749 1750
1750 /* Functions negotiation. */ 1751 /* Functions negotiation. */
1751 - trace_dsn("FUNCTIONS "); 1752 + trace_dsn(hSession,"FUNCTIONS ");
1752 1753
1753 switch (hSession->sbbuf[2]) { 1754 switch (hSession->sbbuf[2]) {
1754 1755
1755 case TN3270E_OP_REQUEST: 1756 case TN3270E_OP_REQUEST:
1756 1757
1757 /* Host is telling us what functions they want. */ 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 e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3); 1761 e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3);
1762 if ((e_rcvd == hSession->e_funcs) || (hSession->e_funcs & ~e_rcvd)) { 1762 if ((e_rcvd == hSession->e_funcs) || (hSession->e_funcs & ~e_rcvd)) {
@@ -1764,7 +1764,7 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1764,7 +1764,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1764 hSession->e_funcs = e_rcvd; 1764 hSession->e_funcs = e_rcvd;
1765 tn3270e_subneg_send(hSession, TN3270E_OP_IS, hSession->e_funcs); 1765 tn3270e_subneg_send(hSession, TN3270E_OP_IS, hSession->e_funcs);
1766 hSession->tn3270e_negotiated = 1; 1766 hSession->tn3270e_negotiated = 1;
1767 - trace_dsn("TN3270E option negotiation complete.\n"); 1767 + trace_dsn(hSession,"TN3270E option negotiation complete.\n");
1768 check_in3270(hSession); 1768 check_in3270(hSession);
1769 } else { 1769 } else {
1770 /* 1770 /*
@@ -1779,7 +1779,7 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1779,7 +1779,7 @@ static int tn3270e_negotiate(H3270 *hSession)
1779 case TN3270E_OP_IS: 1779 case TN3270E_OP_IS:
1780 1780
1781 /* They accept our last request, or a subset thereof. */ 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 e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3); 1783 e_rcvd = tn3270e_fdecode(hSession->sbbuf+3, sblen-3);
1784 if (e_rcvd != hSession->e_funcs) { 1784 if (e_rcvd != hSession->e_funcs) {
1785 if (hSession->e_funcs & ~e_rcvd) { 1785 if (hSession->e_funcs & ~e_rcvd) {
@@ -1799,18 +1799,18 @@ static int tn3270e_negotiate(H3270 *hSession) @@ -1799,18 +1799,18 @@ static int tn3270e_negotiate(H3270 *hSession)
1799 } 1799 }
1800 } 1800 }
1801 hSession->tn3270e_negotiated = 1; 1801 hSession->tn3270e_negotiated = 1;
1802 - trace_dsn("TN3270E option negotiation complete.\n"); 1802 + trace_dsn(hSession,"TN3270E option negotiation complete.\n");
1803 check_in3270(hSession); 1803 check_in3270(hSession);
1804 break; 1804 break;
1805 1805
1806 default: 1806 default:
1807 - trace_dsn("??%u SE\n", hSession->sbbuf[2]); 1807 + trace_dsn(hSession,"??%u SE\n", hSession->sbbuf[2]);
1808 break; 1808 break;
1809 } 1809 }
1810 break; 1810 break;
1811 1811
1812 default: 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 /* Good enough for now. */ 1816 /* Good enough for now. */
@@ -1877,7 +1877,7 @@ static void tn3270e_subneg_send(H3270 *hSession, unsigned char op, unsigned long @@ -1877,7 +1877,7 @@ static void tn3270e_subneg_send(H3270 *hSession, unsigned char op, unsigned long
1877 net_rawout(hSession, proto_buf, proto_len); 1877 net_rawout(hSession, proto_buf, proto_len);
1878 1878
1879 /* Complete and send out the trace text. */ 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 cmd(SB), opt(TELOPT_TN3270E), 1881 cmd(SB), opt(TELOPT_TN3270E),
1882 (op == TN3270E_OP_REQUEST)? "REQUEST": "IS", 1882 (op == TN3270E_OP_REQUEST)? "REQUEST": "IS",
1883 tn3270e_function_names(proto_buf + 5, proto_len - 7), 1883 tn3270e_function_names(proto_buf + 5, proto_len - 7),
@@ -1938,7 +1938,7 @@ process_eor(H3270 *hSession) @@ -1938,7 +1938,7 @@ process_eor(H3270 *hSession)
1938 unsigned char *s; 1938 unsigned char *s;
1939 enum pds rv; 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 e_dt(h->data_type), 1942 e_dt(h->data_type),
1943 e_rq(h->data_type, h->request_flag), 1943 e_rq(h->data_type, h->request_flag),
1944 e_rsp(h->data_type, h->response_flag), 1944 e_rsp(h->data_type, h->response_flag),
@@ -1966,7 +1966,7 @@ process_eor(H3270 *hSession) @@ -1966,7 +1966,7 @@ process_eor(H3270 *hSession)
1966 if (!(hSession->e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) 1966 if (!(hSession->e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE)))
1967 return 0; 1967 return 0;
1968 process_bind(hSession, hSession->ibuf + EH_SIZE, (hSession->ibptr - hSession->ibuf) - EH_SIZE); 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 hSession->tn3270e_bound = 1; 1970 hSession->tn3270e_bound = 1;
1971 check_in3270(hSession); 1971 check_in3270(hSession);
1972 return 0; 1972 return 0;
@@ -2014,7 +2014,7 @@ void net_exception(H3270 *session) @@ -2014,7 +2014,7 @@ void net_exception(H3270 *session)
2014 { 2014 {
2015 CHECK_SESSION_HANDLE(session); 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 if (!session->syncing) 2018 if (!session->syncing)
2019 { 2019 {
2020 session->syncing = 1; 2020 session->syncing = 1;
@@ -2069,13 +2069,13 @@ LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf @@ -2069,13 +2069,13 @@ LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf
2069 2069
2070 e = ERR_get_error(); 2070 e = ERR_get_error();
2071 (void) ERR_error_string(e, err_buf); 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 popup_an_error(hSession,_( "SSL_write:\n%s" ), err_buf); 2073 popup_an_error(hSession,_( "SSL_write:\n%s" ), err_buf);
2074 return -1; 2074 return -1;
2075 } 2075 }
2076 #endif // HAVE_LIBSSL 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 switch(socket_errno()) 2080 switch(socket_errno())
2081 { 2081 {
@@ -2146,10 +2146,10 @@ net_cookedout(H3270 *hSession, const char *buf, int len) @@ -2146,10 +2146,10 @@ net_cookedout(H3270 *hSession, const char *buf, int len)
2146 { 2146 {
2147 int i; 2147 int i;
2148 2148
2149 - trace_dsn(">"); 2149 + trace_dsn(hSession,">");
2150 for (i = 0; i < len; i++) 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 #endif 2154 #endif
2155 net_rawout(hSession,(unsigned const char *) buf, len); 2155 net_rawout(hSession,(unsigned const char *) buf, len);
@@ -2535,7 +2535,7 @@ check_in3270(H3270 *session) @@ -2535,7 +2535,7 @@ check_in3270(H3270 *session)
2535 session->tn3270e_bound = 0; 2535 session->tn3270e_bound = 0;
2536 } 2536 }
2537 #endif /*]*/ 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 host_in3270(session,new_cstate); 2539 host_in3270(session,new_cstate);
2540 } 2540 }
2541 } 2541 }
@@ -2617,7 +2617,7 @@ static void check_linemode(H3270 *hSession, Boolean init) @@ -2617,7 +2617,7 @@ static void check_linemode(H3270 *hSession, Boolean init)
2617 lib3270_st_changed(hSession,LIB3270_STATE_LINE_MODE, hSession->linemode); 2617 lib3270_st_changed(hSession,LIB3270_STATE_LINE_MODE, hSession->linemode);
2618 if (!init) 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 #if defined(X3270_ANSI) /*[*/ 2622 #if defined(X3270_ANSI) /*[*/
2623 if (IN_ANSI && hSession->linemode) 2623 if (IN_ANSI && hSession->linemode)
@@ -2690,18 +2690,17 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in @@ -2690,18 +2690,17 @@ void trace_netdata(H3270 *hSession, char direction, unsigned const char *buf, in
2690 { 2690 {
2691 tdiff = ((1.0e6 * (double)(ts.tv_sec - h3270.ds_ts.tv_sec)) + 2691 tdiff = ((1.0e6 * (double)(ts.tv_sec - h3270.ds_ts.tv_sec)) +
2692 (double)(ts.tv_usec - h3270.ds_ts.tv_usec)) / 1.0e6; 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 hSession->ds_ts = ts; 2696 hSession->ds_ts = ts;
2697 for (offset = 0; offset < len; offset++) 2697 for (offset = 0; offset < len; offset++)
2698 { 2698 {
2699 if (!(offset % LINEDUMP_MAX)) 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 #endif // X3270_TRACE 2705 #endif // X3270_TRACE
2707 2706
@@ -2750,7 +2749,7 @@ void net_output(H3270 *hSession) @@ -2750,7 +2749,7 @@ void net_output(H3270 *hSession)
2750 h->seq_number[0] = (hSession->e_xmit_seq >> 8) & 0xff; 2749 h->seq_number[0] = (hSession->e_xmit_seq >> 8) & 0xff;
2751 h->seq_number[1] = hSession->e_xmit_seq & 0xff; 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 if (hSession->e_funcs & E_OPT(TN3270E_FUNC_RESPONSES)) 2753 if (hSession->e_funcs & E_OPT(TN3270E_FUNC_RESPONSES))
2755 hSession->e_xmit_seq = (hSession->e_xmit_seq + 1) & 0x7fff; 2754 hSession->e_xmit_seq = (hSession->e_xmit_seq + 1) & 0x7fff;
2756 } 2755 }
@@ -2784,7 +2783,7 @@ void net_output(H3270 *hSession) @@ -2784,7 +2783,7 @@ void net_output(H3270 *hSession)
2784 *xoptr++ = EOR; 2783 *xoptr++ = EOR;
2785 net_rawout(hSession,xobuf, xoptr - xobuf); 2784 net_rawout(hSession,xobuf, xoptr - xobuf);
2786 2785
2787 - trace_dsn("SENT EOR\n"); 2786 + trace_dsn(hSession,"SENT EOR\n");
2788 hSession->ns_rsent++; 2787 hSession->ns_rsent++;
2789 #undef BSTART 2788 #undef BSTART
2790 } 2789 }
@@ -2814,8 +2813,7 @@ static void tn3270e_ack(H3270 *hSession) @@ -2814,8 +2813,7 @@ static void tn3270e_ack(H3270 *hSession)
2814 rsp_buf[rsp_len++] = TN3270E_POS_DEVICE_END; 2813 rsp_buf[rsp_len++] = TN3270E_POS_DEVICE_END;
2815 rsp_buf[rsp_len++] = IAC; 2814 rsp_buf[rsp_len++] = IAC;
2816 rsp_buf[rsp_len++] = EOR; 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 net_rawout(hSession, rsp_buf, rsp_len); 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,7 +2847,7 @@ static void tn3270e_nak(H3270 *hSession, enum pds rv)
2849 } 2847 }
2850 rsp_buf[rsp_len++] = IAC; 2848 rsp_buf[rsp_len++] = IAC;
2851 rsp_buf[rsp_len++] = EOR; 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 net_rawout(hSession, rsp_buf, rsp_len); 2851 net_rawout(hSession, rsp_buf, rsp_len);
2854 } 2852 }
2855 2853
@@ -2982,12 +2980,12 @@ net_linemode(void) @@ -2982,12 +2980,12 @@ net_linemode(void)
2982 if (hisopts[TELOPT_ECHO]) { 2980 if (hisopts[TELOPT_ECHO]) {
2983 dont_opt[2] = TELOPT_ECHO; 2981 dont_opt[2] = TELOPT_ECHO;
2984 net_rawout(dont_opt, sizeof(dont_opt)); 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 if (hisopts[TELOPT_SGA]) { 2985 if (hisopts[TELOPT_SGA]) {
2988 dont_opt[2] = TELOPT_SGA; 2986 dont_opt[2] = TELOPT_SGA;
2989 net_rawout(dont_opt, sizeof(dont_opt)); 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,12 +2998,12 @@ net_charmode(void)
3000 if (!hisopts[TELOPT_ECHO]) { 2998 if (!hisopts[TELOPT_ECHO]) {
3001 do_opt[2] = TELOPT_ECHO; 2999 do_opt[2] = TELOPT_ECHO;
3002 net_rawout(do_opt, sizeof(do_opt)); 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 if (!hisopts[TELOPT_SGA]) { 3003 if (!hisopts[TELOPT_SGA]) {
3006 do_opt[2] = TELOPT_SGA; 3004 do_opt[2] = TELOPT_SGA;
3007 net_rawout(do_opt, sizeof(do_opt)); 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 #endif /*]*/ 3009 #endif /*]*/
@@ -3023,7 +3021,7 @@ net_break(void) @@ -3023,7 +3021,7 @@ net_break(void)
3023 3021
3024 /* I don't know if we should first send TELNET synch ? */ 3022 /* I don't know if we should first send TELNET synch ? */
3025 net_rawout(&h3270, buf, sizeof(buf)); 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,7 +3036,7 @@ net_interrupt(void)
3038 3036
3039 /* I don't know if we should first send TELNET synch ? */ 3037 /* I don't know if we should first send TELNET synch ? */
3040 net_rawout(&h3270, buf, sizeof(buf)); 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,7 +3063,7 @@ net_abort(void)
3065 break; 3063 break;
3066 case E_SSCP: 3064 case E_SSCP:
3067 net_rawout(&h3270, buf, sizeof(buf)); 3065 net_rawout(&h3270, buf, sizeof(buf));
3068 - trace_dsn("SENT AO\n"); 3066 + trace_dsn(&h3270,"SENT AO\n");
3069 if (h3270.tn3270e_bound || 3067 if (h3270.tn3270e_bound ||
3070 !(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) { 3068 !(h3270.e_funcs & E_OPT(TN3270E_FUNC_BIND_IMAGE))) {
3071 h3270.tn3270e_submode = E_3270; 3069 h3270.tn3270e_submode = E_3270;
@@ -3074,7 +3072,7 @@ net_abort(void) @@ -3074,7 +3072,7 @@ net_abort(void)
3074 break; 3072 break;
3075 case E_3270: 3073 case E_3270:
3076 net_rawout(&h3270, buf, sizeof(buf)); 3074 net_rawout(&h3270, buf, sizeof(buf));
3077 - trace_dsn("SENT AO\n"); 3075 + trace_dsn(&h3270,"SENT AO\n");
3078 h3270.tn3270e_submode = E_SSCP; 3076 h3270.tn3270e_submode = E_SSCP;
3079 check_in3270(&h3270); 3077 check_in3270(&h3270);
3080 break; 3078 break;
@@ -3349,16 +3347,16 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret) @@ -3349,16 +3347,16 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3349 switch(where) 3347 switch(where)
3350 { 3348 {
3351 case SSL_CB_CONNECT_LOOP: 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 break; 3351 break;
3354 3352
3355 case SSL_CB_CONNECT_EXIT: 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 if (ret == 0) 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 else if (ret < 0) 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,7 +3389,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3391 err_buf[0] = '\0'; 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 show_3270_popup_dialog( hSession, // H3270 *session, 3394 show_3270_popup_dialog( hSession, // H3270 *session,
3397 PW3270_DIALOG_CRITICAL, // PW3270_DIALOG type, 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,7 +3404,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3406 3404
3407 3405
3408 default: 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 // trace("%s: state=%04x where=%04x ret=%d",__FUNCTION__,SSL_state(s),where,ret); 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,11 +3417,11 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret)
3419 #endif 3417 #endif
3420 3418
3421 if(where & SSL_CB_ALERT) 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 if(where & SSL_CB_HANDSHAKE_DONE) 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 if(SSL_state(s) == 0x03) 3425 if(SSL_state(s) == 0x03)
3428 set_ssl_state(hSession,LIB3270_SSL_SECURE); 3426 set_ssl_state(hSession,LIB3270_SSL_SECURE);
3429 else 3427 else
@@ -3442,14 +3440,14 @@ static void continue_tls(unsigned char *sbbuf, int len) @@ -3442,14 +3440,14 @@ static void continue_tls(unsigned char *sbbuf, int len)
3442 /* Make sure the option is FOLLOWS. */ 3440 /* Make sure the option is FOLLOWS. */
3443 if (len < 2 || sbbuf[1] != TLS_FOLLOWS) { 3441 if (len < 2 || sbbuf[1] != TLS_FOLLOWS) {
3444 /* Trace the junk. */ 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 popup_an_error(NULL,"TLS negotiation failure"); 3444 popup_an_error(NULL,"TLS negotiation failure");
3447 net_disconnect(&h3270); 3445 net_disconnect(&h3270);
3448 return; 3446 return;
3449 } 3447 }
3450 3448
3451 /* Trace what we got. */ 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 /* Initialize the SSL library. */ 3452 /* Initialize the SSL library. */
3455 ssl_init(&h3270); 3453 ssl_init(&h3270);
@@ -3463,7 +3461,7 @@ static void continue_tls(unsigned char *sbbuf, int len) @@ -3463,7 +3461,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3463 /* Set up the TLS/SSL connection. */ 3461 /* Set up the TLS/SSL connection. */
3464 if(SSL_set_fd(h3270.ssl_con, h3270.sock) != 1) 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 //#if defined(_WIN32) 3467 //#if defined(_WIN32)
@@ -3481,7 +3479,7 @@ static void continue_tls(unsigned char *sbbuf, int len) @@ -3481,7 +3479,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3481 3479
3482 if (rv != 1) 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 net_disconnect(&h3270); 3483 net_disconnect(&h3270);
3486 return; 3484 return;
3487 } 3485 }
@@ -3489,7 +3487,7 @@ static void continue_tls(unsigned char *sbbuf, int len) @@ -3489,7 +3487,7 @@ static void continue_tls(unsigned char *sbbuf, int len)
3489 // h3270.secure_connection = True; 3487 // h3270.secure_connection = True;
3490 3488
3491 /* Success. */ 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 /* Tell the world that we are (still) connected, now in secure mode. */ 3492 /* Tell the world that we are (still) connected, now in secure mode. */
3495 lib3270_set_connected(&h3270); 3493 lib3270_set_connected(&h3270);
@@ -108,7 +108,7 @@ @@ -108,7 +108,7 @@
108 // static off_t tracef_midpoint = 0; 108 // static off_t tracef_midpoint = 0;
109 109
110 static void __vwtrace(H3270 *session, const char *fmt, va_list args); 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 // static char *create_tracefile_header(const char *mode); 112 // static char *create_tracefile_header(const char *mode);
113 // static void stop_tracing(void); 113 // static void stop_tracing(void);
114 114
@@ -116,7 +116,7 @@ static void wtrace(const char *fmt, ...); @@ -116,7 +116,7 @@ static void wtrace(const char *fmt, ...);
116 // struct timeval ds_ts; 116 // struct timeval ds_ts;
117 117
118 static void (*vwtrace)(H3270 *session, const char *fmt, va_list args) = __vwtrace; 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 LIB3270_EXPORT void lib3270_set_trace_handler( void (*handler)(H3270 *session, const char *fmt, va_list args) ) 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,38 +137,46 @@ const char * rcba(H3270 *hSession, int baddr)
137 // static char *tdsbuf = CN; 137 // static char *tdsbuf = CN;
138 // #define TDS_LEN 75 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 static int dscnt = 0; 142 static int dscnt = 0;
144 int len = strlen(s); 143 int len = strlen(s);
145 Boolean nl = False; 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 return; 147 return;
149 148
150 - if (s && s[len-1] == '\n') { 149 + if (s && s[len-1] == '\n')
  150 + {
151 len--; 151 len--;
152 nl = True; 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 dscnt = 0; 158 dscnt = 0;
157 } 159 }
158 - while (dscnt + len >= 75) { 160 +
  161 + while (dscnt + len >= 75)
  162 + {
159 int plen = 75-dscnt; 163 int plen = 75-dscnt;
160 164
161 - wtrace("%.*s ...\n... ", plen, s); 165 + wtrace(hSession,"%.*s ...\n... ", plen, s);
162 dscnt = 4; 166 dscnt = 4;
163 s += plen; 167 s += plen;
164 len -= plen; 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 dscnt += len; 174 dscnt += len;
169 } 175 }
170 - if (nl) {  
171 - wtrace("\n"); 176 +
  177 + if (nl)
  178 + {
  179 + wtrace(hSession,"\n");
172 dscnt = 0; 180 dscnt = 0;
173 } 181 }
174 } 182 }
@@ -185,25 +193,25 @@ void trace_ds(H3270 *hSession, const char *fmt, ...) @@ -185,25 +193,25 @@ void trace_ds(H3270 *hSession, const char *fmt, ...)
185 193
186 /* print out remainder of message */ 194 /* print out remainder of message */
187 text = lib3270_vsprintf(fmt,args); 195 text = lib3270_vsprintf(fmt,args);
188 - trace_ds_s(text, True); 196 + trace_ds_s(hSession,text, True);
189 va_end(args); 197 va_end(args);
190 lib3270_free(text); 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 va_list args; 204 va_list args;
197 205
198 - if (!lib3270_get_toggle(&h3270,DS_TRACE)) 206 + if (!lib3270_get_toggle(hSession,DS_TRACE))
199 return; 207 return;
200 208
201 va_start(args, fmt); 209 va_start(args, fmt);
202 210
203 /* print out remainder of message */ 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 /* Conditional event trace. */ /* 217 /* Conditional event trace. */ /*
@@ -222,16 +230,16 @@ void trace_event(const char *fmt, ...) @@ -222,16 +230,16 @@ void trace_event(const char *fmt, ...)
222 */ 230 */
223 231
224 /* Conditional data stream trace, without line splitting. */ 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 va_list args; 235 va_list args;
228 236
229 - if (!lib3270_get_toggle(&h3270,DS_TRACE)) 237 + if (!lib3270_get_toggle(hSession,DS_TRACE))
230 return; 238 return;
231 239
232 /* print out message */ 240 /* print out message */
233 va_start(args, fmt); 241 va_start(args, fmt);
234 - vwtrace(&h3270,fmt, args); 242 + vwtrace(hSession,fmt, args);
235 va_end(args); 243 va_end(args);
236 } 244 }
237 245
@@ -247,11 +255,11 @@ static void __vwtrace(H3270 *session, const char *fmt, va_list args) @@ -247,11 +255,11 @@ static void __vwtrace(H3270 *session, const char *fmt, va_list args)
247 } 255 }
248 256
249 /* Write to the trace file. */ 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 va_list args; 260 va_list args;
253 va_start(args, fmt); 261 va_start(args, fmt);
254 - vwtrace(&h3270,fmt, args); 262 + vwtrace(hSession,fmt, args);
255 va_end(args); 263 va_end(args);
256 } 264 }
257 265
@@ -286,7 +294,7 @@ LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...) @@ -286,7 +294,7 @@ LIB3270_EXPORT void lib3270_trace_event(H3270 *session, const char *fmt, ...)
286 */ 294 */
287 void trace_screen(H3270 *session) 295 void trace_screen(H3270 *session)
288 { 296 {
289 - trace_skipping = False; 297 + session->trace_skipping = 0;
290 298
291 if (lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE)) 299 if (lib3270_get_toggle(session,LIB3270_TOGGLE_SCREEN_TRACE))
292 { 300 {
@@ -295,47 +303,51 @@ void trace_screen(H3270 *session) @@ -295,47 +303,51 @@ void trace_screen(H3270 *session)
295 for(row=baddr=0;row < session->rows;row++) 303 for(row=baddr=0;row < session->rows;row++)
296 { 304 {
297 int col; 305 int col;
298 - wtrace("%02d ",row+1); 306 + wtrace(session,"%02d ",row+1);
299 307
300 for(col = 0; col < session->cols;col++) 308 for(col = 0; col < session->cols;col++)
301 { 309 {
302 if(session->text[baddr].attr & LIB3270_ATTR_CG) 310 if(session->text[baddr].attr & LIB3270_ATTR_CG)
303 - wtrace("%c",'.'); 311 + wtrace(session,"%c",'.');
304 else if(session->text[baddr].chr) 312 else if(session->text[baddr].chr)
305 - wtrace("%c",session->text[baddr].chr); 313 + wtrace(session,"%c",session->text[baddr].chr);
306 else 314 else
307 - wtrace("%c",'.'); 315 + wtrace(session,"%c",'.');
308 baddr++; 316 baddr++;
309 } 317 }
310 - wtrace("%s\n",""); 318 + wtrace(session,"%s\n","");
311 } 319 }
312 } 320 }
313 } 321 }
314 322
315 /* Called from ANSI emulation code to log a single character. */ 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 return; 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 * and keep the next screen clear from re-recording the screen image. 335 * and keep the next screen clear from re-recording the screen image.
326 * (In a gross violation of data hiding and modularity, trace_skipping is 336 * (In a gross violation of data hiding and modularity, trace_skipping is
327 * manipulated directly in ctlr_clear()). 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 int i; 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
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
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(H3270 *session, int baddr); 39 const char *rcba(H3270 *session, int baddr);
40 40
@@ -42,11 +42,11 @@ @@ -42,11 +42,11 @@
42 // void toggle_eventTrace(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); 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 void trace_ds(H3270 *hSession, const char *fmt, ...) printflike(2, 3); 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 // void trace_event(const char *fmt, ...) printflike(1, 2); 50 // void trace_event(const char *fmt, ...) printflike(1, 2);
51 void trace_screen(H3270 *session); 51 void trace_screen(H3270 *session);
52 // void trace_rollover_check(void); 52 // void trace_rollover_check(void);
@@ -55,10 +55,10 @@ @@ -55,10 +55,10 @@
55 55
56 #elif defined(__GNUC__) 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 #else 63 #else
64 64