[25] | 1 | '\" |
---|
| 2 | '\" Copyright (c) 1999-2000 Ajuba Solutions. |
---|
| 3 | '\" |
---|
| 4 | '\" See the file "license.terms" for information on usage and redistribution |
---|
| 5 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 6 | '\" |
---|
| 7 | '\" RCS: @(#) $Id: ChnlStack.3,v 1.8 2006/11/15 09:23:01 dkf Exp $ |
---|
| 8 | .so man.macros |
---|
| 9 | .TH Tcl_StackChannel 3 8.3 Tcl "Tcl Library Procedures" |
---|
| 10 | .BS |
---|
| 11 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
| 12 | .SH NAME |
---|
| 13 | Tcl_StackChannel, Tcl_UnstackChannel, Tcl_GetStackedChannel, Tcl_GetTopChannel \- manipulate stacked I/O channels |
---|
| 14 | .SH SYNOPSIS |
---|
| 15 | .nf |
---|
| 16 | .nf |
---|
| 17 | \fB#include <tcl.h>\fR |
---|
| 18 | .sp |
---|
| 19 | Tcl_Channel |
---|
| 20 | \fBTcl_StackChannel\fR(\fIinterp, typePtr, clientData, mask, channel\fR) |
---|
| 21 | .sp |
---|
| 22 | int |
---|
| 23 | \fBTcl_UnstackChannel\fR(\fIinterp, channel\fR) |
---|
| 24 | .sp |
---|
| 25 | Tcl_Channel |
---|
| 26 | \fBTcl_GetStackedChannel\fR(\fIchannel\fR) |
---|
| 27 | .sp |
---|
| 28 | Tcl_Channel |
---|
| 29 | \fBTcl_GetTopChannel\fR(\fIchannel\fR) |
---|
| 30 | .sp |
---|
| 31 | .SH ARGUMENTS |
---|
| 32 | .AS Tcl_ChannelType clientData |
---|
| 33 | .AP Tcl_Interp *interp in |
---|
| 34 | Interpreter for error reporting. |
---|
| 35 | .AP Tcl_ChannelType *typePtr in |
---|
| 36 | The new channel I/O procedures to use for \fIchannel\fR. |
---|
| 37 | .AP ClientData clientData in |
---|
| 38 | Arbitrary one-word value to pass to channel I/O procedures. |
---|
| 39 | .AP int mask in |
---|
| 40 | Conditions under which \fIchannel\fR will be used: OR-ed combination of |
---|
| 41 | \fBTCL_READABLE\fR, \fBTCL_WRITABLE\fR and \fBTCL_EXCEPTION\fR. |
---|
| 42 | This can be a subset of the operations currently allowed on \fIchannel\fR. |
---|
| 43 | .AP Tcl_Channel channel in |
---|
| 44 | An existing Tcl channel such as returned by \fBTcl_CreateChannel\fR. |
---|
| 45 | .BE |
---|
| 46 | |
---|
| 47 | .SH DESCRIPTION |
---|
| 48 | .PP |
---|
| 49 | These functions are for use by extensions that add processing layers to Tcl |
---|
| 50 | I/O channels. Examples include compression and encryption modules. These |
---|
| 51 | functions transparently stack and unstack a new channel on top of an |
---|
| 52 | existing one. Any number of channels can be stacked together. |
---|
| 53 | .PP |
---|
| 54 | The implementation of the Tcl channel code was rewritten in 8.3.2 to |
---|
| 55 | correct some problems with the previous implementation with regard to |
---|
| 56 | stacked channels. Anyone using stacked channels or creating stacked |
---|
| 57 | channel drivers should update to the new \fBTCL_CHANNEL_VERSION_2\fR |
---|
| 58 | \fBTcl_ChannelType\fR structure. See \fBTcl_CreateChannel\fR for details. |
---|
| 59 | .PP |
---|
| 60 | \fBTcl_StackChannel\fR stacks a new \fIchannel\fR on an existing channel |
---|
| 61 | with the same name that was registered for \fIchannel\fR by |
---|
| 62 | \fBTcl_RegisterChannel\fR. |
---|
| 63 | .PP |
---|
| 64 | \fBTcl_StackChannel\fR works by creating a new channel structure and |
---|
| 65 | placing itself on top of the channel stack. EOL translation, encoding and |
---|
| 66 | buffering options are shared between all channels in the stack. The hidden |
---|
| 67 | channel does no buffering, newline translations, or character set encoding. |
---|
| 68 | Instead, the buffering, newline translations, and encoding functions all |
---|
| 69 | remain at the top of the channel stack. A pointer to the new top channel |
---|
| 70 | structure is returned. If an error occurs when stacking the channel, NULL |
---|
| 71 | is returned instead. |
---|
| 72 | .PP |
---|
| 73 | The \fImask\fR parameter specifies the operations that are allowed on the |
---|
| 74 | new channel. These can be a subset of the operations allowed on the |
---|
| 75 | original channel. For example, a read-write channel may become read-only |
---|
| 76 | after the \fBTcl_StackChannel\fR call. |
---|
| 77 | .PP |
---|
| 78 | Closing a channel closes the channels stacked below it. The close of |
---|
| 79 | stacked channels is executed in a way that allows buffered data to be |
---|
| 80 | properly flushed. |
---|
| 81 | .PP |
---|
| 82 | \fBTcl_UnstackChannel\fR reverses the process. The old channel is |
---|
| 83 | associated with the channel name, and the processing module added by |
---|
| 84 | \fBTcl_StackChannel\fR is destroyed. If there is no old channel, then |
---|
| 85 | \fBTcl_UnstackChannel\fR is equivalent to \fBTcl_Close\fR. If an error |
---|
| 86 | occurs unstacking the channel, \fBTCL_ERROR\fR is returned, otherwise |
---|
| 87 | \fBTCL_OK\fR is returned. |
---|
| 88 | .PP |
---|
| 89 | \fBTcl_GetTopChannel\fR returns the top channel in the stack of |
---|
| 90 | channels the supplied channel is part of. |
---|
| 91 | .PP |
---|
| 92 | \fBTcl_GetStackedChannel\fR returns the channel in the stack of |
---|
| 93 | channels which is just below the supplied channel. |
---|
| 94 | |
---|
| 95 | .SH "SEE ALSO" |
---|
| 96 | Notifier(3), Tcl_CreateChannel(3), Tcl_OpenFileChannel(3), vwait(n). |
---|
| 97 | |
---|
| 98 | .SH KEYWORDS |
---|
| 99 | channel, compression |
---|