diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-31 14:58:07 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-01-31 14:58:07 (GMT) |
commit | bfad7e731e065f729b1b29430eadc5599fed2221 (patch) | |
tree | e70de8a0b599ae989b87e4991c3da262f6ea1d33 /unix | |
parent | ff4989d1928248d02e222c2590088c0a5dbb6f46 (diff) | |
download | tcl-bfad7e731e065f729b1b29430eadc5599fed2221.zip tcl-bfad7e731e065f729b1b29430eadc5599fed2221.tar.gz tcl-bfad7e731e065f729b1b29430eadc5599fed2221.tar.bz2 |
Make Tcl_ChannelCloseProc() deprecated too. Implement close2Proc and wideSeekProc for all internal channel types.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixChan.c | 27 | ||||
-rw-r--r-- | unix/tclUnixSock.c | 4 |
2 files changed, 22 insertions, 9 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 56a0276..e1b7223 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -121,7 +121,7 @@ typedef struct { static int FileBlockModeProc(ClientData instanceData, int mode); static int FileCloseProc(ClientData instanceData, - Tcl_Interp *interp); + Tcl_Interp *interp, int flags); static int FileGetHandleProc(ClientData instanceData, int direction, ClientData *handlePtr); static int FileInputProc(ClientData instanceData, char *buf, @@ -139,7 +139,7 @@ static Tcl_WideInt FileWideSeekProc(ClientData instanceData, static void FileWatchProc(ClientData instanceData, int mask); #ifdef SUPPORTS_TTY static int TtyCloseProc(ClientData instanceData, - Tcl_Interp *interp); + Tcl_Interp *interp, int flags); static void TtyGetAttributes(int fd, TtyAttrs *ttyPtr); static int TtyGetOptionProc(ClientData instanceData, Tcl_Interp *interp, const char *optionName, @@ -163,7 +163,7 @@ static int TtySetOptionProc(ClientData instanceData, static const Tcl_ChannelType fileChannelType = { "file", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ - FileCloseProc, /* Close proc. */ + TCL_CLOSE2PROC, /* Close proc. */ FileInputProc, /* Input proc. */ FileOutputProc, /* Output proc. */ #ifndef TCL_NO_DEPRECATED @@ -175,7 +175,7 @@ static const Tcl_ChannelType fileChannelType = { NULL, /* Get option proc. */ FileWatchProc, /* Initialize notifier. */ FileGetHandleProc, /* Get OS handles out of channel. */ - NULL, /* close2proc. */ + FileCloseProc, /* close2proc. */ FileBlockModeProc, /* Set blocking or non-blocking mode.*/ NULL, /* flush proc. */ NULL, /* handler proc. */ @@ -193,7 +193,7 @@ static const Tcl_ChannelType fileChannelType = { static const Tcl_ChannelType ttyChannelType = { "tty", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ - TtyCloseProc, /* Close proc. */ + TCL_CLOSE2PROC, /* Close proc. */ FileInputProc, /* Input proc. */ FileOutputProc, /* Output proc. */ NULL, /* Seek proc. */ @@ -201,7 +201,7 @@ static const Tcl_ChannelType ttyChannelType = { TtyGetOptionProc, /* Get option proc. */ FileWatchProc, /* Initialize notifier. */ FileGetHandleProc, /* Get OS handles out of channel. */ - NULL, /* close2proc. */ + TtyCloseProc, /* close2proc. */ FileBlockModeProc, /* Set blocking or non-blocking mode.*/ NULL, /* flush proc. */ NULL, /* handler proc. */ @@ -359,11 +359,16 @@ FileOutputProc( static int FileCloseProc( ClientData instanceData, /* File state. */ - Tcl_Interp *interp) /* For error reporting - unused. */ + Tcl_Interp *dummy, /* For error reporting - unused. */ + int flags) { FileState *fsPtr = instanceData; int errorCode = 0; + if ((flags & (TCL_CLOSE_READ | TCL_CLOSE_WRITE)) != 0) { + return EINVAL; + } + Tcl_DeleteFileHandler(fsPtr->fd); /* @@ -384,10 +389,14 @@ FileCloseProc( static int TtyCloseProc( ClientData instanceData, - Tcl_Interp *interp) + Tcl_Interp *interp, + int flags) { TtyState *ttyPtr = instanceData; + if ((flags & (TCL_CLOSE_READ | TCL_CLOSE_WRITE)) != 0) { + return EINVAL; + } /* * If we've been asked by the user to drain or flush, do so now. */ @@ -416,7 +425,7 @@ TtyCloseProc( * Delegate to close for files. */ - return FileCloseProc(instanceData, interp); + return FileCloseProc(instanceData, interp, flags); } #endif /* SUPPORTS_TTY */ diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 57735da..e9c552e 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -157,7 +157,11 @@ static void WrapNotify(ClientData clientData, int mask); static const Tcl_ChannelType tcpChannelType = { "tcp", /* Type name. */ TCL_CHANNEL_VERSION_5, /* v5 channel */ +#ifndef TCL_NO_DEPRECATED TcpCloseProc, /* Close proc. */ +#else + TCL_CLOSE2PROC, /* Close proc. */ +#endif TcpInputProc, /* Input proc. */ TcpOutputProc, /* Output proc. */ NULL, /* Seek proc. */ |