Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -322,15 +322,12 @@ VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win:$(srcdir)/macosx # Create a C-source-ified version of the script resources # for TclTLS so that we only need a single file to enable # this extension -tls.tcl.h: @srcdir@/library/tls.tcl Makefile - od -A n -v -t xC < '@srcdir@/library/tls.tcl' > tls.tcl.h.new.1 - sed 's@[^0-9A-Fa-f]@@g;s@..@0x&, @g' < tls.tcl.h.new.1 > tls.tcl.h.new.2 - rm -f tls.tcl.h.new.1 - mv tls.tcl.h.new.2 @srcdir@/generic/tls.tcl.h +tls.tcl.h: $(srcdir)/library/tls.tcl + sed -e '/^\\s*\#/d' -e '/^\\s*$$/d' -e 's/\\/\\\\/g' -e 's/\"/\\"/g' -e 's/^/"/' -e 's/$$/\\n\"/' < `@CYGPATH@ $<` > $@ || { rm -f $@; exit 1; } $(srcdir)/manifest.uuid: printf "git-" >$(srcdir)/manifest.uuid (cd $(srcdir); git rev-parse HEAD >>$(srcdir)/manifest.uuid || \ (printf "svn-r" >$(srcdir)/manifest.uuid ; \ Index: README.txt ================================================================== --- README.txt +++ README.txt @@ -60,10 +60,11 @@ --disable-tls1 disable TLS1 protocol --disable-tls1_1 disable TLS1.1 protocol --disable-tls1_2 disable TLS1.2 protocol --disable-tls1_3 disable TLS1.3 protocol + --enable-debug enable debugging mode and output more status --enable-ssl-fastpath enable using the underlying file descriptor for talking directly to the SSL library --enable-hardening enable hardening attempts --enable-static-ssl enable static linking to the SSL library If either TCL or OpenSSL are installed in non-standard locations, the following Index: acinclude.m4 ================================================================== --- acinclude.m4 +++ acinclude.m4 @@ -55,10 +55,24 @@ AC_MSG_CHECKING([for disable TLS1.3 protocol]) AC_MSG_RESULT([yes]) fi ]) + + dnl Determine if debugging mode should be enabled + AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], + [enable debugging mode and output more status]), [ + tcltls_debug_mode="$enableval" + ], [ + tcltls_debug_mode='no' + ]) + if test "$tcltls_debug_mode" == 'yes'; then + AC_DEFINE(TCLEXT_TCLTLS_DEBUG, [1], [Enable debugging mode]) + fi + AC_MSG_CHECKING([for debug mode]) + AC_MSG_RESULT([$tcltls_debug_mode]) + dnl Determine if we have been asked to use a fast path if possible AC_ARG_ENABLE([ssl-fastpath], AS_HELP_STRING([--enable-ssl-fastpath], [enable using the underlying file descriptor for talking directly to the SSL library]), [ tcltls_ssl_fastpath="$enableval" Index: configure ================================================================== --- configure +++ configure @@ -771,10 +771,11 @@ enable_ssl3 enable_tls1 enable_tls1_1 enable_tls1_2 enable_tls1_3 +enable_debug enable_ssl_fastpath enable_hardening enable_static_ssl with_openssl_dir with_openssl_includedir @@ -1422,10 +1423,11 @@ --disable-ssl3 disable SSL3 protocol --disable-tls1 disable TLS1 protocol --disable-tls1_1 disable TLS1.1 protocol --disable-tls1_2 disable TLS1.2 protocol --disable-tls1_3 disable TLS1.3 protocol + --enable-debug enable debugging mode and output more status --enable-ssl-fastpath enable using the underlying file descriptor for talking directly to the SSL library --enable-hardening enable hardening attempts --enable-static-ssl enable static linking to the SSL library @@ -9175,11 +9177,11 @@ # This marco includes the TCL TLS specific functions to set the # OpenSSL or LibreSSL config. #-------------------------------------------------------------------- - if test -n "$ac_tool_prefix"; then + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_PKG_CONFIG+y} @@ -9370,10 +9372,34 @@ fi fi + + # Check whether --enable-debug was given. +if test ${enable_debug+y} +then : + enableval=$enable_debug; + tcltls_debug_mode="$enableval" + +else case e in #( + e) + tcltls_debug_mode='no' + ;; +esac +fi + + if test "$tcltls_debug_mode" == 'yes'; then + +printf "%s\n" "#define TCLEXT_TCLTLS_DEBUG 1" >>confdefs.h + + fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for debug mode" >&5 +printf %s "checking for debug mode... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcltls_debug_mode" >&5 +printf "%s\n" "$tcltls_debug_mode" >&6; } + # Check whether --enable-ssl-fastpath was given. if test ${enable_ssl_fastpath+y} then : enableval=$enable_ssl_fastpath; Index: generic/tls.c ================================================================== --- generic/tls.c +++ generic/tls.c @@ -2722,10 +2722,15 @@ ), NULL); } return TCL_OK; } +/* Init script */ +static const char tlsTclInitScript[] = { +#include "tls.tcl.h" +}; + /* *------------------------------------------------------------------- * * Tls_Init -- * @@ -2744,15 +2749,10 @@ #define MIN_VERSION "9.0" #else #define MIN_VERSION "8.5" #endif -static const char tlsTclInitScript[] = { -#include "tls.tcl.h" - 0x00 - }; - DLLEXPORT int Tls_Init(Tcl_Interp *interp) { dprintf("Called"); #ifdef USE_TCL_STUBS Index: generic/tlsInt.h ================================================================== --- generic/tlsInt.h +++ generic/tlsInt.h @@ -49,21 +49,23 @@ /* * Backwards compatibility for size type change */ #if TCL_MAJOR_VERSION < 9 && TCL_MINOR_VERSION < 7 - #include - #define TCL_SIZE_MAX INT_MAX - - #ifndef Tcl_Size - typedef int Tcl_Size; - #endif - - #define TCL_SIZE_MODIFIER "" - #define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj - #define Tcl_NewSizeIntObj Tcl_NewIntObj - #define Tcl_NewSizeIntFromObj Tcl_NewWideIntObj +#include +#ifndef TCL_SIZE_MAX +#define TCL_SIZE_MAX INT_MAX +#endif + +#ifndef Tcl_Size + typedef int Tcl_Size; +#endif + +#define TCL_SIZE_MODIFIER "" +#define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj +#define Tcl_NewSizeIntObj Tcl_NewIntObj +#define Tcl_NewSizeIntFromObj Tcl_NewWideIntObj #endif /* Define missing POSIX error codes */ #ifndef ECONNABORTED #define ECONNABORTED 130 /* Software caused connection abort */ Index: win/README.txt ================================================================== --- win/README.txt +++ win/README.txt @@ -67,18 +67,11 @@ set INSTALLDIR=%TCLINSTALL%\lib set SSLINSTALL=\path\to\openssl\dir 2a) Unzip distribution to %BUILDDIR% -2b) Start BASH shell (MinGW62 Git shell) - - cd %BUILDDIR% - od -A n -v -t xC < 'library/tls.tcl' > tls.tcl.h.new.1 - sed 's@[^0-9A-Fa-f]@@g;s@..@0x&, @g' < tls.tcl.h.new.1 > generic/tls.tcl.h - rm -f tls.tcl.h.new.1 - -2c) Start Visual Studio shell +2b) Start Visual Studio shell At Visual Studio x64 native prompt: cd %BUILDDIR%\win Index: win/makefile.vc ================================================================== --- win/makefile.vc +++ win/makefile.vc @@ -72,14 +72,28 @@ clean: default-clean realclean: default-hose +# Explicit dependency rules +$(PRJ_OBJS): $(TMP_DIR)\tls.tcl.h $(TMP_DIR)\tlsUuid.h + # We must define a pkgindex target that will create a pkgIndex.tcl # file in the $(OUT_DIR) directory. We can just redirect to the # default-pkgindex target for our sample extension. pkgindex: default-pkgindex-tea + +$(TMP_DIR)\tls.tcl.h: $(LIBDIR)\tls.tcl + "$(TCLSH)" << $(LIBDIR)\tls.tcl >$(TMP_DIR)\tls.tcl.h + set in [open [lindex $$argv 0] r] + while {[gets $$in line] != -1} { + switch -regexp -- $$line "^$$" - {^\s*#} continue + regsub -all {\\} $$line {\\\\} line + regsub -all {"} $$line {\"} line + puts "\"$$line\\n\"" + } +<< # Manifest which defines fossil/git commit id for build-info command $(ROOT)\manifest.uuid: if not exist $(ROOT)\manifest.uuid ( copy $(WIN_DIR)\gitmanifest.in $(ROOT)\manifest.uuid @@ -106,10 +120,7 @@ ) if exist "$(SSL_INSTALL_FOLDER)\bin\libssl-*-x64.dll" ( xcopy /c /y "$(SSL_INSTALL_FOLDER)\bin\libssl-*-x64.dll" "$(PRJ_INSTALL_DIR)" ) -# Explicit dependency rules -$(GENERICDIR)\tls.c: $(TMP_DIR)\tlsUuid.h - # Test package test: default-test