@@ -22,10 +22,11 @@ * */ #include "tlsInt.h" #include "tclOpts.h" +#include "tlsUuid.h" #include #include #include #include @@ -2771,16 +2772,93 @@ } dprintf("Returning"); } -#if TCL_MAJOR_VERSION > 8 -#define MIN_VERSION "9.0" -#else -#define MIN_VERSION "8.5" +/* + *---------------------------------------------------------------------- + * + * Build Info Command -- + * + * Create command to return build info for package. + * + * Results: + * A standard Tcl result + * + * Side effects: + * Created build-info command. + * + *---------------------------------------------------------------------- + */ + +#ifndef STRINGIFY +# define STRINGIFY(x) STRINGIFY1(x) +# define STRINGIFY1(x) #x +#endif + +int +BuildInfoCommand(Tcl_Interp* interp) { + Tcl_CmdInfo info; + + if (Tcl_GetCommandInfo(interp, "::tcl::build-info", &info)) { + Tcl_CreateObjCommand(interp, "::tls::build-info", info.objProc, (void *)( + PACKAGE_VERSION "+" STRINGIFY(TLS_VERSION_UUID) +#if defined(__clang__) && defined(__clang_major__) + ".clang-" STRINGIFY(__clang_major__) +#if __clang_minor__ < 10 + "0" +#endif + STRINGIFY(__clang_minor__) +#endif +#if defined(__cplusplus) && !defined(__OBJC__) + ".cplusplus" +#endif +#ifndef NDEBUG + ".debug" +#endif +#if !defined(__clang__) && !defined(__INTEL_COMPILER) && defined(__GNUC__) + ".gcc-" STRINGIFY(__GNUC__) +#if __GNUC_MINOR__ < 10 + "0" +#endif + STRINGIFY(__GNUC_MINOR__) +#endif +#ifdef __INTEL_COMPILER + ".icc-" STRINGIFY(__INTEL_COMPILER) +#endif +#ifdef TCL_MEM_DEBUG + ".memdebug" +#endif +#if defined(_MSC_VER) + ".msvc-" STRINGIFY(_MSC_VER) +#endif +#ifdef USE_NMAKE + ".nmake" +#endif +#ifndef TCL_CFG_OPTIMIZED + ".no-optimize" +#endif +#ifdef __OBJC__ + ".objective-c" +#if defined(__cplusplus) + "plusplus" +#endif +#endif +#ifdef TCL_CFG_PROFILED + ".profile" +#endif +#ifdef PURIFY + ".purify" +#endif +#ifdef STATIC_BUILD + ".static" #endif - + ), NULL); + } + return TCL_OK; +} + /* *------------------------------------------------------------------- * * Tls_Init -- * @@ -2792,15 +2870,23 @@ * Side effects: * create the ssl command, initialize ssl context * *------------------------------------------------------------------- */ -DLLEXPORT int Tls_Init(Tcl_Interp *interp) { - const char tlsTclInitScript[] = { + +#if TCL_MAJOR_VERSION > 8 +#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 if (Tcl_InitStubs(interp, MIN_VERSION, 0) == NULL) { @@ -2823,10 +2909,12 @@ Tcl_CreateObjCommand(interp, "::tls::unimport", UnimportObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::status", StatusObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::version", VersionObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::misc", MiscObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "::tls::protocols", ProtocolsObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + BuildInfoCommand(interp); if (interp && Tcl_Eval(interp, tlsTclInitScript) != TCL_OK) { return TCL_ERROR; }