Debian Codegraph @

doc/ChnlStack.3

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