⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crtchannel.3

📁 tcl是工具命令语言
💻 3
📖 第 1 页 / 共 3 页
字号:
in preference to the \fIseekProc\fR, but both must be defined if the\fIwideSeekProc\fR is defined.  \fIWideSeekProc\fR must match thefollowing prototype:.PP.CStypedef Tcl_WideInt Tcl_DriverWideSeekProc(	ClientData \fIinstanceData\fR,	Tcl_WideInt \fIoffset\fR,	int \fIseekMode\fR,	int *\fIerrorCodePtr\fR);.CE.PPThe arguments and return values mean the same thing as with\fIseekProc\fR above, except that the type of offsets and the returntype are different..PPThe \fIseekProc\fR value can be retrieved with\fBTcl_ChannelSeekProc\fR, which returns a pointer to the function,and similarly the \fIwideSeekProc\fR can be retrieved with\fBTcl_ChannelWideSeekProc\fR..VE 8.4.SH SETOPTIONPROC.PPThe \fIsetOptionProc\fR field contains the address of a function called bythe generic layer to set a channel type specific option on a channel.\fIsetOptionProc\fR must match the following prototype:.PP.CStypedef int Tcl_DriverSetOptionProc(	ClientData \fIinstanceData\fR,	Tcl_Interp *\fIinterp\fR,	CONST char *\fIoptionName\fR,	CONST char *\fInewValue\fR);.CE.PP\fIoptionName\fR is the name of an option to set, and \fInewValue\fR isthe new value for that option, as a string. The \fIinstanceData\fR is thesame as the value given to \fBTcl_CreateChannel\fR when this channel wascreated. The function should do whatever channel type specific action isrequired to implement the new value of the option..PPSome options are handled by the generic code and this function is nevercalled to set them, e.g. \fB-blockmode\fR. Other options are specific toeach channel type and the \fIsetOptionProc\fR procedure of the channeldriver will get called to implement them. The \fIsetOptionProc\fR field canbe NULL, which indicates that this channel type supports no type specificoptions. .PPIf the option value is successfully modified to the new value, the functionreturns \fBTCL_OK\fR.It should call \fBTcl_BadChannelOption\fR which itself returns\fBTCL_ERROR\fR if the \fIoptionName\fR isunrecognized. If \fInewValue\fR specifies a value for the option thatis not supported or if a system call error occurs,the function should leave an error message in the\fIresult\fR field of \fIinterp\fR if \fIinterp\fR is not NULL. Thefunction should also call \fBTcl_SetErrno\fR to store an appropriate POSIXerror code..PPThis value can be retrieved with \fBTcl_ChannelSetOptionProc\fR, which returnsa pointer to the function..SH GETOPTIONPROC.PPThe \fIgetOptionProc\fR field contains the address of a function called bythe generic layer to get the value of a channel type specific option on achannel. \fIgetOptionProc\fR must match the following prototype:.PP.CStypedef int Tcl_DriverGetOptionProc(	ClientData \fIinstanceData\fR,	Tcl_Interp *\fIinterp\fR,	CONST char *\fIoptionName\fR,	Tcl_DString *\fIoptionValue\fR);.CE.PP\fIOptionName\fR is the name of an option supported by this type ofchannel. If the option name is not NULL, the function stores its currentvalue, as a string, in the Tcl dynamic string \fIoptionValue\fR.If \fIoptionName\fR is NULL, the function stores in \fIoptionValue\fR analternating list of all supported options and their current values.On success, the function returns \fBTCL_OK\fR. It should call \fBTcl_BadChannelOption\fR which itself returns\fBTCL_ERROR\fR if the \fIoptionName\fR isunrecognized. If a system call error occurs,the function should leave an error message in theresult of \fIinterp\fR if \fIinterp\fR is not NULL. Thefunction should also call \fBTcl_SetErrno\fR to store an appropriate POSIXerror code..PPSome options are handled by the generic code and this function is nevercalled to retrieve their value, e.g. \fB-blockmode\fR. Other options arespecific to each channel type and the \fIgetOptionProc\fR procedure of thechannel driver will get called to implement them. The \fIgetOptionProc\fRfield can be NULL, which indicates that this channel type supports no typespecific options..PPThis value can be retrieved with \fBTcl_ChannelGetOptionProc\fR, which returnsa pointer to the function..SH WATCHPROC.PPThe \fIwatchProc\fR field contains the address of a function calledby the generic layer to initialize the event notification mechanism tonotice events of interest on this channel.\fIWatchProc\fR should match the following prototype:.PP.CStypedef void Tcl_DriverWatchProc(	ClientData \fIinstanceData\fR,	int \fImask\fR);.CE.PPThe \fIinstanceData\fR is the same as the value passed to\fBTcl_CreateChannel\fR when this channel was created. The \fImask\fRargument is an OR-ed combination of \fBTCL_READABLE\fR, \fBTCL_WRITABLE\fRand \fBTCL_EXCEPTION\fR; it indicates events the caller is interested innoticing on this channel..PPThe function should initialize device type specific mechanisms tonotice when an event of interest is present on the channel.  When oneor more of the designated events occurs on the channel, the channeldriver is responsible for calling \fBTcl_NotifyChannel\fR to informthe generic channel module.  The driver should take care not to starveother channel drivers or sources of callbacks by invokingTcl_NotifyChannel too frequently.  Fairness can be insured by usingthe Tcl event queue to allow the channel event to be scheduled in sequencewith other events.  See the description of \fBTcl_QueueEvent\fR fordetails on how to queue an event..PPThis value can be retrieved with \fBTcl_ChannelWatchProc\fR, which returnsa pointer to the function..SH GETHANDLEPROC.PPThe \fIgetHandleProc\fR field contains the address of a function called bythe generic layer to retrieve a device-specific handle from the channel.\fIGetHandleProc\fR should match the following prototype:.PP.CStypedef int Tcl_DriverGetHandleProc(	ClientData \fIinstanceData\fR,	int \fIdirection\fR,	ClientData *\fIhandlePtr\fR);.CE.PP\fIInstanceData\fR is the same as the value passed to\fBTcl_CreateChannel\fR when this channel was created. The \fIdirection\fRargument is either \fBTCL_READABLE\fR to retrieve the handle usedfor input, or \fBTCL_WRITABLE\fR to retrieve the handle used foroutput..PPIf the channel implementation has device-specific handles, thefunction should retrieve the appropriate handle associated with thechannel, according the \fIdirection\fR argument.  The handle should bestored in the location referred to by \fIhandlePtr\fR, and\fBTCL_OK\fR should be returned.  If the channel is not open for thespecified direction, or if the channel implementation does not usedevice handles, the function should return \fBTCL_ERROR\fR..PPThis value can be retrieved with \fBTcl_ChannelGetHandleProc\fR, which returnsa pointer to the function..SH FLUSHPROC.PPThe \fIflushProc\fR field is currently reserved for future use.It should be set to NULL.\fIFlushProc\fR should match the following prototype:.PP.CStypedef int Tcl_DriverFlushProc(	ClientData \fIinstanceData\fR);.CE.PPThis value can be retrieved with \fBTcl_ChannelFlushProc\fR, which returnsa pointer to the function..SH HANDLERPROC.PPThe \fIhandlerProc\fR field contains the address of a function called bythe generic layer to notify the channel that an event occurred.  It shouldbe defined for stacked channel drivers that wish to be notified of eventsthat occur on the underlying (stacked) channel.\fIHandlerProc\fR should match the following prototype:.PP.CStypedef int Tcl_DriverHandlerProc(	ClientData \fIinstanceData\fR,	int \fIinterestMask\fR);.CE.PP\fIInstanceData\fR is the same as the value passed to \fBTcl_CreateChannel\fRwhen this channel was created.  The \fIinterestMask\fR is an OR-edcombination of \fBTCL_READABLE\fR or \fBTCL_WRITABLE\fR; it indicates whattype of event occurred on this channel..PPThis value can be retrieved with \fBTcl_ChannelHandlerProc\fR, which returnsa pointer to the function..SH TCL_BADCHANNELOPTION.PPThis procedure generates a "bad option" error message in an(optional) interpreter.  It is used by channel drivers when a invalid Set/Get option is requested. Its purpose is to concatenatethe generic options list to the specific ones and factorizethe generic options error message string..PPIt always return \fBTCL_ERROR\fR.PPAn error message is generated in \fIinterp\fR's result object toindicate that a command was invoked with the a bad optionThe message has the form.CS    bad option "blah": should be one of     <...generic options...>+<...specific options...>so you get for instance:    bad option "-blah": should be one of -blocking,    -buffering, -buffersize, -eofchar, -translation,    -peername, or -socknamewhen called with \fIoptionList\fR="peername sockname".CE``blah'' is the \fIoptionName\fR argument and ``<specific options>''is a space separated list of specific option words.The function takes good care of inserting minus signs beforeeach option, commas after, and an ``or'' before the last option..SH "OLD CHANNEL TYPES"The original (8.3.1 and below) \fBTcl_ChannelType\fR structure containsthe following fields:.PP.CStypedef struct Tcl_ChannelType {	char *\fItypeName\fR;	Tcl_DriverBlockModeProc *\fIblockModeProc\fR;		Tcl_DriverCloseProc *\fIcloseProc\fR;	Tcl_DriverInputProc *\fIinputProc\fR;	Tcl_DriverOutputProc *\fIoutputProc\fR;	Tcl_DriverSeekProc *\fIseekProc\fR;	Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;	Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;	Tcl_DriverWatchProc *\fIwatchProc\fR;	Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;	Tcl_DriverClose2Proc *\fIclose2Proc\fR;} Tcl_ChannelType;.CE.PPIt is still possible to create channel with the above structure.  Theinternal channel code will determine the version.  It is imperative to usethe new \fBTcl_ChannelType\fR structure if you are creating a stackedchannel driver, due to problems with the earlier stacked channelimplementation (in 8.2.0 to 8.3.1)..PP.VS 8.4Prior to 8.4.0 (i.e. during the later releases of 8.3 and early partof the 8.4 development cycle) the \fBTcl_ChannelType\fR structurecontained the following fields:.PP.CStypedef struct Tcl_ChannelType {	char *\fItypeName\fR;	Tcl_ChannelTypeVersion \fIversion\fR;	Tcl_DriverCloseProc *\fIcloseProc\fR;	Tcl_DriverInputProc *\fIinputProc\fR;	Tcl_DriverOutputProc *\fIoutputProc\fR;	Tcl_DriverSeekProc *\fIseekProc\fR;	Tcl_DriverSetOptionProc *\fIsetOptionProc\fR;	Tcl_DriverGetOptionProc *\fIgetOptionProc\fR;	Tcl_DriverWatchProc *\fIwatchProc\fR;	Tcl_DriverGetHandleProc *\fIgetHandleProc\fR;	Tcl_DriverClose2Proc *\fIclose2Proc\fR;	Tcl_DriverBlockModeProc *\fIblockModeProc\fR;		Tcl_DriverFlushProc *\fIflushProc\fR;		Tcl_DriverHandlerProc *\fIhandlerProc\fR;	} Tcl_ChannelType;.CE.PPWhen the above structure is registered as a channel type, the\fIversion\fR field should always be \fBTCL_CHANNEL_VERSION_2\fR..VE 8.4.SH "SEE ALSO"Tcl_Close(3), Tcl_OpenFileChannel(3), Tcl_SetErrno(3), Tcl_QueueEvent(3), Tcl_StackChannel(3), Tcl_GetStdChannel(3).SH KEYWORDSblocking, channel driver, channel registration, channel type, nonblocking

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -