0000: 27 5c 22 0a 27 5c 22 20 43 6f 70 79 72 69 67 68 '\".'\" Copyrigh
0010: 74 20 28 63 29 20 31 39 39 36 2d 31 39 39 37 20 t (c) 1996-1997
0020: 53 75 6e 20 4d 69 63 72 6f 73 79 73 74 65 6d 73 Sun Microsystems
0030: 2c 20 49 6e 63 2e 0a 27 5c 22 20 43 6f 70 79 72 , Inc..'\" Copyr
0040: 69 67 68 74 20 28 63 29 20 31 39 39 37 2d 32 30 ight (c) 1997-20
0050: 30 30 20 41 6a 75 62 61 20 53 6f 6c 75 74 69 6f 00 Ajuba Solutio
0060: 6e 73 2e 0a 27 5c 22 0a 27 5c 22 20 53 65 65 20 ns..'\".'\" See
0070: 74 68 65 20 66 69 6c 65 20 22 6c 69 63 65 6e 73 the file "licens
0080: 65 2e 74 65 72 6d 73 22 20 66 6f 72 20 69 6e 66 e.terms" for inf
0090: 6f 72 6d 61 74 69 6f 6e 20 6f 6e 20 75 73 61 67 ormation on usag
00a0: 65 20 61 6e 64 20 72 65 64 69 73 74 72 69 62 75 e and redistribu
00b0: 74 69 6f 6e 0a 27 5c 22 20 6f 66 20 74 68 69 73 tion.'\" of this
00c0: 20 66 69 6c 65 2c 20 61 6e 64 20 66 6f 72 20 61 file, and for a
00d0: 20 44 49 53 43 4c 41 49 4d 45 52 20 4f 46 20 41 DISCLAIMER OF A
00e0: 4c 4c 20 57 41 52 52 41 4e 54 49 45 53 2e 0a 2e LL WARRANTIES...
00f0: 54 48 20 54 63 6c 5f 43 72 65 61 74 65 43 68 61 TH Tcl_CreateCha
0100: 6e 6e 65 6c 20 33 20 38 2e 34 20 54 63 6c 20 22 nnel 3 8.4 Tcl "
0110: 54 63 6c 20 4c 69 62 72 61 72 79 20 50 72 6f 63 Tcl Library Proc
0120: 65 64 75 72 65 73 22 0a 2e 73 6f 20 6d 61 6e 2e edures"..so man.
0130: 6d 61 63 72 6f 73 0a 2e 42 53 0a 27 5c 22 20 4e macros..BS.'\" N
0140: 6f 74 65 3a 20 20 64 6f 20 6e 6f 74 20 6d 6f 64 ote: do not mod
0150: 69 66 79 20 74 68 65 20 2e 53 48 20 4e 41 4d 45 ify the .SH NAME
0160: 20 6c 69 6e 65 20 69 6d 6d 65 64 69 61 74 65 6c line immediatel
0170: 79 20 62 65 6c 6f 77 21 0a 2e 53 48 20 4e 41 4d y below!..SH NAM
0180: 45 0a 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e E.Tcl_CreateChan
0190: 6e 65 6c 2c 20 54 63 6c 5f 47 65 74 43 68 61 6e nel, Tcl_GetChan
01a0: 6e 65 6c 49 6e 73 74 61 6e 63 65 44 61 74 61 2c nelInstanceData,
01b0: 20 54 63 6c 5f 47 65 74 43 68 61 6e 6e 65 6c 54 Tcl_GetChannelT
01c0: 79 70 65 2c 20 54 63 6c 5f 47 65 74 43 68 61 6e ype, Tcl_GetChan
01d0: 6e 65 6c 4e 61 6d 65 2c 20 54 63 6c 5f 47 65 74 nelName, Tcl_Get
01e0: 43 68 61 6e 6e 65 6c 48 61 6e 64 6c 65 2c 20 54 ChannelHandle, T
01f0: 63 6c 5f 47 65 74 43 68 61 6e 6e 65 6c 4d 6f 64 cl_GetChannelMod
0200: 65 2c 20 54 63 6c 5f 47 65 74 43 68 61 6e 6e 65 e, Tcl_GetChanne
0210: 6c 42 75 66 66 65 72 53 69 7a 65 2c 20 54 63 6c lBufferSize, Tcl
0220: 5f 53 65 74 43 68 61 6e 6e 65 6c 42 75 66 66 65 _SetChannelBuffe
0230: 72 53 69 7a 65 2c 20 54 63 6c 5f 4e 6f 74 69 66 rSize, Tcl_Notif
0240: 79 43 68 61 6e 6e 65 6c 2c 20 54 63 6c 5f 42 61 yChannel, Tcl_Ba
0250: 64 43 68 61 6e 6e 65 6c 4f 70 74 69 6f 6e 2c 20 dChannelOption,
0260: 54 63 6c 5f 43 68 61 6e 6e 65 6c 4e 61 6d 65 2c Tcl_ChannelName,
0270: 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 56 65 72 73 Tcl_ChannelVers
0280: 69 6f 6e 2c 20 54 63 6c 5f 43 68 61 6e 6e 65 6c ion, Tcl_Channel
0290: 42 6c 6f 63 6b 4d 6f 64 65 50 72 6f 63 2c 20 54 BlockModeProc, T
02a0: 63 6c 5f 43 68 61 6e 6e 65 6c 43 6c 6f 73 65 50 cl_ChannelCloseP
02b0: 72 6f 63 2c 20 54 63 6c 5f 43 68 61 6e 6e 65 6c roc, Tcl_Channel
02c0: 43 6c 6f 73 65 32 50 72 6f 63 2c 20 54 63 6c 5f Close2Proc, Tcl_
02d0: 43 68 61 6e 6e 65 6c 49 6e 70 75 74 50 72 6f 63 ChannelInputProc
02e0: 2c 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 4f 75 74 , Tcl_ChannelOut
02f0: 70 75 74 50 72 6f 63 2c 20 54 63 6c 5f 43 68 61 putProc, Tcl_Cha
0300: 6e 6e 65 6c 53 65 65 6b 50 72 6f 63 2c 20 54 63 nnelSeekProc, Tc
0310: 6c 5f 43 68 61 6e 6e 65 6c 57 69 64 65 53 65 65 l_ChannelWideSee
0320: 6b 50 72 6f 63 2c 20 54 63 6c 5f 43 68 61 6e 6e kProc, Tcl_Chann
0330: 65 6c 54 72 75 6e 63 61 74 65 50 72 6f 63 2c 20 elTruncateProc,
0340: 54 63 6c 5f 43 68 61 6e 6e 65 6c 53 65 74 4f 70 Tcl_ChannelSetOp
0350: 74 69 6f 6e 50 72 6f 63 2c 20 54 63 6c 5f 43 68 tionProc, Tcl_Ch
0360: 61 6e 6e 65 6c 47 65 74 4f 70 74 69 6f 6e 50 72 annelGetOptionPr
0370: 6f 63 2c 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 57 oc, Tcl_ChannelW
0380: 61 74 63 68 50 72 6f 63 2c 20 54 63 6c 5f 43 68 atchProc, Tcl_Ch
0390: 61 6e 6e 65 6c 47 65 74 48 61 6e 64 6c 65 50 72 annelGetHandlePr
03a0: 6f 63 2c 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 46 oc, Tcl_ChannelF
03b0: 6c 75 73 68 50 72 6f 63 2c 20 54 63 6c 5f 43 68 lushProc, Tcl_Ch
03c0: 61 6e 6e 65 6c 48 61 6e 64 6c 65 72 50 72 6f 63 annelHandlerProc
03d0: 2c 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 68 72 , Tcl_ChannelThr
03e0: 65 61 64 41 63 74 69 6f 6e 50 72 6f 63 2c 20 54 eadActionProc, T
03f0: 63 6c 5f 49 73 43 68 61 6e 6e 65 6c 53 68 61 72 cl_IsChannelShar
0400: 65 64 2c 20 54 63 6c 5f 49 73 43 68 61 6e 6e 65 ed, Tcl_IsChanne
0410: 6c 52 65 67 69 73 74 65 72 65 64 2c 20 54 63 6c lRegistered, Tcl
0420: 5f 43 75 74 43 68 61 6e 6e 65 6c 2c 20 54 63 6c _CutChannel, Tcl
0430: 5f 53 70 6c 69 63 65 43 68 61 6e 6e 65 6c 2c 20 _SpliceChannel,
0440: 54 63 6c 5f 49 73 43 68 61 6e 6e 65 6c 45 78 69 Tcl_IsChannelExi
0450: 73 74 69 6e 67 2c 20 54 63 6c 5f 43 6c 65 61 72 sting, Tcl_Clear
0460: 43 68 61 6e 6e 65 6c 48 61 6e 64 6c 65 72 73 2c ChannelHandlers,
0470: 20 54 63 6c 5f 47 65 74 43 68 61 6e 6e 65 6c 54 Tcl_GetChannelT
0480: 68 72 65 61 64 2c 20 54 63 6c 5f 43 68 61 6e 6e hread, Tcl_Chann
0490: 65 6c 42 75 66 66 65 72 65 64 20 5c 2d 20 70 72 elBuffered \- pr
04a0: 6f 63 65 64 75 72 65 73 20 66 6f 72 20 63 72 65 ocedures for cre
04b0: 61 74 69 6e 67 20 61 6e 64 20 6d 61 6e 69 70 75 ating and manipu
04c0: 6c 61 74 69 6e 67 20 63 68 61 6e 6e 65 6c 73 0a lating channels.
04d0: 2e 53 48 20 53 59 4e 4f 50 53 49 53 0a 2e 6e 66 .SH SYNOPSIS..nf
04e0: 0a 5c 66 42 23 69 6e 63 6c 75 64 65 20 3c 74 63 .\fB#include <tc
04f0: 6c 2e 68 3e 5c 66 52 0a 2e 73 70 0a 54 63 6c 5f l.h>\fR..sp.Tcl_
0500: 43 68 61 6e 6e 65 6c 0a 5c 66 42 54 63 6c 5f 43 Channel.\fBTcl_C
0510: 72 65 61 74 65 43 68 61 6e 6e 65 6c 5c 66 52 28 reateChannel\fR(
0520: 5c 66 49 74 79 70 65 50 74 72 2c 20 63 68 61 6e \fItypePtr, chan
0530: 6e 65 6c 4e 61 6d 65 2c 20 69 6e 73 74 61 6e 63 nelName, instanc
0540: 65 44 61 74 61 2c 20 6d 61 73 6b 5c 66 52 29 0a eData, mask\fR).
0550: 2e 73 70 0a 43 6c 69 65 6e 74 44 61 74 61 0a 5c .sp.ClientData.\
0560: 66 42 54 63 6c 5f 47 65 74 43 68 61 6e 6e 65 6c fBTcl_GetChannel
0570: 49 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 28 InstanceData\fR(
0580: 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 29 0a 2e \fIchannel\fR)..
0590: 73 70 0a 63 6f 6e 73 74 20 54 63 6c 5f 43 68 61 sp.const Tcl_Cha
05a0: 6e 6e 65 6c 54 79 70 65 20 2a 0a 5c 66 42 54 63 nnelType *.\fBTc
05b0: 6c 5f 47 65 74 43 68 61 6e 6e 65 6c 54 79 70 65 l_GetChannelType
05c0: 5c 66 52 28 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 \fR(\fIchannel\f
05d0: 52 29 0a 2e 73 70 0a 63 6f 6e 73 74 20 63 68 61 R)..sp.const cha
05e0: 72 20 2a 0a 5c 66 42 54 63 6c 5f 47 65 74 43 68 r *.\fBTcl_GetCh
05f0: 61 6e 6e 65 6c 4e 61 6d 65 5c 66 52 28 5c 66 49 annelName\fR(\fI
0600: 63 68 61 6e 6e 65 6c 5c 66 52 29 0a 2e 73 70 0a channel\fR)..sp.
0610: 69 6e 74 0a 5c 66 42 54 63 6c 5f 47 65 74 43 68 int.\fBTcl_GetCh
0620: 61 6e 6e 65 6c 48 61 6e 64 6c 65 5c 66 52 28 5c annelHandle\fR(\
0630: 66 49 63 68 61 6e 6e 65 6c 2c 20 64 69 72 65 63 fIchannel, direc
0640: 74 69 6f 6e 2c 20 68 61 6e 64 6c 65 50 74 72 5c tion, handlePtr\
0650: 66 52 29 0a 2e 73 70 0a 54 63 6c 5f 54 68 72 65 fR)..sp.Tcl_Thre
0660: 61 64 49 64 0a 5c 66 42 54 63 6c 5f 47 65 74 43 adId.\fBTcl_GetC
0670: 68 61 6e 6e 65 6c 54 68 72 65 61 64 5c 66 52 28 hannelThread\fR(
0680: 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 29 0a 2e \fIchannel\fR)..
0690: 73 70 0a 69 6e 74 0a 5c 66 42 54 63 6c 5f 47 65 sp.int.\fBTcl_Ge
06a0: 74 43 68 61 6e 6e 65 6c 4d 6f 64 65 5c 66 52 28 tChannelMode\fR(
06b0: 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 29 0a 2e \fIchannel\fR)..
06c0: 73 70 0a 69 6e 74 0a 5c 66 42 54 63 6c 5f 47 65 sp.int.\fBTcl_Ge
06d0: 74 43 68 61 6e 6e 65 6c 42 75 66 66 65 72 53 69 tChannelBufferSi
06e0: 7a 65 5c 66 52 28 5c 66 49 63 68 61 6e 6e 65 6c ze\fR(\fIchannel
06f0: 5c 66 52 29 0a 2e 73 70 0a 5c 66 42 54 63 6c 5f \fR)..sp.\fBTcl_
0700: 53 65 74 43 68 61 6e 6e 65 6c 42 75 66 66 65 72 SetChannelBuffer
0710: 53 69 7a 65 5c 66 52 28 5c 66 49 63 68 61 6e 6e Size\fR(\fIchann
0720: 65 6c 2c 20 73 69 7a 65 5c 66 52 29 0a 2e 73 70 el, size\fR)..sp
0730: 0a 5c 66 42 54 63 6c 5f 4e 6f 74 69 66 79 43 68 .\fBTcl_NotifyCh
0740: 61 6e 6e 65 6c 5c 66 52 28 5c 66 49 63 68 61 6e annel\fR(\fIchan
0750: 6e 65 6c 2c 20 6d 61 73 6b 5c 66 52 29 0a 2e 73 nel, mask\fR)..s
0760: 70 0a 69 6e 74 0a 5c 66 42 54 63 6c 5f 42 61 64 p.int.\fBTcl_Bad
0770: 43 68 61 6e 6e 65 6c 4f 70 74 69 6f 6e 5c 66 52 ChannelOption\fR
0780: 28 5c 66 49 69 6e 74 65 72 70 2c 20 6f 70 74 69 (\fIinterp, opti
0790: 6f 6e 4e 61 6d 65 2c 20 6f 70 74 69 6f 6e 4c 69 onName, optionLi
07a0: 73 74 5c 66 52 29 0a 2e 73 70 0a 69 6e 74 0a 5c st\fR)..sp.int.\
07b0: 66 42 54 63 6c 5f 49 73 43 68 61 6e 6e 65 6c 53 fBTcl_IsChannelS
07c0: 68 61 72 65 64 5c 66 52 28 5c 66 49 63 68 61 6e hared\fR(\fIchan
07d0: 6e 65 6c 5c 66 52 29 0a 2e 73 70 0a 69 6e 74 0a nel\fR)..sp.int.
07e0: 5c 66 42 54 63 6c 5f 49 73 43 68 61 6e 6e 65 6c \fBTcl_IsChannel
07f0: 52 65 67 69 73 74 65 72 65 64 5c 66 52 28 5c 66 Registered\fR(\f
0800: 49 69 6e 74 65 72 70 2c 20 63 68 61 6e 6e 65 6c Iinterp, channel
0810: 5c 66 52 29 0a 2e 73 70 0a 69 6e 74 0a 5c 66 42 \fR)..sp.int.\fB
0820: 54 63 6c 5f 49 73 43 68 61 6e 6e 65 6c 45 78 69 Tcl_IsChannelExi
0830: 73 74 69 6e 67 5c 66 52 28 5c 66 49 63 68 61 6e sting\fR(\fIchan
0840: 6e 65 6c 4e 61 6d 65 5c 66 52 29 0a 2e 73 70 0a nelName\fR)..sp.
0850: 76 6f 69 64 0a 5c 66 42 54 63 6c 5f 43 75 74 43 void.\fBTcl_CutC
0860: 68 61 6e 6e 65 6c 5c 66 52 28 5c 66 49 63 68 61 hannel\fR(\fIcha
0870: 6e 6e 65 6c 5c 66 52 29 0a 2e 73 70 0a 76 6f 69 nnel\fR)..sp.voi
0880: 64 0a 5c 66 42 54 63 6c 5f 53 70 6c 69 63 65 43 d.\fBTcl_SpliceC
0890: 68 61 6e 6e 65 6c 5c 66 52 28 5c 66 49 63 68 61 hannel\fR(\fIcha
08a0: 6e 6e 65 6c 5c 66 52 29 0a 2e 73 70 0a 76 6f 69 nnel\fR)..sp.voi
08b0: 64 0a 5c 66 42 54 63 6c 5f 43 6c 65 61 72 43 68 d.\fBTcl_ClearCh
08c0: 61 6e 6e 65 6c 48 61 6e 64 6c 65 72 73 5c 66 52 annelHandlers\fR
08d0: 28 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 29 0a (\fIchannel\fR).
08e0: 2e 73 70 0a 69 6e 74 0a 5c 66 42 54 63 6c 5f 43 .sp.int.\fBTcl_C
08f0: 68 61 6e 6e 65 6c 42 75 66 66 65 72 65 64 5c 66 hannelBuffered\f
0900: 52 28 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 29 R(\fIchannel\fR)
0910: 0a 2e 73 70 0a 63 6f 6e 73 74 20 63 68 61 72 20 ..sp.const char
0920: 2a 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c *.\fBTcl_Channel
0930: 4e 61 6d 65 5c 66 52 28 5c 66 49 74 79 70 65 50 Name\fR(\fItypeP
0940: 74 72 5c 66 52 29 0a 2e 73 70 0a 54 63 6c 5f 43 tr\fR)..sp.Tcl_C
0950: 68 61 6e 6e 65 6c 54 79 70 65 56 65 72 73 69 6f hannelTypeVersio
0960: 6e 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c n.\fBTcl_Channel
0970: 56 65 72 73 69 6f 6e 5c 66 52 28 5c 66 49 74 79 Version\fR(\fIty
0980: 70 65 50 74 72 5c 66 52 29 0a 2e 73 70 0a 54 63 pePtr\fR)..sp.Tc
0990: 6c 5f 44 72 69 76 65 72 42 6c 6f 63 6b 4d 6f 64 l_DriverBlockMod
09a0: 65 50 72 6f 63 20 2a 0a 5c 66 42 54 63 6c 5f 43 eProc *.\fBTcl_C
09b0: 68 61 6e 6e 65 6c 42 6c 6f 63 6b 4d 6f 64 65 50 hannelBlockModeP
09c0: 72 6f 63 5c 66 52 28 5c 66 49 74 79 70 65 50 74 roc\fR(\fItypePt
09d0: 72 5c 66 52 29 0a 2e 73 70 0a 54 63 6c 5f 44 72 r\fR)..sp.Tcl_Dr
09e0: 69 76 65 72 43 6c 6f 73 65 50 72 6f 63 20 2a 0a iverCloseProc *.
09f0: 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 43 6c \fBTcl_ChannelCl
0a00: 6f 73 65 50 72 6f 63 5c 66 52 28 5c 66 49 74 79 oseProc\fR(\fIty
0a10: 70 65 50 74 72 5c 66 52 29 0a 2e 73 70 0a 54 63 pePtr\fR)..sp.Tc
0a20: 6c 5f 44 72 69 76 65 72 43 6c 6f 73 65 32 50 72 l_DriverClose2Pr
0a30: 6f 63 20 2a 0a 5c 66 42 54 63 6c 5f 43 68 61 6e oc *.\fBTcl_Chan
0a40: 6e 65 6c 43 6c 6f 73 65 32 50 72 6f 63 5c 66 52 nelClose2Proc\fR
0a50: 28 5c 66 49 74 79 70 65 50 74 72 5c 66 52 29 0a (\fItypePtr\fR).
0a60: 2e 73 70 0a 54 63 6c 5f 44 72 69 76 65 72 49 6e .sp.Tcl_DriverIn
0a70: 70 75 74 50 72 6f 63 20 2a 0a 5c 66 42 54 63 6c putProc *.\fBTcl
0a80: 5f 43 68 61 6e 6e 65 6c 49 6e 70 75 74 50 72 6f _ChannelInputPro
0a90: 63 5c 66 52 28 5c 66 49 74 79 70 65 50 74 72 5c c\fR(\fItypePtr\
0aa0: 66 52 29 0a 2e 73 70 0a 54 63 6c 5f 44 72 69 76 fR)..sp.Tcl_Driv
0ab0: 65 72 4f 75 74 70 75 74 50 72 6f 63 20 2a 0a 5c erOutputProc *.\
0ac0: 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 4f 75 74 fBTcl_ChannelOut
0ad0: 70 75 74 50 72 6f 63 5c 66 52 28 5c 66 49 74 79 putProc\fR(\fIty
0ae0: 70 65 50 74 72 5c 66 52 29 0a 2e 73 70 0a 54 63 pePtr\fR)..sp.Tc
0af0: 6c 5f 44 72 69 76 65 72 53 65 65 6b 50 72 6f 63 l_DriverSeekProc
0b00: 20 2a 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 *.\fBTcl_Channe
0b10: 6c 53 65 65 6b 50 72 6f 63 5c 66 52 28 5c 66 49 lSeekProc\fR(\fI
0b20: 74 79 70 65 50 74 72 5c 66 52 29 0a 2e 73 70 0a typePtr\fR)..sp.
0b30: 54 63 6c 5f 44 72 69 76 65 72 57 69 64 65 53 65 Tcl_DriverWideSe
0b40: 65 6b 50 72 6f 63 20 2a 0a 5c 66 42 54 63 6c 5f ekProc *.\fBTcl_
0b50: 43 68 61 6e 6e 65 6c 57 69 64 65 53 65 65 6b 50 ChannelWideSeekP
0b60: 72 6f 63 5c 66 52 28 5c 66 49 74 79 70 65 50 74 roc\fR(\fItypePt
0b70: 72 5c 66 52 29 0a 2e 73 70 0a 54 63 6c 5f 44 72 r\fR)..sp.Tcl_Dr
0b80: 69 76 65 72 54 68 72 65 61 64 41 63 74 69 6f 6e iverThreadAction
0b90: 50 72 6f 63 20 2a 0a 5c 66 42 54 63 6c 5f 43 68 Proc *.\fBTcl_Ch
0ba0: 61 6e 6e 65 6c 54 68 72 65 61 64 41 63 74 69 6f annelThreadActio
0bb0: 6e 50 72 6f 63 5c 66 52 28 5c 66 49 74 79 70 65 nProc\fR(\fItype
0bc0: 50 74 72 5c 66 52 29 0a 2e 73 70 0a 54 63 6c 5f Ptr\fR)..sp.Tcl_
0bd0: 44 72 69 76 65 72 54 72 75 6e 63 61 74 65 50 72 DriverTruncatePr
0be0: 6f 63 20 2a 0a 5c 66 42 54 63 6c 5f 43 68 61 6e oc *.\fBTcl_Chan
0bf0: 6e 65 6c 54 72 75 6e 63 61 74 65 50 72 6f 63 5c nelTruncateProc\
0c00: 66 52 28 5c 66 49 74 79 70 65 50 74 72 5c 66 52 fR(\fItypePtr\fR
0c10: 29 0a 2e 73 70 0a 54 63 6c 5f 44 72 69 76 65 72 )..sp.Tcl_Driver
0c20: 53 65 74 4f 70 74 69 6f 6e 50 72 6f 63 20 2a 0a SetOptionProc *.
0c30: 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 53 65 \fBTcl_ChannelSe
0c40: 74 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 28 5c tOptionProc\fR(\
0c50: 66 49 74 79 70 65 50 74 72 5c 66 52 29 0a 2e 73 fItypePtr\fR)..s
0c60: 70 0a 54 63 6c 5f 44 72 69 76 65 72 47 65 74 4f p.Tcl_DriverGetO
0c70: 70 74 69 6f 6e 50 72 6f 63 20 2a 0a 5c 66 42 54 ptionProc *.\fBT
0c80: 63 6c 5f 43 68 61 6e 6e 65 6c 47 65 74 4f 70 74 cl_ChannelGetOpt
0c90: 69 6f 6e 50 72 6f 63 5c 66 52 28 5c 66 49 74 79 ionProc\fR(\fIty
0ca0: 70 65 50 74 72 5c 66 52 29 0a 2e 73 70 0a 54 63 pePtr\fR)..sp.Tc
0cb0: 6c 5f 44 72 69 76 65 72 57 61 74 63 68 50 72 6f l_DriverWatchPro
0cc0: 63 20 2a 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e c *.\fBTcl_Chann
0cd0: 65 6c 57 61 74 63 68 50 72 6f 63 5c 66 52 28 5c elWatchProc\fR(\
0ce0: 66 49 74 79 70 65 50 74 72 5c 66 52 29 0a 2e 73 fItypePtr\fR)..s
0cf0: 70 0a 54 63 6c 5f 44 72 69 76 65 72 47 65 74 48 p.Tcl_DriverGetH
0d00: 61 6e 64 6c 65 50 72 6f 63 20 2a 0a 5c 66 42 54 andleProc *.\fBT
0d10: 63 6c 5f 43 68 61 6e 6e 65 6c 47 65 74 48 61 6e cl_ChannelGetHan
0d20: 64 6c 65 50 72 6f 63 5c 66 52 28 5c 66 49 74 79 dleProc\fR(\fIty
0d30: 70 65 50 74 72 5c 66 52 29 0a 2e 73 70 0a 54 63 pePtr\fR)..sp.Tc
0d40: 6c 5f 44 72 69 76 65 72 46 6c 75 73 68 50 72 6f l_DriverFlushPro
0d50: 63 20 2a 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e c *.\fBTcl_Chann
0d60: 65 6c 46 6c 75 73 68 50 72 6f 63 5c 66 52 28 5c elFlushProc\fR(\
0d70: 66 49 74 79 70 65 50 74 72 5c 66 52 29 0a 2e 73 fItypePtr\fR)..s
0d80: 70 0a 54 63 6c 5f 44 72 69 76 65 72 48 61 6e 64 p.Tcl_DriverHand
0d90: 6c 65 72 50 72 6f 63 20 2a 0a 5c 66 42 54 63 6c lerProc *.\fBTcl
0da0: 5f 43 68 61 6e 6e 65 6c 48 61 6e 64 6c 65 72 50 _ChannelHandlerP
0db0: 72 6f 63 5c 66 52 28 5c 66 49 74 79 70 65 50 74 roc\fR(\fItypePt
0dc0: 72 5c 66 52 29 0a 2e 73 70 0a 2e 53 48 20 41 52 r\fR)..sp..SH AR
0dd0: 47 55 4d 45 4e 54 53 0a 2e 41 53 20 22 63 6f 6e GUMENTS..AS "con
0de0: 73 74 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 st Tcl_ChannelTy
0df0: 70 65 22 20 2a 63 68 61 6e 6e 65 6c 4e 61 6d 65 pe" *channelName
0e00: 0a 2e 41 50 20 22 63 6f 6e 73 74 20 54 63 6c 5f ..AP "const Tcl_
0e10: 43 68 61 6e 6e 65 6c 54 79 70 65 22 20 2a 74 79 ChannelType" *ty
0e20: 70 65 50 74 72 20 69 6e 0a 50 6f 69 6e 74 73 20 pePtr in.Points
0e30: 74 6f 20 61 20 73 74 72 75 63 74 75 72 65 20 63 to a structure c
0e40: 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 61 64 ontaining the ad
0e50: 64 72 65 73 73 65 73 20 6f 66 20 70 72 6f 63 65 dresses of proce
0e60: 64 75 72 65 73 20 74 68 61 74 0a 63 61 6e 20 62 dures that.can b
0e70: 65 20 63 61 6c 6c 65 64 20 74 6f 20 70 65 72 66 e called to perf
0e80: 6f 72 6d 20 49 2f 4f 20 61 6e 64 20 6f 74 68 65 orm I/O and othe
0e90: 72 20 66 75 6e 63 74 69 6f 6e 73 20 6f 6e 20 74 r functions on t
0ea0: 68 65 20 63 68 61 6e 6e 65 6c 2e 0a 2e 41 50 20 he channel...AP
0eb0: 22 63 6f 6e 73 74 20 63 68 61 72 22 20 2a 63 68 "const char" *ch
0ec0: 61 6e 6e 65 6c 4e 61 6d 65 20 69 6e 0a 54 68 65 annelName in.The
0ed0: 20 6e 61 6d 65 20 6f 66 20 74 68 69 73 20 63 68 name of this ch
0ee0: 61 6e 6e 65 6c 2c 20 73 75 63 68 20 61 73 20 5c annel, such as \
0ef0: 66 42 66 69 6c 65 33 5c 66 52 3b 20 6d 75 73 74 fBfile3\fR; must
0f00: 20 6e 6f 74 20 62 65 20 69 6e 20 75 73 65 0a 62 not be in use.b
0f10: 79 20 61 6e 79 20 6f 74 68 65 72 20 63 68 61 6e y any other chan
0f20: 6e 65 6c 2e 20 43 61 6e 20 62 65 20 4e 55 4c 4c nel. Can be NULL
0f30: 2c 20 69 6e 20 77 68 69 63 68 20 63 61 73 65 20 , in which case
0f40: 74 68 65 20 63 68 61 6e 6e 65 6c 20 69 73 0a 63 the channel is.c
0f50: 72 65 61 74 65 64 20 77 69 74 68 6f 75 74 20 61 reated without a
0f60: 20 6e 61 6d 65 2e 20 49 66 20 74 68 65 20 63 72 name. If the cr
0f70: 65 61 74 65 64 20 63 68 61 6e 6e 65 6c 20 69 73 eated channel is
0f80: 20 61 73 73 69 67 6e 65 64 20 74 6f 20 6f 6e 65 assigned to one
0f90: 0a 6f 66 20 74 68 65 20 73 74 61 6e 64 61 72 64 .of the standard
0fa0: 20 63 68 61 6e 6e 65 6c 73 20 28 5c 66 42 73 74 channels (\fBst
0fb0: 64 69 6e 5c 66 52 2c 20 5c 66 42 73 74 64 6f 75 din\fR, \fBstdou
0fc0: 74 5c 66 52 20 6f 72 20 5c 66 42 73 74 64 65 72 t\fR or \fBstder
0fd0: 72 5c 66 52 29 2c 0a 74 68 65 20 61 73 73 69 67 r\fR),.the assig
0fe0: 6e 65 64 20 63 68 61 6e 6e 65 6c 20 6e 61 6d 65 ned channel name
0ff0: 20 77 69 6c 6c 20 62 65 20 74 68 65 20 6e 61 6d will be the nam
1000: 65 20 6f 66 20 74 68 65 20 73 74 61 6e 64 61 72 e of the standar
1010: 64 20 63 68 61 6e 6e 65 6c 2e 0a 2e 41 50 20 43 d channel...AP C
1020: 6c 69 65 6e 74 44 61 74 61 20 69 6e 73 74 61 6e lientData instan
1030: 63 65 44 61 74 61 20 69 6e 0a 41 72 62 69 74 72 ceData in.Arbitr
1040: 61 72 79 20 6f 6e 65 2d 77 6f 72 64 20 76 61 6c ary one-word val
1050: 75 65 20 74 6f 20 62 65 20 61 73 73 6f 63 69 61 ue to be associa
1060: 74 65 64 20 77 69 74 68 20 74 68 69 73 20 63 68 ted with this ch
1070: 61 6e 6e 65 6c 2e 20 20 54 68 69 73 0a 76 61 6c annel. This.val
1080: 75 65 20 69 73 20 70 61 73 73 65 64 20 74 6f 20 ue is passed to
1090: 70 72 6f 63 65 64 75 72 65 73 20 69 6e 20 5c 66 procedures in \f
10a0: 49 74 79 70 65 50 74 72 5c 66 52 20 77 68 65 6e ItypePtr\fR when
10b0: 20 74 68 65 79 20 61 72 65 20 69 6e 76 6f 6b 65 they are invoke
10c0: 64 2e 0a 2e 41 50 20 69 6e 74 20 6d 61 73 6b 20 d...AP int mask
10d0: 69 6e 0a 4f 52 2d 65 64 20 63 6f 6d 62 69 6e 61 in.OR-ed combina
10e0: 74 69 6f 6e 20 6f 66 20 5c 66 42 54 43 4c 5f 52 tion of \fBTCL_R
10f0: 45 41 44 41 42 4c 45 5c 66 52 20 61 6e 64 20 5c EADABLE\fR and \
1100: 66 42 54 43 4c 5f 57 52 49 54 41 42 4c 45 5c 66 fBTCL_WRITABLE\f
1110: 52 20 74 6f 20 69 6e 64 69 63 61 74 65 0a 77 68 R to indicate.wh
1120: 65 74 68 65 72 20 61 20 63 68 61 6e 6e 65 6c 20 ether a channel
1130: 69 73 20 72 65 61 64 61 62 6c 65 20 61 6e 64 20 is readable and
1140: 77 72 69 74 61 62 6c 65 2e 0a 2e 41 50 20 54 63 writable...AP Tc
1150: 6c 5f 43 68 61 6e 6e 65 6c 20 63 68 61 6e 6e 65 l_Channel channe
1160: 6c 20 69 6e 0a 54 68 65 20 63 68 61 6e 6e 65 6c l in.The channel
1170: 20 74 6f 20 6f 70 65 72 61 74 65 20 6f 6e 2e 0a to operate on..
1180: 2e 41 50 20 69 6e 74 20 64 69 72 65 63 74 69 6f .AP int directio
1190: 6e 20 69 6e 0a 5c 66 42 54 43 4c 5f 52 45 41 44 n in.\fBTCL_READ
11a0: 41 42 4c 45 5c 66 52 20 6d 65 61 6e 73 20 74 68 ABLE\fR means th
11b0: 65 20 69 6e 70 75 74 20 68 61 6e 64 6c 65 20 69 e input handle i
11c0: 73 20 77 61 6e 74 65 64 3b 20 5c 66 42 54 43 4c s wanted; \fBTCL
11d0: 5f 57 52 49 54 41 42 4c 45 5c 66 52 0a 6d 65 61 _WRITABLE\fR.mea
11e0: 6e 73 20 74 68 65 20 6f 75 74 70 75 74 20 68 61 ns the output ha
11f0: 6e 64 6c 65 20 69 73 20 77 61 6e 74 65 64 2e 0a ndle is wanted..
1200: 2e 41 50 20 43 6c 69 65 6e 74 44 61 74 61 20 2a .AP ClientData *
1210: 68 61 6e 64 6c 65 50 74 72 20 6f 75 74 0a 50 6f handlePtr out.Po
1220: 69 6e 74 73 20 74 6f 20 74 68 65 20 6c 6f 63 61 ints to the loca
1230: 74 69 6f 6e 20 77 68 65 72 65 20 74 68 65 20 64 tion where the d
1240: 65 73 69 72 65 64 20 4f 53 2d 73 70 65 63 69 66 esired OS-specif
1250: 69 63 20 68 61 6e 64 6c 65 20 73 68 6f 75 6c 64 ic handle should
1260: 20 62 65 0a 73 74 6f 72 65 64 2e 0a 2e 41 50 20 be.stored...AP
1270: 69 6e 74 20 73 69 7a 65 20 69 6e 0a 54 68 65 20 int size in.The
1280: 73 69 7a 65 2c 20 69 6e 20 62 79 74 65 73 2c 20 size, in bytes,
1290: 6f 66 20 62 75 66 66 65 72 73 20 74 6f 20 61 6c of buffers to al
12a0: 6c 6f 63 61 74 65 20 69 6e 20 74 68 69 73 20 63 locate in this c
12b0: 68 61 6e 6e 65 6c 2e 0a 2e 41 50 20 69 6e 74 20 hannel...AP int
12c0: 6d 61 73 6b 20 69 6e 0a 41 6e 20 4f 52 2d 65 64 mask in.An OR-ed
12d0: 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 6f 66 20 combination of
12e0: 5c 66 42 54 43 4c 5f 52 45 41 44 41 42 4c 45 5c \fBTCL_READABLE\
12f0: 66 52 2c 20 5c 66 42 54 43 4c 5f 57 52 49 54 41 fR, \fBTCL_WRITA
1300: 42 4c 45 5c 66 52 0a 61 6e 64 20 5c 66 42 54 43 BLE\fR.and \fBTC
1310: 4c 5f 45 58 43 45 50 54 49 4f 4e 5c 66 52 20 74 L_EXCEPTION\fR t
1320: 68 61 74 20 69 6e 64 69 63 61 74 65 73 20 65 76 hat indicates ev
1330: 65 6e 74 73 20 74 68 61 74 20 68 61 76 65 20 6f ents that have o
1340: 63 63 75 72 72 65 64 20 6f 6e 0a 74 68 69 73 20 ccurred on.this
1350: 63 68 61 6e 6e 65 6c 2e 0a 2e 41 50 20 54 63 6c channel...AP Tcl
1360: 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 20 _Interp *interp
1370: 69 6e 0a 43 75 72 72 65 6e 74 20 69 6e 74 65 72 in.Current inter
1380: 70 72 65 74 65 72 2e 20 28 63 61 6e 20 62 65 20 preter. (can be
1390: 4e 55 4c 4c 29 0a 2e 41 50 20 22 63 6f 6e 73 74 NULL)..AP "const
13a0: 20 63 68 61 72 22 20 2a 6f 70 74 69 6f 6e 4e 61 char" *optionNa
13b0: 6d 65 20 69 6e 0a 4e 61 6d 65 20 6f 66 20 74 68 me in.Name of th
13c0: 65 20 69 6e 76 61 6c 69 64 20 6f 70 74 69 6f 6e e invalid option
13d0: 2e 0a 2e 41 50 20 22 63 6f 6e 73 74 20 63 68 61 ...AP "const cha
13e0: 72 22 20 2a 6f 70 74 69 6f 6e 4c 69 73 74 20 69 r" *optionList i
13f0: 6e 0a 53 70 65 63 69 66 69 63 20 6f 70 74 69 6f n.Specific optio
1400: 6e 73 20 6c 69 73 74 20 28 73 70 61 63 65 20 73 ns list (space s
1410: 65 70 61 72 61 74 65 64 20 77 6f 72 64 73 2c 20 eparated words,
1420: 77 69 74 68 6f 75 74 0a 2e 51 57 20 5c 2d 20 29 without..QW \- )
1430: 0a 74 6f 20 61 70 70 65 6e 64 20 74 6f 20 74 68 .to append to th
1440: 65 20 73 74 61 6e 64 61 72 64 20 67 65 6e 65 72 e standard gener
1450: 69 63 20 6f 70 74 69 6f 6e 73 20 6c 69 73 74 2e ic options list.
1460: 0a 43 61 6e 20 62 65 20 4e 55 4c 4c 20 66 6f 72 .Can be NULL for
1470: 20 67 65 6e 65 72 69 63 20 6f 70 74 69 6f 6e 73 generic options
1480: 20 65 72 72 6f 72 20 6d 65 73 73 61 67 65 20 6f error message o
1490: 6e 6c 79 2e 0a 2e 42 45 0a 2e 53 48 20 44 45 53 nly...BE..SH DES
14a0: 43 52 49 50 54 49 4f 4e 0a 2e 50 50 0a 54 63 6c CRIPTION..PP.Tcl
14b0: 20 75 73 65 73 20 61 20 74 77 6f 2d 6c 61 79 65 uses a two-laye
14c0: 72 65 64 20 63 68 61 6e 6e 65 6c 20 61 72 63 68 red channel arch
14d0: 69 74 65 63 74 75 72 65 2e 20 49 74 20 70 72 6f itecture. It pro
14e0: 76 69 64 65 73 20 61 20 67 65 6e 65 72 69 63 20 vides a generic
14f0: 75 70 70 65 72 0a 6c 61 79 65 72 20 74 6f 20 65 upper.layer to e
1500: 6e 61 62 6c 65 20 43 20 61 6e 64 20 54 63 6c 20 nable C and Tcl
1510: 70 72 6f 67 72 61 6d 73 20 74 6f 20 70 65 72 66 programs to perf
1520: 6f 72 6d 20 69 6e 70 75 74 20 61 6e 64 20 6f 75 orm input and ou
1530: 74 70 75 74 20 75 73 69 6e 67 20 74 68 65 0a 73 tput using the.s
1540: 61 6d 65 20 41 50 49 73 20 66 6f 72 20 61 20 76 ame APIs for a v
1550: 61 72 69 65 74 79 20 6f 66 20 66 69 6c 65 73 2c ariety of files,
1560: 20 64 65 76 69 63 65 73 2c 20 73 6f 63 6b 65 74 devices, socket
1570: 73 20 65 74 63 2e 20 54 68 65 20 67 65 6e 65 72 s etc. The gener
1580: 69 63 20 43 20 41 50 49 73 0a 61 72 65 20 64 65 ic C APIs.are de
1590: 73 63 72 69 62 65 64 20 69 6e 20 74 68 65 20 6d scribed in the m
15a0: 61 6e 75 61 6c 20 65 6e 74 72 79 20 66 6f 72 20 anual entry for
15b0: 5c 66 42 54 63 6c 5f 4f 70 65 6e 46 69 6c 65 43 \fBTcl_OpenFileC
15c0: 68 61 6e 6e 65 6c 5c 66 52 2e 0a 2e 50 50 0a 54 hannel\fR...PP.T
15d0: 68 65 20 6c 6f 77 65 72 20 6c 61 79 65 72 20 70 he lower layer p
15e0: 72 6f 76 69 64 65 73 20 74 79 70 65 2d 73 70 65 rovides type-spe
15f0: 63 69 66 69 63 20 63 68 61 6e 6e 65 6c 20 64 72 cific channel dr
1600: 69 76 65 72 73 20 66 6f 72 20 65 61 63 68 20 74 ivers for each t
1610: 79 70 65 0a 6f 66 20 64 65 76 69 63 65 20 73 75 ype.of device su
1620: 70 70 6f 72 74 65 64 20 6f 6e 20 65 61 63 68 20 pported on each
1630: 70 6c 61 74 66 6f 72 6d 2e 20 20 54 68 69 73 20 platform. This
1640: 6d 61 6e 75 61 6c 20 65 6e 74 72 79 20 64 65 73 manual entry des
1650: 63 72 69 62 65 73 20 74 68 65 0a 43 20 41 50 49 cribes the.C API
1660: 73 20 75 73 65 64 20 74 6f 20 63 6f 6d 6d 75 6e s used to commun
1670: 69 63 61 74 65 20 62 65 74 77 65 65 6e 20 74 68 icate between th
1680: 65 20 67 65 6e 65 72 69 63 20 6c 61 79 65 72 20 e generic layer
1690: 61 6e 64 20 74 68 65 0a 74 79 70 65 2d 73 70 65 and the.type-spe
16a0: 63 69 66 69 63 20 63 68 61 6e 6e 65 6c 20 64 72 cific channel dr
16b0: 69 76 65 72 73 2e 20 20 49 74 20 61 6c 73 6f 20 ivers. It also
16c0: 65 78 70 6c 61 69 6e 73 20 68 6f 77 20 6e 65 77 explains how new
16d0: 20 74 79 70 65 73 20 6f 66 0a 63 68 61 6e 6e 65 types of.channe
16e0: 6c 73 20 63 61 6e 20 62 65 20 61 64 64 65 64 20 ls can be added
16f0: 62 79 20 70 72 6f 76 69 64 69 6e 67 20 6e 65 77 by providing new
1700: 20 63 68 61 6e 6e 65 6c 20 64 72 69 76 65 72 73 channel drivers
1710: 2e 0a 2e 50 50 0a 43 68 61 6e 6e 65 6c 20 64 72 ...PP.Channel dr
1720: 69 76 65 72 73 20 63 6f 6e 73 69 73 74 20 6f 66 ivers consist of
1730: 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 63 6f 6d a number of com
1740: 70 6f 6e 65 6e 74 73 3a 20 46 69 72 73 74 2c 20 ponents: First,
1750: 65 61 63 68 20 63 68 61 6e 6e 65 6c 0a 64 72 69 each channel.dri
1760: 76 65 72 20 70 72 6f 76 69 64 65 73 20 61 20 5c ver provides a \
1770: 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 fBTcl_ChannelTyp
1780: 65 5c 66 52 20 73 74 72 75 63 74 75 72 65 20 63 e\fR structure c
1790: 6f 6e 74 61 69 6e 69 6e 67 20 70 6f 69 6e 74 65 ontaining pointe
17a0: 72 73 20 74 6f 0a 66 75 6e 63 74 69 6f 6e 73 20 rs to.functions
17b0: 69 6d 70 6c 65 6d 65 6e 74 69 6e 67 20 74 68 65 implementing the
17c0: 20 76 61 72 69 6f 75 73 20 6f 70 65 72 61 74 69 various operati
17d0: 6f 6e 73 20 75 73 65 64 20 62 79 20 74 68 65 20 ons used by the
17e0: 67 65 6e 65 72 69 63 20 6c 61 79 65 72 20 74 6f generic layer to
17f0: 0a 63 6f 6d 6d 75 6e 69 63 61 74 65 20 77 69 74 .communicate wit
1800: 68 20 74 68 65 20 63 68 61 6e 6e 65 6c 20 64 72 h the channel dr
1810: 69 76 65 72 2e 20 54 68 65 20 5c 66 42 54 63 6c iver. The \fBTcl
1820: 5f 43 68 61 6e 6e 65 6c 54 79 70 65 5c 66 52 20 _ChannelType\fR
1830: 73 74 72 75 63 74 75 72 65 0a 61 6e 64 20 74 68 structure.and th
1840: 65 20 66 75 6e 63 74 69 6f 6e 73 20 72 65 66 65 e functions refe
1850: 72 65 6e 63 65 64 20 62 79 20 69 74 20 61 72 65 renced by it are
1860: 20 64 65 73 63 72 69 62 65 64 20 69 6e 20 74 68 described in th
1870: 65 20 73 65 63 74 69 6f 6e 0a 5c 66 42 54 43 4c e section.\fBTCL
1880: 5f 43 48 41 4e 4e 45 4c 54 59 50 45 5c 66 52 2c _CHANNELTYPE\fR,
1890: 20 62 65 6c 6f 77 2e 0a 2e 50 50 0a 53 65 63 6f below...PP.Seco
18a0: 6e 64 2c 20 63 68 61 6e 6e 65 6c 20 64 72 69 76 nd, channel driv
18b0: 65 72 73 20 75 73 75 61 6c 6c 79 20 70 72 6f 76 ers usually prov
18c0: 69 64 65 20 61 20 54 63 6c 20 63 6f 6d 6d 61 6e ide a Tcl comman
18d0: 64 20 74 6f 20 63 72 65 61 74 65 0a 69 6e 73 74 d to create.inst
18e0: 61 6e 63 65 73 20 6f 66 20 74 68 61 74 20 74 79 ances of that ty
18f0: 70 65 20 6f 66 20 63 68 61 6e 6e 65 6c 2e 20 46 pe of channel. F
1900: 6f 72 20 65 78 61 6d 70 6c 65 2c 20 74 68 65 20 or example, the
1910: 54 63 6c 20 5c 66 42 6f 70 65 6e 5c 66 52 0a 63 Tcl \fBopen\fR.c
1920: 6f 6d 6d 61 6e 64 20 63 72 65 61 74 65 73 20 63 ommand creates c
1930: 68 61 6e 6e 65 6c 73 20 74 68 61 74 20 75 73 65 hannels that use
1940: 20 74 68 65 20 66 69 6c 65 20 61 6e 64 20 63 6f the file and co
1950: 6d 6d 61 6e 64 20 63 68 61 6e 6e 65 6c 0a 64 72 mmand channel.dr
1960: 69 76 65 72 73 2c 20 61 6e 64 20 74 68 65 20 54 ivers, and the T
1970: 63 6c 20 5c 66 42 73 6f 63 6b 65 74 5c 66 52 20 cl \fBsocket\fR
1980: 63 6f 6d 6d 61 6e 64 20 63 72 65 61 74 65 73 20 command creates
1990: 63 68 61 6e 6e 65 6c 73 20 74 68 61 74 20 75 73 channels that us
19a0: 65 0a 54 43 50 20 73 6f 63 6b 65 74 73 20 66 6f e.TCP sockets fo
19b0: 72 20 6e 65 74 77 6f 72 6b 20 63 6f 6d 6d 75 6e r network commun
19c0: 69 63 61 74 69 6f 6e 2e 0a 2e 50 50 0a 54 68 69 ication...PP.Thi
19d0: 72 64 2c 20 61 20 63 68 61 6e 6e 65 6c 20 64 72 rd, a channel dr
19e0: 69 76 65 72 20 6f 70 74 69 6f 6e 61 6c 6c 79 20 iver optionally
19f0: 70 72 6f 76 69 64 65 73 20 61 20 43 20 66 75 6e provides a C fun
1a00: 63 74 69 6f 6e 20 74 6f 20 6f 70 65 6e 0a 63 68 ction to open.ch
1a10: 61 6e 6e 65 6c 20 69 6e 73 74 61 6e 63 65 73 20 annel instances
1a20: 6f 66 20 74 68 61 74 20 74 79 70 65 2e 20 46 6f of that type. Fo
1a30: 72 20 65 78 61 6d 70 6c 65 2c 20 5c 66 42 54 63 r example, \fBTc
1a40: 6c 5f 4f 70 65 6e 46 69 6c 65 43 68 61 6e 6e 65 l_OpenFileChanne
1a50: 6c 5c 66 52 0a 6f 70 65 6e 73 20 61 20 63 68 61 l\fR.opens a cha
1a60: 6e 6e 65 6c 20 74 68 61 74 20 75 73 65 73 20 74 nnel that uses t
1a70: 68 65 20 66 69 6c 65 20 63 68 61 6e 6e 65 6c 20 he file channel
1a80: 64 72 69 76 65 72 2c 20 61 6e 64 0a 5c 66 42 54 driver, and.\fBT
1a90: 63 6c 5f 4f 70 65 6e 54 63 70 43 6c 69 65 6e 74 cl_OpenTcpClient
1aa0: 5c 66 52 20 6f 70 65 6e 73 20 61 20 63 68 61 6e \fR opens a chan
1ab0: 6e 65 6c 20 74 68 61 74 20 75 73 65 73 20 74 68 nel that uses th
1ac0: 65 20 54 43 50 20 6e 65 74 77 6f 72 6b 0a 70 72 e TCP network.pr
1ad0: 6f 74 6f 63 6f 6c 2e 20 20 54 68 65 73 65 20 63 otocol. These c
1ae0: 72 65 61 74 69 6f 6e 20 66 75 6e 63 74 69 6f 6e reation function
1af0: 73 20 74 79 70 69 63 61 6c 6c 79 20 75 73 65 0a s typically use.
1b00: 5c 66 42 54 63 6c 5f 43 72 65 61 74 65 43 68 61 \fBTcl_CreateCha
1b10: 6e 6e 65 6c 5c 66 52 20 69 6e 74 65 72 6e 61 6c nnel\fR internal
1b20: 6c 79 20 74 6f 20 6f 70 65 6e 20 74 68 65 20 63 ly to open the c
1b30: 68 61 6e 6e 65 6c 2e 0a 2e 50 50 0a 54 6f 20 61 hannel...PP.To a
1b40: 64 64 20 61 20 6e 65 77 20 74 79 70 65 20 6f 66 dd a new type of
1b50: 20 63 68 61 6e 6e 65 6c 20 79 6f 75 20 6d 75 73 channel you mus
1b60: 74 20 69 6d 70 6c 65 6d 65 6e 74 20 61 20 43 20 t implement a C
1b70: 41 50 49 20 6f 72 20 61 20 54 63 6c 20 63 6f 6d API or a Tcl com
1b80: 6d 61 6e 64 0a 74 68 61 74 20 6f 70 65 6e 73 20 mand.that opens
1b90: 61 20 63 68 61 6e 6e 65 6c 20 62 79 20 69 6e 76 a channel by inv
1ba0: 6f 6b 69 6e 67 20 5c 66 42 54 63 6c 5f 43 72 65 oking \fBTcl_Cre
1bb0: 61 74 65 43 68 61 6e 6e 65 6c 5c 66 52 2e 0a 57 ateChannel\fR..W
1bc0: 68 65 6e 20 79 6f 75 72 20 64 72 69 76 65 72 20 hen your driver
1bd0: 63 61 6c 6c 73 20 5c 66 42 54 63 6c 5f 43 72 65 calls \fBTcl_Cre
1be0: 61 74 65 43 68 61 6e 6e 65 6c 5c 66 52 20 69 74 ateChannel\fR it
1bf0: 20 70 61 73 73 65 73 20 69 6e 0a 61 20 5c 66 42 passes in.a \fB
1c00: 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 65 5c Tcl_ChannelType\
1c10: 66 52 20 73 74 72 75 63 74 75 72 65 20 64 65 73 fR structure des
1c20: 63 72 69 62 69 6e 67 20 74 68 65 20 64 72 69 76 cribing the driv
1c30: 65 72 27 73 20 49 2f 4f 0a 70 72 6f 63 65 64 75 er's I/O.procedu
1c40: 72 65 73 2e 0a 54 68 65 20 67 65 6e 65 72 69 63 res..The generic
1c50: 20 6c 61 79 65 72 20 77 69 6c 6c 20 74 68 65 6e layer will then
1c60: 20 69 6e 76 6f 6b 65 20 74 68 65 20 66 75 6e 63 invoke the func
1c70: 74 69 6f 6e 73 20 72 65 66 65 72 65 6e 63 65 64 tions referenced
1c80: 20 69 6e 20 74 68 61 74 0a 73 74 72 75 63 74 75 in that.structu
1c90: 72 65 20 74 6f 20 70 65 72 66 6f 72 6d 20 6f 70 re to perform op
1ca0: 65 72 61 74 69 6f 6e 73 20 6f 6e 20 74 68 65 20 erations on the
1cb0: 63 68 61 6e 6e 65 6c 2e 0a 2e 50 50 0a 5c 66 42 channel...PP.\fB
1cc0: 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e 6e 65 Tcl_CreateChanne
1cd0: 6c 5c 66 52 20 6f 70 65 6e 73 20 61 20 6e 65 77 l\fR opens a new
1ce0: 20 63 68 61 6e 6e 65 6c 20 61 6e 64 20 61 73 73 channel and ass
1cf0: 6f 63 69 61 74 65 73 20 74 68 65 20 73 75 70 70 ociates the supp
1d00: 6c 69 65 64 0a 5c 66 49 74 79 70 65 50 74 72 5c lied.\fItypePtr\
1d10: 66 52 20 61 6e 64 20 5c 66 49 69 6e 73 74 61 6e fR and \fIinstan
1d20: 63 65 44 61 74 61 5c 66 52 20 77 69 74 68 20 69 ceData\fR with i
1d30: 74 2e 20 54 68 65 20 63 68 61 6e 6e 65 6c 20 69 t. The channel i
1d40: 73 20 6f 70 65 6e 65 64 20 69 6e 20 74 68 65 0a s opened in the.
1d50: 6d 6f 64 65 20 69 6e 64 69 63 61 74 65 64 20 62 mode indicated b
1d60: 79 20 5c 66 49 6d 61 73 6b 5c 66 52 2e 0a 46 6f y \fImask\fR..Fo
1d70: 72 20 61 20 64 69 73 63 75 73 73 69 6f 6e 20 6f r a discussion o
1d80: 66 20 63 68 61 6e 6e 65 6c 20 64 72 69 76 65 72 f channel driver
1d90: 73 2c 20 74 68 65 69 72 20 6f 70 65 72 61 74 69 s, their operati
1da0: 6f 6e 73 20 61 6e 64 20 74 68 65 0a 5c 66 42 54 ons and the.\fBT
1db0: 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 65 5c 66 cl_ChannelType\f
1dc0: 52 20 73 74 72 75 63 74 75 72 65 2c 20 73 65 65 R structure, see
1dd0: 20 74 68 65 20 73 65 63 74 69 6f 6e 20 5c 66 42 the section \fB
1de0: 54 43 4c 5f 43 48 41 4e 4e 45 4c 54 59 50 45 5c TCL_CHANNELTYPE\
1df0: 66 52 2c 20 62 65 6c 6f 77 2e 0a 2e 50 50 0a 5c fR, below...PP.\
1e00: 66 42 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e fBTcl_CreateChan
1e10: 6e 65 6c 5c 66 52 20 69 6e 74 65 72 61 63 74 73 nel\fR interacts
1e20: 20 77 69 74 68 20 74 68 65 20 63 6f 64 65 20 6d with the code m
1e30: 61 6e 61 67 69 6e 67 20 74 68 65 20 73 74 61 6e anaging the stan
1e40: 64 61 72 64 0a 63 68 61 6e 6e 65 6c 73 2e 20 4f dard.channels. O
1e50: 6e 63 65 20 61 20 73 74 61 6e 64 61 72 64 20 63 nce a standard c
1e60: 68 61 6e 6e 65 6c 20 77 61 73 20 69 6e 69 74 69 hannel was initi
1e70: 61 6c 69 7a 65 64 20 65 69 74 68 65 72 20 74 68 alized either th
1e80: 72 6f 75 67 68 20 61 0a 63 61 6c 6c 20 74 6f 20 rough a.call to
1e90: 5c 66 42 54 63 6c 5f 47 65 74 53 74 64 43 68 61 \fBTcl_GetStdCha
1ea0: 6e 6e 65 6c 5c 66 52 20 6f 72 20 61 20 63 61 6c nnel\fR or a cal
1eb0: 6c 20 74 6f 20 5c 66 42 54 63 6c 5f 53 65 74 53 l to \fBTcl_SetS
1ec0: 74 64 43 68 61 6e 6e 65 6c 5c 66 52 0a 63 6c 6f tdChannel\fR.clo
1ed0: 73 69 6e 67 20 74 68 69 73 20 73 74 61 6e 64 61 sing this standa
1ee0: 72 64 20 63 68 61 6e 6e 65 6c 20 77 69 6c 6c 20 rd channel will
1ef0: 63 61 75 73 65 20 74 68 65 20 6e 65 78 74 20 63 cause the next c
1f00: 61 6c 6c 20 74 6f 0a 5c 66 42 54 63 6c 5f 43 72 all to.\fBTcl_Cr
1f10: 65 61 74 65 43 68 61 6e 6e 65 6c 5c 66 52 20 74 eateChannel\fR t
1f20: 6f 20 6d 61 6b 65 20 74 68 65 20 6e 65 77 20 63 o make the new c
1f30: 68 61 6e 6e 65 6c 20 74 68 65 20 6e 65 77 20 73 hannel the new s
1f40: 74 61 6e 64 61 72 64 0a 63 68 61 6e 6e 65 6c 20 tandard.channel
1f50: 74 6f 6f 2e 20 53 65 65 20 5c 66 42 54 63 6c 5f too. See \fBTcl_
1f60: 53 74 61 6e 64 61 72 64 43 68 61 6e 6e 65 6c 73 StandardChannels
1f70: 5c 66 52 20 66 6f 72 20 61 20 67 65 6e 65 72 61 \fR for a genera
1f80: 6c 20 74 72 65 61 74 69 73 65 0a 61 62 6f 75 74 l treatise.about
1f90: 20 73 74 61 6e 64 61 72 64 20 63 68 61 6e 6e 65 standard channe
1fa0: 6c 73 20 61 6e 64 20 74 68 65 20 62 65 68 61 76 ls and the behav
1fb0: 69 6f 72 20 6f 66 20 74 68 65 20 54 63 6c 20 6c ior of the Tcl l
1fc0: 69 62 72 61 72 79 20 77 69 74 68 0a 72 65 67 61 ibrary with.rega
1fd0: 72 64 20 74 6f 20 74 68 65 6d 2e 0a 2e 50 50 0a rd to them...PP.
1fe0: 5c 66 42 54 63 6c 5f 47 65 74 43 68 61 6e 6e 65 \fBTcl_GetChanne
1ff0: 6c 49 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 lInstanceData\fR
2000: 20 72 65 74 75 72 6e 73 20 74 68 65 20 69 6e 73 returns the ins
2010: 74 61 6e 63 65 20 64 61 74 61 20 61 73 73 6f 63 tance data assoc
2020: 69 61 74 65 64 20 77 69 74 68 0a 74 68 65 20 63 iated with.the c
2030: 68 61 6e 6e 65 6c 20 69 6e 20 5c 66 49 63 68 61 hannel in \fIcha
2040: 6e 6e 65 6c 5c 66 52 2e 20 54 68 69 73 20 69 73 nnel\fR. This is
2050: 20 74 68 65 20 73 61 6d 65 20 61 73 20 74 68 65 the same as the
2060: 20 5c 66 49 69 6e 73 74 61 6e 63 65 44 61 74 61 \fIinstanceData
2070: 5c 66 52 0a 61 72 67 75 6d 65 6e 74 20 69 6e 20 \fR.argument in
2080: 74 68 65 20 63 61 6c 6c 20 74 6f 20 5c 66 42 54 the call to \fBT
2090: 63 6c 5f 43 72 65 61 74 65 43 68 61 6e 6e 65 6c cl_CreateChannel
20a0: 5c 66 52 20 74 68 61 74 20 63 72 65 61 74 65 64 \fR that created
20b0: 20 74 68 69 73 20 63 68 61 6e 6e 65 6c 2e 0a 2e this channel...
20c0: 50 50 0a 5c 66 42 54 63 6c 5f 47 65 74 43 68 61 PP.\fBTcl_GetCha
20d0: 6e 6e 65 6c 54 79 70 65 5c 66 52 20 72 65 74 75 nnelType\fR retu
20e0: 72 6e 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f rns a pointer to
20f0: 20 74 68 65 20 5c 66 42 54 63 6c 5f 43 68 61 6e the \fBTcl_Chan
2100: 6e 65 6c 54 79 70 65 5c 66 52 0a 73 74 72 75 63 nelType\fR.struc
2110: 74 75 72 65 20 75 73 65 64 20 62 79 20 74 68 65 ture used by the
2120: 20 63 68 61 6e 6e 65 6c 20 69 6e 20 74 68 65 20 channel in the
2130: 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 20 61 72 \fIchannel\fR ar
2140: 67 75 6d 65 6e 74 2e 20 54 68 69 73 20 69 73 0a gument. This is.
2150: 74 68 65 20 73 61 6d 65 20 61 73 20 74 68 65 20 the same as the
2160: 5c 66 49 74 79 70 65 50 74 72 5c 66 52 20 61 72 \fItypePtr\fR ar
2170: 67 75 6d 65 6e 74 20 69 6e 20 74 68 65 20 63 61 gument in the ca
2180: 6c 6c 20 74 6f 0a 5c 66 42 54 63 6c 5f 43 72 65 ll to.\fBTcl_Cre
2190: 61 74 65 43 68 61 6e 6e 65 6c 5c 66 52 20 74 68 ateChannel\fR th
21a0: 61 74 20 63 72 65 61 74 65 64 20 74 68 69 73 20 at created this
21b0: 63 68 61 6e 6e 65 6c 2e 0a 2e 50 50 0a 5c 66 42 channel...PP.\fB
21c0: 54 63 6c 5f 47 65 74 43 68 61 6e 6e 65 6c 4e 61 Tcl_GetChannelNa
21d0: 6d 65 5c 66 52 20 72 65 74 75 72 6e 73 20 61 20 me\fR returns a
21e0: 73 74 72 69 6e 67 20 63 6f 6e 74 61 69 6e 69 6e string containin
21f0: 67 20 74 68 65 20 6e 61 6d 65 20 61 73 73 6f 63 g the name assoc
2200: 69 61 74 65 64 0a 77 69 74 68 20 74 68 65 20 63 iated.with the c
2210: 68 61 6e 6e 65 6c 2c 20 6f 72 20 4e 55 4c 4c 20 hannel, or NULL
2220: 69 66 20 74 68 65 20 5c 66 49 63 68 61 6e 6e 65 if the \fIchanne
2230: 6c 4e 61 6d 65 5c 66 52 20 61 72 67 75 6d 65 6e lName\fR argumen
2240: 74 20 74 6f 0a 5c 66 42 54 63 6c 5f 43 72 65 61 t to.\fBTcl_Crea
2250: 74 65 43 68 61 6e 6e 65 6c 5c 66 52 20 77 61 73 teChannel\fR was
2260: 20 4e 55 4c 4c 2e 0a 2e 50 50 0a 5c 66 42 54 63 NULL...PP.\fBTc
2270: 6c 5f 47 65 74 43 68 61 6e 6e 65 6c 48 61 6e 64 l_GetChannelHand
2280: 6c 65 5c 66 52 20 70 6c 61 63 65 73 20 74 68 65 le\fR places the
2290: 20 4f 53 2d 73 70 65 63 69 66 69 63 20 64 65 76 OS-specific dev
22a0: 69 63 65 20 68 61 6e 64 6c 65 0a 61 73 73 6f 63 ice handle.assoc
22b0: 69 61 74 65 64 20 77 69 74 68 20 5c 66 49 63 68 iated with \fIch
22c0: 61 6e 6e 65 6c 5c 66 52 20 66 6f 72 20 74 68 65 annel\fR for the
22d0: 20 67 69 76 65 6e 20 5c 66 49 64 69 72 65 63 74 given \fIdirect
22e0: 69 6f 6e 5c 66 52 20 69 6e 20 74 68 65 0a 6c 6f ion\fR in the.lo
22f0: 63 61 74 69 6f 6e 20 73 70 65 63 69 66 69 65 64 cation specified
2300: 20 62 79 20 5c 66 49 68 61 6e 64 6c 65 50 74 72 by \fIhandlePtr
2310: 5c 66 52 20 61 6e 64 20 72 65 74 75 72 6e 73 20 \fR and returns
2320: 5c 66 42 54 43 4c 5f 4f 4b 5c 66 52 2e 20 20 49 \fBTCL_OK\fR. I
2330: 66 0a 74 68 65 20 63 68 61 6e 6e 65 6c 20 64 6f f.the channel do
2340: 65 73 20 6e 6f 74 20 68 61 76 65 20 61 20 64 65 es not have a de
2350: 76 69 63 65 20 68 61 6e 64 6c 65 20 66 6f 72 20 vice handle for
2360: 74 68 65 20 73 70 65 63 69 66 69 65 64 20 64 69 the specified di
2370: 72 65 63 74 69 6f 6e 2c 0a 74 68 65 6e 20 5c 66 rection,.then \f
2380: 42 54 43 4c 5f 45 52 52 4f 52 5c 66 52 20 69 73 BTCL_ERROR\fR is
2390: 20 72 65 74 75 72 6e 65 64 20 69 6e 73 74 65 61 returned instea
23a0: 64 2e 20 20 44 69 66 66 65 72 65 6e 74 20 63 68 d. Different ch
23b0: 61 6e 6e 65 6c 20 64 72 69 76 65 72 73 0a 77 69 annel drivers.wi
23c0: 6c 6c 20 72 65 74 75 72 6e 20 64 69 66 66 65 72 ll return differ
23d0: 65 6e 74 20 74 79 70 65 73 20 6f 66 20 68 61 6e ent types of han
23e0: 64 6c 65 2e 20 20 52 65 66 65 72 20 74 6f 20 74 dle. Refer to t
23f0: 68 65 20 6d 61 6e 75 61 6c 20 65 6e 74 72 69 65 he manual entrie
2400: 73 0a 66 6f 72 20 65 61 63 68 20 64 72 69 76 65 s.for each drive
2410: 72 20 74 6f 20 64 65 74 65 72 6d 69 6e 65 20 77 r to determine w
2420: 68 61 74 20 74 79 70 65 20 6f 66 20 68 61 6e 64 hat type of hand
2430: 6c 65 20 69 73 20 72 65 74 75 72 6e 65 64 2e 0a le is returned..
2440: 2e 50 50 0a 5c 66 42 54 63 6c 5f 47 65 74 43 68 .PP.\fBTcl_GetCh
2450: 61 6e 6e 65 6c 54 68 72 65 61 64 5c 66 52 20 72 annelThread\fR r
2460: 65 74 75 72 6e 73 20 74 68 65 20 69 64 20 6f 66 eturns the id of
2470: 20 74 68 65 20 74 68 72 65 61 64 20 63 75 72 72 the thread curr
2480: 65 6e 74 6c 79 20 6d 61 6e 61 67 69 6e 67 0a 74 ently managing.t
2490: 68 65 20 73 70 65 63 69 66 69 65 64 20 5c 66 49 he specified \fI
24a0: 63 68 61 6e 6e 65 6c 5c 66 52 2e 20 54 68 69 73 channel\fR. This
24b0: 20 61 6c 6c 6f 77 73 20 63 68 61 6e 6e 65 6c 20 allows channel
24c0: 64 72 69 76 65 72 73 20 74 6f 20 73 65 6e 64 20 drivers to send
24d0: 74 68 65 69 72 20 66 69 6c 65 0a 65 76 65 6e 74 their file.event
24e0: 73 20 74 6f 20 74 68 65 20 63 6f 72 72 65 63 74 s to the correct
24f0: 20 65 76 65 6e 74 20 71 75 65 75 65 20 65 76 65 event queue eve
2500: 6e 20 66 6f 72 20 61 20 6d 75 6c 74 69 2d 74 68 n for a multi-th
2510: 72 65 61 64 65 64 20 63 6f 72 65 2e 0a 2e 50 50 readed core...PP
2520: 0a 5c 66 42 54 63 6c 5f 47 65 74 43 68 61 6e 6e .\fBTcl_GetChann
2530: 65 6c 4d 6f 64 65 5c 66 52 20 72 65 74 75 72 6e elMode\fR return
2540: 73 20 61 6e 20 4f 52 2d 65 64 20 63 6f 6d 62 69 s an OR-ed combi
2550: 6e 61 74 69 6f 6e 20 6f 66 20 5c 66 42 54 43 4c nation of \fBTCL
2560: 5f 52 45 41 44 41 42 4c 45 5c 66 52 0a 61 6e 64 _READABLE\fR.and
2570: 20 5c 66 42 54 43 4c 5f 57 52 49 54 41 42 4c 45 \fBTCL_WRITABLE
2580: 5c 66 52 2c 20 69 6e 64 69 63 61 74 69 6e 67 20 \fR, indicating
2590: 77 68 65 74 68 65 72 20 74 68 65 20 63 68 61 6e whether the chan
25a0: 6e 65 6c 20 69 73 20 6f 70 65 6e 20 66 6f 72 20 nel is open for
25b0: 69 6e 70 75 74 0a 61 6e 64 20 6f 75 74 70 75 74 input.and output
25c0: 2e 0a 2e 50 50 0a 5c 66 42 54 63 6c 5f 47 65 74 ...PP.\fBTcl_Get
25d0: 43 68 61 6e 6e 65 6c 42 75 66 66 65 72 53 69 7a ChannelBufferSiz
25e0: 65 5c 66 52 20 72 65 74 75 72 6e 73 20 74 68 65 e\fR returns the
25f0: 20 73 69 7a 65 2c 20 69 6e 20 62 79 74 65 73 2c size, in bytes,
2600: 20 6f 66 20 62 75 66 66 65 72 73 0a 61 6c 6c 6f of buffers.allo
2610: 63 61 74 65 64 20 74 6f 20 73 74 6f 72 65 20 69 cated to store i
2620: 6e 70 75 74 20 6f 72 20 6f 75 74 70 75 74 20 69 nput or output i
2630: 6e 20 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 2e n \fIchannel\fR.
2640: 20 49 66 20 74 68 65 20 76 61 6c 75 65 20 77 61 If the value wa
2650: 73 20 6e 6f 74 20 73 65 74 0a 62 79 20 61 20 70 s not set.by a p
2660: 72 65 76 69 6f 75 73 20 63 61 6c 6c 20 74 6f 20 revious call to
2670: 5c 66 42 54 63 6c 5f 53 65 74 43 68 61 6e 6e 65 \fBTcl_SetChanne
2680: 6c 42 75 66 66 65 72 53 69 7a 65 5c 66 52 2c 20 lBufferSize\fR,
2690: 64 65 73 63 72 69 62 65 64 20 62 65 6c 6f 77 2c described below,
26a0: 20 74 68 65 6e 0a 74 68 65 20 64 65 66 61 75 6c then.the defaul
26b0: 74 20 76 61 6c 75 65 20 6f 66 20 34 30 39 36 20 t value of 4096
26c0: 69 73 20 72 65 74 75 72 6e 65 64 2e 0a 2e 50 50 is returned...PP
26d0: 0a 5c 66 42 54 63 6c 5f 53 65 74 43 68 61 6e 6e .\fBTcl_SetChann
26e0: 65 6c 42 75 66 66 65 72 53 69 7a 65 5c 66 52 20 elBufferSize\fR
26f0: 73 65 74 73 20 74 68 65 20 73 69 7a 65 2c 20 69 sets the size, i
2700: 6e 20 62 79 74 65 73 2c 20 6f 66 20 62 75 66 66 n bytes, of buff
2710: 65 72 73 20 74 68 61 74 0a 77 69 6c 6c 20 62 65 ers that.will be
2720: 20 61 6c 6c 6f 63 61 74 65 64 20 69 6e 20 73 75 allocated in su
2730: 62 73 65 71 75 65 6e 74 20 6f 70 65 72 61 74 69 bsequent operati
2740: 6f 6e 73 20 6f 6e 20 74 68 65 20 63 68 61 6e 6e ons on the chann
2750: 65 6c 20 74 6f 20 73 74 6f 72 65 20 69 6e 70 75 el to store inpu
2760: 74 20 6f 72 0a 6f 75 74 70 75 74 2e 20 54 68 65 t or.output. The
2770: 20 5c 66 49 73 69 7a 65 5c 66 52 20 61 72 67 75 \fIsize\fR argu
2780: 6d 65 6e 74 20 73 68 6f 75 6c 64 20 62 65 20 62 ment should be b
2790: 65 74 77 65 65 6e 20 6f 6e 65 20 61 6e 64 20 6f etween one and o
27a0: 6e 65 20 6d 69 6c 6c 69 6f 6e 2c 0a 61 6c 6c 6f ne million,.allo
27b0: 77 69 6e 67 20 62 75 66 66 65 72 73 20 6f 66 20 wing buffers of
27c0: 6f 6e 65 20 62 79 74 65 20 74 6f 20 6f 6e 65 20 one byte to one
27d0: 6d 69 6c 6c 69 6f 6e 20 62 79 74 65 73 2e 20 49 million bytes. I
27e0: 66 20 5c 66 49 73 69 7a 65 5c 66 52 20 69 73 0a f \fIsize\fR is.
27f0: 6f 75 74 73 69 64 65 20 74 68 69 73 20 72 61 6e outside this ran
2800: 67 65 2c 20 5c 66 42 54 63 6c 5f 53 65 74 43 68 ge, \fBTcl_SetCh
2810: 61 6e 6e 65 6c 42 75 66 66 65 72 53 69 7a 65 5c annelBufferSize\
2820: 66 52 20 73 65 74 73 20 74 68 65 20 62 75 66 66 fR sets the buff
2830: 65 72 20 73 69 7a 65 20 74 6f 0a 34 30 39 36 2e er size to.4096.
2840: 0a 2e 50 50 0a 5c 66 42 54 63 6c 5f 4e 6f 74 69 ..PP.\fBTcl_Noti
2850: 66 79 43 68 61 6e 6e 65 6c 5c 66 52 20 69 73 20 fyChannel\fR is
2860: 63 61 6c 6c 65 64 20 62 79 20 61 20 63 68 61 6e called by a chan
2870: 6e 65 6c 20 64 72 69 76 65 72 20 74 6f 20 69 6e nel driver to in
2880: 64 69 63 61 74 65 20 74 6f 0a 74 68 65 20 67 65 dicate to.the ge
2890: 6e 65 72 69 63 20 6c 61 79 65 72 20 74 68 61 74 neric layer that
28a0: 20 74 68 65 20 65 76 65 6e 74 73 20 73 70 65 63 the events spec
28b0: 69 66 69 65 64 20 62 79 20 5c 66 49 6d 61 73 6b ified by \fImask
28c0: 5c 66 52 20 68 61 76 65 0a 6f 63 63 75 72 72 65 \fR have.occurre
28d0: 64 20 6f 6e 20 74 68 65 20 63 68 61 6e 6e 65 6c d on the channel
28e0: 2e 20 20 43 68 61 6e 6e 65 6c 20 64 72 69 76 65 . Channel drive
28f0: 72 73 20 61 72 65 20 72 65 73 70 6f 6e 73 69 62 rs are responsib
2900: 6c 65 20 66 6f 72 20 69 6e 76 6f 6b 69 6e 67 0a le for invoking.
2910: 74 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 77 68 this function wh
2920: 65 6e 65 76 65 72 20 74 68 65 20 63 68 61 6e 6e enever the chann
2930: 65 6c 20 68 61 6e 64 6c 65 72 73 20 6e 65 65 64 el handlers need
2940: 20 74 6f 20 62 65 20 63 61 6c 6c 65 64 20 66 6f to be called fo
2950: 72 20 74 68 65 0a 63 68 61 6e 6e 65 6c 2e 20 20 r the.channel.
2960: 53 65 65 20 5c 66 42 57 41 54 43 48 50 52 4f 43 See \fBWATCHPROC
2970: 5c 66 52 20 62 65 6c 6f 77 20 66 6f 72 20 6d 6f \fR below for mo
2980: 72 65 20 64 65 74 61 69 6c 73 2e 0a 2e 50 50 0a re details...PP.
2990: 5c 66 42 54 63 6c 5f 42 61 64 43 68 61 6e 6e 65 \fBTcl_BadChanne
29a0: 6c 4f 70 74 69 6f 6e 5c 66 52 20 69 73 20 63 61 lOption\fR is ca
29b0: 6c 6c 65 64 20 66 72 6f 6d 20 64 72 69 76 65 72 lled from driver
29c0: 20 73 70 65 63 69 66 69 63 0a 5c 66 49 73 65 74 specific.\fIset
29d0: 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 20 6f 72 OptionProc\fR or
29e0: 20 5c 66 49 67 65 74 4f 70 74 69 6f 6e 50 72 6f \fIgetOptionPro
29f0: 63 5c 66 52 20 74 6f 20 67 65 6e 65 72 61 74 65 c\fR to generate
2a00: 20 61 20 63 6f 6d 70 6c 65 74 65 0a 65 72 72 6f a complete.erro
2a10: 72 20 6d 65 73 73 61 67 65 2e 0a 2e 50 50 0a 5c r message...PP.\
2a20: 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 42 75 66 fBTcl_ChannelBuf
2a30: 66 65 72 65 64 5c 66 52 20 72 65 74 75 72 6e 73 fered\fR returns
2a40: 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 20 62 the number of b
2a50: 79 74 65 73 20 6f 66 20 69 6e 70 75 74 0a 63 75 ytes of input.cu
2a60: 72 72 65 6e 74 6c 79 20 62 75 66 66 65 72 65 64 rrently buffered
2a70: 20 69 6e 20 74 68 65 20 69 6e 74 65 72 6e 61 6c in the internal
2a80: 20 62 75 66 66 65 72 20 28 70 75 73 68 20 62 61 buffer (push ba
2a90: 63 6b 20 61 72 65 61 29 20 6f 66 20 74 68 65 0a ck area) of the.
2aa0: 63 68 61 6e 6e 65 6c 20 69 74 73 65 6c 66 2e 20 channel itself.
2ab0: 49 74 20 64 6f 65 73 20 6e 6f 74 20 72 65 70 6f It does not repo
2ac0: 72 74 20 61 62 6f 75 74 20 74 68 65 20 64 61 74 rt about the dat
2ad0: 61 20 69 6e 20 74 68 65 20 6f 76 65 72 61 6c 6c a in the overall
2ae0: 0a 62 75 66 66 65 72 73 20 66 6f 72 20 74 68 65 .buffers for the
2af0: 20 73 74 61 63 6b 20 6f 66 20 63 68 61 6e 6e 65 stack of channe
2b00: 6c 73 20 74 68 65 20 73 75 70 70 6c 69 65 64 20 ls the supplied
2b10: 63 68 61 6e 6e 65 6c 20 69 73 20 70 61 72 74 20 channel is part
2b20: 6f 66 2e 0a 2e 50 50 0a 5c 66 42 54 63 6c 5f 49 of...PP.\fBTcl_I
2b30: 73 43 68 61 6e 6e 65 6c 53 68 61 72 65 64 5c 66 sChannelShared\f
2b40: 52 20 63 68 65 63 6b 73 20 74 68 65 20 72 65 66 R checks the ref
2b50: 63 6f 75 6e 74 20 6f 66 20 74 68 65 20 73 70 65 count of the spe
2b60: 63 69 66 69 65 64 0a 5c 66 49 63 68 61 6e 6e 65 cified.\fIchanne
2b70: 6c 5c 66 52 20 61 6e 64 20 72 65 74 75 72 6e 73 l\fR and returns
2b80: 20 77 68 65 74 68 65 72 20 74 68 65 20 5c 66 49 whether the \fI
2b90: 63 68 61 6e 6e 65 6c 5c 66 52 20 77 61 73 20 73 channel\fR was s
2ba0: 68 61 72 65 64 20 61 6d 6f 6e 67 0a 6d 75 6c 74 hared among.mult
2bb0: 69 70 6c 65 20 69 6e 74 65 72 70 72 65 74 65 72 iple interpreter
2bc0: 73 20 28 72 65 73 75 6c 74 20 3d 3d 20 31 29 20 s (result == 1)
2bd0: 6f 72 20 6e 6f 74 20 28 72 65 73 75 6c 74 20 3d or not (result =
2be0: 3d 20 30 29 2e 0a 2e 50 50 0a 5c 66 42 54 63 6c = 0)...PP.\fBTcl
2bf0: 5f 49 73 43 68 61 6e 6e 65 6c 52 65 67 69 73 74 _IsChannelRegist
2c00: 65 72 65 64 5c 66 52 20 63 68 65 63 6b 73 20 77 ered\fR checks w
2c10: 68 65 74 68 65 72 20 74 68 65 20 73 70 65 63 69 hether the speci
2c20: 66 69 65 64 20 5c 66 49 63 68 61 6e 6e 65 6c 5c fied \fIchannel\
2c30: 66 52 20 69 73 0a 72 65 67 69 73 74 65 72 65 64 fR is.registered
2c40: 20 69 6e 20 74 68 65 20 67 69 76 65 6e 20 5c 66 in the given \f
2c50: 49 69 6e 74 65 72 70 5c 66 52 72 65 74 65 72 20 Iinterp\fRreter
2c60: 28 72 65 73 75 6c 74 20 3d 3d 20 31 29 20 6f 72 (result == 1) or
2c70: 20 6e 6f 74 0a 28 72 65 73 75 6c 74 20 3d 3d 20 not.(result ==
2c80: 30 29 2e 0a 2e 50 50 0a 5c 66 42 54 63 6c 5f 49 0)...PP.\fBTcl_I
2c90: 73 43 68 61 6e 6e 65 6c 45 78 69 73 74 69 6e 67 sChannelExisting
2ca0: 5c 66 52 20 63 68 65 63 6b 73 20 77 68 65 74 68 \fR checks wheth
2cb0: 65 72 20 61 20 63 68 61 6e 6e 65 6c 20 77 69 74 er a channel wit
2cc0: 68 20 74 68 65 20 73 70 65 63 69 66 69 65 64 0a h the specified.
2cd0: 6e 61 6d 65 20 69 73 20 72 65 67 69 73 74 65 72 name is register
2ce0: 65 64 20 69 6e 20 74 68 65 20 28 74 68 72 65 61 ed in the (threa
2cf0: 64 29 2d 67 6c 6f 62 61 6c 20 6c 69 73 74 20 6f d)-global list o
2d00: 66 20 61 6c 6c 20 63 68 61 6e 6e 65 6c 73 20 28 f all channels (
2d10: 72 65 73 75 6c 74 0a 3d 3d 20 31 29 20 6f 72 20 result.== 1) or
2d20: 6e 6f 74 20 28 72 65 73 75 6c 74 20 3d 3d 20 30 not (result == 0
2d30: 29 2e 0a 2e 50 50 0a 5c 66 42 54 63 6c 5f 43 75 )...PP.\fBTcl_Cu
2d40: 74 43 68 61 6e 6e 65 6c 5c 66 52 20 72 65 6d 6f tChannel\fR remo
2d50: 76 65 73 20 74 68 65 20 73 70 65 63 69 66 69 65 ves the specifie
2d60: 64 20 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 20 d \fIchannel\fR
2d70: 66 72 6f 6d 20 74 68 65 0a 28 74 68 72 65 61 64 from the.(thread
2d80: 29 67 6c 6f 62 61 6c 20 6c 69 73 74 20 6f 66 20 )global list of
2d90: 61 6c 6c 20 63 68 61 6e 6e 65 6c 73 20 28 6f 66 all channels (of
2da0: 20 74 68 65 20 63 75 72 72 65 6e 74 20 74 68 72 the current thr
2db0: 65 61 64 29 2e 0a 41 70 70 6c 69 63 61 74 69 6f ead)..Applicatio
2dc0: 6e 20 74 6f 20 61 20 63 68 61 6e 6e 65 6c 20 73 n to a channel s
2dd0: 74 69 6c 6c 20 72 65 67 69 73 74 65 72 65 64 20 till registered
2de0: 69 6e 20 73 6f 6d 65 20 69 6e 74 65 72 70 72 65 in some interpre
2df0: 74 65 72 0a 69 73 20 6e 6f 74 20 61 6c 6c 6f 77 ter.is not allow
2e00: 65 64 2e 0a 41 6c 73 6f 20 6e 6f 74 69 66 69 65 ed..Also notifie
2e10: 73 20 74 68 65 20 64 72 69 76 65 72 20 69 66 20 s the driver if
2e20: 74 68 65 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e the \fBTcl_Chann
2e30: 65 6c 54 79 70 65 5c 66 52 20 76 65 72 73 69 6f elType\fR versio
2e40: 6e 20 69 73 0a 5c 66 42 54 43 4c 5f 43 48 41 4e n is.\fBTCL_CHAN
2e50: 4e 45 4c 5f 56 45 52 53 49 4f 4e 5f 34 5c 66 52 NEL_VERSION_4\fR
2e60: 20 28 6f 72 20 68 69 67 68 65 72 29 2c 20 61 6e (or higher), an
2e70: 64 0a 5c 66 42 54 63 6c 5f 44 72 69 76 65 72 54 d.\fBTcl_DriverT
2e80: 68 72 65 61 64 41 63 74 69 6f 6e 50 72 6f 63 5c hreadActionProc\
2e90: 66 52 20 69 73 20 64 65 66 69 6e 65 64 20 66 6f fR is defined fo
2ea0: 72 20 69 74 2e 0a 2e 50 50 0a 5c 66 42 54 63 6c r it...PP.\fBTcl
2eb0: 5f 53 70 6c 69 63 65 43 68 61 6e 6e 65 6c 5c 66 _SpliceChannel\f
2ec0: 52 20 61 64 64 73 20 74 68 65 20 73 70 65 63 69 R adds the speci
2ed0: 66 69 65 64 20 5c 66 49 63 68 61 6e 6e 65 6c 5c fied \fIchannel\
2ee0: 66 52 20 74 6f 20 74 68 65 0a 28 74 68 72 65 61 fR to the.(threa
2ef0: 64 29 67 6c 6f 62 61 6c 20 6c 69 73 74 20 6f 66 d)global list of
2f00: 20 61 6c 6c 20 63 68 61 6e 6e 65 6c 73 20 28 6f all channels (o
2f10: 66 20 74 68 65 20 63 75 72 72 65 6e 74 20 74 68 f the current th
2f20: 72 65 61 64 29 2e 0a 41 70 70 6c 69 63 61 74 69 read)..Applicati
2f30: 6f 6e 20 74 6f 20 61 20 63 68 61 6e 6e 65 6c 20 on to a channel
2f40: 72 65 67 69 73 74 65 72 65 64 20 69 6e 20 73 6f registered in so
2f50: 6d 65 20 69 6e 74 65 72 70 72 65 74 65 72 20 69 me interpreter i
2f60: 73 20 6e 6f 74 20 61 6c 6c 6f 77 65 64 2e 0a 41 s not allowed..A
2f70: 6c 73 6f 20 6e 6f 74 69 66 69 65 73 20 74 68 65 lso notifies the
2f80: 20 64 72 69 76 65 72 20 69 66 20 74 68 65 20 5c driver if the \
2f90: 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 fBTcl_ChannelTyp
2fa0: 65 5c 66 52 20 76 65 72 73 69 6f 6e 20 69 73 0a e\fR version is.
2fb0: 5c 66 42 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 \fBTCL_CHANNEL_V
2fc0: 45 52 53 49 4f 4e 5f 34 5c 66 52 20 28 6f 72 20 ERSION_4\fR (or
2fd0: 68 69 67 68 65 72 29 2c 20 61 6e 64 0a 5c 66 42 higher), and.\fB
2fe0: 54 63 6c 5f 44 72 69 76 65 72 54 68 72 65 61 64 Tcl_DriverThread
2ff0: 41 63 74 69 6f 6e 50 72 6f 63 5c 66 52 20 69 73 ActionProc\fR is
3000: 20 64 65 66 69 6e 65 64 20 66 6f 72 20 69 74 2e defined for it.
3010: 0a 2e 50 50 0a 5c 66 42 54 63 6c 5f 43 6c 65 61 ..PP.\fBTcl_Clea
3020: 72 43 68 61 6e 6e 65 6c 48 61 6e 64 6c 65 72 73 rChannelHandlers
3030: 5c 66 52 20 72 65 6d 6f 76 65 73 20 61 6c 6c 20 \fR removes all
3040: 63 68 61 6e 6e 65 6c 20 68 61 6e 64 6c 65 72 73 channel handlers
3050: 20 61 6e 64 20 65 76 65 6e 74 0a 73 63 72 69 70 and event.scrip
3060: 74 73 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 ts associated wi
3070: 74 68 20 74 68 65 20 73 70 65 63 69 66 69 65 64 th the specified
3080: 20 5c 66 49 63 68 61 6e 6e 65 6c 5c 66 52 2c 20 \fIchannel\fR,
3090: 74 68 75 73 20 73 68 75 74 74 69 6e 67 0a 64 6f thus shutting.do
30a0: 77 6e 20 61 6c 6c 20 65 76 65 6e 74 20 70 72 6f wn all event pro
30b0: 63 65 73 73 69 6e 67 20 66 6f 72 20 74 68 69 73 cessing for this
30c0: 20 63 68 61 6e 6e 65 6c 2e 0a 2e 53 48 20 54 43 channel...SH TC
30d0: 4c 5f 43 48 41 4e 4e 45 4c 54 59 50 45 0a 2e 50 L_CHANNELTYPE..P
30e0: 50 0a 41 20 63 68 61 6e 6e 65 6c 20 64 72 69 76 P.A channel driv
30f0: 65 72 20 70 72 6f 76 69 64 65 73 20 61 20 5c 66 er provides a \f
3100: 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 65 BTcl_ChannelType
3110: 5c 66 52 20 73 74 72 75 63 74 75 72 65 20 74 68 \fR structure th
3120: 61 74 20 63 6f 6e 74 61 69 6e 73 0a 70 6f 69 6e at contains.poin
3130: 74 65 72 73 20 74 6f 20 66 75 6e 63 74 69 6f 6e ters to function
3140: 73 20 74 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74 s that implement
3150: 20 74 68 65 20 76 61 72 69 6f 75 73 20 6f 70 65 the various ope
3160: 72 61 74 69 6f 6e 73 20 6f 6e 20 61 20 63 68 61 rations on a cha
3170: 6e 6e 65 6c 3b 0a 74 68 65 73 65 20 6f 70 65 72 nnel;.these oper
3180: 61 74 69 6f 6e 73 20 61 72 65 20 69 6e 76 6f 6b ations are invok
3190: 65 64 20 61 73 20 6e 65 65 64 65 64 20 62 79 20 ed as needed by
31a0: 74 68 65 20 67 65 6e 65 72 69 63 20 6c 61 79 65 the generic laye
31b0: 72 2e 20 20 54 68 65 20 73 74 72 75 63 74 75 72 r. The structur
31c0: 65 0a 77 61 73 20 76 65 72 73 69 6f 6e 65 64 20 e.was versioned
31d0: 73 74 61 72 74 69 6e 67 20 69 6e 20 54 63 6c 20 starting in Tcl
31e0: 38 2e 33 2e 32 2f 38 2e 34 20 74 6f 20 63 6f 72 8.3.2/8.4 to cor
31f0: 72 65 63 74 20 61 20 70 72 6f 62 6c 65 6d 20 77 rect a problem w
3200: 69 74 68 20 73 74 61 63 6b 65 64 0a 63 68 61 6e ith stacked.chan
3210: 6e 65 6c 20 64 72 69 76 65 72 73 2e 20 20 53 65 nel drivers. Se
3220: 65 20 74 68 65 20 5c 66 42 4f 4c 44 20 43 48 41 e the \fBOLD CHA
3230: 4e 4e 45 4c 20 54 59 50 45 53 5c 66 52 20 73 65 NNEL TYPES\fR se
3240: 63 74 69 6f 6e 20 62 65 6c 6f 77 20 66 6f 72 0a ction below for.
3250: 64 65 74 61 69 6c 73 20 61 62 6f 75 74 20 74 68 details about th
3260: 65 20 6f 6c 64 20 73 74 72 75 63 74 75 72 65 2e e old structure.
3270: 0a 2e 50 50 0a 54 68 65 20 5c 66 42 54 63 6c 5f ..PP.The \fBTcl_
3280: 43 68 61 6e 6e 65 6c 54 79 70 65 5c 66 52 20 73 ChannelType\fR s
3290: 74 72 75 63 74 75 72 65 20 63 6f 6e 74 61 69 6e tructure contain
32a0: 73 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 s the following
32b0: 66 69 65 6c 64 73 3a 0a 2e 50 50 0a 2e 43 53 0a fields:..PP..CS.
32c0: 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 54 typedef struct T
32d0: 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 65 20 7b cl_ChannelType {
32e0: 0a 20 20 20 20 20 20 20 20 63 6f 6e 73 74 20 63 . const c
32f0: 68 61 72 20 2a 5c 66 49 74 79 70 65 4e 61 6d 65 har *\fItypeName
3300: 5c 66 52 3b 0a 20 20 20 20 20 20 20 20 54 63 6c \fR;. Tcl
3310: 5f 43 68 61 6e 6e 65 6c 54 79 70 65 56 65 72 73 _ChannelTypeVers
3320: 69 6f 6e 20 5c 66 49 76 65 72 73 69 6f 6e 5c 66 ion \fIversion\f
3330: 52 3b 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 44 R;. Tcl_D
3340: 72 69 76 65 72 43 6c 6f 73 65 50 72 6f 63 20 2a riverCloseProc *
3350: 5c 66 49 63 6c 6f 73 65 50 72 6f 63 5c 66 52 3b \fIcloseProc\fR;
3360: 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 . Tcl_Dri
3370: 76 65 72 49 6e 70 75 74 50 72 6f 63 20 2a 5c 66 verInputProc *\f
3380: 49 69 6e 70 75 74 50 72 6f 63 5c 66 52 3b 0a 20 IinputProc\fR;.
3390: 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 76 65 Tcl_Drive
33a0: 72 4f 75 74 70 75 74 50 72 6f 63 20 2a 5c 66 49 rOutputProc *\fI
33b0: 6f 75 74 70 75 74 50 72 6f 63 5c 66 52 3b 0a 20 outputProc\fR;.
33c0: 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 76 65 Tcl_Drive
33d0: 72 53 65 65 6b 50 72 6f 63 20 2a 5c 66 49 73 65 rSeekProc *\fIse
33e0: 65 6b 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 20 ekProc\fR;.
33f0: 20 20 20 54 63 6c 5f 44 72 69 76 65 72 53 65 74 Tcl_DriverSet
3400: 4f 70 74 69 6f 6e 50 72 6f 63 20 2a 5c 66 49 73 OptionProc *\fIs
3410: 65 74 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 3b etOptionProc\fR;
3420: 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 . Tcl_Dri
3430: 76 65 72 47 65 74 4f 70 74 69 6f 6e 50 72 6f 63 verGetOptionProc
3440: 20 2a 5c 66 49 67 65 74 4f 70 74 69 6f 6e 50 72 *\fIgetOptionPr
3450: 6f 63 5c 66 52 3b 0a 20 20 20 20 20 20 20 20 54 oc\fR;. T
3460: 63 6c 5f 44 72 69 76 65 72 57 61 74 63 68 50 72 cl_DriverWatchPr
3470: 6f 63 20 2a 5c 66 49 77 61 74 63 68 50 72 6f 63 oc *\fIwatchProc
3480: 5c 66 52 3b 0a 20 20 20 20 20 20 20 20 54 63 6c \fR;. Tcl
3490: 5f 44 72 69 76 65 72 47 65 74 48 61 6e 64 6c 65 _DriverGetHandle
34a0: 50 72 6f 63 20 2a 5c 66 49 67 65 74 48 61 6e 64 Proc *\fIgetHand
34b0: 6c 65 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 20 leProc\fR;.
34c0: 20 20 20 54 63 6c 5f 44 72 69 76 65 72 43 6c 6f Tcl_DriverClo
34d0: 73 65 32 50 72 6f 63 20 2a 5c 66 49 63 6c 6f 73 se2Proc *\fIclos
34e0: 65 32 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 20 e2Proc\fR;.
34f0: 20 20 20 54 63 6c 5f 44 72 69 76 65 72 42 6c 6f Tcl_DriverBlo
3500: 63 6b 4d 6f 64 65 50 72 6f 63 20 2a 5c 66 49 62 ckModeProc *\fIb
3510: 6c 6f 63 6b 4d 6f 64 65 50 72 6f 63 5c 66 52 3b lockModeProc\fR;
3520: 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 . Tcl_Dri
3530: 76 65 72 46 6c 75 73 68 50 72 6f 63 20 2a 5c 66 verFlushProc *\f
3540: 49 66 6c 75 73 68 50 72 6f 63 5c 66 52 3b 0a 20 IflushProc\fR;.
3550: 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 76 65 Tcl_Drive
3560: 72 48 61 6e 64 6c 65 72 50 72 6f 63 20 2a 5c 66 rHandlerProc *\f
3570: 49 68 61 6e 64 6c 65 72 50 72 6f 63 5c 66 52 3b IhandlerProc\fR;
3580: 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 . Tcl_Dri
3590: 76 65 72 57 69 64 65 53 65 65 6b 50 72 6f 63 20 verWideSeekProc
35a0: 2a 5c 66 49 77 69 64 65 53 65 65 6b 50 72 6f 63 *\fIwideSeekProc
35b0: 5c 66 52 3b 0a 20 20 20 20 20 20 20 20 54 63 6c \fR;. Tcl
35c0: 5f 44 72 69 76 65 72 54 68 72 65 61 64 41 63 74 _DriverThreadAct
35d0: 69 6f 6e 50 72 6f 63 20 2a 5c 66 49 74 68 72 65 ionProc *\fIthre
35e0: 61 64 41 63 74 69 6f 6e 50 72 6f 63 5c 66 52 3b adActionProc\fR;
35f0: 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 44 72 69 . Tcl_Dri
3600: 76 65 72 54 72 75 6e 63 61 74 65 50 72 6f 63 20 verTruncateProc
3610: 2a 5c 66 49 74 72 75 6e 63 61 74 65 50 72 6f 63 *\fItruncateProc
3620: 5c 66 52 3b 0a 7d 20 5c 66 42 54 63 6c 5f 43 68 \fR;.} \fBTcl_Ch
3630: 61 6e 6e 65 6c 54 79 70 65 5c 66 52 3b 0a 2e 43 annelType\fR;..C
3640: 45 0a 2e 50 50 0a 49 74 20 69 73 20 6e 6f 74 20 E..PP.It is not
3650: 6e 65 63 65 73 73 61 72 79 20 74 6f 20 70 72 6f necessary to pro
3660: 76 69 64 65 20 69 6d 70 6c 65 6d 65 6e 74 61 74 vide implementat
3670: 69 6f 6e 73 20 66 6f 72 20 61 6c 6c 20 63 68 61 ions for all cha
3680: 6e 6e 65 6c 0a 6f 70 65 72 61 74 69 6f 6e 73 2e nnel.operations.
3690: 20 20 54 68 6f 73 65 20 77 68 69 63 68 20 61 72 Those which ar
36a0: 65 20 6e 6f 74 20 6e 65 63 65 73 73 61 72 79 20 e not necessary
36b0: 6d 61 79 20 62 65 20 73 65 74 20 74 6f 20 4e 55 may be set to NU
36c0: 4c 4c 20 69 6e 20 74 68 65 0a 73 74 72 75 63 74 LL in the.struct
36d0: 3a 20 5c 66 49 62 6c 6f 63 6b 4d 6f 64 65 50 72 : \fIblockModePr
36e0: 6f 63 5c 66 52 2c 20 5c 66 49 73 65 65 6b 50 72 oc\fR, \fIseekPr
36f0: 6f 63 5c 66 52 2c 20 5c 66 49 73 65 74 4f 70 74 oc\fR, \fIsetOpt
3700: 69 6f 6e 50 72 6f 63 5c 66 52 2c 0a 5c 66 49 67 ionProc\fR,.\fIg
3710: 65 74 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 2c etOptionProc\fR,
3720: 20 5c 66 49 67 65 74 48 61 6e 64 6c 65 50 72 6f \fIgetHandlePro
3730: 63 5c 66 52 2c 20 61 6e 64 20 5c 66 49 63 6c 6f c\fR, and \fIclo
3740: 73 65 32 50 72 6f 63 5c 66 52 2c 20 69 6e 20 61 se2Proc\fR, in a
3750: 64 64 69 74 69 6f 6e 20 74 6f 0a 5c 66 49 66 6c ddition to.\fIfl
3760: 75 73 68 50 72 6f 63 5c 66 52 2c 20 5c 66 49 68 ushProc\fR, \fIh
3770: 61 6e 64 6c 65 72 50 72 6f 63 5c 66 52 2c 20 5c andlerProc\fR, \
3780: 66 49 74 68 72 65 61 64 41 63 74 69 6f 6e 50 72 fIthreadActionPr
3790: 6f 63 5c 66 52 2c 20 61 6e 64 0a 5c 66 49 74 72 oc\fR, and.\fItr
37a0: 75 6e 63 61 74 65 50 72 6f 63 5c 66 52 2e 20 20 uncateProc\fR.
37b0: 4f 74 68 65 72 20 66 75 6e 63 74 69 6f 6e 73 20 Other functions
37c0: 74 68 61 74 20 63 61 6e 6e 6f 74 20 62 65 20 69 that cannot be i
37d0: 6d 70 6c 65 6d 65 6e 74 65 64 20 69 6e 20 61 0a mplemented in a.
37e0: 6d 65 61 6e 69 6e 67 66 75 6c 20 77 61 79 20 73 meaningful way s
37f0: 68 6f 75 6c 64 20 72 65 74 75 72 6e 20 5c 66 42 hould return \fB
3800: 45 49 4e 56 41 4c 5c 66 52 20 77 68 65 6e 20 63 EINVAL\fR when c
3810: 61 6c 6c 65 64 2c 20 74 6f 20 69 6e 64 69 63 61 alled, to indica
3820: 74 65 0a 74 68 61 74 20 74 68 65 20 6f 70 65 72 te.that the oper
3830: 61 74 69 6f 6e 73 20 74 68 65 79 20 72 65 70 72 ations they repr
3840: 65 73 65 6e 74 20 61 72 65 20 6e 6f 74 20 61 76 esent are not av
3850: 61 69 6c 61 62 6c 65 2e 20 41 6c 73 6f 20 6e 6f ailable. Also no
3860: 74 65 20 74 68 61 74 0a 5c 66 49 77 69 64 65 53 te that.\fIwideS
3870: 65 65 6b 50 72 6f 63 5c 66 52 20 63 61 6e 20 62 eekProc\fR can b
3880: 65 20 4e 55 4c 4c 20 69 66 20 5c 66 49 73 65 65 e NULL if \fIsee
3890: 6b 50 72 6f 63 5c 66 52 20 69 73 2e 0a 2e 50 50 kProc\fR is...PP
38a0: 0a 54 68 65 20 75 73 65 72 20 73 68 6f 75 6c 64 .The user should
38b0: 20 6f 6e 6c 79 20 75 73 65 20 74 68 65 20 61 62 only use the ab
38c0: 6f 76 65 20 73 74 72 75 63 74 75 72 65 20 66 6f ove structure fo
38d0: 72 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c r \fBTcl_Channel
38e0: 54 79 70 65 5c 66 52 0a 69 6e 73 74 61 6e 74 69 Type\fR.instanti
38f0: 61 74 69 6f 6e 2e 20 20 57 68 65 6e 20 72 65 66 ation. When ref
3900: 65 72 65 6e 63 69 6e 67 20 66 69 65 6c 64 73 20 erencing fields
3910: 69 6e 20 61 20 5c 66 42 54 63 6c 5f 43 68 61 6e in a \fBTcl_Chan
3920: 6e 65 6c 54 79 70 65 5c 66 52 0a 73 74 72 75 63 nelType\fR.struc
3930: 74 75 72 65 2c 20 74 68 65 20 66 6f 6c 6c 6f 77 ture, the follow
3940: 69 6e 67 20 66 75 6e 63 74 69 6f 6e 73 20 73 68 ing functions sh
3950: 6f 75 6c 64 20 62 65 20 75 73 65 64 20 74 6f 20 ould be used to
3960: 6f 62 74 61 69 6e 20 74 68 65 20 76 61 6c 75 65 obtain the value
3970: 73 3a 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 s:.\fBTcl_Channe
3980: 6c 4e 61 6d 65 5c 66 52 2c 20 5c 66 42 54 63 6c lName\fR, \fBTcl
3990: 5f 43 68 61 6e 6e 65 6c 56 65 72 73 69 6f 6e 5c _ChannelVersion\
39a0: 66 52 2c 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e fR,.\fBTcl_Chann
39b0: 65 6c 42 6c 6f 63 6b 4d 6f 64 65 50 72 6f 63 5c elBlockModeProc\
39c0: 66 52 2c 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e fR, \fBTcl_Chann
39d0: 65 6c 43 6c 6f 73 65 50 72 6f 63 5c 66 52 2c 0a elCloseProc\fR,.
39e0: 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 43 6c \fBTcl_ChannelCl
39f0: 6f 73 65 32 50 72 6f 63 5c 66 52 2c 20 5c 66 42 ose2Proc\fR, \fB
3a00: 54 63 6c 5f 43 68 61 6e 6e 65 6c 49 6e 70 75 74 Tcl_ChannelInput
3a10: 50 72 6f 63 5c 66 52 2c 0a 5c 66 42 54 63 6c 5f Proc\fR,.\fBTcl_
3a20: 43 68 61 6e 6e 65 6c 4f 75 74 70 75 74 50 72 6f ChannelOutputPro
3a30: 63 5c 66 52 2c 20 5c 66 42 54 63 6c 5f 43 68 61 c\fR, \fBTcl_Cha
3a40: 6e 6e 65 6c 53 65 65 6b 50 72 6f 63 5c 66 52 2c nnelSeekProc\fR,
3a50: 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 57 .\fBTcl_ChannelW
3a60: 69 64 65 53 65 65 6b 50 72 6f 63 5c 66 52 2c 20 ideSeekProc\fR,
3a70: 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 68 \fBTcl_ChannelTh
3a80: 72 65 61 64 41 63 74 69 6f 6e 50 72 6f 63 5c 66 readActionProc\f
3a90: 52 2c 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 R,.\fBTcl_Channe
3aa0: 6c 54 72 75 6e 63 61 74 65 50 72 6f 63 5c 66 52 lTruncateProc\fR
3ab0: 2c 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c ,.\fBTcl_Channel
3ac0: 53 65 74 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 SetOptionProc\fR
3ad0: 2c 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c , \fBTcl_Channel
3ae0: 47 65 74 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 GetOptionProc\fR
3af0: 2c 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c ,.\fBTcl_Channel
3b00: 57 61 74 63 68 50 72 6f 63 5c 66 52 2c 20 5c 66 WatchProc\fR, \f
3b10: 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 47 65 74 48 BTcl_ChannelGetH
3b20: 61 6e 64 6c 65 50 72 6f 63 5c 66 52 2c 0a 5c 66 andleProc\fR,.\f
3b30: 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 46 6c 75 73 BTcl_ChannelFlus
3b40: 68 50 72 6f 63 5c 66 52 2c 20 6f 72 20 5c 66 42 hProc\fR, or \fB
3b50: 54 63 6c 5f 43 68 61 6e 6e 65 6c 48 61 6e 64 6c Tcl_ChannelHandl
3b60: 65 72 50 72 6f 63 5c 66 52 2e 0a 2e 50 50 0a 54 erProc\fR...PP.T
3b70: 68 65 20 63 68 61 6e 67 65 20 74 6f 20 74 68 65 he change to the
3b80: 20 73 74 72 75 63 74 75 72 65 73 20 77 61 73 20 structures was
3b90: 6d 61 64 65 20 69 6e 20 73 75 63 68 20 61 20 77 made in such a w
3ba0: 61 79 20 74 68 61 74 20 73 74 61 6e 64 61 72 64 ay that standard
3bb0: 20 63 68 61 6e 6e 65 6c 0a 74 79 70 65 73 20 61 channel.types a
3bc0: 72 65 20 62 69 6e 61 72 79 20 63 6f 6d 70 61 74 re binary compat
3bd0: 69 62 6c 65 2e 20 20 48 6f 77 65 76 65 72 2c 20 ible. However,
3be0: 63 68 61 6e 6e 65 6c 20 74 79 70 65 73 20 74 68 channel types th
3bf0: 61 74 20 75 73 65 20 73 74 61 63 6b 65 64 0a 63 at use stacked.c
3c00: 68 61 6e 6e 65 6c 73 20 28 69 2e 65 2e 20 54 4c hannels (i.e. TL
3c10: 53 2c 20 54 72 66 29 20 68 61 76 65 20 6e 65 77 S, Trf) have new
3c20: 20 76 65 72 73 69 6f 6e 73 20 74 6f 20 63 6f 72 versions to cor
3c30: 72 65 73 70 6f 6e 64 20 74 6f 20 74 68 65 20 61 respond to the a
3c40: 62 6f 76 65 20 63 68 61 6e 67 65 0a 73 69 6e 63 bove change.sinc
3c50: 65 20 74 68 65 20 70 72 65 76 69 6f 75 73 20 63 e the previous c
3c60: 6f 64 65 20 66 6f 72 20 73 74 61 63 6b 65 64 20 ode for stacked
3c70: 63 68 61 6e 6e 65 6c 73 20 68 61 64 20 70 72 6f channels had pro
3c80: 62 6c 65 6d 73 2e 0a 2e 53 53 20 54 59 50 45 4e blems...SS TYPEN
3c90: 41 4d 45 0a 2e 50 50 0a 54 68 65 20 5c 66 49 74 AME..PP.The \fIt
3ca0: 79 70 65 4e 61 6d 65 5c 66 52 20 66 69 65 6c 64 ypeName\fR field
3cb0: 20 63 6f 6e 74 61 69 6e 73 20 61 20 6e 75 6c 6c contains a null
3cc0: 2d 74 65 72 6d 69 6e 61 74 65 64 20 73 74 72 69 -terminated stri
3cd0: 6e 67 20 74 68 61 74 0a 69 64 65 6e 74 69 66 69 ng that.identifi
3ce0: 65 73 20 74 68 65 20 74 79 70 65 20 6f 66 20 74 es the type of t
3cf0: 68 65 20 64 65 76 69 63 65 20 69 6d 70 6c 65 6d he device implem
3d00: 65 6e 74 65 64 20 62 79 20 74 68 69 73 20 64 72 ented by this dr
3d10: 69 76 65 72 2c 20 65 2e 67 2e 0a 5c 66 42 66 69 iver, e.g..\fBfi
3d20: 6c 65 5c 66 52 20 6f 72 20 5c 66 42 73 6f 63 6b le\fR or \fBsock
3d30: 65 74 5c 66 52 2e 0a 2e 50 50 0a 54 68 69 73 20 et\fR...PP.This
3d40: 76 61 6c 75 65 20 63 61 6e 20 62 65 20 72 65 74 value can be ret
3d50: 72 69 65 76 65 64 20 77 69 74 68 20 5c 66 42 54 rieved with \fBT
3d60: 63 6c 5f 43 68 61 6e 6e 65 6c 4e 61 6d 65 5c 66 cl_ChannelName\f
3d70: 52 2c 20 77 68 69 63 68 20 72 65 74 75 72 6e 73 R, which returns
3d80: 0a 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 .a pointer to th
3d90: 65 20 73 74 72 69 6e 67 2e 0a 2e 53 53 20 56 45 e string...SS VE
3da0: 52 53 49 4f 4e 0a 2e 50 50 0a 0a 54 68 65 20 5c RSION..PP..The \
3db0: 66 49 76 65 72 73 69 6f 6e 5c 66 52 20 66 69 65 fIversion\fR fie
3dc0: 6c 64 20 73 68 6f 75 6c 64 20 62 65 20 73 65 74 ld should be set
3dd0: 20 74 6f 20 74 68 65 20 76 65 72 73 69 6f 6e 20 to the version
3de0: 6f 66 20 74 68 65 20 73 74 72 75 63 74 75 72 65 of the structure
3df0: 0a 74 68 61 74 20 79 6f 75 20 72 65 71 75 69 72 .that you requir
3e00: 65 2e 20 5c 66 42 54 43 4c 5f 43 48 41 4e 4e 45 e. \fBTCL_CHANNE
3e10: 4c 5f 56 45 52 53 49 4f 4e 5f 32 5c 66 52 20 69 L_VERSION_2\fR i
3e20: 73 20 74 68 65 20 6d 69 6e 69 6d 75 6d 20 72 65 s the minimum re
3e30: 63 6f 6d 6d 65 6e 64 65 64 2e 0a 5c 66 42 54 43 commended..\fBTC
3e40: 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 49 4f L_CHANNEL_VERSIO
3e50: 4e 5f 33 5c 66 52 20 6d 75 73 74 20 62 65 20 73 N_3\fR must be s
3e60: 65 74 20 74 6f 20 73 70 65 63 69 66 79 20 74 68 et to specify th
3e70: 65 20 5c 66 49 77 69 64 65 53 65 65 6b 50 72 6f e \fIwideSeekPro
3e80: 63 5c 66 52 20 6d 65 6d 62 65 72 2e 0a 5c 66 42 c\fR member..\fB
3e90: 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 TCL_CHANNEL_VERS
3ea0: 49 4f 4e 5f 34 5c 66 52 20 6d 75 73 74 20 62 65 ION_4\fR must be
3eb0: 20 73 65 74 20 74 6f 20 73 70 65 63 69 66 79 20 set to specify
3ec0: 74 68 65 20 5c 66 49 74 68 72 65 61 64 41 63 74 the \fIthreadAct
3ed0: 69 6f 6e 50 72 6f 63 5c 66 52 20 6d 65 6d 62 65 ionProc\fR membe
3ee0: 72 0a 28 69 6e 63 6c 75 64 65 73 20 5c 66 49 77 r.(includes \fIw
3ef0: 69 64 65 53 65 65 6b 50 72 6f 63 5c 66 52 29 2e ideSeekProc\fR).
3f00: 0a 5c 66 42 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f .\fBTCL_CHANNEL_
3f10: 56 45 52 53 49 4f 4e 5f 35 5c 66 52 20 6d 75 73 VERSION_5\fR mus
3f20: 74 20 62 65 20 73 65 74 20 74 6f 20 73 70 65 63 t be set to spec
3f30: 69 66 79 20 74 68 65 0a 5c 66 49 74 72 75 6e 63 ify the.\fItrunc
3f40: 61 74 65 50 72 6f 63 5c 66 52 20 6d 65 6d 62 65 ateProc\fR membe
3f50: 72 73 20 28 69 6e 63 6c 75 64 65 73 0a 5c 66 49 rs (includes.\fI
3f60: 77 69 64 65 53 65 65 6b 50 72 6f 63 5c 66 52 20 wideSeekProc\fR
3f70: 61 6e 64 20 5c 66 49 74 68 72 65 61 64 41 63 74 and \fIthreadAct
3f80: 69 6f 6e 50 72 6f 63 5c 66 52 29 2e 0a 49 66 20 ionProc\fR)..If
3f90: 69 74 20 69 73 20 6e 6f 74 20 73 65 74 20 74 6f it is not set to
3fa0: 20 61 6e 79 20 6f 66 20 74 68 65 73 65 2c 20 74 any of these, t
3fb0: 68 65 6e 20 74 68 69 73 0a 5c 66 42 54 63 6c 5f hen this.\fBTcl_
3fc0: 43 68 61 6e 6e 65 6c 54 79 70 65 5c 66 52 20 69 ChannelType\fR i
3fd0: 73 20 61 73 73 75 6d 65 64 20 74 6f 20 68 61 76 s assumed to hav
3fe0: 65 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 73 e the original s
3ff0: 74 72 75 63 74 75 72 65 2e 20 20 53 65 65 0a 5c tructure. See.\
4000: 66 42 4f 4c 44 20 43 48 41 4e 4e 45 4c 20 54 59 fBOLD CHANNEL TY
4010: 50 45 53 5c 66 52 20 66 6f 72 20 6d 6f 72 65 20 PES\fR for more
4020: 64 65 74 61 69 6c 73 2e 20 20 57 68 69 6c 65 20 details. While
4030: 54 63 6c 20 77 69 6c 6c 20 72 65 63 6f 67 6e 69 Tcl will recogni
4040: 7a 65 0a 61 6e 64 20 66 75 6e 63 74 69 6f 6e 20 ze.and function
4050: 77 69 74 68 20 65 69 74 68 65 72 20 73 74 72 75 with either stru
4060: 63 74 75 72 65 73 2c 20 73 74 61 63 6b 65 64 20 ctures, stacked
4070: 63 68 61 6e 6e 65 6c 73 20 6d 75 73 74 20 62 65 channels must be
4080: 20 6f 66 20 61 74 0a 6c 65 61 73 74 20 5c 66 42 of at.least \fB
4090: 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 TCL_CHANNEL_VERS
40a0: 49 4f 4e 5f 32 5c 66 52 20 74 6f 20 66 75 6e 63 ION_2\fR to func
40b0: 74 69 6f 6e 20 63 6f 72 72 65 63 74 6c 79 2e 0a tion correctly..
40c0: 2e 50 50 0a 54 68 69 73 20 76 61 6c 75 65 20 63 .PP.This value c
40d0: 61 6e 20 62 65 20 72 65 74 72 69 65 76 65 64 20 an be retrieved
40e0: 77 69 74 68 20 5c 66 42 54 63 6c 5f 43 68 61 6e with \fBTcl_Chan
40f0: 6e 65 6c 56 65 72 73 69 6f 6e 5c 66 52 2c 20 77 nelVersion\fR, w
4100: 68 69 63 68 20 72 65 74 75 72 6e 73 0a 6f 6e 65 hich returns.one
4110: 20 6f 66 0a 5c 66 42 54 43 4c 5f 43 48 41 4e 4e of.\fBTCL_CHANN
4120: 45 4c 5f 56 45 52 53 49 4f 4e 5f 35 5c 66 52 2c EL_VERSION_5\fR,
4130: 0a 5c 66 42 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f .\fBTCL_CHANNEL_
4140: 56 45 52 53 49 4f 4e 5f 34 5c 66 52 2c 0a 5c 66 VERSION_4\fR,.\f
4150: 42 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 BTCL_CHANNEL_VER
4160: 53 49 4f 4e 5f 33 5c 66 52 2c 0a 5c 66 42 54 43 SION_3\fR,.\fBTC
4170: 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 49 4f L_CHANNEL_VERSIO
4180: 4e 5f 32 5c 66 52 20 6f 72 20 5c 66 42 54 43 4c N_2\fR or \fBTCL
4190: 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 49 4f 4e _CHANNEL_VERSION
41a0: 5f 31 5c 66 52 2e 0a 2e 53 53 20 42 4c 4f 43 4b _1\fR...SS BLOCK
41b0: 4d 4f 44 45 50 52 4f 43 0a 2e 50 50 0a 54 68 65 MODEPROC..PP.The
41c0: 20 5c 66 49 62 6c 6f 63 6b 4d 6f 64 65 50 72 6f \fIblockModePro
41d0: 63 5c 66 52 20 66 69 65 6c 64 20 63 6f 6e 74 61 c\fR field conta
41e0: 69 6e 73 20 74 68 65 20 61 64 64 72 65 73 73 20 ins the address
41f0: 6f 66 20 61 20 66 75 6e 63 74 69 6f 6e 20 63 61 of a function ca
4200: 6c 6c 65 64 20 62 79 0a 74 68 65 20 67 65 6e 65 lled by.the gene
4210: 72 69 63 20 6c 61 79 65 72 20 74 6f 20 73 65 74 ric layer to set
4220: 20 62 6c 6f 63 6b 69 6e 67 20 61 6e 64 20 6e 6f blocking and no
4230: 6e 62 6c 6f 63 6b 69 6e 67 20 6d 6f 64 65 20 6f nblocking mode o
4240: 6e 20 74 68 65 20 64 65 76 69 63 65 2e 0a 5c 66 n the device..\f
4250: 49 42 6c 6f 63 6b 4d 6f 64 65 50 72 6f 63 5c 66 IBlockModeProc\f
4260: 52 20 73 68 6f 75 6c 64 20 6d 61 74 63 68 20 74 R should match t
4270: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 70 72 6f he following pro
4280: 74 6f 74 79 70 65 3a 0a 2e 50 50 0a 2e 43 53 0a totype:..PP..CS.
4290: 74 79 70 65 64 65 66 20 69 6e 74 20 5c 66 42 54 typedef int \fBT
42a0: 63 6c 5f 44 72 69 76 65 72 42 6c 6f 63 6b 4d 6f cl_DriverBlockMo
42b0: 64 65 50 72 6f 63 5c 66 52 28 0a 20 20 20 20 20 deProc\fR(.
42c0: 20 20 20 43 6c 69 65 6e 74 44 61 74 61 20 5c 66 ClientData \f
42d0: 49 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 IinstanceData\fR
42e0: 2c 0a 20 20 20 20 20 20 20 20 69 6e 74 20 5c 66 ,. int \f
42f0: 49 6d 6f 64 65 5c 66 52 29 3b 0a 2e 43 45 0a 2e Imode\fR);..CE..
4300: 50 50 0a 54 68 65 20 5c 66 49 69 6e 73 74 61 6e PP.The \fIinstan
4310: 63 65 44 61 74 61 5c 66 52 20 69 73 20 74 68 65 ceData\fR is the
4320: 20 73 61 6d 65 20 61 73 20 74 68 65 20 76 61 6c same as the val
4330: 75 65 20 70 61 73 73 65 64 20 74 6f 0a 5c 66 42 ue passed to.\fB
4340: 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e 6e 65 Tcl_CreateChanne
4350: 6c 5c 66 52 20 77 68 65 6e 20 74 68 69 73 20 63 l\fR when this c
4360: 68 61 6e 6e 65 6c 20 77 61 73 20 63 72 65 61 74 hannel was creat
4370: 65 64 2e 20 20 54 68 65 20 5c 66 49 6d 6f 64 65 ed. The \fImode
4380: 5c 66 52 0a 61 72 67 75 6d 65 6e 74 20 69 73 20 \fR.argument is
4390: 65 69 74 68 65 72 20 5c 66 42 54 43 4c 5f 4d 4f either \fBTCL_MO
43a0: 44 45 5f 42 4c 4f 43 4b 49 4e 47 5c 66 52 20 6f DE_BLOCKING\fR o
43b0: 72 20 5c 66 42 54 43 4c 5f 4d 4f 44 45 5f 4e 4f r \fBTCL_MODE_NO
43c0: 4e 42 4c 4f 43 4b 49 4e 47 5c 66 52 20 74 6f 0a NBLOCKING\fR to.
43d0: 73 65 74 20 74 68 65 20 64 65 76 69 63 65 20 69 set the device i
43e0: 6e 74 6f 20 62 6c 6f 63 6b 69 6e 67 20 6f 72 20 nto blocking or
43f0: 6e 6f 6e 62 6c 6f 63 6b 69 6e 67 20 6d 6f 64 65 nonblocking mode
4400: 2e 20 54 68 65 20 66 75 6e 63 74 69 6f 6e 20 73 . The function s
4410: 68 6f 75 6c 64 0a 72 65 74 75 72 6e 20 7a 65 72 hould.return zer
4420: 6f 20 69 66 20 74 68 65 20 6f 70 65 72 61 74 69 o if the operati
4430: 6f 6e 20 77 61 73 20 73 75 63 63 65 73 73 66 75 on was successfu
4440: 6c 2c 20 6f 72 20 61 20 6e 6f 6e 7a 65 72 6f 20 l, or a nonzero
4450: 50 4f 53 49 58 20 65 72 72 6f 72 20 63 6f 64 65 POSIX error code
4460: 0a 69 66 20 74 68 65 20 6f 70 65 72 61 74 69 6f .if the operatio
4470: 6e 20 66 61 69 6c 65 64 2e 0a 2e 50 50 0a 49 66 n failed...PP.If
4480: 20 74 68 65 20 6f 70 65 72 61 74 69 6f 6e 20 69 the operation i
4490: 73 20 73 75 63 63 65 73 73 66 75 6c 2c 20 74 68 s successful, th
44a0: 65 20 66 75 6e 63 74 69 6f 6e 20 63 61 6e 20 6d e function can m
44b0: 6f 64 69 66 79 20 74 68 65 20 73 75 70 70 6c 69 odify the suppli
44c0: 65 64 0a 5c 66 49 69 6e 73 74 61 6e 63 65 44 61 ed.\fIinstanceDa
44d0: 74 61 5c 66 52 20 74 6f 20 72 65 63 6f 72 64 20 ta\fR to record
44e0: 74 68 61 74 20 74 68 65 20 63 68 61 6e 6e 65 6c that the channel
44f0: 20 65 6e 74 65 72 65 64 20 62 6c 6f 63 6b 69 6e entered blockin
4500: 67 20 6f 72 0a 6e 6f 6e 62 6c 6f 63 6b 69 6e 67 g or.nonblocking
4510: 20 6d 6f 64 65 20 61 6e 64 20 74 6f 20 69 6d 70 mode and to imp
4520: 6c 65 6d 65 6e 74 20 74 68 65 20 62 6c 6f 63 6b lement the block
4530: 69 6e 67 20 6f 72 20 6e 6f 6e 62 6c 6f 63 6b 69 ing or nonblocki
4540: 6e 67 20 62 65 68 61 76 69 6f 72 2e 0a 46 6f 72 ng behavior..For
4550: 20 73 6f 6d 65 20 64 65 76 69 63 65 20 74 79 70 some device typ
4560: 65 73 2c 20 74 68 65 20 62 6c 6f 63 6b 69 6e 67 es, the blocking
4570: 20 61 6e 64 20 6e 6f 6e 62 6c 6f 63 6b 69 6e 67 and nonblocking
4580: 20 62 65 68 61 76 69 6f 72 20 63 61 6e 20 62 65 behavior can be
4590: 0a 69 6d 70 6c 65 6d 65 6e 74 65 64 20 62 79 20 .implemented by
45a0: 74 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 20 6f the underlying o
45b0: 70 65 72 61 74 69 6e 67 20 73 79 73 74 65 6d 3b perating system;
45c0: 20 66 6f 72 20 6f 74 68 65 72 20 64 65 76 69 63 for other devic
45d0: 65 20 74 79 70 65 73 2c 20 74 68 65 0a 62 65 68 e types, the.beh
45e0: 61 76 69 6f 72 20 6d 75 73 74 20 62 65 20 65 6d avior must be em
45f0: 75 6c 61 74 65 64 20 69 6e 20 74 68 65 20 63 68 ulated in the ch
4600: 61 6e 6e 65 6c 20 64 72 69 76 65 72 2e 0a 2e 50 annel driver...P
4610: 50 0a 54 68 69 73 20 76 61 6c 75 65 20 63 61 6e P.This value can
4620: 20 62 65 20 72 65 74 72 69 65 76 65 64 20 77 69 be retrieved wi
4630: 74 68 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 th \fBTcl_Channe
4640: 6c 42 6c 6f 63 6b 4d 6f 64 65 50 72 6f 63 5c 66 lBlockModeProc\f
4650: 52 2c 20 77 68 69 63 68 20 72 65 74 75 72 6e 73 R, which returns
4660: 0a 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 .a pointer to th
4670: 65 20 66 75 6e 63 74 69 6f 6e 2e 0a 2e 50 50 0a e function...PP.
4680: 41 20 63 68 61 6e 6e 65 6c 20 64 72 69 76 65 72 A channel driver
4690: 20 5c 66 42 6e 6f 74 5c 66 52 20 73 75 70 70 6c \fBnot\fR suppl
46a0: 79 69 6e 67 20 61 20 5c 66 49 62 6c 6f 63 6b 4d ying a \fIblockM
46b0: 6f 64 65 50 72 6f 63 5c 66 52 20 68 61 73 20 74 odeProc\fR has t
46c0: 6f 20 62 65 0a 76 65 72 79 2c 20 76 65 72 79 20 o be.very, very
46d0: 63 61 72 65 66 75 6c 2e 20 49 74 20 68 61 73 20 careful. It has
46e0: 74 6f 20 74 65 6c 6c 20 74 68 65 20 67 65 6e 65 to tell the gene
46f0: 72 69 63 20 6c 61 79 65 72 20 65 78 61 63 74 6c ric layer exactl
4700: 79 20 77 68 69 63 68 0a 62 6c 6f 63 6b 69 6e 67 y which.blocking
4710: 20 6d 6f 64 65 20 69 73 20 61 63 63 65 70 74 61 mode is accepta
4720: 62 6c 65 20 74 6f 20 69 74 2c 20 61 6e 64 20 73 ble to it, and s
4730: 68 6f 75 6c 64 20 74 68 69 73 20 61 6c 73 6f 20 hould this also
4740: 64 6f 63 75 6d 65 6e 74 20 66 6f 72 0a 74 68 65 document for.the
4750: 20 75 73 65 72 20 73 6f 20 74 68 61 74 20 74 68 user so that th
4760: 65 20 62 6c 6f 63 6b 69 6e 67 20 6d 6f 64 65 20 e blocking mode
4770: 6f 66 20 74 68 65 20 63 68 61 6e 6e 65 6c 20 69 of the channel i
4780: 73 20 6e 6f 74 20 63 68 61 6e 67 65 64 20 74 6f s not changed to
4790: 20 61 6e 0a 75 6e 61 63 63 65 70 74 61 62 6c 65 an.unacceptable
47a0: 20 76 61 6c 75 65 2e 20 41 6e 79 20 63 6f 6e 66 value. Any conf
47b0: 75 73 69 6f 6e 20 68 65 72 65 20 6d 61 79 20 6c usion here may l
47c0: 65 61 64 20 74 68 65 20 69 6e 74 65 72 70 72 65 ead the interpre
47d0: 74 65 72 20 69 6e 74 6f 20 61 0a 28 73 70 75 72 ter into a.(spur
47e0: 69 6f 75 73 20 61 6e 64 20 64 69 66 66 69 63 75 ious and difficu
47f0: 6c 74 20 74 6f 20 66 69 6e 64 29 20 64 65 61 64 lt to find) dead
4800: 6c 6f 63 6b 2e 0a 2e 53 53 20 22 43 4c 4f 53 45 lock...SS "CLOSE
4810: 50 52 4f 43 20 41 4e 44 20 43 4c 4f 53 45 32 50 PROC AND CLOSE2P
4820: 52 4f 43 22 0a 2e 50 50 0a 54 68 65 20 5c 66 49 ROC"..PP.The \fI
4830: 63 6c 6f 73 65 50 72 6f 63 5c 66 52 20 66 69 65 closeProc\fR fie
4840: 6c 64 20 63 6f 6e 74 61 69 6e 73 20 74 68 65 20 ld contains the
4850: 61 64 64 72 65 73 73 20 6f 66 20 61 20 66 75 6e address of a fun
4860: 63 74 69 6f 6e 20 63 61 6c 6c 65 64 20 62 79 20 ction called by
4870: 74 68 65 0a 67 65 6e 65 72 69 63 20 6c 61 79 65 the.generic laye
4880: 72 20 74 6f 20 63 6c 65 61 6e 20 75 70 20 64 72 r to clean up dr
4890: 69 76 65 72 2d 72 65 6c 61 74 65 64 20 69 6e 66 iver-related inf
48a0: 6f 72 6d 61 74 69 6f 6e 20 77 68 65 6e 20 74 68 ormation when th
48b0: 65 20 63 68 61 6e 6e 65 6c 20 69 73 0a 63 6c 6f e channel is.clo
48c0: 73 65 64 2e 20 5c 66 49 43 6c 6f 73 65 50 72 6f sed. \fIClosePro
48d0: 63 5c 66 52 20 6d 75 73 74 20 6d 61 74 63 68 20 c\fR must match
48e0: 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 70 72 the following pr
48f0: 6f 74 6f 74 79 70 65 3a 0a 2e 50 50 0a 2e 43 53 ototype:..PP..CS
4900: 0a 74 79 70 65 64 65 66 20 69 6e 74 20 5c 66 42 .typedef int \fB
4910: 54 63 6c 5f 44 72 69 76 65 72 43 6c 6f 73 65 50 Tcl_DriverCloseP
4920: 72 6f 63 5c 66 52 28 0a 20 20 20 20 20 20 20 20 roc\fR(.
4930: 43 6c 69 65 6e 74 44 61 74 61 20 5c 66 49 69 6e ClientData \fIin
4940: 73 74 61 6e 63 65 44 61 74 61 5c 66 52 2c 0a 20 stanceData\fR,.
4950: 20 20 20 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 Tcl_Inter
4960: 70 20 2a 5c 66 49 69 6e 74 65 72 70 5c 66 52 29 p *\fIinterp\fR)
4970: 3b 0a 2e 43 45 0a 2e 50 50 0a 54 68 65 20 5c 66 ;..CE..PP.The \f
4980: 49 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 IinstanceData\fR
4990: 20 61 72 67 75 6d 65 6e 74 20 69 73 20 74 68 65 argument is the
49a0: 20 73 61 6d 65 20 61 73 20 74 68 65 20 76 61 6c same as the val
49b0: 75 65 20 70 72 6f 76 69 64 65 64 20 74 6f 0a 5c ue provided to.\
49c0: 66 42 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e fBTcl_CreateChan
49d0: 6e 65 6c 5c 66 52 20 77 68 65 6e 20 74 68 65 20 nel\fR when the
49e0: 63 68 61 6e 6e 65 6c 20 77 61 73 20 63 72 65 61 channel was crea
49f0: 74 65 64 2e 20 54 68 65 20 66 75 6e 63 74 69 6f ted. The functio
4a00: 6e 20 73 68 6f 75 6c 64 0a 72 65 6c 65 61 73 65 n should.release
4a10: 20 61 6e 79 20 73 74 6f 72 61 67 65 20 6d 61 69 any storage mai
4a20: 6e 74 61 69 6e 65 64 20 62 79 20 74 68 65 20 63 ntained by the c
4a30: 68 61 6e 6e 65 6c 20 64 72 69 76 65 72 20 66 6f hannel driver fo
4a40: 72 20 74 68 69 73 20 63 68 61 6e 6e 65 6c 2c 20 r this channel,
4a50: 61 6e 64 0a 63 6c 6f 73 65 20 74 68 65 20 69 6e and.close the in
4a60: 70 75 74 20 61 6e 64 20 6f 75 74 70 75 74 20 64 put and output d
4a70: 65 76 69 63 65 73 20 65 6e 63 61 70 73 75 6c 61 evices encapsula
4a80: 74 65 64 20 62 79 20 74 68 69 73 20 63 68 61 6e ted by this chan
4a90: 6e 65 6c 2e 20 41 6c 6c 20 71 75 65 75 65 64 0a nel. All queued.
4aa0: 6f 75 74 70 75 74 20 77 69 6c 6c 20 68 61 76 65 output will have
4ab0: 20 62 65 65 6e 20 66 6c 75 73 68 65 64 20 74 6f been flushed to
4ac0: 20 74 68 65 20 64 65 76 69 63 65 20 62 65 66 6f the device befo
4ad0: 72 65 20 74 68 69 73 20 66 75 6e 63 74 69 6f 6e re this function
4ae0: 20 69 73 20 63 61 6c 6c 65 64 2c 0a 61 6e 64 20 is called,.and
4af0: 6e 6f 20 66 75 72 74 68 65 72 20 64 72 69 76 65 no further drive
4b00: 72 20 6f 70 65 72 61 74 69 6f 6e 73 20 77 69 6c r operations wil
4b10: 6c 20 62 65 20 69 6e 76 6f 6b 65 64 20 6f 6e 20 l be invoked on
4b20: 74 68 69 73 20 69 6e 73 74 61 6e 63 65 20 61 66 this instance af
4b30: 74 65 72 0a 63 61 6c 6c 69 6e 67 20 74 68 65 20 ter.calling the
4b40: 5c 66 49 63 6c 6f 73 65 50 72 6f 63 5c 66 52 2e \fIcloseProc\fR.
4b50: 20 49 66 20 74 68 65 20 63 6c 6f 73 65 20 6f 70 If the close op
4b60: 65 72 61 74 69 6f 6e 20 69 73 20 73 75 63 63 65 eration is succe
4b70: 73 73 66 75 6c 2c 20 74 68 65 0a 70 72 6f 63 65 ssful, the.proce
4b80: 64 75 72 65 20 73 68 6f 75 6c 64 20 72 65 74 75 dure should retu
4b90: 72 6e 20 7a 65 72 6f 3b 20 6f 74 68 65 72 77 69 rn zero; otherwi
4ba0: 73 65 20 69 74 20 73 68 6f 75 6c 64 20 72 65 74 se it should ret
4bb0: 75 72 6e 20 61 20 6e 6f 6e 7a 65 72 6f 20 50 4f urn a nonzero PO
4bc0: 53 49 58 0a 65 72 72 6f 72 20 63 6f 64 65 2e 20 SIX.error code.
4bd0: 49 6e 20 61 64 64 69 74 69 6f 6e 2c 20 69 66 20 In addition, if
4be0: 61 6e 20 65 72 72 6f 72 20 6f 63 63 75 72 73 20 an error occurs
4bf0: 61 6e 64 20 5c 66 49 69 6e 74 65 72 70 5c 66 52 and \fIinterp\fR
4c00: 20 69 73 20 6e 6f 74 20 4e 55 4c 4c 2c 0a 74 68 is not NULL,.th
4c10: 65 20 70 72 6f 63 65 64 75 72 65 20 73 68 6f 75 e procedure shou
4c20: 6c 64 20 73 74 6f 72 65 20 61 6e 20 65 72 72 6f ld store an erro
4c30: 72 20 6d 65 73 73 61 67 65 20 69 6e 20 74 68 65 r message in the
4c40: 20 69 6e 74 65 72 70 72 65 74 65 72 27 73 20 72 interpreter's r
4c50: 65 73 75 6c 74 2e 0a 2e 50 50 0a 41 6c 74 65 72 esult...PP.Alter
4c60: 6e 61 74 69 76 65 6c 79 2c 20 63 68 61 6e 6e 65 natively, channe
4c70: 6c 73 20 74 68 61 74 20 73 75 70 70 6f 72 74 20 ls that support
4c80: 63 6c 6f 73 69 6e 67 20 74 68 65 20 72 65 61 64 closing the read
4c90: 20 61 6e 64 20 77 72 69 74 65 20 73 69 64 65 73 and write sides
4ca0: 0a 69 6e 64 65 70 65 6e 64 65 6e 74 6c 79 20 6d .independently m
4cb0: 61 79 20 73 65 74 20 5c 66 49 63 6c 6f 73 65 50 ay set \fIcloseP
4cc0: 72 6f 63 5c 66 52 20 74 6f 20 5c 66 42 54 43 4c roc\fR to \fBTCL
4cd0: 5f 43 4c 4f 53 45 32 50 52 4f 43 5c 66 52 20 61 _CLOSE2PROC\fR a
4ce0: 6e 64 20 73 65 74 0a 5c 66 49 63 6c 6f 73 65 32 nd set.\fIclose2
4cf0: 50 72 6f 63 5c 66 52 20 74 6f 20 74 68 65 20 61 Proc\fR to the a
4d00: 64 64 72 65 73 73 20 6f 66 20 61 20 66 75 6e 63 ddress of a func
4d10: 74 69 6f 6e 20 74 68 61 74 20 6d 61 74 63 68 65 tion that matche
4d20: 73 20 74 68 65 0a 66 6f 6c 6c 6f 77 69 6e 67 20 s the.following
4d30: 70 72 6f 74 6f 74 79 70 65 3a 0a 2e 50 50 0a 2e prototype:..PP..
4d40: 43 53 0a 74 79 70 65 64 65 66 20 69 6e 74 20 5c CS.typedef int \
4d50: 66 42 54 63 6c 5f 44 72 69 76 65 72 43 6c 6f 73 fBTcl_DriverClos
4d60: 65 32 50 72 6f 63 5c 66 52 28 0a 20 20 20 20 20 e2Proc\fR(.
4d70: 20 20 20 43 6c 69 65 6e 74 44 61 74 61 20 5c 66 ClientData \f
4d80: 49 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 IinstanceData\fR
4d90: 2c 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 49 6e ,. Tcl_In
4da0: 74 65 72 70 20 2a 5c 66 49 69 6e 74 65 72 70 5c terp *\fIinterp\
4db0: 66 52 2c 0a 20 20 20 20 20 20 20 20 69 6e 74 20 fR,. int
4dc0: 5c 66 49 66 6c 61 67 73 5c 66 52 29 3b 0a 2e 43 \fIflags\fR);..C
4dd0: 45 0a 2e 50 50 0a 54 68 65 20 5c 66 49 63 6c 6f E..PP.The \fIclo
4de0: 73 65 32 50 72 6f 63 5c 66 52 20 77 69 6c 6c 20 se2Proc\fR will
4df0: 62 65 20 63 61 6c 6c 65 64 20 77 69 74 68 20 5c be called with \
4e00: 66 49 66 6c 61 67 73 5c 66 52 20 73 65 74 20 74 fIflags\fR set t
4e10: 6f 20 61 6e 20 4f 52 27 65 64 0a 63 6f 6d 62 69 o an OR'ed.combi
4e20: 6e 61 74 69 6f 6e 20 6f 66 20 5c 66 42 54 43 4c nation of \fBTCL
4e30: 5f 43 4c 4f 53 45 5f 52 45 41 44 5c 66 52 20 6f _CLOSE_READ\fR o
4e40: 72 20 5c 66 42 54 43 4c 5f 43 4c 4f 53 45 5f 57 r \fBTCL_CLOSE_W
4e50: 52 49 54 45 5c 66 52 20 74 6f 0a 69 6e 64 69 63 RITE\fR to.indic
4e60: 61 74 65 20 74 68 61 74 20 74 68 65 20 64 72 69 ate that the dri
4e70: 76 65 72 20 73 68 6f 75 6c 64 20 63 6c 6f 73 65 ver should close
4e80: 20 74 68 65 20 72 65 61 64 20 61 6e 64 2f 6f 72 the read and/or
4e90: 20 77 72 69 74 65 20 73 69 64 65 20 6f 66 0a 74 write side of.t
4ea0: 68 65 20 63 68 61 6e 6e 65 6c 2e 20 20 54 68 65 he channel. The
4eb0: 20 63 68 61 6e 6e 65 6c 20 64 72 69 76 65 72 20 channel driver
4ec0: 6d 61 79 20 62 65 20 69 6e 76 6f 6b 65 64 20 74 may be invoked t
4ed0: 6f 20 70 65 72 66 6f 72 6d 0a 61 64 64 69 74 69 o perform.additi
4ee0: 6f 6e 61 6c 20 6f 70 65 72 61 74 69 6f 6e 73 20 onal operations
4ef0: 6f 6e 20 74 68 65 20 63 68 61 6e 6e 65 6c 20 61 on the channel a
4f00: 66 74 65 72 20 5c 66 49 63 6c 6f 73 65 32 50 72 fter \fIclose2Pr
4f10: 6f 63 5c 66 52 20 69 73 0a 63 61 6c 6c 65 64 20 oc\fR is.called
4f20: 74 6f 20 63 6c 6f 73 65 20 6f 6e 65 20 6f 72 20 to close one or
4f30: 62 6f 74 68 20 73 69 64 65 73 20 6f 66 20 74 68 both sides of th
4f40: 65 20 63 68 61 6e 6e 65 6c 2e 20 20 49 66 20 5c e channel. If \
4f50: 66 49 66 6c 61 67 73 5c 66 52 20 69 73 0a 5c 66 fIflags\fR is.\f
4f60: 42 30 5c 66 52 20 28 7a 65 72 6f 29 2c 20 74 68 B0\fR (zero), th
4f70: 65 20 64 72 69 76 65 72 20 73 68 6f 75 6c 64 20 e driver should
4f80: 63 6c 6f 73 65 20 74 68 65 20 63 68 61 6e 6e 65 close the channe
4f90: 6c 20 69 6e 20 74 68 65 20 6d 61 6e 6e 65 72 0a l in the manner.
4fa0: 64 65 73 63 72 69 62 65 64 20 61 62 6f 76 65 20 described above
4fb0: 66 6f 72 20 5c 66 49 63 6c 6f 73 65 50 72 6f 63 for \fIcloseProc
4fc0: 5c 66 52 2e 20 20 4e 6f 20 66 75 72 74 68 65 72 \fR. No further
4fd0: 20 6f 70 65 72 61 74 69 6f 6e 73 20 77 69 6c 6c operations will
4fe0: 20 62 65 0a 69 6e 76 6f 6b 65 64 20 6f 6e 20 74 be.invoked on t
4ff0: 68 69 73 20 69 6e 73 74 61 6e 63 65 20 61 66 74 his instance aft
5000: 65 72 20 5c 66 49 63 6c 6f 73 65 32 50 72 6f 63 er \fIclose2Proc
5010: 5c 66 52 20 69 73 20 63 61 6c 6c 65 64 20 77 69 \fR is called wi
5020: 74 68 20 61 6c 6c 0a 66 6c 61 67 73 20 63 6c 65 th all.flags cle
5030: 61 72 65 64 2e 20 20 49 6e 20 61 6c 6c 20 63 61 ared. In all ca
5040: 73 65 73 2c 20 74 68 65 20 5c 66 49 63 6c 6f 73 ses, the \fIclos
5050: 65 32 50 72 6f 63 5c 66 52 20 66 75 6e 63 74 69 e2Proc\fR functi
5060: 6f 6e 20 73 68 6f 75 6c 64 0a 72 65 74 75 72 6e on should.return
5070: 20 7a 65 72 6f 20 69 66 20 74 68 65 20 63 6c 6f zero if the clo
5080: 73 65 20 6f 70 65 72 61 74 69 6f 6e 20 77 61 73 se operation was
5090: 20 73 75 63 63 65 73 73 66 75 6c 3b 20 6f 74 68 successful; oth
50a0: 65 72 77 69 73 65 20 69 74 20 73 68 6f 75 6c 64 erwise it should
50b0: 0a 72 65 74 75 72 6e 20 61 20 6e 6f 6e 7a 65 72 .return a nonzer
50c0: 6f 20 50 4f 53 49 58 20 65 72 72 6f 72 20 63 6f o POSIX error co
50d0: 64 65 2e 20 49 6e 20 61 64 64 69 74 69 6f 6e 2c de. In addition,
50e0: 20 69 66 20 61 6e 20 65 72 72 6f 72 20 6f 63 63 if an error occ
50f0: 75 72 73 20 61 6e 64 0a 5c 66 49 69 6e 74 65 72 urs and.\fIinter
5100: 70 5c 66 52 20 69 73 20 6e 6f 74 20 4e 55 4c 4c p\fR is not NULL
5110: 2c 20 74 68 65 20 70 72 6f 63 65 64 75 72 65 20 , the procedure
5120: 73 68 6f 75 6c 64 20 73 74 6f 72 65 20 61 6e 20 should store an
5130: 65 72 72 6f 72 20 6d 65 73 73 61 67 65 0a 69 6e error message.in
5140: 20 74 68 65 20 69 6e 74 65 72 70 72 65 74 65 72 the interpreter
5150: 27 73 20 72 65 73 75 6c 74 2e 0a 2e 50 50 0a 54 's result...PP.T
5160: 68 65 20 5c 66 49 63 6c 6f 73 65 50 72 6f 63 5c he \fIcloseProc\
5170: 66 52 20 61 6e 64 20 5c 66 49 63 6c 6f 73 65 32 fR and \fIclose2
5180: 50 72 6f 63 5c 66 52 20 76 61 6c 75 65 73 20 63 Proc\fR values c
5190: 61 6e 20 62 65 20 72 65 74 72 69 65 76 65 64 20 an be retrieved
51a0: 77 69 74 68 0a 5c 66 42 54 63 6c 5f 43 68 61 6e with.\fBTcl_Chan
51b0: 6e 65 6c 43 6c 6f 73 65 50 72 6f 63 5c 66 52 20 nelCloseProc\fR
51c0: 6f 72 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 or \fBTcl_Channe
51d0: 6c 43 6c 6f 73 65 32 50 72 6f 63 5c 66 52 2c 20 lClose2Proc\fR,
51e0: 77 68 69 63 68 0a 72 65 74 75 72 6e 20 61 20 70 which.return a p
51f0: 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 72 65 ointer to the re
5200: 73 70 65 63 74 69 76 65 20 66 75 6e 63 74 69 6f spective functio
5210: 6e 2e 0a 2e 53 53 20 49 4e 50 55 54 50 52 4f 43 n...SS INPUTPROC
5220: 0a 2e 50 50 0a 54 68 65 20 5c 66 49 69 6e 70 75 ..PP.The \fIinpu
5230: 74 50 72 6f 63 5c 66 52 20 66 69 65 6c 64 20 63 tProc\fR field c
5240: 6f 6e 74 61 69 6e 73 20 74 68 65 20 61 64 64 72 ontains the addr
5250: 65 73 73 20 6f 66 20 61 20 66 75 6e 63 74 69 6f ess of a functio
5260: 6e 20 63 61 6c 6c 65 64 20 62 79 20 74 68 65 0a n called by the.
5270: 67 65 6e 65 72 69 63 20 6c 61 79 65 72 20 74 6f generic layer to
5280: 20 72 65 61 64 20 64 61 74 61 20 66 72 6f 6d 20 read data from
5290: 74 68 65 20 66 69 6c 65 20 6f 72 20 64 65 76 69 the file or devi
52a0: 63 65 20 61 6e 64 20 73 74 6f 72 65 20 69 74 20 ce and store it
52b0: 69 6e 20 61 6e 0a 69 6e 74 65 72 6e 61 6c 20 62 in an.internal b
52c0: 75 66 66 65 72 2e 20 5c 66 49 49 6e 70 75 74 50 uffer. \fIInputP
52d0: 72 6f 63 5c 66 52 20 6d 75 73 74 20 6d 61 74 63 roc\fR must matc
52e0: 68 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 h the following
52f0: 70 72 6f 74 6f 74 79 70 65 3a 0a 2e 50 50 0a 2e prototype:..PP..
5300: 43 53 0a 74 79 70 65 64 65 66 20 69 6e 74 20 5c CS.typedef int \
5310: 66 42 54 63 6c 5f 44 72 69 76 65 72 49 6e 70 75 fBTcl_DriverInpu
5320: 74 50 72 6f 63 5c 66 52 28 0a 20 20 20 20 20 20 tProc\fR(.
5330: 20 20 43 6c 69 65 6e 74 44 61 74 61 20 5c 66 49 ClientData \fI
5340: 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 2c instanceData\fR,
5350: 0a 20 20 20 20 20 20 20 20 63 68 61 72 20 2a 5c . char *\
5360: 66 49 62 75 66 5c 66 52 2c 0a 20 20 20 20 20 20 fIbuf\fR,.
5370: 20 20 69 6e 74 20 5c 66 49 62 75 66 53 69 7a 65 int \fIbufSize
5380: 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 69 6e 74 \fR,. int
5390: 20 2a 5c 66 49 65 72 72 6f 72 43 6f 64 65 50 74 *\fIerrorCodePt
53a0: 72 5c 66 52 29 3b 0a 2e 43 45 0a 2e 50 50 0a 5c r\fR);..CE..PP.\
53b0: 66 49 49 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 fIInstanceData\f
53c0: 52 20 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 R is the same as
53d0: 20 74 68 65 20 76 61 6c 75 65 20 70 61 73 73 65 the value passe
53e0: 64 20 74 6f 0a 5c 66 42 54 63 6c 5f 43 72 65 61 d to.\fBTcl_Crea
53f0: 74 65 43 68 61 6e 6e 65 6c 5c 66 52 20 77 68 65 teChannel\fR whe
5400: 6e 20 74 68 65 20 63 68 61 6e 6e 65 6c 20 77 61 n the channel wa
5410: 73 20 63 72 65 61 74 65 64 2e 20 20 54 68 65 20 s created. The
5420: 5c 66 49 62 75 66 5c 66 52 0a 61 72 67 75 6d 65 \fIbuf\fR.argume
5430: 6e 74 20 70 6f 69 6e 74 73 20 74 6f 20 61 6e 20 nt points to an
5440: 61 72 72 61 79 20 6f 66 20 62 79 74 65 73 20 69 array of bytes i
5450: 6e 20 77 68 69 63 68 20 74 6f 20 73 74 6f 72 65 n which to store
5460: 20 69 6e 70 75 74 20 66 72 6f 6d 20 74 68 65 0a input from the.
5470: 64 65 76 69 63 65 2c 20 61 6e 64 20 74 68 65 20 device, and the
5480: 5c 66 49 62 75 66 53 69 7a 65 5c 66 52 20 61 72 \fIbufSize\fR ar
5490: 67 75 6d 65 6e 74 20 69 6e 64 69 63 61 74 65 73 gument indicates
54a0: 20 68 6f 77 20 6d 61 6e 79 20 62 79 74 65 73 20 how many bytes
54b0: 61 72 65 0a 61 76 61 69 6c 61 62 6c 65 20 61 74 are.available at
54c0: 20 5c 66 49 62 75 66 5c 66 52 2e 0a 2e 50 50 0a \fIbuf\fR...PP.
54d0: 54 68 65 20 5c 66 49 65 72 72 6f 72 43 6f 64 65 The \fIerrorCode
54e0: 50 74 72 5c 66 52 20 61 72 67 75 6d 65 6e 74 20 Ptr\fR argument
54f0: 70 6f 69 6e 74 73 20 74 6f 20 61 6e 20 69 6e 74 points to an int
5500: 65 67 65 72 20 76 61 72 69 61 62 6c 65 20 70 72 eger variable pr
5510: 6f 76 69 64 65 64 20 62 79 0a 74 68 65 20 67 65 ovided by.the ge
5520: 6e 65 72 69 63 20 6c 61 79 65 72 2e 20 49 66 20 neric layer. If
5530: 61 6e 20 65 72 72 6f 72 20 6f 63 63 75 72 73 2c an error occurs,
5540: 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 73 68 the function sh
5550: 6f 75 6c 64 20 73 65 74 20 74 68 65 20 76 61 72 ould set the var
5560: 69 61 62 6c 65 0a 74 6f 20 61 20 50 4f 53 49 58 iable.to a POSIX
5570: 20 65 72 72 6f 72 20 63 6f 64 65 20 74 68 61 74 error code that
5580: 20 69 64 65 6e 74 69 66 69 65 73 20 74 68 65 20 identifies the
5590: 65 72 72 6f 72 20 74 68 61 74 20 6f 63 63 75 72 error that occur
55a0: 72 65 64 2e 0a 2e 50 50 0a 54 68 65 20 66 75 6e red...PP.The fun
55b0: 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 72 65 61 ction should rea
55c0: 64 20 64 61 74 61 20 66 72 6f 6d 20 74 68 65 20 d data from the
55d0: 69 6e 70 75 74 20 64 65 76 69 63 65 20 65 6e 63 input device enc
55e0: 61 70 73 75 6c 61 74 65 64 20 62 79 20 74 68 65 apsulated by the
55f0: 0a 63 68 61 6e 6e 65 6c 20 61 6e 64 20 73 74 6f .channel and sto
5600: 72 65 20 69 74 20 61 74 20 5c 66 49 62 75 66 5c re it at \fIbuf\
5610: 66 52 2e 20 20 4f 6e 20 73 75 63 63 65 73 73 2c fR. On success,
5620: 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 73 68 the function sh
5630: 6f 75 6c 64 20 72 65 74 75 72 6e 0a 61 20 6e 6f ould return.a no
5640: 6e 6e 65 67 61 74 69 76 65 20 69 6e 74 65 67 65 nnegative intege
5650: 72 20 69 6e 64 69 63 61 74 69 6e 67 20 68 6f 77 r indicating how
5660: 20 6d 61 6e 79 20 62 79 74 65 73 20 77 65 72 65 many bytes were
5670: 20 72 65 61 64 20 66 72 6f 6d 20 74 68 65 20 69 read from the i
5680: 6e 70 75 74 0a 64 65 76 69 63 65 20 61 6e 64 20 nput.device and
5690: 73 74 6f 72 65 64 20 61 74 20 5c 66 49 62 75 66 stored at \fIbuf
56a0: 5c 66 52 2e 20 4f 6e 20 65 72 72 6f 72 2c 20 74 \fR. On error, t
56b0: 68 65 20 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 he function shou
56c0: 6c 64 20 72 65 74 75 72 6e 20 2d 31 2e 20 49 66 ld return -1. If
56d0: 0a 61 6e 20 65 72 72 6f 72 20 6f 63 63 75 72 73 .an error occurs
56e0: 20 61 66 74 65 72 20 73 6f 6d 65 20 64 61 74 61 after some data
56f0: 20 68 61 73 20 62 65 65 6e 20 72 65 61 64 20 66 has been read f
5700: 72 6f 6d 20 74 68 65 20 64 65 76 69 63 65 2c 20 rom the device,
5710: 74 68 61 74 20 64 61 74 61 20 69 73 0a 6c 6f 73 that data is.los
5720: 74 2e 0a 2e 50 50 0a 49 66 20 5c 66 49 69 6e 70 t...PP.If \fIinp
5730: 75 74 50 72 6f 63 5c 66 52 20 63 61 6e 20 64 65 utProc\fR can de
5740: 74 65 72 6d 69 6e 65 20 74 68 61 74 20 74 68 65 termine that the
5750: 20 69 6e 70 75 74 20 64 65 76 69 63 65 20 68 61 input device ha
5760: 73 20 73 6f 6d 65 20 64 61 74 61 0a 61 76 61 69 s some data.avai
5770: 6c 61 62 6c 65 20 62 75 74 20 6c 65 73 73 20 74 lable but less t
5780: 68 61 6e 20 72 65 71 75 65 73 74 65 64 20 62 79 han requested by
5790: 20 74 68 65 20 5c 66 49 62 75 66 53 69 7a 65 5c the \fIbufSize\
57a0: 66 52 20 61 72 67 75 6d 65 6e 74 2c 20 74 68 65 fR argument, the
57b0: 0a 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 .function should
57c0: 20 6f 6e 6c 79 20 61 74 74 65 6d 70 74 20 74 6f only attempt to
57d0: 20 72 65 61 64 20 61 73 20 6d 75 63 68 20 64 61 read as much da
57e0: 74 61 20 61 73 20 69 73 20 61 76 61 69 6c 61 62 ta as is availab
57f0: 6c 65 20 61 6e 64 0a 72 65 74 75 72 6e 20 77 69 le and.return wi
5800: 74 68 6f 75 74 20 62 6c 6f 63 6b 69 6e 67 2e 20 thout blocking.
5810: 49 66 20 74 68 65 20 69 6e 70 75 74 20 64 65 76 If the input dev
5820: 69 63 65 20 68 61 73 20 6e 6f 20 64 61 74 61 20 ice has no data
5830: 61 76 61 69 6c 61 62 6c 65 0a 77 68 61 74 73 6f available.whatso
5840: 65 76 65 72 20 61 6e 64 20 74 68 65 20 63 68 61 ever and the cha
5850: 6e 6e 65 6c 20 69 73 20 69 6e 20 6e 6f 6e 62 6c nnel is in nonbl
5860: 6f 63 6b 69 6e 67 20 6d 6f 64 65 2c 20 74 68 65 ocking mode, the
5870: 20 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 function should
5880: 0a 72 65 74 75 72 6e 20 61 6e 20 5c 66 42 45 41 .return an \fBEA
5890: 47 41 49 4e 5c 66 52 20 65 72 72 6f 72 2e 20 49 GAIN\fR error. I
58a0: 66 20 74 68 65 20 69 6e 70 75 74 20 64 65 76 69 f the input devi
58b0: 63 65 20 68 61 73 20 6e 6f 20 64 61 74 61 20 61 ce has no data a
58c0: 76 61 69 6c 61 62 6c 65 0a 77 68 61 74 73 6f 65 vailable.whatsoe
58d0: 76 65 72 20 61 6e 64 20 74 68 65 20 63 68 61 6e ver and the chan
58e0: 6e 65 6c 20 69 73 20 69 6e 20 62 6c 6f 63 6b 69 nel is in blocki
58f0: 6e 67 20 6d 6f 64 65 2c 20 74 68 65 20 66 75 6e ng mode, the fun
5900: 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 62 6c 6f ction should blo
5910: 63 6b 0a 66 6f 72 20 74 68 65 20 73 68 6f 72 74 ck.for the short
5920: 65 73 74 20 70 6f 73 73 69 62 6c 65 20 74 69 6d est possible tim
5930: 65 20 75 6e 74 69 6c 20 61 74 20 6c 65 61 73 74 e until at least
5940: 20 6f 6e 65 20 62 79 74 65 20 6f 66 20 64 61 74 one byte of dat
5950: 61 20 63 61 6e 20 62 65 20 72 65 61 64 0a 66 72 a can be read.fr
5960: 6f 6d 20 74 68 65 20 64 65 76 69 63 65 3b 20 74 om the device; t
5970: 68 65 6e 2c 20 69 74 20 73 68 6f 75 6c 64 20 72 hen, it should r
5980: 65 74 75 72 6e 20 61 73 20 6d 75 63 68 20 64 61 eturn as much da
5990: 74 61 20 61 73 20 69 74 20 63 61 6e 20 72 65 61 ta as it can rea
59a0: 64 20 77 69 74 68 6f 75 74 0a 62 6c 6f 63 6b 69 d without.blocki
59b0: 6e 67 2e 0a 2e 50 50 0a 54 68 69 73 20 76 61 6c ng...PP.This val
59c0: 75 65 20 63 61 6e 20 62 65 20 72 65 74 72 69 65 ue can be retrie
59d0: 76 65 64 20 77 69 74 68 20 5c 66 42 54 63 6c 5f ved with \fBTcl_
59e0: 43 68 61 6e 6e 65 6c 49 6e 70 75 74 50 72 6f 63 ChannelInputProc
59f0: 5c 66 52 2c 20 77 68 69 63 68 20 72 65 74 75 72 \fR, which retur
5a00: 6e 73 0a 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 ns.a pointer to
5a10: 74 68 65 20 66 75 6e 63 74 69 6f 6e 2e 0a 2e 53 the function...S
5a20: 53 20 4f 55 54 50 55 54 50 52 4f 43 0a 2e 50 50 S OUTPUTPROC..PP
5a30: 0a 54 68 65 20 5c 66 49 6f 75 74 70 75 74 50 72 .The \fIoutputPr
5a40: 6f 63 5c 66 52 20 66 69 65 6c 64 20 63 6f 6e 74 oc\fR field cont
5a50: 61 69 6e 73 20 74 68 65 20 61 64 64 72 65 73 73 ains the address
5a60: 20 6f 66 20 61 20 66 75 6e 63 74 69 6f 6e 20 63 of a function c
5a70: 61 6c 6c 65 64 20 62 79 20 74 68 65 0a 67 65 6e alled by the.gen
5a80: 65 72 69 63 20 6c 61 79 65 72 20 74 6f 20 74 72 eric layer to tr
5a90: 61 6e 73 66 65 72 20 64 61 74 61 20 66 72 6f 6d ansfer data from
5aa0: 20 61 6e 20 69 6e 74 65 72 6e 61 6c 20 62 75 66 an internal buf
5ab0: 66 65 72 20 74 6f 20 74 68 65 20 6f 75 74 70 75 fer to the outpu
5ac0: 74 20 64 65 76 69 63 65 2e 0a 5c 66 49 4f 75 74 t device..\fIOut
5ad0: 70 75 74 50 72 6f 63 5c 66 52 20 6d 75 73 74 20 putProc\fR must
5ae0: 6d 61 74 63 68 20 74 68 65 20 66 6f 6c 6c 6f 77 match the follow
5af0: 69 6e 67 20 70 72 6f 74 6f 74 79 70 65 3a 0a 2e ing prototype:..
5b00: 50 50 0a 2e 43 53 0a 74 79 70 65 64 65 66 20 69 PP..CS.typedef i
5b10: 6e 74 20 5c 66 42 54 63 6c 5f 44 72 69 76 65 72 nt \fBTcl_Driver
5b20: 4f 75 74 70 75 74 50 72 6f 63 5c 66 52 28 0a 20 OutputProc\fR(.
5b30: 20 20 20 20 20 20 20 43 6c 69 65 6e 74 44 61 74 ClientDat
5b40: 61 20 5c 66 49 69 6e 73 74 61 6e 63 65 44 61 74 a \fIinstanceDat
5b50: 61 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 63 6f a\fR,. co
5b60: 6e 73 74 20 63 68 61 72 20 2a 5c 66 49 62 75 66 nst char *\fIbuf
5b70: 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 69 6e 74 \fR,. int
5b80: 20 5c 66 49 74 6f 57 72 69 74 65 5c 66 52 2c 0a \fItoWrite\fR,.
5b90: 20 20 20 20 20 20 20 20 69 6e 74 20 2a 5c 66 49 int *\fI
5ba0: 65 72 72 6f 72 43 6f 64 65 50 74 72 5c 66 52 29 errorCodePtr\fR)
5bb0: 3b 0a 2e 43 45 0a 2e 50 50 0a 5c 66 49 49 6e 73 ;..CE..PP.\fIIns
5bc0: 74 61 6e 63 65 44 61 74 61 5c 66 52 20 69 73 20 tanceData\fR is
5bd0: 74 68 65 20 73 61 6d 65 20 61 73 20 74 68 65 20 the same as the
5be0: 76 61 6c 75 65 20 70 61 73 73 65 64 20 74 6f 0a value passed to.
5bf0: 5c 66 42 54 63 6c 5f 43 72 65 61 74 65 43 68 61 \fBTcl_CreateCha
5c00: 6e 6e 65 6c 5c 66 52 20 77 68 65 6e 20 74 68 65 nnel\fR when the
5c10: 20 63 68 61 6e 6e 65 6c 20 77 61 73 20 63 72 65 channel was cre
5c20: 61 74 65 64 2e 20 54 68 65 20 5c 66 49 62 75 66 ated. The \fIbuf
5c30: 5c 66 52 0a 61 72 67 75 6d 65 6e 74 20 63 6f 6e \fR.argument con
5c40: 74 61 69 6e 73 20 61 6e 20 61 72 72 61 79 20 6f tains an array o
5c50: 66 20 62 79 74 65 73 20 74 6f 20 62 65 20 77 72 f bytes to be wr
5c60: 69 74 74 65 6e 20 74 6f 20 74 68 65 20 64 65 76 itten to the dev
5c70: 69 63 65 2c 20 61 6e 64 20 74 68 65 0a 5c 66 49 ice, and the.\fI
5c80: 74 6f 57 72 69 74 65 5c 66 52 20 61 72 67 75 6d toWrite\fR argum
5c90: 65 6e 74 20 69 6e 64 69 63 61 74 65 73 20 68 6f ent indicates ho
5ca0: 77 20 6d 61 6e 79 20 62 79 74 65 73 20 61 72 65 w many bytes are
5cb0: 20 74 6f 20 62 65 20 77 72 69 74 74 65 6e 20 66 to be written f
5cc0: 72 6f 6d 20 74 68 65 0a 5c 66 49 62 75 66 5c 66 rom the.\fIbuf\f
5cd0: 52 20 61 72 67 75 6d 65 6e 74 2e 0a 2e 50 50 0a R argument...PP.
5ce0: 54 68 65 20 5c 66 49 65 72 72 6f 72 43 6f 64 65 The \fIerrorCode
5cf0: 50 74 72 5c 66 52 20 61 72 67 75 6d 65 6e 74 20 Ptr\fR argument
5d00: 70 6f 69 6e 74 73 20 74 6f 20 61 6e 20 69 6e 74 points to an int
5d10: 65 67 65 72 20 76 61 72 69 61 62 6c 65 20 70 72 eger variable pr
5d20: 6f 76 69 64 65 64 20 62 79 0a 74 68 65 20 67 65 ovided by.the ge
5d30: 6e 65 72 69 63 20 6c 61 79 65 72 2e 20 49 66 20 neric layer. If
5d40: 61 6e 20 65 72 72 6f 72 20 6f 63 63 75 72 73 2c an error occurs,
5d50: 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 73 68 the function sh
5d60: 6f 75 6c 64 20 73 65 74 20 74 68 69 73 0a 76 61 ould set this.va
5d70: 72 69 61 62 6c 65 20 74 6f 20 61 20 50 4f 53 49 riable to a POSI
5d80: 58 20 65 72 72 6f 72 20 63 6f 64 65 20 74 68 61 X error code tha
5d90: 74 20 69 64 65 6e 74 69 66 69 65 73 20 74 68 65 t identifies the
5da0: 20 65 72 72 6f 72 2e 0a 2e 50 50 0a 54 68 65 20 error...PP.The
5db0: 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 function should
5dc0: 77 72 69 74 65 20 74 68 65 20 64 61 74 61 20 61 write the data a
5dd0: 74 20 5c 66 49 62 75 66 5c 66 52 20 74 6f 20 74 t \fIbuf\fR to t
5de0: 68 65 20 6f 75 74 70 75 74 20 64 65 76 69 63 65 he output device
5df0: 0a 65 6e 63 61 70 73 75 6c 61 74 65 64 20 62 79 .encapsulated by
5e00: 20 74 68 65 20 63 68 61 6e 6e 65 6c 2e 20 4f 6e the channel. On
5e10: 20 73 75 63 63 65 73 73 2c 20 74 68 65 20 66 75 success, the fu
5e20: 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 72 65 nction should re
5e30: 74 75 72 6e 20 61 0a 6e 6f 6e 6e 65 67 61 74 69 turn a.nonnegati
5e40: 76 65 20 69 6e 74 65 67 65 72 20 69 6e 64 69 63 ve integer indic
5e50: 61 74 69 6e 67 20 68 6f 77 20 6d 61 6e 79 20 62 ating how many b
5e60: 79 74 65 73 20 77 65 72 65 20 77 72 69 74 74 65 ytes were writte
5e70: 6e 20 74 6f 20 74 68 65 20 6f 75 74 70 75 74 0a n to the output.
5e80: 64 65 76 69 63 65 2e 20 20 54 68 65 20 72 65 74 device. The ret
5e90: 75 72 6e 20 76 61 6c 75 65 20 69 73 20 6e 6f 72 urn value is nor
5ea0: 6d 61 6c 6c 79 20 74 68 65 20 73 61 6d 65 20 61 mally the same a
5eb0: 73 20 5c 66 49 74 6f 57 72 69 74 65 5c 66 52 2c s \fItoWrite\fR,
5ec0: 20 62 75 74 20 6d 61 79 20 62 65 0a 6c 65 73 73 but may be.less
5ed0: 20 69 6e 20 73 6f 6d 65 20 63 61 73 65 73 20 73 in some cases s
5ee0: 75 63 68 20 61 73 20 69 66 20 74 68 65 20 6f 75 uch as if the ou
5ef0: 74 70 75 74 20 6f 70 65 72 61 74 69 6f 6e 20 69 tput operation i
5f00: 73 20 69 6e 74 65 72 72 75 70 74 65 64 20 62 79 s interrupted by
5f10: 20 61 0a 73 69 67 6e 61 6c 2e 20 49 66 20 61 6e a.signal. If an
5f20: 20 65 72 72 6f 72 20 6f 63 63 75 72 73 20 74 68 error occurs th
5f30: 65 20 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c e function shoul
5f40: 64 20 72 65 74 75 72 6e 20 2d 31 2e 20 20 49 6e d return -1. In
5f50: 20 63 61 73 65 20 6f 66 0a 65 72 72 6f 72 2c 20 case of.error,
5f60: 73 6f 6d 65 20 64 61 74 61 20 6d 61 79 20 68 61 some data may ha
5f70: 76 65 20 62 65 65 6e 20 77 72 69 74 74 65 6e 20 ve been written
5f80: 74 6f 20 74 68 65 20 64 65 76 69 63 65 2e 0a 2e to the device...
5f90: 50 50 0a 49 66 20 74 68 65 20 63 68 61 6e 6e 65 PP.If the channe
5fa0: 6c 20 69 73 20 6e 6f 6e 62 6c 6f 63 6b 69 6e 67 l is nonblocking
5fb0: 20 61 6e 64 20 74 68 65 20 6f 75 74 70 75 74 20 and the output
5fc0: 64 65 76 69 63 65 20 69 73 20 75 6e 61 62 6c 65 device is unable
5fd0: 20 74 6f 20 61 62 73 6f 72 62 20 61 6e 79 0a 64 to absorb any.d
5fe0: 61 74 61 20 77 68 61 74 73 6f 65 76 65 72 2c 20 ata whatsoever,
5ff0: 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 73 68 6f the function sho
6000: 75 6c 64 20 72 65 74 75 72 6e 20 2d 31 20 77 69 uld return -1 wi
6010: 74 68 20 61 6e 20 5c 66 42 45 41 47 41 49 4e 5c th an \fBEAGAIN\
6020: 66 52 20 65 72 72 6f 72 0a 77 69 74 68 6f 75 74 fR error.without
6030: 20 77 72 69 74 69 6e 67 20 61 6e 79 20 64 61 74 writing any dat
6040: 61 2e 0a 2e 50 50 0a 54 68 69 73 20 76 61 6c 75 a...PP.This valu
6050: 65 20 63 61 6e 20 62 65 20 72 65 74 72 69 65 76 e can be retriev
6060: 65 64 20 77 69 74 68 20 5c 66 42 54 63 6c 5f 43 ed with \fBTcl_C
6070: 68 61 6e 6e 65 6c 4f 75 74 70 75 74 50 72 6f 63 hannelOutputProc
6080: 5c 66 52 2c 20 77 68 69 63 68 20 72 65 74 75 72 \fR, which retur
6090: 6e 73 0a 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 ns.a pointer to
60a0: 74 68 65 20 66 75 6e 63 74 69 6f 6e 2e 0a 2e 53 the function...S
60b0: 53 20 22 53 45 45 4b 50 52 4f 43 20 41 4e 44 20 S "SEEKPROC AND
60c0: 57 49 44 45 53 45 45 4b 50 52 4f 43 22 0a 2e 50 WIDESEEKPROC"..P
60d0: 50 0a 54 68 65 20 5c 66 49 73 65 65 6b 50 72 6f P.The \fIseekPro
60e0: 63 5c 66 52 20 66 69 65 6c 64 20 63 6f 6e 74 61 c\fR field conta
60f0: 69 6e 73 20 74 68 65 20 61 64 64 72 65 73 73 20 ins the address
6100: 6f 66 20 61 20 66 75 6e 63 74 69 6f 6e 20 63 61 of a function ca
6110: 6c 6c 65 64 20 62 79 20 74 68 65 0a 67 65 6e 65 lled by the.gene
6120: 72 69 63 20 6c 61 79 65 72 20 74 6f 20 6d 6f 76 ric layer to mov
6130: 65 20 74 68 65 20 61 63 63 65 73 73 20 70 6f 69 e the access poi
6140: 6e 74 20 61 74 20 77 68 69 63 68 20 73 75 62 73 nt at which subs
6150: 65 71 75 65 6e 74 20 69 6e 70 75 74 20 6f 72 20 equent input or
6160: 6f 75 74 70 75 74 0a 6f 70 65 72 61 74 69 6f 6e output.operation
6170: 73 20 77 69 6c 6c 20 62 65 20 61 70 70 6c 69 65 s will be applie
6180: 64 2e 20 5c 66 49 53 65 65 6b 50 72 6f 63 5c 66 d. \fISeekProc\f
6190: 52 20 6d 75 73 74 20 6d 61 74 63 68 20 74 68 65 R must match the
61a0: 20 66 6f 6c 6c 6f 77 69 6e 67 0a 70 72 6f 74 6f following.proto
61b0: 74 79 70 65 3a 0a 2e 50 50 0a 2e 43 53 0a 74 79 type:..PP..CS.ty
61c0: 70 65 64 65 66 20 69 6e 74 20 5c 66 42 54 63 6c pedef int \fBTcl
61d0: 5f 44 72 69 76 65 72 53 65 65 6b 50 72 6f 63 5c _DriverSeekProc\
61e0: 66 52 28 0a 20 20 20 20 20 20 20 20 43 6c 69 65 fR(. Clie
61f0: 6e 74 44 61 74 61 20 5c 66 49 69 6e 73 74 61 6e ntData \fIinstan
6200: 63 65 44 61 74 61 5c 66 52 2c 0a 20 20 20 20 20 ceData\fR,.
6210: 20 20 20 6c 6f 6e 67 20 5c 66 49 6f 66 66 73 65 long \fIoffse
6220: 74 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 69 6e t\fR,. in
6230: 74 20 5c 66 49 73 65 65 6b 4d 6f 64 65 5c 66 52 t \fIseekMode\fR
6240: 2c 0a 20 20 20 20 20 20 20 20 69 6e 74 20 2a 5c ,. int *\
6250: 66 49 65 72 72 6f 72 43 6f 64 65 50 74 72 5c 66 fIerrorCodePtr\f
6260: 52 29 3b 0a 2e 43 45 0a 2e 50 50 0a 54 68 65 20 R);..CE..PP.The
6270: 5c 66 49 69 6e 73 74 61 6e 63 65 44 61 74 61 5c \fIinstanceData\
6280: 66 52 20 61 72 67 75 6d 65 6e 74 20 69 73 20 74 fR argument is t
6290: 68 65 20 73 61 6d 65 20 61 73 20 74 68 65 20 76 he same as the v
62a0: 61 6c 75 65 20 67 69 76 65 6e 20 74 6f 0a 5c 66 alue given to.\f
62b0: 42 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e 6e BTcl_CreateChann
62c0: 65 6c 5c 66 52 20 77 68 65 6e 20 74 68 69 73 20 el\fR when this
62d0: 63 68 61 6e 6e 65 6c 20 77 61 73 20 63 72 65 61 channel was crea
62e0: 74 65 64 2e 20 20 5c 66 49 4f 66 66 73 65 74 5c ted. \fIOffset\
62f0: 66 52 20 61 6e 64 0a 5c 66 49 73 65 65 6b 4d 6f fR and.\fIseekMo
6300: 64 65 5c 66 52 20 68 61 76 65 20 74 68 65 20 73 de\fR have the s
6310: 61 6d 65 20 6d 65 61 6e 69 6e 67 20 61 73 20 66 ame meaning as f
6320: 6f 72 20 74 68 65 20 5c 66 42 54 63 6c 5f 53 65 or the \fBTcl_Se
6330: 65 6b 5c 66 52 0a 70 72 6f 63 65 64 75 72 65 20 ek\fR.procedure
6340: 28 64 65 73 63 72 69 62 65 64 20 69 6e 20 74 68 (described in th
6350: 65 20 6d 61 6e 75 61 6c 20 65 6e 74 72 79 20 66 e manual entry f
6360: 6f 72 20 5c 66 42 54 63 6c 5f 4f 70 65 6e 46 69 or \fBTcl_OpenFi
6370: 6c 65 43 68 61 6e 6e 65 6c 5c 66 52 29 2e 0a 2e leChannel\fR)...
6380: 50 50 0a 54 68 65 20 5c 66 49 65 72 72 6f 72 43 PP.The \fIerrorC
6390: 6f 64 65 50 74 72 5c 66 52 20 61 72 67 75 6d 65 odePtr\fR argume
63a0: 6e 74 20 70 6f 69 6e 74 73 20 74 6f 20 61 6e 20 nt points to an
63b0: 69 6e 74 65 67 65 72 20 76 61 72 69 61 62 6c 65 integer variable
63c0: 20 70 72 6f 76 69 64 65 64 20 62 79 0a 74 68 65 provided by.the
63d0: 20 67 65 6e 65 72 69 63 20 6c 61 79 65 72 20 66 generic layer f
63e0: 6f 72 20 72 65 74 75 72 6e 69 6e 67 20 5c 66 42 or returning \fB
63f0: 65 72 72 6e 6f 5c 66 52 20 76 61 6c 75 65 73 20 errno\fR values
6400: 66 72 6f 6d 20 74 68 65 20 66 75 6e 63 74 69 6f from the functio
6410: 6e 2e 20 20 54 68 65 0a 66 75 6e 63 74 69 6f 6e n. The.function
6420: 20 73 68 6f 75 6c 64 20 73 65 74 20 74 68 69 73 should set this
6430: 20 76 61 72 69 61 62 6c 65 20 74 6f 20 61 20 50 variable to a P
6440: 4f 53 49 58 20 65 72 72 6f 72 20 63 6f 64 65 20 OSIX error code
6450: 69 66 20 61 6e 20 65 72 72 6f 72 20 6f 63 63 75 if an error occu
6460: 72 73 2e 0a 54 68 65 20 66 75 6e 63 74 69 6f 6e rs..The function
6470: 20 73 68 6f 75 6c 64 20 73 74 6f 72 65 20 61 6e should store an
6480: 20 5c 66 42 45 49 4e 56 41 4c 5c 66 52 20 65 72 \fBEINVAL\fR er
6490: 72 6f 72 20 63 6f 64 65 20 69 66 20 74 68 65 20 ror code if the
64a0: 63 68 61 6e 6e 65 6c 20 74 79 70 65 0a 64 6f 65 channel type.doe
64b0: 73 20 6e 6f 74 20 69 6d 70 6c 65 6d 65 6e 74 20 s not implement
64c0: 73 65 65 6b 69 6e 67 2e 0a 2e 50 50 0a 54 68 65 seeking...PP.The
64d0: 20 72 65 74 75 72 6e 20 76 61 6c 75 65 20 69 73 return value is
64e0: 20 74 68 65 20 6e 65 77 20 61 63 63 65 73 73 20 the new access
64f0: 70 6f 69 6e 74 20 6f 72 20 2d 31 20 69 6e 20 63 point or -1 in c
6500: 61 73 65 20 6f 66 20 65 72 72 6f 72 2e 20 49 66 ase of error. If
6510: 20 61 6e 0a 65 72 72 6f 72 20 6f 63 63 75 72 72 an.error occurr
6520: 65 64 2c 20 74 68 65 20 66 75 6e 63 74 69 6f 6e ed, the function
6530: 20 73 68 6f 75 6c 64 20 6e 6f 74 20 6d 6f 76 65 should not move
6540: 20 74 68 65 20 61 63 63 65 73 73 20 70 6f 69 6e the access poin
6550: 74 2e 0a 2e 50 50 0a 49 66 20 74 68 65 72 65 20 t...PP.If there
6560: 69 73 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 20 5c 66 is a non-NULL \f
6570: 49 73 65 65 6b 50 72 6f 63 5c 66 52 20 66 69 65 IseekProc\fR fie
6580: 6c 64 2c 20 74 68 65 20 5c 66 49 77 69 64 65 53 ld, the \fIwideS
6590: 65 65 6b 50 72 6f 63 5c 66 52 0a 66 69 65 6c 64 eekProc\fR.field
65a0: 20 6d 61 79 20 63 6f 6e 74 61 69 6e 20 74 68 65 may contain the
65b0: 20 61 64 64 72 65 73 73 20 6f 66 20 61 6e 20 61 address of an a
65c0: 6c 74 65 72 6e 61 74 69 76 65 20 66 75 6e 63 74 lternative funct
65d0: 69 6f 6e 20 74 6f 20 75 73 65 20 77 68 69 63 68 ion to use which
65e0: 0a 68 61 6e 64 6c 65 73 20 77 69 64 65 20 28 69 .handles wide (i
65f0: 2e 65 2e 20 6c 61 72 67 65 72 20 74 68 61 6e 20 .e. larger than
6600: 33 32 2d 62 69 74 29 20 6f 66 66 73 65 74 73 2c 32-bit) offsets,
6610: 20 73 6f 20 61 6c 6c 6f 77 69 6e 67 20 73 65 65 so allowing see
6620: 6b 73 0a 77 69 74 68 69 6e 20 66 69 6c 65 73 20 ks.within files
6630: 6c 61 72 67 65 72 20 74 68 61 6e 20 32 47 42 2e larger than 2GB.
6640: 20 20 54 68 65 20 5c 66 49 77 69 64 65 53 65 65 The \fIwideSee
6650: 6b 50 72 6f 63 5c 66 52 20 77 69 6c 6c 20 62 65 kProc\fR will be
6660: 20 63 61 6c 6c 65 64 0a 69 6e 20 70 72 65 66 65 called.in prefe
6670: 72 65 6e 63 65 20 74 6f 20 74 68 65 20 5c 66 49 rence to the \fI
6680: 73 65 65 6b 50 72 6f 63 5c 66 52 2c 20 62 75 74 seekProc\fR, but
6690: 20 62 6f 74 68 20 6d 75 73 74 20 62 65 20 64 65 both must be de
66a0: 66 69 6e 65 64 20 69 66 20 74 68 65 0a 5c 66 49 fined if the.\fI
66b0: 77 69 64 65 53 65 65 6b 50 72 6f 63 5c 66 52 20 wideSeekProc\fR
66c0: 69 73 20 64 65 66 69 6e 65 64 2e 20 20 5c 66 49 is defined. \fI
66d0: 57 69 64 65 53 65 65 6b 50 72 6f 63 5c 66 52 20 WideSeekProc\fR
66e0: 6d 75 73 74 20 6d 61 74 63 68 20 74 68 65 0a 66 must match the.f
66f0: 6f 6c 6c 6f 77 69 6e 67 20 70 72 6f 74 6f 74 79 ollowing prototy
6700: 70 65 3a 0a 2e 50 50 0a 2e 43 53 0a 74 79 70 65 pe:..PP..CS.type
6710: 64 65 66 20 54 63 6c 5f 57 69 64 65 49 6e 74 20 def Tcl_WideInt
6720: 5c 66 42 54 63 6c 5f 44 72 69 76 65 72 57 69 64 \fBTcl_DriverWid
6730: 65 53 65 65 6b 50 72 6f 63 5c 66 52 28 0a 20 20 eSeekProc\fR(.
6740: 20 20 20 20 20 20 43 6c 69 65 6e 74 44 61 74 61 ClientData
6750: 20 5c 66 49 69 6e 73 74 61 6e 63 65 44 61 74 61 \fIinstanceData
6760: 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 54 63 6c \fR,. Tcl
6770: 5f 57 69 64 65 49 6e 74 20 5c 66 49 6f 66 66 73 _WideInt \fIoffs
6780: 65 74 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 69 et\fR,. i
6790: 6e 74 20 5c 66 49 73 65 65 6b 4d 6f 64 65 5c 66 nt \fIseekMode\f
67a0: 52 2c 0a 20 20 20 20 20 20 20 20 69 6e 74 20 2a R,. int *
67b0: 5c 66 49 65 72 72 6f 72 43 6f 64 65 50 74 72 5c \fIerrorCodePtr\
67c0: 66 52 29 3b 0a 2e 43 45 0a 2e 50 50 0a 54 68 65 fR);..CE..PP.The
67d0: 20 61 72 67 75 6d 65 6e 74 73 20 61 6e 64 20 72 arguments and r
67e0: 65 74 75 72 6e 20 76 61 6c 75 65 73 20 6d 65 61 eturn values mea
67f0: 6e 20 74 68 65 20 73 61 6d 65 20 74 68 69 6e 67 n the same thing
6800: 20 61 73 20 77 69 74 68 0a 5c 66 49 73 65 65 6b as with.\fIseek
6810: 50 72 6f 63 5c 66 52 20 61 62 6f 76 65 2c 20 65 Proc\fR above, e
6820: 78 63 65 70 74 20 74 68 61 74 20 74 68 65 20 74 xcept that the t
6830: 79 70 65 20 6f 66 20 6f 66 66 73 65 74 73 20 61 ype of offsets a
6840: 6e 64 20 74 68 65 20 72 65 74 75 72 6e 0a 74 79 nd the return.ty
6850: 70 65 20 61 72 65 20 64 69 66 66 65 72 65 6e 74 pe are different
6860: 2e 0a 2e 50 50 0a 54 68 65 20 5c 66 49 73 65 65 ...PP.The \fIsee
6870: 6b 50 72 6f 63 5c 66 52 20 76 61 6c 75 65 20 63 kProc\fR value c
6880: 61 6e 20 62 65 20 72 65 74 72 69 65 76 65 64 20 an be retrieved
6890: 77 69 74 68 0a 5c 66 42 54 63 6c 5f 43 68 61 6e with.\fBTcl_Chan
68a0: 6e 65 6c 53 65 65 6b 50 72 6f 63 5c 66 52 2c 20 nelSeekProc\fR,
68b0: 77 68 69 63 68 20 72 65 74 75 72 6e 73 20 61 20 which returns a
68c0: 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 66 pointer to the f
68d0: 75 6e 63 74 69 6f 6e 2c 0a 61 6e 64 20 73 69 6d unction,.and sim
68e0: 69 6c 61 72 6c 79 20 74 68 65 20 5c 66 49 77 69 ilarly the \fIwi
68f0: 64 65 53 65 65 6b 50 72 6f 63 5c 66 52 20 63 61 deSeekProc\fR ca
6900: 6e 20 62 65 20 72 65 74 72 69 65 76 65 64 20 77 n be retrieved w
6910: 69 74 68 0a 5c 66 42 54 63 6c 5f 43 68 61 6e 6e ith.\fBTcl_Chann
6920: 65 6c 57 69 64 65 53 65 65 6b 50 72 6f 63 5c 66 elWideSeekProc\f
6930: 52 2e 0a 2e 53 53 20 53 45 54 4f 50 54 49 4f 4e R...SS SETOPTION
6940: 50 52 4f 43 0a 2e 50 50 0a 54 68 65 20 5c 66 49 PROC..PP.The \fI
6950: 73 65 74 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 setOptionProc\fR
6960: 20 66 69 65 6c 64 20 63 6f 6e 74 61 69 6e 73 20 field contains
6970: 74 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 61 the address of a
6980: 20 66 75 6e 63 74 69 6f 6e 20 63 61 6c 6c 65 64 function called
6990: 20 62 79 0a 74 68 65 20 67 65 6e 65 72 69 63 20 by.the generic
69a0: 6c 61 79 65 72 20 74 6f 20 73 65 74 20 61 20 63 layer to set a c
69b0: 68 61 6e 6e 65 6c 20 74 79 70 65 20 73 70 65 63 hannel type spec
69c0: 69 66 69 63 20 6f 70 74 69 6f 6e 20 6f 6e 20 61 ific option on a
69d0: 20 63 68 61 6e 6e 65 6c 2e 0a 5c 66 49 73 65 74 channel..\fIset
69e0: 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 20 6d 75 OptionProc\fR mu
69f0: 73 74 20 6d 61 74 63 68 20 74 68 65 20 66 6f 6c st match the fol
6a00: 6c 6f 77 69 6e 67 20 70 72 6f 74 6f 74 79 70 65 lowing prototype
6a10: 3a 0a 2e 50 50 0a 2e 43 53 0a 74 79 70 65 64 65 :..PP..CS.typede
6a20: 66 20 69 6e 74 20 5c 66 42 54 63 6c 5f 44 72 69 f int \fBTcl_Dri
6a30: 76 65 72 53 65 74 4f 70 74 69 6f 6e 50 72 6f 63 verSetOptionProc
6a40: 5c 66 52 28 0a 20 20 20 20 20 20 20 20 43 6c 69 \fR(. Cli
6a50: 65 6e 74 44 61 74 61 20 5c 66 49 69 6e 73 74 61 entData \fIinsta
6a60: 6e 63 65 44 61 74 61 5c 66 52 2c 0a 20 20 20 20 nceData\fR,.
6a70: 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a Tcl_Interp *
6a80: 5c 66 49 69 6e 74 65 72 70 5c 66 52 2c 0a 20 20 \fIinterp\fR,.
6a90: 20 20 20 20 20 20 63 6f 6e 73 74 20 63 68 61 72 const char
6aa0: 20 2a 5c 66 49 6f 70 74 69 6f 6e 4e 61 6d 65 5c *\fIoptionName\
6ab0: 66 52 2c 0a 20 20 20 20 20 20 20 20 63 6f 6e 73 fR,. cons
6ac0: 74 20 63 68 61 72 20 2a 5c 66 49 6e 65 77 56 61 t char *\fInewVa
6ad0: 6c 75 65 5c 66 52 29 3b 0a 2e 43 45 0a 2e 50 50 lue\fR);..CE..PP
6ae0: 0a 5c 66 49 6f 70 74 69 6f 6e 4e 61 6d 65 5c 66 .\fIoptionName\f
6af0: 52 20 69 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 R is the name of
6b00: 20 61 6e 20 6f 70 74 69 6f 6e 20 74 6f 20 73 65 an option to se
6b10: 74 2c 20 61 6e 64 20 5c 66 49 6e 65 77 56 61 6c t, and \fInewVal
6b20: 75 65 5c 66 52 20 69 73 0a 74 68 65 20 6e 65 77 ue\fR is.the new
6b30: 20 76 61 6c 75 65 20 66 6f 72 20 74 68 61 74 20 value for that
6b40: 6f 70 74 69 6f 6e 2c 20 61 73 20 61 20 73 74 72 option, as a str
6b50: 69 6e 67 2e 20 54 68 65 20 5c 66 49 69 6e 73 74 ing. The \fIinst
6b60: 61 6e 63 65 44 61 74 61 5c 66 52 20 69 73 20 74 anceData\fR is t
6b70: 68 65 0a 73 61 6d 65 20 61 73 20 74 68 65 20 76 he.same as the v
6b80: 61 6c 75 65 20 67 69 76 65 6e 20 74 6f 20 5c 66 alue given to \f
6b90: 42 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e 6e BTcl_CreateChann
6ba0: 65 6c 5c 66 52 20 77 68 65 6e 20 74 68 69 73 20 el\fR when this
6bb0: 63 68 61 6e 6e 65 6c 20 77 61 73 0a 63 72 65 61 channel was.crea
6bc0: 74 65 64 2e 20 54 68 65 20 66 75 6e 63 74 69 6f ted. The functio
6bd0: 6e 20 73 68 6f 75 6c 64 20 64 6f 20 77 68 61 74 n should do what
6be0: 65 76 65 72 20 63 68 61 6e 6e 65 6c 20 74 79 70 ever channel typ
6bf0: 65 20 73 70 65 63 69 66 69 63 20 61 63 74 69 6f e specific actio
6c00: 6e 20 69 73 0a 72 65 71 75 69 72 65 64 20 74 6f n is.required to
6c10: 20 69 6d 70 6c 65 6d 65 6e 74 20 74 68 65 20 6e implement the n
6c20: 65 77 20 76 61 6c 75 65 20 6f 66 20 74 68 65 20 ew value of the
6c30: 6f 70 74 69 6f 6e 2e 0a 2e 50 50 0a 53 6f 6d 65 option...PP.Some
6c40: 20 6f 70 74 69 6f 6e 73 20 61 72 65 20 68 61 6e options are han
6c50: 64 6c 65 64 20 62 79 20 74 68 65 20 67 65 6e 65 dled by the gene
6c60: 72 69 63 20 63 6f 64 65 20 61 6e 64 20 74 68 69 ric code and thi
6c70: 73 20 66 75 6e 63 74 69 6f 6e 20 69 73 20 6e 65 s function is ne
6c80: 76 65 72 0a 63 61 6c 6c 65 64 20 74 6f 20 73 65 ver.called to se
6c90: 74 20 74 68 65 6d 2c 20 65 2e 67 2e 20 5c 66 42 t them, e.g. \fB
6ca0: 5c 2d 62 6c 6f 63 6b 6d 6f 64 65 5c 66 52 2e 20 \-blockmode\fR.
6cb0: 4f 74 68 65 72 20 6f 70 74 69 6f 6e 73 20 61 72 Other options ar
6cc0: 65 20 73 70 65 63 69 66 69 63 20 74 6f 0a 65 61 e specific to.ea
6cd0: 63 68 20 63 68 61 6e 6e 65 6c 20 74 79 70 65 20 ch channel type
6ce0: 61 6e 64 20 74 68 65 20 5c 66 49 73 65 74 4f 70 and the \fIsetOp
6cf0: 74 69 6f 6e 50 72 6f 63 5c 66 52 20 70 72 6f 63 tionProc\fR proc
6d00: 65 64 75 72 65 20 6f 66 20 74 68 65 20 63 68 61 edure of the cha
6d10: 6e 6e 65 6c 0a 64 72 69 76 65 72 20 77 69 6c 6c nnel.driver will
6d20: 20 67 65 74 20 63 61 6c 6c 65 64 20 74 6f 20 69 get called to i
6d30: 6d 70 6c 65 6d 65 6e 74 20 74 68 65 6d 2e 20 54 mplement them. T
6d40: 68 65 20 5c 66 49 73 65 74 4f 70 74 69 6f 6e 50 he \fIsetOptionP
6d50: 72 6f 63 5c 66 52 20 66 69 65 6c 64 20 63 61 6e roc\fR field can
6d60: 0a 62 65 20 4e 55 4c 4c 2c 20 77 68 69 63 68 20 .be NULL, which
6d70: 69 6e 64 69 63 61 74 65 73 20 74 68 61 74 20 74 indicates that t
6d80: 68 69 73 20 63 68 61 6e 6e 65 6c 20 74 79 70 65 his channel type
6d90: 20 73 75 70 70 6f 72 74 73 20 6e 6f 20 74 79 70 supports no typ
6da0: 65 20 73 70 65 63 69 66 69 63 0a 6f 70 74 69 6f e specific.optio
6db0: 6e 73 2e 0a 2e 50 50 0a 49 66 20 74 68 65 20 6f ns...PP.If the o
6dc0: 70 74 69 6f 6e 20 76 61 6c 75 65 20 69 73 20 73 ption value is s
6dd0: 75 63 63 65 73 73 66 75 6c 6c 79 20 6d 6f 64 69 uccessfully modi
6de0: 66 69 65 64 20 74 6f 20 74 68 65 20 6e 65 77 20 fied to the new
6df0: 76 61 6c 75 65 2c 20 74 68 65 20 66 75 6e 63 74 value, the funct
6e00: 69 6f 6e 0a 72 65 74 75 72 6e 73 20 5c 66 42 54 ion.returns \fBT
6e10: 43 4c 5f 4f 4b 5c 66 52 2e 0a 49 74 20 73 68 6f CL_OK\fR..It sho
6e20: 75 6c 64 20 63 61 6c 6c 20 5c 66 42 54 63 6c 5f uld call \fBTcl_
6e30: 42 61 64 43 68 61 6e 6e 65 6c 4f 70 74 69 6f 6e BadChannelOption
6e40: 5c 66 52 20 77 68 69 63 68 20 69 74 73 65 6c 66 \fR which itself
6e50: 20 72 65 74 75 72 6e 73 0a 5c 66 42 54 43 4c 5f returns.\fBTCL_
6e60: 45 52 52 4f 52 5c 66 52 20 69 66 20 74 68 65 20 ERROR\fR if the
6e70: 5c 66 49 6f 70 74 69 6f 6e 4e 61 6d 65 5c 66 52 \fIoptionName\fR
6e80: 20 69 73 0a 75 6e 72 65 63 6f 67 6e 69 7a 65 64 is.unrecognized
6e90: 2e 0a 49 66 20 5c 66 49 6e 65 77 56 61 6c 75 65 ..If \fInewValue
6ea0: 5c 66 52 20 73 70 65 63 69 66 69 65 73 20 61 20 \fR specifies a
6eb0: 76 61 6c 75 65 20 66 6f 72 20 74 68 65 20 6f 70 value for the op
6ec0: 74 69 6f 6e 20 74 68 61 74 0a 69 73 20 6e 6f 74 tion that.is not
6ed0: 20 73 75 70 70 6f 72 74 65 64 20 6f 72 20 69 66 supported or if
6ee0: 20 61 20 73 79 73 74 65 6d 20 63 61 6c 6c 20 65 a system call e
6ef0: 72 72 6f 72 20 6f 63 63 75 72 73 2c 0a 74 68 65 rror occurs,.the
6f00: 20 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 function should
6f10: 20 6c 65 61 76 65 20 61 6e 20 65 72 72 6f 72 20 leave an error
6f20: 6d 65 73 73 61 67 65 20 69 6e 20 74 68 65 20 72 message in the r
6f30: 65 73 75 6c 74 0a 6f 66 20 5c 66 49 69 6e 74 65 esult.of \fIinte
6f40: 72 70 5c 66 52 20 69 66 20 5c 66 49 69 6e 74 65 rp\fR if \fIinte
6f50: 72 70 5c 66 52 20 69 73 20 6e 6f 74 20 4e 55 4c rp\fR is not NUL
6f60: 4c 2e 20 54 68 65 0a 66 75 6e 63 74 69 6f 6e 20 L. The.function
6f70: 73 68 6f 75 6c 64 20 61 6c 73 6f 20 63 61 6c 6c should also call
6f80: 20 5c 66 42 54 63 6c 5f 53 65 74 45 72 72 6e 6f \fBTcl_SetErrno
6f90: 5c 66 52 20 74 6f 20 73 74 6f 72 65 20 61 6e 20 \fR to store an
6fa0: 61 70 70 72 6f 70 72 69 61 74 65 20 50 4f 53 49 appropriate POSI
6fb0: 58 0a 65 72 72 6f 72 20 63 6f 64 65 2e 0a 2e 50 X.error code...P
6fc0: 50 0a 54 68 69 73 20 76 61 6c 75 65 20 63 61 6e P.This value can
6fd0: 20 62 65 20 72 65 74 72 69 65 76 65 64 20 77 69 be retrieved wi
6fe0: 74 68 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 th \fBTcl_Channe
6ff0: 6c 53 65 74 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 lSetOptionProc\f
7000: 52 2c 20 77 68 69 63 68 20 72 65 74 75 72 6e 73 R, which returns
7010: 0a 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 .a pointer to th
7020: 65 20 66 75 6e 63 74 69 6f 6e 2e 0a 2e 53 53 20 e function...SS
7030: 47 45 54 4f 50 54 49 4f 4e 50 52 4f 43 0a 2e 50 GETOPTIONPROC..P
7040: 50 0a 54 68 65 20 5c 66 49 67 65 74 4f 70 74 69 P.The \fIgetOpti
7050: 6f 6e 50 72 6f 63 5c 66 52 20 66 69 65 6c 64 20 onProc\fR field
7060: 63 6f 6e 74 61 69 6e 73 20 74 68 65 20 61 64 64 contains the add
7070: 72 65 73 73 20 6f 66 20 61 20 66 75 6e 63 74 69 ress of a functi
7080: 6f 6e 20 63 61 6c 6c 65 64 20 62 79 0a 74 68 65 on called by.the
7090: 20 67 65 6e 65 72 69 63 20 6c 61 79 65 72 20 74 generic layer t
70a0: 6f 20 67 65 74 20 74 68 65 20 76 61 6c 75 65 20 o get the value
70b0: 6f 66 20 61 20 63 68 61 6e 6e 65 6c 20 74 79 70 of a channel typ
70c0: 65 20 73 70 65 63 69 66 69 63 20 6f 70 74 69 6f e specific optio
70d0: 6e 20 6f 6e 20 61 0a 63 68 61 6e 6e 65 6c 2e 20 n on a.channel.
70e0: 5c 66 49 67 65 74 4f 70 74 69 6f 6e 50 72 6f 63 \fIgetOptionProc
70f0: 5c 66 52 20 6d 75 73 74 20 6d 61 74 63 68 20 74 \fR must match t
7100: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 70 72 6f he following pro
7110: 74 6f 74 79 70 65 3a 0a 2e 50 50 0a 2e 43 53 0a totype:..PP..CS.
7120: 74 79 70 65 64 65 66 20 69 6e 74 20 5c 66 42 54 typedef int \fBT
7130: 63 6c 5f 44 72 69 76 65 72 47 65 74 4f 70 74 69 cl_DriverGetOpti
7140: 6f 6e 50 72 6f 63 5c 66 52 28 0a 20 20 20 20 20 onProc\fR(.
7150: 20 20 20 43 6c 69 65 6e 74 44 61 74 61 20 5c 66 ClientData \f
7160: 49 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 IinstanceData\fR
7170: 2c 0a 20 20 20 20 20 20 20 20 54 63 6c 5f 49 6e ,. Tcl_In
7180: 74 65 72 70 20 2a 5c 66 49 69 6e 74 65 72 70 5c terp *\fIinterp\
7190: 66 52 2c 0a 20 20 20 20 20 20 20 20 63 6f 6e 73 fR,. cons
71a0: 74 20 63 68 61 72 20 2a 5c 66 49 6f 70 74 69 6f t char *\fIoptio
71b0: 6e 4e 61 6d 65 5c 66 52 2c 0a 20 20 20 20 20 20 nName\fR,.
71c0: 20 20 54 63 6c 5f 44 53 74 72 69 6e 67 20 2a 5c Tcl_DString *\
71d0: 66 49 6f 70 74 69 6f 6e 56 61 6c 75 65 5c 66 52 fIoptionValue\fR
71e0: 29 3b 0a 2e 43 45 0a 2e 50 50 0a 5c 66 49 4f 70 );..CE..PP.\fIOp
71f0: 74 69 6f 6e 4e 61 6d 65 5c 66 52 20 69 73 20 74 tionName\fR is t
7200: 68 65 20 6e 61 6d 65 20 6f 66 20 61 6e 20 6f 70 he name of an op
7210: 74 69 6f 6e 20 73 75 70 70 6f 72 74 65 64 20 62 tion supported b
7220: 79 20 74 68 69 73 20 74 79 70 65 20 6f 66 0a 63 y this type of.c
7230: 68 61 6e 6e 65 6c 2e 20 49 66 20 74 68 65 20 6f hannel. If the o
7240: 70 74 69 6f 6e 20 6e 61 6d 65 20 69 73 20 6e 6f ption name is no
7250: 74 20 4e 55 4c 4c 2c 20 74 68 65 20 66 75 6e 63 t NULL, the func
7260: 74 69 6f 6e 20 73 74 6f 72 65 73 20 69 74 73 20 tion stores its
7270: 63 75 72 72 65 6e 74 0a 76 61 6c 75 65 2c 20 61 current.value, a
7280: 73 20 61 20 73 74 72 69 6e 67 2c 20 69 6e 20 74 s a string, in t
7290: 68 65 20 54 63 6c 20 64 79 6e 61 6d 69 63 20 73 he Tcl dynamic s
72a0: 74 72 69 6e 67 20 5c 66 49 6f 70 74 69 6f 6e 56 tring \fIoptionV
72b0: 61 6c 75 65 5c 66 52 2e 0a 49 66 20 5c 66 49 6f alue\fR..If \fIo
72c0: 70 74 69 6f 6e 4e 61 6d 65 5c 66 52 20 69 73 20 ptionName\fR is
72d0: 4e 55 4c 4c 2c 20 74 68 65 20 66 75 6e 63 74 69 NULL, the functi
72e0: 6f 6e 20 73 74 6f 72 65 73 20 69 6e 20 5c 66 49 on stores in \fI
72f0: 6f 70 74 69 6f 6e 56 61 6c 75 65 5c 66 52 20 61 optionValue\fR a
7300: 6e 0a 61 6c 74 65 72 6e 61 74 69 6e 67 20 6c 69 n.alternating li
7310: 73 74 20 6f 66 20 61 6c 6c 20 73 75 70 70 6f 72 st of all suppor
7320: 74 65 64 20 6f 70 74 69 6f 6e 73 20 61 6e 64 20 ted options and
7330: 74 68 65 69 72 20 63 75 72 72 65 6e 74 20 76 61 their current va
7340: 6c 75 65 73 2e 0a 4f 6e 20 73 75 63 63 65 73 73 lues..On success
7350: 2c 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 72 , the function r
7360: 65 74 75 72 6e 73 20 5c 66 42 54 43 4c 5f 4f 4b eturns \fBTCL_OK
7370: 5c 66 52 2e 0a 49 74 20 73 68 6f 75 6c 64 20 63 \fR..It should c
7380: 61 6c 6c 20 5c 66 42 54 63 6c 5f 42 61 64 43 68 all \fBTcl_BadCh
7390: 61 6e 6e 65 6c 4f 70 74 69 6f 6e 5c 66 52 20 77 annelOption\fR w
73a0: 68 69 63 68 20 69 74 73 65 6c 66 20 72 65 74 75 hich itself retu
73b0: 72 6e 73 0a 5c 66 42 54 43 4c 5f 45 52 52 4f 52 rns.\fBTCL_ERROR
73c0: 5c 66 52 20 69 66 20 74 68 65 20 5c 66 49 6f 70 \fR if the \fIop
73d0: 74 69 6f 6e 4e 61 6d 65 5c 66 52 20 69 73 0a 75 tionName\fR is.u
73e0: 6e 72 65 63 6f 67 6e 69 7a 65 64 2e 20 49 66 20 nrecognized. If
73f0: 61 20 73 79 73 74 65 6d 20 63 61 6c 6c 20 65 72 a system call er
7400: 72 6f 72 20 6f 63 63 75 72 73 2c 0a 74 68 65 20 ror occurs,.the
7410: 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 function should
7420: 6c 65 61 76 65 20 61 6e 20 65 72 72 6f 72 20 6d leave an error m
7430: 65 73 73 61 67 65 20 69 6e 20 74 68 65 0a 72 65 essage in the.re
7440: 73 75 6c 74 20 6f 66 20 5c 66 49 69 6e 74 65 72 sult of \fIinter
7450: 70 5c 66 52 20 69 66 20 5c 66 49 69 6e 74 65 72 p\fR if \fIinter
7460: 70 5c 66 52 20 69 73 20 6e 6f 74 20 4e 55 4c 4c p\fR is not NULL
7470: 2e 20 54 68 65 0a 66 75 6e 63 74 69 6f 6e 20 73 . The.function s
7480: 68 6f 75 6c 64 20 61 6c 73 6f 20 63 61 6c 6c 20 hould also call
7490: 5c 66 42 54 63 6c 5f 53 65 74 45 72 72 6e 6f 5c \fBTcl_SetErrno\
74a0: 66 52 20 74 6f 20 73 74 6f 72 65 20 61 6e 20 61 fR to store an a
74b0: 70 70 72 6f 70 72 69 61 74 65 20 50 4f 53 49 58 ppropriate POSIX
74c0: 0a 65 72 72 6f 72 20 63 6f 64 65 2e 0a 2e 50 50 .error code...PP
74d0: 0a 53 6f 6d 65 20 6f 70 74 69 6f 6e 73 20 61 72 .Some options ar
74e0: 65 20 68 61 6e 64 6c 65 64 20 62 79 20 74 68 65 e handled by the
74f0: 20 67 65 6e 65 72 69 63 20 63 6f 64 65 20 61 6e generic code an
7500: 64 20 74 68 69 73 20 66 75 6e 63 74 69 6f 6e 20 d this function
7510: 69 73 20 6e 65 76 65 72 0a 63 61 6c 6c 65 64 20 is never.called
7520: 74 6f 20 72 65 74 72 69 65 76 65 20 74 68 65 69 to retrieve thei
7530: 72 20 76 61 6c 75 65 2c 20 65 2e 67 2e 20 5c 66 r value, e.g. \f
7540: 42 5c 2d 62 6c 6f 63 6b 6d 6f 64 65 5c 66 52 2e B\-blockmode\fR.
7550: 20 4f 74 68 65 72 20 6f 70 74 69 6f 6e 73 20 61 Other options a
7560: 72 65 0a 73 70 65 63 69 66 69 63 20 74 6f 20 65 re.specific to e
7570: 61 63 68 20 63 68 61 6e 6e 65 6c 20 74 79 70 65 ach channel type
7580: 20 61 6e 64 20 74 68 65 20 5c 66 49 67 65 74 4f and the \fIgetO
7590: 70 74 69 6f 6e 50 72 6f 63 5c 66 52 20 70 72 6f ptionProc\fR pro
75a0: 63 65 64 75 72 65 20 6f 66 20 74 68 65 0a 63 68 cedure of the.ch
75b0: 61 6e 6e 65 6c 20 64 72 69 76 65 72 20 77 69 6c annel driver wil
75c0: 6c 20 67 65 74 20 63 61 6c 6c 65 64 20 74 6f 20 l get called to
75d0: 69 6d 70 6c 65 6d 65 6e 74 20 74 68 65 6d 2e 20 implement them.
75e0: 54 68 65 20 5c 66 49 67 65 74 4f 70 74 69 6f 6e The \fIgetOption
75f0: 50 72 6f 63 5c 66 52 0a 66 69 65 6c 64 20 63 61 Proc\fR.field ca
7600: 6e 20 62 65 20 4e 55 4c 4c 2c 20 77 68 69 63 68 n be NULL, which
7610: 20 69 6e 64 69 63 61 74 65 73 20 74 68 61 74 20 indicates that
7620: 74 68 69 73 20 63 68 61 6e 6e 65 6c 20 74 79 70 this channel typ
7630: 65 20 73 75 70 70 6f 72 74 73 20 6e 6f 20 74 79 e supports no ty
7640: 70 65 0a 73 70 65 63 69 66 69 63 20 6f 70 74 69 pe.specific opti
7650: 6f 6e 73 2e 0a 2e 50 50 0a 54 68 69 73 20 76 61 ons...PP.This va
7660: 6c 75 65 20 63 61 6e 20 62 65 20 72 65 74 72 69 lue can be retri
7670: 65 76 65 64 20 77 69 74 68 20 5c 66 42 54 63 6c eved with \fBTcl
7680: 5f 43 68 61 6e 6e 65 6c 47 65 74 4f 70 74 69 6f _ChannelGetOptio
7690: 6e 50 72 6f 63 5c 66 52 2c 20 77 68 69 63 68 20 nProc\fR, which
76a0: 72 65 74 75 72 6e 73 0a 61 20 70 6f 69 6e 74 65 returns.a pointe
76b0: 72 20 74 6f 20 74 68 65 20 66 75 6e 63 74 69 6f r to the functio
76c0: 6e 2e 0a 2e 53 53 20 57 41 54 43 48 50 52 4f 43 n...SS WATCHPROC
76d0: 0a 2e 50 50 0a 54 68 65 20 5c 66 49 77 61 74 63 ..PP.The \fIwatc
76e0: 68 50 72 6f 63 5c 66 52 20 66 69 65 6c 64 20 63 hProc\fR field c
76f0: 6f 6e 74 61 69 6e 73 20 74 68 65 20 61 64 64 72 ontains the addr
7700: 65 73 73 20 6f 66 20 61 20 66 75 6e 63 74 69 6f ess of a functio
7710: 6e 20 63 61 6c 6c 65 64 0a 62 79 20 74 68 65 20 n called.by the
7720: 67 65 6e 65 72 69 63 20 6c 61 79 65 72 20 74 6f generic layer to
7730: 20 69 6e 69 74 69 61 6c 69 7a 65 20 74 68 65 20 initialize the
7740: 65 76 65 6e 74 20 6e 6f 74 69 66 69 63 61 74 69 event notificati
7750: 6f 6e 20 6d 65 63 68 61 6e 69 73 6d 20 74 6f 0a on mechanism to.
7760: 6e 6f 74 69 63 65 20 65 76 65 6e 74 73 20 6f 66 notice events of
7770: 20 69 6e 74 65 72 65 73 74 20 6f 6e 20 74 68 69 interest on thi
7780: 73 20 63 68 61 6e 6e 65 6c 2e 0a 5c 66 49 57 61 s channel..\fIWa
7790: 74 63 68 50 72 6f 63 5c 66 52 20 73 68 6f 75 6c tchProc\fR shoul
77a0: 64 20 6d 61 74 63 68 20 74 68 65 20 66 6f 6c 6c d match the foll
77b0: 6f 77 69 6e 67 20 70 72 6f 74 6f 74 79 70 65 3a owing prototype:
77c0: 0a 2e 50 50 0a 2e 43 53 0a 74 79 70 65 64 65 66 ..PP..CS.typedef
77d0: 20 76 6f 69 64 20 5c 66 42 54 63 6c 5f 44 72 69 void \fBTcl_Dri
77e0: 76 65 72 57 61 74 63 68 50 72 6f 63 5c 66 52 28 verWatchProc\fR(
77f0: 0a 20 20 20 20 20 20 20 20 43 6c 69 65 6e 74 44 . ClientD
7800: 61 74 61 20 5c 66 49 69 6e 73 74 61 6e 63 65 44 ata \fIinstanceD
7810: 61 74 61 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 ata\fR,.
7820: 69 6e 74 20 5c 66 49 6d 61 73 6b 5c 66 52 29 3b int \fImask\fR);
7830: 0a 2e 43 45 0a 2e 50 50 0a 54 68 65 20 5c 66 49 ..CE..PP.The \fI
7840: 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 20 instanceData\fR
7850: 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 20 74 is the same as t
7860: 68 65 20 76 61 6c 75 65 20 70 61 73 73 65 64 20 he value passed
7870: 74 6f 0a 5c 66 42 54 63 6c 5f 43 72 65 61 74 65 to.\fBTcl_Create
7880: 43 68 61 6e 6e 65 6c 5c 66 52 20 77 68 65 6e 20 Channel\fR when
7890: 74 68 69 73 20 63 68 61 6e 6e 65 6c 20 77 61 73 this channel was
78a0: 20 63 72 65 61 74 65 64 2e 20 54 68 65 20 5c 66 created. The \f
78b0: 49 6d 61 73 6b 5c 66 52 0a 61 72 67 75 6d 65 6e Imask\fR.argumen
78c0: 74 20 69 73 20 61 6e 20 4f 52 2d 65 64 20 63 6f t is an OR-ed co
78d0: 6d 62 69 6e 61 74 69 6f 6e 20 6f 66 20 5c 66 42 mbination of \fB
78e0: 54 43 4c 5f 52 45 41 44 41 42 4c 45 5c 66 52 2c TCL_READABLE\fR,
78f0: 20 5c 66 42 54 43 4c 5f 57 52 49 54 41 42 4c 45 \fBTCL_WRITABLE
7900: 5c 66 52 0a 61 6e 64 20 5c 66 42 54 43 4c 5f 45 \fR.and \fBTCL_E
7910: 58 43 45 50 54 49 4f 4e 5c 66 52 3b 20 69 74 20 XCEPTION\fR; it
7920: 69 6e 64 69 63 61 74 65 73 20 65 76 65 6e 74 73 indicates events
7930: 20 74 68 65 20 63 61 6c 6c 65 72 20 69 73 20 69 the caller is i
7940: 6e 74 65 72 65 73 74 65 64 20 69 6e 0a 6e 6f 74 nterested in.not
7950: 69 63 69 6e 67 20 6f 6e 20 74 68 69 73 20 63 68 icing on this ch
7960: 61 6e 6e 65 6c 2e 0a 2e 50 50 0a 54 68 65 20 66 annel...PP.The f
7970: 75 6e 63 74 69 6f 6e 20 73 68 6f 75 6c 64 20 69 unction should i
7980: 6e 69 74 69 61 6c 69 7a 65 20 64 65 76 69 63 65 nitialize device
7990: 20 74 79 70 65 20 73 70 65 63 69 66 69 63 20 6d type specific m
79a0: 65 63 68 61 6e 69 73 6d 73 20 74 6f 0a 6e 6f 74 echanisms to.not
79b0: 69 63 65 20 77 68 65 6e 20 61 6e 20 65 76 65 6e ice when an even
79c0: 74 20 6f 66 20 69 6e 74 65 72 65 73 74 20 69 73 t of interest is
79d0: 20 70 72 65 73 65 6e 74 20 6f 6e 20 74 68 65 20 present on the
79e0: 63 68 61 6e 6e 65 6c 2e 20 20 57 68 65 6e 20 6f channel. When o
79f0: 6e 65 0a 6f 72 20 6d 6f 72 65 20 6f 66 20 74 68 ne.or more of th
7a00: 65 20 64 65 73 69 67 6e 61 74 65 64 20 65 76 65 e designated eve
7a10: 6e 74 73 20 6f 63 63 75 72 73 20 6f 6e 20 74 68 nts occurs on th
7a20: 65 20 63 68 61 6e 6e 65 6c 2c 20 74 68 65 20 63 e channel, the c
7a30: 68 61 6e 6e 65 6c 0a 64 72 69 76 65 72 20 69 73 hannel.driver is
7a40: 20 72 65 73 70 6f 6e 73 69 62 6c 65 20 66 6f 72 responsible for
7a50: 20 63 61 6c 6c 69 6e 67 20 5c 66 42 54 63 6c 5f calling \fBTcl_
7a60: 4e 6f 74 69 66 79 43 68 61 6e 6e 65 6c 5c 66 52 NotifyChannel\fR
7a70: 20 74 6f 20 69 6e 66 6f 72 6d 0a 74 68 65 20 67 to inform.the g
7a80: 65 6e 65 72 69 63 20 63 68 61 6e 6e 65 6c 20 6d eneric channel m
7a90: 6f 64 75 6c 65 2e 20 20 54 68 65 20 64 72 69 76 odule. The driv
7aa0: 65 72 20 73 68 6f 75 6c 64 20 74 61 6b 65 20 63 er should take c
7ab0: 61 72 65 20 6e 6f 74 20 74 6f 20 73 74 61 72 76 are not to starv
7ac0: 65 0a 6f 74 68 65 72 20 63 68 61 6e 6e 65 6c 20 e.other channel
7ad0: 64 72 69 76 65 72 73 20 6f 72 20 73 6f 75 72 63 drivers or sourc
7ae0: 65 73 20 6f 66 20 63 61 6c 6c 62 61 63 6b 73 20 es of callbacks
7af0: 62 79 20 69 6e 76 6f 6b 69 6e 67 0a 54 63 6c 5f by invoking.Tcl_
7b00: 4e 6f 74 69 66 79 43 68 61 6e 6e 65 6c 20 74 6f NotifyChannel to
7b10: 6f 20 66 72 65 71 75 65 6e 74 6c 79 2e 20 20 46 o frequently. F
7b20: 61 69 72 6e 65 73 73 20 63 61 6e 20 62 65 20 69 airness can be i
7b30: 6e 73 75 72 65 64 20 62 79 20 75 73 69 6e 67 0a nsured by using.
7b40: 74 68 65 20 54 63 6c 20 65 76 65 6e 74 20 71 75 the Tcl event qu
7b50: 65 75 65 20 74 6f 20 61 6c 6c 6f 77 20 74 68 65 eue to allow the
7b60: 20 63 68 61 6e 6e 65 6c 20 65 76 65 6e 74 20 74 channel event t
7b70: 6f 20 62 65 20 73 63 68 65 64 75 6c 65 64 20 69 o be scheduled i
7b80: 6e 20 73 65 71 75 65 6e 63 65 0a 77 69 74 68 20 n sequence.with
7b90: 6f 74 68 65 72 20 65 76 65 6e 74 73 2e 20 20 53 other events. S
7ba0: 65 65 20 74 68 65 20 64 65 73 63 72 69 70 74 69 ee the descripti
7bb0: 6f 6e 20 6f 66 20 5c 66 42 54 63 6c 5f 51 75 65 on of \fBTcl_Que
7bc0: 75 65 45 76 65 6e 74 5c 66 52 20 66 6f 72 0a 64 ueEvent\fR for.d
7bd0: 65 74 61 69 6c 73 20 6f 6e 20 68 6f 77 20 74 6f etails on how to
7be0: 20 71 75 65 75 65 20 61 6e 20 65 76 65 6e 74 2e queue an event.
7bf0: 0a 2e 50 50 0a 54 68 69 73 20 76 61 6c 75 65 20 ..PP.This value
7c00: 63 61 6e 20 62 65 20 72 65 74 72 69 65 76 65 64 can be retrieved
7c10: 20 77 69 74 68 20 5c 66 42 54 63 6c 5f 43 68 61 with \fBTcl_Cha
7c20: 6e 6e 65 6c 57 61 74 63 68 50 72 6f 63 5c 66 52 nnelWatchProc\fR
7c30: 2c 20 77 68 69 63 68 20 72 65 74 75 72 6e 73 0a , which returns.
7c40: 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 a pointer to the
7c50: 20 66 75 6e 63 74 69 6f 6e 2e 0a 2e 53 53 20 47 function...SS G
7c60: 45 54 48 41 4e 44 4c 45 50 52 4f 43 0a 2e 50 50 ETHANDLEPROC..PP
7c70: 0a 54 68 65 20 5c 66 49 67 65 74 48 61 6e 64 6c .The \fIgetHandl
7c80: 65 50 72 6f 63 5c 66 52 20 66 69 65 6c 64 20 63 eProc\fR field c
7c90: 6f 6e 74 61 69 6e 73 20 74 68 65 20 61 64 64 72 ontains the addr
7ca0: 65 73 73 20 6f 66 20 61 20 66 75 6e 63 74 69 6f ess of a functio
7cb0: 6e 20 63 61 6c 6c 65 64 20 62 79 0a 74 68 65 20 n called by.the
7cc0: 67 65 6e 65 72 69 63 20 6c 61 79 65 72 20 74 6f generic layer to
7cd0: 20 72 65 74 72 69 65 76 65 20 61 20 64 65 76 69 retrieve a devi
7ce0: 63 65 2d 73 70 65 63 69 66 69 63 20 68 61 6e 64 ce-specific hand
7cf0: 6c 65 20 66 72 6f 6d 20 74 68 65 20 63 68 61 6e le from the chan
7d00: 6e 65 6c 2e 0a 5c 66 49 47 65 74 48 61 6e 64 6c nel..\fIGetHandl
7d10: 65 50 72 6f 63 5c 66 52 20 73 68 6f 75 6c 64 20 eProc\fR should
7d20: 6d 61 74 63 68 20 74 68 65 20 66 6f 6c 6c 6f 77 match the follow
7d30: 69 6e 67 20 70 72 6f 74 6f 74 79 70 65 3a 0a 2e ing prototype:..
7d40: 50 50 0a 2e 43 53 0a 74 79 70 65 64 65 66 20 69 PP..CS.typedef i
7d50: 6e 74 20 5c 66 42 54 63 6c 5f 44 72 69 76 65 72 nt \fBTcl_Driver
7d60: 47 65 74 48 61 6e 64 6c 65 50 72 6f 63 5c 66 52 GetHandleProc\fR
7d70: 28 0a 20 20 20 20 20 20 20 20 43 6c 69 65 6e 74 (. Client
7d80: 44 61 74 61 20 5c 66 49 69 6e 73 74 61 6e 63 65 Data \fIinstance
7d90: 44 61 74 61 5c 66 52 2c 0a 20 20 20 20 20 20 20 Data\fR,.
7da0: 20 69 6e 74 20 5c 66 49 64 69 72 65 63 74 69 6f int \fIdirectio
7db0: 6e 5c 66 52 2c 0a 20 20 20 20 20 20 20 20 43 6c n\fR,. Cl
7dc0: 69 65 6e 74 44 61 74 61 20 2a 5c 66 49 68 61 6e ientData *\fIhan
7dd0: 64 6c 65 50 74 72 5c 66 52 29 3b 0a 2e 43 45 0a dlePtr\fR);..CE.
7de0: 2e 50 50 0a 5c 66 49 49 6e 73 74 61 6e 63 65 44 .PP.\fIInstanceD
7df0: 61 74 61 5c 66 52 20 69 73 20 74 68 65 20 73 61 ata\fR is the sa
7e00: 6d 65 20 61 73 20 74 68 65 20 76 61 6c 75 65 20 me as the value
7e10: 70 61 73 73 65 64 20 74 6f 0a 5c 66 42 54 63 6c passed to.\fBTcl
7e20: 5f 43 72 65 61 74 65 43 68 61 6e 6e 65 6c 5c 66 _CreateChannel\f
7e30: 52 20 77 68 65 6e 20 74 68 69 73 20 63 68 61 6e R when this chan
7e40: 6e 65 6c 20 77 61 73 20 63 72 65 61 74 65 64 2e nel was created.
7e50: 20 54 68 65 20 5c 66 49 64 69 72 65 63 74 69 6f The \fIdirectio
7e60: 6e 5c 66 52 0a 61 72 67 75 6d 65 6e 74 20 69 73 n\fR.argument is
7e70: 20 65 69 74 68 65 72 20 5c 66 42 54 43 4c 5f 52 either \fBTCL_R
7e80: 45 41 44 41 42 4c 45 5c 66 52 20 74 6f 20 72 65 EADABLE\fR to re
7e90: 74 72 69 65 76 65 20 74 68 65 20 68 61 6e 64 6c trieve the handl
7ea0: 65 20 75 73 65 64 0a 66 6f 72 20 69 6e 70 75 74 e used.for input
7eb0: 2c 20 6f 72 20 5c 66 42 54 43 4c 5f 57 52 49 54 , or \fBTCL_WRIT
7ec0: 41 42 4c 45 5c 66 52 20 74 6f 20 72 65 74 72 69 ABLE\fR to retri
7ed0: 65 76 65 20 74 68 65 20 68 61 6e 64 6c 65 20 75 eve the handle u
7ee0: 73 65 64 20 66 6f 72 0a 6f 75 74 70 75 74 2e 0a sed for.output..
7ef0: 2e 50 50 0a 49 66 20 74 68 65 20 63 68 61 6e 6e .PP.If the chann
7f00: 65 6c 20 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f el implementatio
7f10: 6e 20 68 61 73 20 64 65 76 69 63 65 2d 73 70 65 n has device-spe
7f20: 63 69 66 69 63 20 68 61 6e 64 6c 65 73 2c 20 74 cific handles, t
7f30: 68 65 0a 66 75 6e 63 74 69 6f 6e 20 73 68 6f 75 he.function shou
7f40: 6c 64 20 72 65 74 72 69 65 76 65 20 74 68 65 20 ld retrieve the
7f50: 61 70 70 72 6f 70 72 69 61 74 65 20 68 61 6e 64 appropriate hand
7f60: 6c 65 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 le associated wi
7f70: 74 68 20 74 68 65 0a 63 68 61 6e 6e 65 6c 2c 20 th the.channel,
7f80: 61 63 63 6f 72 64 69 6e 67 20 74 68 65 20 5c 66 according the \f
7f90: 49 64 69 72 65 63 74 69 6f 6e 5c 66 52 20 61 72 Idirection\fR ar
7fa0: 67 75 6d 65 6e 74 2e 20 20 54 68 65 20 68 61 6e gument. The han
7fb0: 64 6c 65 20 73 68 6f 75 6c 64 20 62 65 0a 73 74 dle should be.st
7fc0: 6f 72 65 64 20 69 6e 20 74 68 65 20 6c 6f 63 61 ored in the loca
7fd0: 74 69 6f 6e 20 72 65 66 65 72 72 65 64 20 74 6f tion referred to
7fe0: 20 62 79 20 5c 66 49 68 61 6e 64 6c 65 50 74 72 by \fIhandlePtr
7ff0: 5c 66 52 2c 20 61 6e 64 0a 5c 66 42 54 43 4c 5f \fR, and.\fBTCL_
8000: 4f 4b 5c 66 52 20 73 68 6f 75 6c 64 20 62 65 20 OK\fR should be
8010: 72 65 74 75 72 6e 65 64 2e 20 20 49 66 20 74 68 returned. If th
8020: 65 20 63 68 61 6e 6e 65 6c 20 69 73 20 6e 6f 74 e channel is not
8030: 20 6f 70 65 6e 20 66 6f 72 20 74 68 65 0a 73 70 open for the.sp
8040: 65 63 69 66 69 65 64 20 64 69 72 65 63 74 69 6f ecified directio
8050: 6e 2c 20 6f 72 20 69 66 20 74 68 65 20 63 68 61 n, or if the cha
8060: 6e 6e 65 6c 20 69 6d 70 6c 65 6d 65 6e 74 61 74 nnel implementat
8070: 69 6f 6e 20 64 6f 65 73 20 6e 6f 74 20 75 73 65 ion does not use
8080: 0a 64 65 76 69 63 65 20 68 61 6e 64 6c 65 73 2c .device handles,
8090: 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 20 73 68 the function sh
80a0: 6f 75 6c 64 20 72 65 74 75 72 6e 20 5c 66 42 54 ould return \fBT
80b0: 43 4c 5f 45 52 52 4f 52 5c 66 52 2e 0a 2e 50 50 CL_ERROR\fR...PP
80c0: 0a 54 68 69 73 20 76 61 6c 75 65 20 63 61 6e 20 .This value can
80d0: 62 65 20 72 65 74 72 69 65 76 65 64 20 77 69 74 be retrieved wit
80e0: 68 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c h \fBTcl_Channel
80f0: 47 65 74 48 61 6e 64 6c 65 50 72 6f 63 5c 66 52 GetHandleProc\fR
8100: 2c 20 77 68 69 63 68 20 72 65 74 75 72 6e 73 0a , which returns.
8110: 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 a pointer to the
8120: 20 66 75 6e 63 74 69 6f 6e 2e 0a 2e 53 53 20 46 function...SS F
8130: 4c 55 53 48 50 52 4f 43 0a 2e 50 50 0a 54 68 65 LUSHPROC..PP.The
8140: 20 5c 66 49 66 6c 75 73 68 50 72 6f 63 5c 66 52 \fIflushProc\fR
8150: 20 66 69 65 6c 64 20 69 73 20 63 75 72 72 65 6e field is curren
8160: 74 6c 79 20 72 65 73 65 72 76 65 64 20 66 6f 72 tly reserved for
8170: 20 66 75 74 75 72 65 20 75 73 65 2e 0a 49 74 20 future use..It
8180: 73 68 6f 75 6c 64 20 62 65 20 73 65 74 20 74 6f should be set to
8190: 20 4e 55 4c 4c 2e 0a 5c 66 49 46 6c 75 73 68 50 NULL..\fIFlushP
81a0: 72 6f 63 5c 66 52 20 73 68 6f 75 6c 64 20 6d 61 roc\fR should ma
81b0: 74 63 68 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e tch the followin
81c0: 67 20 70 72 6f 74 6f 74 79 70 65 3a 0a 2e 50 50 g prototype:..PP
81d0: 0a 2e 43 53 0a 74 79 70 65 64 65 66 20 69 6e 74 ..CS.typedef int
81e0: 20 5c 66 42 54 63 6c 5f 44 72 69 76 65 72 46 6c \fBTcl_DriverFl
81f0: 75 73 68 50 72 6f 63 5c 66 52 28 0a 20 20 20 20 ushProc\fR(.
8200: 20 20 20 20 43 6c 69 65 6e 74 44 61 74 61 20 5c ClientData \
8210: 66 49 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 fIinstanceData\f
8220: 52 29 3b 0a 2e 43 45 0a 2e 50 50 0a 54 68 69 73 R);..CE..PP.This
8230: 20 76 61 6c 75 65 20 63 61 6e 20 62 65 20 72 65 value can be re
8240: 74 72 69 65 76 65 64 20 77 69 74 68 20 5c 66 42 trieved with \fB
8250: 54 63 6c 5f 43 68 61 6e 6e 65 6c 46 6c 75 73 68 Tcl_ChannelFlush
8260: 50 72 6f 63 5c 66 52 2c 20 77 68 69 63 68 20 72 Proc\fR, which r
8270: 65 74 75 72 6e 73 0a 61 20 70 6f 69 6e 74 65 72 eturns.a pointer
8280: 20 74 6f 20 74 68 65 20 66 75 6e 63 74 69 6f 6e to the function
8290: 2e 0a 2e 53 53 20 48 41 4e 44 4c 45 52 50 52 4f ...SS HANDLERPRO
82a0: 43 0a 2e 50 50 0a 54 68 65 20 5c 66 49 68 61 6e C..PP.The \fIhan
82b0: 64 6c 65 72 50 72 6f 63 5c 66 52 20 66 69 65 6c dlerProc\fR fiel
82c0: 64 20 63 6f 6e 74 61 69 6e 73 20 74 68 65 20 61 d contains the a
82d0: 64 64 72 65 73 73 20 6f 66 20 61 20 66 75 6e 63 ddress of a func
82e0: 74 69 6f 6e 20 63 61 6c 6c 65 64 20 62 79 0a 74 tion called by.t
82f0: 68 65 20 67 65 6e 65 72 69 63 20 6c 61 79 65 72 he generic layer
8300: 20 74 6f 20 6e 6f 74 69 66 79 20 74 68 65 20 63 to notify the c
8310: 68 61 6e 6e 65 6c 20 74 68 61 74 20 61 6e 20 65 hannel that an e
8320: 76 65 6e 74 20 6f 63 63 75 72 72 65 64 2e 20 20 vent occurred.
8330: 49 74 20 73 68 6f 75 6c 64 0a 62 65 20 64 65 66 It should.be def
8340: 69 6e 65 64 20 66 6f 72 20 73 74 61 63 6b 65 64 ined for stacked
8350: 20 63 68 61 6e 6e 65 6c 20 64 72 69 76 65 72 73 channel drivers
8360: 20 74 68 61 74 20 77 69 73 68 20 74 6f 20 62 65 that wish to be
8370: 20 6e 6f 74 69 66 69 65 64 20 6f 66 20 65 76 65 notified of eve
8380: 6e 74 73 0a 74 68 61 74 20 6f 63 63 75 72 20 6f nts.that occur o
8390: 6e 20 74 68 65 20 75 6e 64 65 72 6c 79 69 6e 67 n the underlying
83a0: 20 28 73 74 61 63 6b 65 64 29 20 63 68 61 6e 6e (stacked) chann
83b0: 65 6c 2e 0a 5c 66 49 48 61 6e 64 6c 65 72 50 72 el..\fIHandlerPr
83c0: 6f 63 5c 66 52 20 73 68 6f 75 6c 64 20 6d 61 74 oc\fR should mat
83d0: 63 68 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 ch the following
83e0: 20 70 72 6f 74 6f 74 79 70 65 3a 0a 2e 50 50 0a prototype:..PP.
83f0: 2e 43 53 0a 74 79 70 65 64 65 66 20 69 6e 74 20 .CS.typedef int
8400: 5c 66 42 54 63 6c 5f 44 72 69 76 65 72 48 61 6e \fBTcl_DriverHan
8410: 64 6c 65 72 50 72 6f 63 5c 66 52 28 0a 20 20 20 dlerProc\fR(.
8420: 20 20 20 20 20 43 6c 69 65 6e 74 44 61 74 61 20 ClientData
8430: 5c 66 49 69 6e 73 74 61 6e 63 65 44 61 74 61 5c \fIinstanceData\
8440: 66 52 2c 0a 20 20 20 20 20 20 20 20 69 6e 74 20 fR,. int
8450: 5c 66 49 69 6e 74 65 72 65 73 74 4d 61 73 6b 5c \fIinterestMask\
8460: 66 52 29 3b 0a 2e 43 45 0a 2e 50 50 0a 5c 66 49 fR);..CE..PP.\fI
8470: 49 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 20 InstanceData\fR
8480: 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 20 74 is the same as t
8490: 68 65 20 76 61 6c 75 65 20 70 61 73 73 65 64 20 he value passed
84a0: 74 6f 20 5c 66 42 54 63 6c 5f 43 72 65 61 74 65 to \fBTcl_Create
84b0: 43 68 61 6e 6e 65 6c 5c 66 52 0a 77 68 65 6e 20 Channel\fR.when
84c0: 74 68 69 73 20 63 68 61 6e 6e 65 6c 20 77 61 73 this channel was
84d0: 20 63 72 65 61 74 65 64 2e 20 20 54 68 65 20 5c created. The \
84e0: 66 49 69 6e 74 65 72 65 73 74 4d 61 73 6b 5c 66 fIinterestMask\f
84f0: 52 20 69 73 20 61 6e 20 4f 52 2d 65 64 0a 63 6f R is an OR-ed.co
8500: 6d 62 69 6e 61 74 69 6f 6e 20 6f 66 20 5c 66 42 mbination of \fB
8510: 54 43 4c 5f 52 45 41 44 41 42 4c 45 5c 66 52 20 TCL_READABLE\fR
8520: 6f 72 20 5c 66 42 54 43 4c 5f 57 52 49 54 41 42 or \fBTCL_WRITAB
8530: 4c 45 5c 66 52 3b 20 69 74 20 69 6e 64 69 63 61 LE\fR; it indica
8540: 74 65 73 20 77 68 61 74 0a 74 79 70 65 20 6f 66 tes what.type of
8550: 20 65 76 65 6e 74 20 6f 63 63 75 72 72 65 64 20 event occurred
8560: 6f 6e 20 74 68 69 73 20 63 68 61 6e 6e 65 6c 2e on this channel.
8570: 0a 2e 50 50 0a 54 68 69 73 20 76 61 6c 75 65 20 ..PP.This value
8580: 63 61 6e 20 62 65 20 72 65 74 72 69 65 76 65 64 can be retrieved
8590: 20 77 69 74 68 20 5c 66 42 54 63 6c 5f 43 68 61 with \fBTcl_Cha
85a0: 6e 6e 65 6c 48 61 6e 64 6c 65 72 50 72 6f 63 5c nnelHandlerProc\
85b0: 66 52 2c 20 77 68 69 63 68 20 72 65 74 75 72 6e fR, which return
85c0: 73 0a 61 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 s.a pointer to t
85d0: 68 65 20 66 75 6e 63 74 69 6f 6e 2e 0a 0a 2e 53 he function....S
85e0: 53 20 22 54 48 52 45 41 44 41 43 54 49 4f 4e 50 S "THREADACTIONP
85f0: 52 4f 43 22 0a 2e 50 50 0a 54 68 65 20 5c 66 49 ROC"..PP.The \fI
8600: 74 68 72 65 61 64 41 63 74 69 6f 6e 50 72 6f 63 threadActionProc
8610: 5c 66 52 20 66 69 65 6c 64 20 63 6f 6e 74 61 69 \fR field contai
8620: 6e 73 20 74 68 65 20 61 64 64 72 65 73 73 20 6f ns the address o
8630: 66 20 74 68 65 20 66 75 6e 63 74 69 6f 6e 0a 63 f the function.c
8640: 61 6c 6c 65 64 20 62 79 20 74 68 65 20 67 65 6e alled by the gen
8650: 65 72 69 63 20 6c 61 79 65 72 20 77 68 65 6e 20 eric layer when
8660: 61 20 63 68 61 6e 6e 65 6c 20 69 73 20 63 72 65 a channel is cre
8670: 61 74 65 64 2c 20 63 6c 6f 73 65 64 2c 20 6f 72 ated, closed, or
8680: 0a 67 6f 69 6e 67 20 74 6f 20 6d 6f 76 65 20 74 .going to move t
8690: 6f 20 61 20 64 69 66 66 65 72 65 6e 74 20 74 68 o a different th
86a0: 72 65 61 64 2c 20 69 2e 65 2e 20 77 68 65 6e 65 read, i.e. whene
86b0: 76 65 72 20 74 68 72 65 61 64 2d 73 70 65 63 69 ver thread-speci
86c0: 66 69 63 0a 64 72 69 76 65 72 20 73 74 61 74 65 fic.driver state
86d0: 20 6d 69 67 68 74 20 68 61 76 65 20 74 6f 20 69 might have to i
86e0: 6e 69 74 69 61 6c 69 7a 65 64 20 6f 72 20 75 70 nitialized or up
86f0: 64 61 74 65 64 2e 20 49 74 20 63 61 6e 20 62 65 dated. It can be
8700: 20 4e 55 4c 4c 2e 0a 54 68 65 20 61 63 74 69 6f NULL..The actio
8710: 6e 20 5c 66 49 54 43 4c 5f 43 48 41 4e 4e 45 4c n \fITCL_CHANNEL
8720: 5f 54 48 52 45 41 44 5f 52 45 4d 4f 56 45 5c 66 _THREAD_REMOVE\f
8730: 52 20 69 73 20 75 73 65 64 20 74 6f 20 6e 6f 74 R is used to not
8740: 69 66 79 20 74 68 65 0a 64 72 69 76 65 72 20 74 ify the.driver t
8750: 68 61 74 20 69 74 20 73 68 6f 75 6c 64 20 75 70 hat it should up
8760: 64 61 74 65 20 6f 72 20 72 65 6d 6f 76 65 20 61 date or remove a
8770: 6e 79 20 74 68 72 65 61 64 2d 73 70 65 63 69 66 ny thread-specif
8780: 69 63 20 64 61 74 61 20 69 74 0a 6d 69 67 68 74 ic data it.might
8790: 20 62 65 20 6d 61 69 6e 74 61 69 6e 69 6e 67 20 be maintaining
87a0: 66 6f 72 20 74 68 65 20 63 68 61 6e 6e 65 6c 2e for the channel.
87b0: 0a 2e 50 50 0a 54 68 65 20 61 63 74 69 6f 6e 20 ..PP.The action
87c0: 5c 66 49 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 54 \fITCL_CHANNEL_T
87d0: 48 52 45 41 44 5f 49 4e 53 45 52 54 5c 66 52 20 HREAD_INSERT\fR
87e0: 69 73 20 75 73 65 64 20 74 6f 20 6e 6f 74 69 66 is used to notif
87f0: 79 20 74 68 65 0a 64 72 69 76 65 72 20 74 68 61 y the.driver tha
8800: 74 20 69 74 20 73 68 6f 75 6c 64 20 75 70 64 61 t it should upda
8810: 74 65 20 6f 72 20 69 6e 69 74 69 61 6c 69 7a 65 te or initialize
8820: 20 61 6e 79 20 74 68 72 65 61 64 2d 73 70 65 63 any thread-spec
8830: 69 66 69 63 20 64 61 74 61 20 69 74 0a 6d 69 67 ific data it.mig
8840: 68 74 20 62 65 20 6d 61 69 6e 74 61 69 6e 69 6e ht be maintainin
8850: 67 20 75 73 69 6e 67 20 74 68 65 20 63 61 6c 6c g using the call
8860: 69 6e 67 20 74 68 72 65 61 64 20 61 73 20 74 68 ing thread as th
8870: 65 20 61 73 73 6f 63 69 61 74 65 2e 20 53 65 65 e associate. See
8880: 0a 5c 66 42 54 63 6c 5f 43 75 74 43 68 61 6e 6e .\fBTcl_CutChann
8890: 65 6c 5c 66 52 20 61 6e 64 20 5c 66 42 54 63 6c el\fR and \fBTcl
88a0: 5f 53 70 6c 69 63 65 43 68 61 6e 6e 65 6c 5c 66 _SpliceChannel\f
88b0: 52 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69 R for more detai
88c0: 6c 2e 0a 2e 50 50 0a 2e 43 53 0a 74 79 70 65 64 l...PP..CS.typed
88d0: 65 66 20 76 6f 69 64 20 5c 66 42 54 63 6c 5f 44 ef void \fBTcl_D
88e0: 72 69 76 65 72 54 68 72 65 61 64 41 63 74 69 6f riverThreadActio
88f0: 6e 50 72 6f 63 5c 66 52 28 0a 20 20 20 20 20 20 nProc\fR(.
8900: 20 20 43 6c 69 65 6e 74 44 61 74 61 20 5c 66 49 ClientData \fI
8910: 69 6e 73 74 61 6e 63 65 44 61 74 61 5c 66 52 2c instanceData\fR,
8920: 0a 20 20 20 20 20 20 20 20 69 6e 74 20 5c 66 49 . int \fI
8930: 61 63 74 69 6f 6e 5c 66 52 29 3b 0a 2e 43 45 0a action\fR);..CE.
8940: 2e 50 50 0a 5c 66 49 49 6e 73 74 61 6e 63 65 44 .PP.\fIInstanceD
8950: 61 74 61 5c 66 52 20 69 73 20 74 68 65 20 73 61 ata\fR is the sa
8960: 6d 65 20 61 73 20 74 68 65 20 76 61 6c 75 65 20 me as the value
8970: 70 61 73 73 65 64 20 74 6f 0a 5c 66 42 54 63 6c passed to.\fBTcl
8980: 5f 43 72 65 61 74 65 43 68 61 6e 6e 65 6c 5c 66 _CreateChannel\f
8990: 52 20 77 68 65 6e 20 74 68 69 73 20 63 68 61 6e R when this chan
89a0: 6e 65 6c 20 77 61 73 20 63 72 65 61 74 65 64 2e nel was created.
89b0: 0a 2e 50 50 0a 54 68 65 73 65 20 76 61 6c 75 65 ..PP.These value
89c0: 73 20 63 61 6e 20 62 65 20 72 65 74 72 69 65 76 s can be retriev
89d0: 65 64 20 77 69 74 68 20 5c 66 42 54 63 6c 5f 43 ed with \fBTcl_C
89e0: 68 61 6e 6e 65 6c 54 68 72 65 61 64 41 63 74 69 hannelThreadActi
89f0: 6f 6e 50 72 6f 63 5c 66 52 2c 0a 77 68 69 63 68 onProc\fR,.which
8a00: 20 72 65 74 75 72 6e 73 20 61 20 70 6f 69 6e 74 returns a point
8a10: 65 72 20 74 6f 20 74 68 65 20 66 75 6e 63 74 69 er to the functi
8a20: 6f 6e 2e 0a 2e 53 53 20 22 54 52 55 4e 43 41 54 on...SS "TRUNCAT
8a30: 45 50 52 4f 43 22 0a 2e 50 50 0a 54 68 65 20 5c EPROC"..PP.The \
8a40: 66 49 74 72 75 6e 63 61 74 65 50 72 6f 63 5c 66 fItruncateProc\f
8a50: 52 20 66 69 65 6c 64 20 63 6f 6e 74 61 69 6e 73 R field contains
8a60: 20 74 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 the address of
8a70: 74 68 65 20 66 75 6e 63 74 69 6f 6e 0a 63 61 6c the function.cal
8a80: 6c 65 64 20 62 79 20 74 68 65 20 67 65 6e 65 72 led by the gener
8a90: 69 63 20 6c 61 79 65 72 20 77 68 65 6e 20 61 20 ic layer when a
8aa0: 63 68 61 6e 6e 65 6c 20 69 73 20 74 72 75 6e 63 channel is trunc
8ab0: 61 74 65 64 20 74 6f 20 73 6f 6d 65 0a 6c 65 6e ated to some.len
8ac0: 67 74 68 2e 20 49 74 20 63 61 6e 20 62 65 20 4e gth. It can be N
8ad0: 55 4c 4c 2e 0a 2e 50 50 0a 2e 43 53 0a 74 79 70 ULL...PP..CS.typ
8ae0: 65 64 65 66 20 69 6e 74 20 5c 66 42 54 63 6c 5f edef int \fBTcl_
8af0: 44 72 69 76 65 72 54 72 75 6e 63 61 74 65 50 72 DriverTruncatePr
8b00: 6f 63 5c 66 52 28 0a 20 20 20 20 20 20 20 20 43 oc\fR(. C
8b10: 6c 69 65 6e 74 44 61 74 61 20 5c 66 49 69 6e 73 lientData \fIins
8b20: 74 61 6e 63 65 44 61 74 61 5c 66 52 2c 0a 20 20 tanceData\fR,.
8b30: 20 20 20 20 20 20 54 63 6c 5f 57 69 64 65 49 6e Tcl_WideIn
8b40: 74 20 5c 66 49 6c 65 6e 67 74 68 5c 66 52 29 3b t \fIlength\fR);
8b50: 0a 2e 43 45 0a 2e 50 50 0a 5c 66 49 49 6e 73 74 ..CE..PP.\fIInst
8b60: 61 6e 63 65 44 61 74 61 5c 66 52 20 69 73 20 74 anceData\fR is t
8b70: 68 65 20 73 61 6d 65 20 61 73 20 74 68 65 20 76 he same as the v
8b80: 61 6c 75 65 20 70 61 73 73 65 64 20 74 6f 0a 5c alue passed to.\
8b90: 66 42 54 63 6c 5f 43 72 65 61 74 65 43 68 61 6e fBTcl_CreateChan
8ba0: 6e 65 6c 5c 66 52 20 77 68 65 6e 20 74 68 69 73 nel\fR when this
8bb0: 20 63 68 61 6e 6e 65 6c 20 77 61 73 20 63 72 65 channel was cre
8bc0: 61 74 65 64 2c 20 61 6e 64 0a 5c 66 49 6c 65 6e ated, and.\fIlen
8bd0: 67 74 68 5c 66 52 20 69 73 20 74 68 65 20 6e 65 gth\fR is the ne
8be0: 77 20 6c 65 6e 67 74 68 20 6f 66 20 74 68 65 20 w length of the
8bf0: 75 6e 64 65 72 6c 79 69 6e 67 20 66 69 6c 65 2c underlying file,
8c00: 20 77 68 69 63 68 20 73 68 6f 75 6c 64 0a 6e 6f which should.no
8c10: 74 20 62 65 20 6e 65 67 61 74 69 76 65 2e 20 54 t be negative. T
8c20: 68 65 20 72 65 73 75 6c 74 20 73 68 6f 75 6c 64 he result should
8c30: 20 62 65 20 30 20 6f 6e 20 73 75 63 63 65 73 73 be 0 on success
8c40: 20 6f 72 20 61 6e 20 65 72 72 6e 6f 20 63 6f 64 or an errno cod
8c50: 65 0a 28 73 75 69 74 61 62 6c 65 20 66 6f 72 20 e.(suitable for
8c60: 75 73 65 20 77 69 74 68 20 5c 66 42 54 63 6c 5f use with \fBTcl_
8c70: 53 65 74 45 72 72 6e 6f 5c 66 52 29 20 6f 6e 20 SetErrno\fR) on
8c80: 66 61 69 6c 75 72 65 2e 0a 2e 50 50 0a 54 68 65 failure...PP.The
8c90: 73 65 20 76 61 6c 75 65 73 20 63 61 6e 20 62 65 se values can be
8ca0: 20 72 65 74 72 69 65 76 65 64 20 77 69 74 68 20 retrieved with
8cb0: 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 72 \fBTcl_ChannelTr
8cc0: 75 6e 63 61 74 65 50 72 6f 63 5c 66 52 2c 0a 77 uncateProc\fR,.w
8cd0: 68 69 63 68 20 72 65 74 75 72 6e 73 20 61 20 70 hich returns a p
8ce0: 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 66 75 ointer to the fu
8cf0: 6e 63 74 69 6f 6e 2e 0a 2e 53 48 20 54 43 4c 5f nction...SH TCL_
8d00: 42 41 44 43 48 41 4e 4e 45 4c 4f 50 54 49 4f 4e BADCHANNELOPTION
8d10: 0a 2e 50 50 0a 54 68 69 73 20 70 72 6f 63 65 64 ..PP.This proced
8d20: 75 72 65 20 67 65 6e 65 72 61 74 65 73 20 61 0a ure generates a.
8d30: 2e 51 57 20 22 62 61 64 20 6f 70 74 69 6f 6e 22 .QW "bad option"
8d40: 0a 65 72 72 6f 72 20 6d 65 73 73 61 67 65 20 69 .error message i
8d50: 6e 20 61 6e 0a 28 6f 70 74 69 6f 6e 61 6c 29 20 n an.(optional)
8d60: 69 6e 74 65 72 70 72 65 74 65 72 2e 20 20 49 74 interpreter. It
8d70: 20 69 73 20 75 73 65 64 20 62 79 20 63 68 61 6e is used by chan
8d80: 6e 65 6c 20 64 72 69 76 65 72 73 20 77 68 65 6e nel drivers when
8d90: 0a 61 6e 20 69 6e 76 61 6c 69 64 20 53 65 74 2f .an invalid Set/
8da0: 47 65 74 20 6f 70 74 69 6f 6e 20 69 73 20 72 65 Get option is re
8db0: 71 75 65 73 74 65 64 2e 20 49 74 73 20 70 75 72 quested. Its pur
8dc0: 70 6f 73 65 20 69 73 20 74 6f 20 63 6f 6e 63 61 pose is to conca
8dd0: 74 65 6e 61 74 65 0a 74 68 65 20 67 65 6e 65 72 tenate.the gener
8de0: 69 63 20 6f 70 74 69 6f 6e 73 20 6c 69 73 74 20 ic options list
8df0: 74 6f 20 74 68 65 20 73 70 65 63 69 66 69 63 20 to the specific
8e00: 6f 6e 65 73 20 61 6e 64 20 66 61 63 74 6f 72 69 ones and factori
8e10: 7a 65 0a 74 68 65 20 67 65 6e 65 72 69 63 20 6f ze.the generic o
8e20: 70 74 69 6f 6e 73 20 65 72 72 6f 72 20 6d 65 73 ptions error mes
8e30: 73 61 67 65 20 73 74 72 69 6e 67 2e 0a 2e 50 50 sage string...PP
8e40: 0a 49 74 20 61 6c 77 61 79 73 20 72 65 74 75 72 .It always retur
8e50: 6e 73 20 5c 66 42 54 43 4c 5f 45 52 52 4f 52 5c ns \fBTCL_ERROR\
8e60: 66 52 0a 2e 50 50 0a 41 6e 20 65 72 72 6f 72 20 fR..PP.An error
8e70: 6d 65 73 73 61 67 65 20 69 73 20 67 65 6e 65 72 message is gener
8e80: 61 74 65 64 20 69 6e 20 5c 66 49 69 6e 74 65 72 ated in \fIinter
8e90: 70 5c 66 52 27 73 20 72 65 73 75 6c 74 20 76 61 p\fR's result va
8ea0: 6c 75 65 20 74 6f 0a 69 6e 64 69 63 61 74 65 20 lue to.indicate
8eb0: 74 68 61 74 20 61 20 63 6f 6d 6d 61 6e 64 20 77 that a command w
8ec0: 61 73 20 69 6e 76 6f 6b 65 64 20 77 69 74 68 20 as invoked with
8ed0: 61 20 62 61 64 20 6f 70 74 69 6f 6e 2e 0a 54 68 a bad option..Th
8ee0: 65 20 6d 65 73 73 61 67 65 20 68 61 73 20 74 68 e message has th
8ef0: 65 20 66 6f 72 6d 0a 2e 43 53 0a 20 20 20 20 62 e form..CS. b
8f00: 61 64 20 6f 70 74 69 6f 6e 20 22 62 6c 61 68 22 ad option "blah"
8f10: 3a 20 73 68 6f 75 6c 64 20 62 65 20 6f 6e 65 20 : should be one
8f20: 6f 66 0a 20 20 20 20 3c 2e 2e 2e 67 65 6e 65 72 of. <...gener
8f30: 69 63 20 6f 70 74 69 6f 6e 73 2e 2e 2e 3e 2b 3c ic options...>+<
8f40: 2e 2e 2e 73 70 65 63 69 66 69 63 20 6f 70 74 69 ...specific opti
8f50: 6f 6e 73 2e 2e 2e 3e 0a 2e 43 45 0a 73 6f 20 79 ons...>..CE.so y
8f60: 6f 75 20 67 65 74 20 66 6f 72 20 69 6e 73 74 61 ou get for insta
8f70: 6e 63 65 3a 0a 2e 43 53 0a 20 20 20 20 62 61 64 nce:..CS. bad
8f80: 20 6f 70 74 69 6f 6e 20 22 2d 62 6c 61 68 22 3a option "-blah":
8f90: 20 73 68 6f 75 6c 64 20 62 65 20 6f 6e 65 20 6f should be one o
8fa0: 66 20 2d 62 6c 6f 63 6b 69 6e 67 2c 0a 20 20 20 f -blocking,.
8fb0: 20 2d 62 75 66 66 65 72 69 6e 67 2c 20 2d 62 75 -buffering, -bu
8fc0: 66 66 65 72 73 69 7a 65 2c 20 2d 65 6f 66 63 68 ffersize, -eofch
8fd0: 61 72 2c 20 2d 74 72 61 6e 73 6c 61 74 69 6f 6e ar, -translation
8fe0: 2c 0a 20 20 20 20 2d 70 65 65 72 6e 61 6d 65 2c ,. -peername,
8ff0: 20 6f 72 20 2d 73 6f 63 6b 6e 61 6d 65 0a 2e 43 or -sockname..C
9000: 45 0a 77 68 65 6e 20 63 61 6c 6c 65 64 20 77 69 E.when called wi
9010: 74 68 20 5c 66 49 6f 70 74 69 6f 6e 4c 69 73 74 th \fIoptionList
9020: 5c 66 52 20 65 71 75 61 6c 20 74 6f 0a 2e 51 57 \fR equal to..QW
9030: 20 22 70 65 65 72 6e 61 6d 65 20 73 6f 63 6b 6e "peername sockn
9040: 61 6d 65 22 0a 2e 50 50 0a 2e 51 57 20 62 6c 61 ame"..PP..QW bla
9050: 68 0a 69 73 20 74 68 65 20 5c 66 49 6f 70 74 69 h.is the \fIopti
9060: 6f 6e 4e 61 6d 65 5c 66 52 20 61 72 67 75 6d 65 onName\fR argume
9070: 6e 74 20 61 6e 64 0a 2e 51 57 20 22 3c 73 70 65 nt and..QW "<spe
9080: 63 69 66 69 63 20 6f 70 74 69 6f 6e 73 3e 22 0a cific options>".
9090: 69 73 20 61 20 73 70 61 63 65 20 73 65 70 61 72 is a space separ
90a0: 61 74 65 64 20 6c 69 73 74 20 6f 66 20 73 70 65 ated list of spe
90b0: 63 69 66 69 63 20 6f 70 74 69 6f 6e 20 77 6f 72 cific option wor
90c0: 64 73 2e 0a 54 68 65 20 66 75 6e 63 74 69 6f 6e ds..The function
90d0: 20 74 61 6b 65 73 20 67 6f 6f 64 20 63 61 72 65 takes good care
90e0: 20 6f 66 20 69 6e 73 65 72 74 69 6e 67 20 6d 69 of inserting mi
90f0: 6e 75 73 20 73 69 67 6e 73 20 62 65 66 6f 72 65 nus signs before
9100: 0a 65 61 63 68 20 6f 70 74 69 6f 6e 2c 20 63 6f .each option, co
9110: 6d 6d 61 73 20 61 66 74 65 72 2c 20 61 6e 64 20 mmas after, and
9120: 61 6e 0a 2e 51 57 20 6f 72 0a 62 65 66 6f 72 65 an..QW or.before
9130: 20 74 68 65 20 6c 61 73 74 20 6f 70 74 69 6f 6e the last option
9140: 2e 0a 2e 53 48 20 22 4f 4c 44 20 43 48 41 4e 4e ...SH "OLD CHANN
9150: 45 4c 20 54 59 50 45 53 22 0a 54 68 65 20 6f 72 EL TYPES".The or
9160: 69 67 69 6e 61 6c 20 28 38 2e 33 2e 31 20 61 6e iginal (8.3.1 an
9170: 64 20 62 65 6c 6f 77 29 20 5c 66 42 54 63 6c 5f d below) \fBTcl_
9180: 43 68 61 6e 6e 65 6c 54 79 70 65 5c 66 52 20 73 ChannelType\fR s
9190: 74 72 75 63 74 75 72 65 20 63 6f 6e 74 61 69 6e tructure contain
91a0: 73 0a 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 s.the following
91b0: 66 69 65 6c 64 73 3a 0a 2e 50 50 0a 2e 43 53 0a fields:..PP..CS.
91c0: 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 54 typedef struct T
91d0: 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 65 20 7b cl_ChannelType {
91e0: 0a 20 20 20 20 63 6f 6e 73 74 20 63 68 61 72 20 . const char
91f0: 2a 5c 66 49 74 79 70 65 4e 61 6d 65 5c 66 52 3b *\fItypeName\fR;
9200: 0a 20 20 20 20 54 63 6c 5f 44 72 69 76 65 72 42 . Tcl_DriverB
9210: 6c 6f 63 6b 4d 6f 64 65 50 72 6f 63 20 2a 5c 66 lockModeProc *\f
9220: 49 62 6c 6f 63 6b 4d 6f 64 65 50 72 6f 63 5c 66 IblockModeProc\f
9230: 52 3b 0a 20 20 20 20 54 63 6c 5f 44 72 69 76 65 R;. Tcl_Drive
9240: 72 43 6c 6f 73 65 50 72 6f 63 20 2a 5c 66 49 63 rCloseProc *\fIc
9250: 6c 6f 73 65 50 72 6f 63 5c 66 52 3b 0a 20 20 20 loseProc\fR;.
9260: 20 54 63 6c 5f 44 72 69 76 65 72 49 6e 70 75 74 Tcl_DriverInput
9270: 50 72 6f 63 20 2a 5c 66 49 69 6e 70 75 74 50 72 Proc *\fIinputPr
9280: 6f 63 5c 66 52 3b 0a 20 20 20 20 54 63 6c 5f 44 oc\fR;. Tcl_D
9290: 72 69 76 65 72 4f 75 74 70 75 74 50 72 6f 63 20 riverOutputProc
92a0: 2a 5c 66 49 6f 75 74 70 75 74 50 72 6f 63 5c 66 *\fIoutputProc\f
92b0: 52 3b 0a 20 20 20 20 54 63 6c 5f 44 72 69 76 65 R;. Tcl_Drive
92c0: 72 53 65 65 6b 50 72 6f 63 20 2a 5c 66 49 73 65 rSeekProc *\fIse
92d0: 65 6b 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 54 ekProc\fR;. T
92e0: 63 6c 5f 44 72 69 76 65 72 53 65 74 4f 70 74 69 cl_DriverSetOpti
92f0: 6f 6e 50 72 6f 63 20 2a 5c 66 49 73 65 74 4f 70 onProc *\fIsetOp
9300: 74 69 6f 6e 50 72 6f 63 5c 66 52 3b 0a 20 20 20 tionProc\fR;.
9310: 20 54 63 6c 5f 44 72 69 76 65 72 47 65 74 4f 70 Tcl_DriverGetOp
9320: 74 69 6f 6e 50 72 6f 63 20 2a 5c 66 49 67 65 74 tionProc *\fIget
9330: 4f 70 74 69 6f 6e 50 72 6f 63 5c 66 52 3b 0a 20 OptionProc\fR;.
9340: 20 20 20 54 63 6c 5f 44 72 69 76 65 72 57 61 74 Tcl_DriverWat
9350: 63 68 50 72 6f 63 20 2a 5c 66 49 77 61 74 63 68 chProc *\fIwatch
9360: 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 54 63 6c Proc\fR;. Tcl
9370: 5f 44 72 69 76 65 72 47 65 74 48 61 6e 64 6c 65 _DriverGetHandle
9380: 50 72 6f 63 20 2a 5c 66 49 67 65 74 48 61 6e 64 Proc *\fIgetHand
9390: 6c 65 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 54 leProc\fR;. T
93a0: 63 6c 5f 44 72 69 76 65 72 43 6c 6f 73 65 32 50 cl_DriverClose2P
93b0: 72 6f 63 20 2a 5c 66 49 63 6c 6f 73 65 32 50 72 roc *\fIclose2Pr
93c0: 6f 63 5c 66 52 3b 0a 7d 20 5c 66 42 54 63 6c 5f oc\fR;.} \fBTcl_
93d0: 43 68 61 6e 6e 65 6c 54 79 70 65 5c 66 52 3b 0a ChannelType\fR;.
93e0: 2e 43 45 0a 2e 50 50 0a 49 74 20 69 73 20 73 74 .CE..PP.It is st
93f0: 69 6c 6c 20 70 6f 73 73 69 62 6c 65 20 74 6f 20 ill possible to
9400: 63 72 65 61 74 65 20 63 68 61 6e 6e 65 6c 20 77 create channel w
9410: 69 74 68 20 74 68 65 20 61 62 6f 76 65 20 73 74 ith the above st
9420: 72 75 63 74 75 72 65 2e 20 20 54 68 65 0a 69 6e ructure. The.in
9430: 74 65 72 6e 61 6c 20 63 68 61 6e 6e 65 6c 20 63 ternal channel c
9440: 6f 64 65 20 77 69 6c 6c 20 64 65 74 65 72 6d 69 ode will determi
9450: 6e 65 20 74 68 65 20 76 65 72 73 69 6f 6e 2e 20 ne the version.
9460: 20 49 74 20 69 73 20 69 6d 70 65 72 61 74 69 76 It is imperativ
9470: 65 20 74 6f 20 75 73 65 0a 74 68 65 20 6e 65 77 e to use.the new
9480: 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 \fBTcl_ChannelT
9490: 79 70 65 5c 66 52 20 73 74 72 75 63 74 75 72 65 ype\fR structure
94a0: 20 69 66 20 79 6f 75 20 61 72 65 20 63 72 65 61 if you are crea
94b0: 74 69 6e 67 20 61 20 73 74 61 63 6b 65 64 0a 63 ting a stacked.c
94c0: 68 61 6e 6e 65 6c 20 64 72 69 76 65 72 2c 20 64 hannel driver, d
94d0: 75 65 20 74 6f 20 70 72 6f 62 6c 65 6d 73 20 77 ue to problems w
94e0: 69 74 68 20 74 68 65 20 65 61 72 6c 69 65 72 20 ith the earlier
94f0: 73 74 61 63 6b 65 64 20 63 68 61 6e 6e 65 6c 0a stacked channel.
9500: 69 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 20 28 implementation (
9510: 69 6e 20 38 2e 32 2e 30 20 74 6f 20 38 2e 33 2e in 8.2.0 to 8.3.
9520: 31 29 2e 0a 2e 50 50 0a 50 72 69 6f 72 20 74 6f 1)...PP.Prior to
9530: 20 38 2e 34 2e 30 20 28 69 2e 65 2e 20 64 75 72 8.4.0 (i.e. dur
9540: 69 6e 67 20 74 68 65 20 6c 61 74 65 72 20 72 65 ing the later re
9550: 6c 65 61 73 65 73 20 6f 66 20 38 2e 33 20 61 6e leases of 8.3 an
9560: 64 20 65 61 72 6c 79 20 70 61 72 74 0a 6f 66 20 d early part.of
9570: 74 68 65 20 38 2e 34 20 64 65 76 65 6c 6f 70 6d the 8.4 developm
9580: 65 6e 74 20 63 79 63 6c 65 29 20 74 68 65 20 5c ent cycle) the \
9590: 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 fBTcl_ChannelTyp
95a0: 65 5c 66 52 20 73 74 72 75 63 74 75 72 65 0a 63 e\fR structure.c
95b0: 6f 6e 74 61 69 6e 65 64 20 74 68 65 20 66 6f 6c ontained the fol
95c0: 6c 6f 77 69 6e 67 20 66 69 65 6c 64 73 3a 0a 2e lowing fields:..
95d0: 50 50 0a 2e 43 53 0a 74 79 70 65 64 65 66 20 73 PP..CS.typedef s
95e0: 74 72 75 63 74 20 54 63 6c 5f 43 68 61 6e 6e 65 truct Tcl_Channe
95f0: 6c 54 79 70 65 20 7b 0a 20 20 20 20 63 6f 6e 73 lType {. cons
9600: 74 20 63 68 61 72 20 2a 5c 66 49 74 79 70 65 4e t char *\fItypeN
9610: 61 6d 65 5c 66 52 3b 0a 20 20 20 20 54 63 6c 5f ame\fR;. Tcl_
9620: 43 68 61 6e 6e 65 6c 54 79 70 65 56 65 72 73 69 ChannelTypeVersi
9630: 6f 6e 20 5c 66 49 76 65 72 73 69 6f 6e 5c 66 52 on \fIversion\fR
9640: 3b 0a 20 20 20 20 54 63 6c 5f 44 72 69 76 65 72 ;. Tcl_Driver
9650: 43 6c 6f 73 65 50 72 6f 63 20 2a 5c 66 49 63 6c CloseProc *\fIcl
9660: 6f 73 65 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 oseProc\fR;.
9670: 54 63 6c 5f 44 72 69 76 65 72 49 6e 70 75 74 50 Tcl_DriverInputP
9680: 72 6f 63 20 2a 5c 66 49 69 6e 70 75 74 50 72 6f roc *\fIinputPro
9690: 63 5c 66 52 3b 0a 20 20 20 20 54 63 6c 5f 44 72 c\fR;. Tcl_Dr
96a0: 69 76 65 72 4f 75 74 70 75 74 50 72 6f 63 20 2a iverOutputProc *
96b0: 5c 66 49 6f 75 74 70 75 74 50 72 6f 63 5c 66 52 \fIoutputProc\fR
96c0: 3b 0a 20 20 20 20 54 63 6c 5f 44 72 69 76 65 72 ;. Tcl_Driver
96d0: 53 65 65 6b 50 72 6f 63 20 2a 5c 66 49 73 65 65 SeekProc *\fIsee
96e0: 6b 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 54 63 kProc\fR;. Tc
96f0: 6c 5f 44 72 69 76 65 72 53 65 74 4f 70 74 69 6f l_DriverSetOptio
9700: 6e 50 72 6f 63 20 2a 5c 66 49 73 65 74 4f 70 74 nProc *\fIsetOpt
9710: 69 6f 6e 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 ionProc\fR;.
9720: 54 63 6c 5f 44 72 69 76 65 72 47 65 74 4f 70 74 Tcl_DriverGetOpt
9730: 69 6f 6e 50 72 6f 63 20 2a 5c 66 49 67 65 74 4f ionProc *\fIgetO
9740: 70 74 69 6f 6e 50 72 6f 63 5c 66 52 3b 0a 20 20 ptionProc\fR;.
9750: 20 20 54 63 6c 5f 44 72 69 76 65 72 57 61 74 63 Tcl_DriverWatc
9760: 68 50 72 6f 63 20 2a 5c 66 49 77 61 74 63 68 50 hProc *\fIwatchP
9770: 72 6f 63 5c 66 52 3b 0a 20 20 20 20 54 63 6c 5f roc\fR;. Tcl_
9780: 44 72 69 76 65 72 47 65 74 48 61 6e 64 6c 65 50 DriverGetHandleP
9790: 72 6f 63 20 2a 5c 66 49 67 65 74 48 61 6e 64 6c roc *\fIgetHandl
97a0: 65 50 72 6f 63 5c 66 52 3b 0a 20 20 20 20 54 63 eProc\fR;. Tc
97b0: 6c 5f 44 72 69 76 65 72 43 6c 6f 73 65 32 50 72 l_DriverClose2Pr
97c0: 6f 63 20 2a 5c 66 49 63 6c 6f 73 65 32 50 72 6f oc *\fIclose2Pro
97d0: 63 5c 66 52 3b 0a 20 20 20 20 54 63 6c 5f 44 72 c\fR;. Tcl_Dr
97e0: 69 76 65 72 42 6c 6f 63 6b 4d 6f 64 65 50 72 6f iverBlockModePro
97f0: 63 20 2a 5c 66 49 62 6c 6f 63 6b 4d 6f 64 65 50 c *\fIblockModeP
9800: 72 6f 63 5c 66 52 3b 0a 20 20 20 20 54 63 6c 5f roc\fR;. Tcl_
9810: 44 72 69 76 65 72 46 6c 75 73 68 50 72 6f 63 20 DriverFlushProc
9820: 2a 5c 66 49 66 6c 75 73 68 50 72 6f 63 5c 66 52 *\fIflushProc\fR
9830: 3b 0a 20 20 20 20 54 63 6c 5f 44 72 69 76 65 72 ;. Tcl_Driver
9840: 48 61 6e 64 6c 65 72 50 72 6f 63 20 2a 5c 66 49 HandlerProc *\fI
9850: 68 61 6e 64 6c 65 72 50 72 6f 63 5c 66 52 3b 0a handlerProc\fR;.
9860: 20 20 20 20 54 63 6c 5f 44 72 69 76 65 72 54 72 Tcl_DriverTr
9870: 75 6e 63 61 74 65 50 72 6f 63 20 2a 5c 66 49 74 uncateProc *\fIt
9880: 72 75 6e 63 61 74 65 50 72 6f 63 5c 66 52 3b 0a runcateProc\fR;.
9890: 7d 20 5c 66 42 54 63 6c 5f 43 68 61 6e 6e 65 6c } \fBTcl_Channel
98a0: 54 79 70 65 5c 66 52 3b 0a 2e 43 45 0a 2e 50 50 Type\fR;..CE..PP
98b0: 0a 57 68 65 6e 20 74 68 65 20 61 62 6f 76 65 20 .When the above
98c0: 73 74 72 75 63 74 75 72 65 20 69 73 20 72 65 67 structure is reg
98d0: 69 73 74 65 72 65 64 20 61 73 20 61 20 63 68 61 istered as a cha
98e0: 6e 6e 65 6c 20 74 79 70 65 2c 20 74 68 65 0a 5c nnel type, the.\
98f0: 66 49 76 65 72 73 69 6f 6e 5c 66 52 20 66 69 65 fIversion\fR fie
9900: 6c 64 20 73 68 6f 75 6c 64 20 61 6c 77 61 79 73 ld should always
9910: 20 62 65 20 5c 66 42 54 43 4c 5f 43 48 41 4e 4e be \fBTCL_CHANN
9920: 45 4c 5f 56 45 52 53 49 4f 4e 5f 32 5c 66 52 2e EL_VERSION_2\fR.
9930: 0a 2e 53 48 20 22 53 45 45 20 41 4c 53 4f 22 0a ..SH "SEE ALSO".
9940: 54 63 6c 5f 43 6c 6f 73 65 28 33 29 2c 20 54 63 Tcl_Close(3), Tc
9950: 6c 5f 4f 70 65 6e 46 69 6c 65 43 68 61 6e 6e 65 l_OpenFileChanne
9960: 6c 28 33 29 2c 20 54 63 6c 5f 53 65 74 45 72 72 l(3), Tcl_SetErr
9970: 6e 6f 28 33 29 2c 20 54 63 6c 5f 51 75 65 75 65 no(3), Tcl_Queue
9980: 45 76 65 6e 74 28 33 29 2c 20 54 63 6c 5f 53 74 Event(3), Tcl_St
9990: 61 63 6b 43 68 61 6e 6e 65 6c 28 33 29 2c 20 54 ackChannel(3), T
99a0: 63 6c 5f 47 65 74 53 74 64 43 68 61 6e 6e 65 6c cl_GetStdChannel
99b0: 28 33 29 0a 2e 53 48 20 4b 45 59 57 4f 52 44 53 (3)..SH KEYWORDS
99c0: 0a 62 6c 6f 63 6b 69 6e 67 2c 20 63 68 61 6e 6e .blocking, chann
99d0: 65 6c 20 64 72 69 76 65 72 2c 20 63 68 61 6e 6e el driver, chann
99e0: 65 6c 20 72 65 67 69 73 74 72 61 74 69 6f 6e 2c el registration,
99f0: 20 63 68 61 6e 6e 65 6c 20 74 79 70 65 2c 20 6e channel type, n
9a00: 6f 6e 62 6c 6f 63 6b 69 6e 67 0a onblocking.