Pegasus InfoCorp: Web site design and web software development company

Tcl_GetFile (3)

procedures to manipulate generic file handles

SYNOPSIS

    #include <tcl.h>
    Tcl_File
    Tcl_GetFile(osHandle, type)
    Tcl_FreeFile(handle)
    ClientData
    Tcl_GetFileInfo(handle, typePtr)
    ClientData
    Tcl_GetNotifierData(handle, freeProcPtr)
    Tcl_SetNotifierData(handle, freeProc, clientData)
    

ARGUMENTS

    Tcl_FileFreeProc **freeProcPtr ClientData osHandle in Platform-specific file handle to be associated with the generic file handle. int type in The type of platform-specific file handle associated with the generic file handle. See below for a list of valid types. Tcl_File handle in Generic file handle associated with platform-specific file information. int *typePtr in/out If *typePtr is not NULL, then the specified word is set to contain the type associated with handle. Tcl_FileFreeProc *freeProc in Procedure to call when handle is deleted. Tcl_FileFreeProc **freeProcPtr in/out Pointer to location in which to store address of current free procedure for file handle. Ignored if NULL. ClientData clientData in Arbitrary one-word value associated with the given file handle. This data is owned by the caller.

DESCRIPTION

    A Tcl_File is an opaque handle used to refer to files in a platform independent way in Tcl routines like Tcl_CreateFileHandler. A file handle has an associated platform-dependent osHandle, a type 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 osHandle. The types that are defined by the core are:

    TCL_UNIX_FD

      The osHandle is a Unix file descriptor.

    TCL_MAC_FILE

      The file is a Macintosh file handle.

    TCL_WIN_FILE

      The osHandle is a Windows normal file HANDLE.

    TCL_WIN_PIPE

      The osHandle is a Windows anonymous pipe HANDLE.

    TCL_WIN_SOCKET

      The osHandle is a Windows SOCKET.

    TCL_WIN_CONSOLE

      The osHandle is a Windows console buffer HANDLE.

    Tcl_GetFile locates the file handle corresponding to a particular osHandle and a type. 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.

    When a file handle is no longer in use, it should be deallocated with a call to Tcl_FreeFile. A call to this function will invoke the notifier free procedure proc, if there is one. After the notifier has cleaned up, any resources used by the file handle will be deallocated. Tcl_FreeFile will not close the platform-specific osHandle.

    Tcl_GetFileInfo may be used to retrieve the platform-specific osHandle and type associated with a file handle. If typePtr is not NULL, then the word at *typePtr is set to the type of the file handle. The return value of the function is the associated platform-specific osHandle. Note that this function may be used to extract the platform-specific file handle from a Tcl_File so that it may be used in external interfaces. However, programs written using this interface will be platform-specific.

    The Tcl_SetNotifierData and Tcl_GetNotifierData procedures are intended to be used only by notifier writers. See the Tcl_CreateEventSource(3) manual entry for more information on the notifier.

    Tcl_SetNotifierData may be used by notifier writers to associate notifier-specific information with a Tcl_File. The data argument specifies a word that may be retrieved with a later call to Tcl_GetNotifierData. If the freeProc argument is non-NULL it specifies the address of a procedure to invoke when the Tcl_File is deleted. freeProc should have arguments and result that match the type Tcl_FileFreeProc: typedef void Tcl_FileFreeProc( ClientData clientData); When freeProc is invoked the clientData argument will be the same as the corresponding argument passed to Tcl_SetNotifierData.

    Tcl_GetNotifierData returns the clientData associated with the given Tcl_File, and if the freeProcPtr field is non-NULL, the address indicated by it gets the address of the free procedure stored with this file.

KEYWORDS

    generic file handle, file type, file descriptor, notifier

    '\" '\" Copyright (c) 1989-1993 The Regents of the University of California. '\" Copyright (c) 1994-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. '\" '\" RCS: @(#) $Id: Hash.3,v 1.2 1998/09/14 18:39:49 stanton Exp $ '\" '\" 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 ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another 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. '\" '\" RCS: @(#) $Id: man.macros,v 1.2 1998/09/14 18:39:54 stanton Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. t .wh -1.3i ^B ^l \n(.l b '\" # Start an argument description AP !"\\$4"" .TP \\$4 \{\ !"\\$2"" .TP \\n()Cu .TP 15