Index: tests/oldTests/tlsHttp.tcl ================================================================== --- tests/oldTests/tlsHttp.tcl +++ tests/oldTests/tlsHttp.tcl @@ -10,11 +10,11 @@ # # Initialize context # #tls::init -certfile client.pem -cafile server.pem -ssl2 1 -ssl3 1 -tls1 0 ;#-cipher RC4-MD5 -tls::init -cafile server.pem +tls::init -cafile server.pem # # Register with http module # http::register https 443 [list ::tls::socket -require 1] Index: tls.c ================================================================== --- tls.c +++ tls.c @@ -921,11 +921,11 @@ Tcl_GetChannelOption(interp, chan, "-translation", &upperChannelTranslation); Tcl_GetChannelOption(interp, chan, "-blocking", &upperChannelBlocking); Tcl_SetChannelOption(interp, chan, "-translation", "binary"); Tcl_SetChannelOption(interp, chan, "-blocking", "true"); dprintf("Consuming Tcl channel %s", Tcl_GetChannelName(chan)); - statePtr->self = Tcl_StackChannel(interp, Tls_ChannelType(), (ClientData) statePtr, (TCL_READABLE | TCL_WRITABLE), chan); + statePtr->self = Tcl_StackChannel(interp, Tls_ChannelType(), statePtr, (TCL_READABLE | TCL_WRITABLE), chan); dprintf("Created channel named %s", Tcl_GetChannelName(statePtr->self)); if (statePtr->self == (Tcl_Channel) NULL) { /* * No use of Tcl_EventuallyFree because no possible Tcl_Preserve. */ Index: tlsIO.c ================================================================== --- tlsIO.c +++ tlsIO.c @@ -28,19 +28,32 @@ static int TlsOutputProc (ClientData instanceData, const char *buf, int toWrite, int *errorCodePtr); static int TlsGetOptionProc (ClientData instanceData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); static void TlsWatchProc (ClientData instanceData, int mask); static int TlsGetHandleProc (ClientData instanceData, int direction, ClientData *handlePtr); static int TlsNotifyProc (ClientData instanceData, int mask); -#if 0 -static void TlsChannelHandler (ClientData clientData, int mask); -#endif static void TlsChannelHandlerTimer (ClientData clientData); /* * TLS Channel Type */ -static Tcl_ChannelType *tlsChannelType = NULL; +static const Tcl_ChannelType tlsChannelType = { + "tls", /* typeName */ + TCL_CHANNEL_VERSION_5, /* version */ + TlsCloseProc, /* closeProc */ + TlsInputProc, /* inputProc */ + TlsOutputProc, /* outputProc */ + 0, /* seekProc */ + 0, /* setOptionProc */ + TlsGetOptionProc, /* getOptionProc */ + TlsWatchProc, /* watchProc */ + TlsGetHandleProc, /* getHandleProc */ + NULL, /* close2Proc */ + TlsBlockModeProc, /* blockModeProc */ + 0, /* flushProc */ + TlsNotifyProc /* handlerProc */ +}; + /* *------------------------------------------------------------------- * * Tls_ChannelType -- @@ -53,67 +66,12 @@ * Side effects: * None. * *------------------------------------------------------------------- */ -Tcl_ChannelType *Tls_ChannelType(void) { - unsigned int size; - - /* - * Initialize the channel type if necessary - */ - if (tlsChannelType == NULL) { - /* - * Allocation of a new channeltype structure is not easy, because of - * the various verson of the core and subsequent changes to the - * structure. The main challenge is to allocate enough memory for - * modern versions even if this extsension is compiled against one - * of the older variant! - * - * (1) Versions before stubs (8.0.x) are simple, because they are - * supported only if the extension is compiled against exactly - * that version of the core. - * - * (2) With stubs we just determine the difference between the older - * and modern variant and overallocate accordingly if compiled - * against an older variant. - */ - size = sizeof(Tcl_ChannelType); /* Base size */ - - tlsChannelType = (Tcl_ChannelType *) ckalloc(size); - memset(tlsChannelType, 0, size); - - /* - * Common elements of the structure (no changes in location or name) - * close2Proc, seekProc, setOptionProc stay NULL. - */ - - tlsChannelType->typeName = "tls"; - tlsChannelType->closeProc = TlsCloseProc; - tlsChannelType->inputProc = TlsInputProc; - tlsChannelType->outputProc = TlsOutputProc; - tlsChannelType->getOptionProc = TlsGetOptionProc; - tlsChannelType->watchProc = TlsWatchProc; - tlsChannelType->getHandleProc = TlsGetHandleProc; - - /* - * Compiled against 8.3.2+. Direct access to all elements possible. Use - * channelTypeVersion information to select the values to use. - */ - - /* - * For the 8.3.2 core we present ourselves as a version 2 - * driver. This means a special value in version (ex - * blockModeProc), blockModeProc in a different place and of - * course usage of the handlerProc. - */ - tlsChannelType->version = TCL_CHANNEL_VERSION_5; - tlsChannelType->blockModeProc = TlsBlockModeProc; - tlsChannelType->handlerProc = TlsNotifyProc; - } - - return(tlsChannelType); +const Tcl_ChannelType *Tls_ChannelType(void) { + return &tlsChannelType; } /* *------------------------------------------------------------------- * Index: tlsInt.h ================================================================== --- tlsInt.h +++ tlsInt.h @@ -157,11 +157,11 @@ #endif /* USE_TCL_STUBS */ /* * Forward declarations */ -Tcl_ChannelType *Tls_ChannelType(void); +const Tcl_ChannelType *Tls_ChannelType(void); Tcl_Channel Tls_GetParent(State *statePtr, int maskFlags); Tcl_Obj *Tls_NewX509Obj(Tcl_Interp *interp, X509 *cert); void Tls_Error(State *statePtr, char *msg); void Tls_Free(char *blockPtr);