diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-23 20:26:43 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-23 20:26:43 (GMT) |
| commit | eb922c8eb52aaaaf9ac4f63fd1f0a0789907c277 (patch) | |
| tree | dfd06a05f08b68807caab6788a30b1ff48aa9840 /generic/tclIO.c | |
| parent | 01bcdd015088be3e7a9ea7d76a012c34473b354b (diff) | |
| download | tcl-eb922c8eb52aaaaf9ac4f63fd1f0a0789907c277.zip tcl-eb922c8eb52aaaaf9ac4f63fd1f0a0789907c277.tar.gz tcl-eb922c8eb52aaaaf9ac4f63fd1f0a0789907c277.tar.bz2 | |
Add "chan isbinary" for checking whether a _channel_ is binary.
Diffstat (limited to 'generic/tclIO.c')
| -rw-r--r-- | generic/tclIO.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 75a9025..2df5da5 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -7537,6 +7537,34 @@ CheckChannelErrors( /* *---------------------------------------------------------------------- * + * TclChanIsBinary -- + * + * Returns 1 if the channel is a binary channel, 0 otherwise. + * + * Results: + * 1 or 0, always. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TclChanIsBinary( + Tcl_Channel chan) /* Does this channel have EOF? */ +{ + ChannelState *statePtr = ((Channel *) chan)->state; + /* State of real channel structure. */ + + return ((statePtr->encoding == GetBinaryEncoding()) && !statePtr->inEofChar + && (!GotFlag(statePtr, TCL_READABLE) || (statePtr->inputTranslation == TCL_TRANSLATE_LF)) + && (!GotFlag(statePtr, TCL_WRITABLE) || (statePtr->outputTranslation == TCL_TRANSLATE_LF))); +} + +/* + *---------------------------------------------------------------------- + * * Tcl_Eof -- * * Returns 1 if the channel is at EOF, 0 otherwise. |
