summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclIO.c19
-rw-r--r--generic/tclIORChan.c30
2 files changed, 48 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 86ec27a..aabae0b 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -1548,6 +1548,25 @@ Tcl_CreateChannel(
*/
assert(sizeof(Tcl_ChannelTypeVersion) == sizeof(Tcl_DriverBlockModeProc *));
+ assert(typePtr->typeName != NULL);
+ if (NULL == typePtr->closeProc) {
+ Tcl_Panic("channel type %s must define closeProc", typePtr->typeName);
+ }
+ if ((TCL_READABLE & mask) && (NULL == typePtr->inputProc)) {
+ Tcl_Panic("channel type %s must define inputProc when used for reader channel", typePtr->typeName);
+ }
+ if ((TCL_WRITABLE & mask) && (NULL == typePtr->outputProc)) {
+ Tcl_Panic("channel type %s must define outputProc when used for writer channel", typePtr->typeName);
+ }
+ if (NULL == typePtr->watchProc) {
+ Tcl_Panic("channel type %s must define watchProc", typePtr->typeName);
+ }
+ if (NULL == typePtr->getHandleProc) {
+ Tcl_Panic("channel type %s must define getHandleProc", typePtr->typeName);
+ }
+ if ((NULL!=typePtr->wideSeekProc) && (NULL == typePtr->seekProc)) {
+ Tcl_Panic("channel type %s must define seekProc if defining wideSeekProc", typePtr->typeName);
+ }
/*
* JH: We could subsequently memset these to 0 to avoid the numerous
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 21c766e..0f7f021 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -30,6 +30,8 @@
/*
* Signatures of all functions used in the C layer of the reflection.
*/
+static int ReflectGetHandle( ClientData instanceData,
+ int direction, ClientData *handlePtr);
static int ReflectClose(ClientData clientData,
Tcl_Interp *interp);
@@ -68,7 +70,7 @@ static const Tcl_ChannelType tclRChannelType = {
ReflectSetOption, /* Set options. NULL'able */
ReflectGetOption, /* Get options. NULL'able */
ReflectWatch, /* Initialize notifier */
- NULL, /* Get OS handle from the channel. NULL'able */
+ ReflectGetHandle, /* Get OS handle from the channel. */
NULL, /* No close2 support. NULL'able */
ReflectBlock, /* Set blocking/nonblocking. NULL'able */
NULL, /* Flush channel. Not used by core. NULL'able */
@@ -1644,6 +1646,32 @@ ReflectWatch(
/*
*----------------------------------------------------------------------
*
+ * ReflectGetHandle --
+ *
+ * This function is invoked to return OS channel handles, or EINVAL
+ * if not applicable or otherwise invalid.
+ *
+ * Results:
+ * EINVAL.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+ReflectGetHandle(
+ ClientData instanceData,
+ int direction,
+ ClientData *handlePtr)
+{
+ return EINVAL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* ReflectBlock --
*
* This function is invoked to tell the channel which blocking behaviour