'\" '\" Copyright (c) 1995-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" SCCS: @(#) GetFile.3 1.8 96/03/25 20:03:31 '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. If an argument is present, then a line break is '\" forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" SCCS: @(#) man.macros 1.8 96/02/15 20:02:24 '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ie !"\\$3"" \{\ .ta \\n()Au \\n()Bu \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$1"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 4c 8c 12c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH Tcl_GetFile 3 7.5 Tcl "Tcl Library Procedures" .BS .SH NAME Tcl_GetFile, Tcl_FreeFile, Tcl_GetFileInfo \- procedures to manipulate generic file handles .SH SYNOPSIS .nf \fB#include \fR .sp Tcl_File \fBTcl_GetFile\fR(\fIosHandle, type\fR) .sp \fBTcl_FreeFile\fR(\fIhandle\fR) .sp ClientData \fBTcl_GetFileInfo\fR(\fIhandle, typePtr\fR) .sp ClientData \fBTcl_GetNotifierData\fR(\fIhandle, freeProcPtr\fR) .sp \fBTcl_SetNotifierData\fR(\fIhandle, freeProc, clientData\fR) .SH ARGUMENTS .AS Tcl_FileFreeProc **freeProcPtr .AP ClientData osHandle in Platform-specific file handle to be associated with the generic file handle. .AP int type in The type of platform-specific file handle associated with the generic file handle. See below for a list of valid types. .AP Tcl_File handle in Generic file handle associated with platform-specific file information. .AP int *typePtr in/out If \fI*typePtr\fR is not NULL, then the specified word is set to contain the type associated with \fIhandle\fR. .AP Tcl_FileFreeProc *freeProc in Procedure to call when \fIhandle\fR is deleted. .AP Tcl_FileFreeProc **freeProcPtr in/out Pointer to location in which to store address of current free procedure for file handle. Ignored if NULL. .AP ClientData clientData in Arbitrary one-word value associated with the given file handle. This data is owned by the caller. .BE .SH DESCRIPTION .PP A \fBTcl_File\fR is an opaque handle used to refer to files in a platform independent way in Tcl routines like \fBTcl_CreateFileHandler\fR. A file handle has an associated platform-dependent \fIosHandle\fR, a \fItype\fR and additional private data used by the notifier to generate events for the file. The type is an integer that determines how the platform-specific drivers will interpret the \fIosHandle\fR. The types that are defined by the core are: .TP 22 \fBTCL_UNIX_FD\fR The \fIosHandle\fR is a Unix file descriptor. .TP 22 \fBTCL_MAC_FILE\fR The file is a Macintosh file handle. .TP 22 \fBTCL_WIN_FILE\fR The \fIosHandle\fR is a Windows normal file \fBHANDLE\fR. .TP 22 \fBTCL_WIN_PIPE\fR The \fIosHandle\fR is a Windows anonymous pipe \fBHANDLE\fR. .TP 22 \fBTCL_WIN_SOCKET\fR The \fIosHandle\fR is a Windows \fBSOCKET\fR. .TP 22 \fBTCL_WIN_CONSOLE\fR The \fIosHandle\fR is a Windows console buffer \fBHANDLE\fR. .PP \fBTcl_GetFile\fR locates the file handle corresponding to a particular \fIosHandle\fR and a \fItype\fR. If a file handle already existed for the given file, then that handle will be returned. If this is the first time that the file handle for a particular file is being retrieved, then a new file handle will be allocated and returned. .PP When a file handle is no longer in use, it should be deallocated with a call to \fBTcl_FreeFile\fR. A call to this function will invoke the notifier free procedure \fIproc\fR, if there is one. After the notifier has cleaned up, any resources used by the file handle will be deallocated. \fBTcl_FreeFile\fR will not close the platform-specific \fIosHandle\fR. .PP \fBTcl_GetFileInfo\fR may be used to retrieve the platform-specific \fIosHandle\fR and type associated with a file handle. If \fItypePtr\fR is not NULL, then the word at \fI*typePtr\fR is set to the type of the file handle. The return value of the function is the associated platform-specific \fIosHandle\fR. Note that this function may be used to extract the platform-specific file handle from a \fBTcl_File\fR so that it may be used in external interfaces. However, programs written using this interface will be platform-specific. .PP The \fBTcl_SetNotifierData\fR and \fBTcl_GetNotifierData\fR procedures are intended to be used only by notifier writers. See the \fITcl_CreateEventSource(3)\fR manual entry for more information on the notifier. .PP \fBTcl_SetNotifierData\fR may be used by notifier writers to associate notifier-specific information with a \fBTcl_File\fR. The \fIdata\fR argument specifies a word that may be retrieved with a later call to \fBTcl_GetNotifierData\fR. If the \fIfreeProc\fR argument is non-NULL it specifies the address of a procedure to invoke when the \fBTcl_File\fR is deleted. \fIfreeProc\fR should have arguments and result that match the type \fBTcl_FileFreeProc\fR: .CS typedef void Tcl_FileFreeProc( ClientData \fIclientData\fR); .CE When \fIfreeProc\fR is invoked the \fIclientData\fR argument will be the same as the corresponding argument passed to \fBTcl_SetNotifierData\fR. .PP \fBTcl_GetNotifierData\fR returns the \fIclientData\fR associated with the given \fBTcl_File\fR, and if the \fIfreeProcPtr\fR field is non-\fBNULL\fR, the address indicated by it gets the address of the free procedure stored with this file. .SH KEYWORDS generic file handle, file type, file descriptor, notifier