1Handles(TCL)                                                      Handles(TCL)
2
3
4

NAME

6       Tcl_HandleAlloc,  Tcl_HandleFree,  Tcl_HandleTblInit,  Tcl_HandleTblRe‐
7       lease,   Tcl_HandleTblUseCount,   Tcl_HandleWalk,   Tcl_HandleXlate   -
8       Dynamic, handle addressable tables.
9
10

SYNOPSIS

12       #include <tclExtend.h>
13
14       void_pt
15       Tcl_HandleTblInit (const char *handleBase,
16                          int         entrySize,
17                          int         initEntries);
18
19       int
20       Tcl_HandleTblUseCount (void_pt  headerPtr,
21                              int      amount);
22
23       void
24       Tcl_HandleTblRelease (void_pt headerPtr);
25
26       void_pt
27       Tcl_HandleAlloc (void_pt   headerPtr,
28                        char     *handlePtr);
29
30       void_pt
31       Tcl_HandleXlate (Tcl_Interp *interp,
32                        void_pt     headerPtr,
33                        const char *handle);
34
35       void_pt
36       Tcl_HandleWalk (void_pt   headerPtr,
37                       int      *walkKeyPtr);
38
39       void
40       Tcl_WalkKeyToHandle (void_pt   headerPtr,
41                            int       walkKey,
42                            char     *handlePtr);
43
44       void
45       Tcl_HandleFree (void_pt headerPtr,
46                       void_pt entryPtr);
47

DESCRIPTION

49       The Tcl handle facility provides a way to manage table entries that may
50       be referenced by a textual handle from Tcl code.  This is provided  for
51       applications that need to create data structures in one command, return
52       a reference (i.e. pointer) to that particular data structure  and  then
53       access that data structure in other commands. An example application is
54       file handles.
55
56       A handle consists of a base name,  which  is  some  unique,  meaningful
57       name,  such  as  `file'  and  a numeric value appended to the base name
58       (e.g. `file3').  The handle facility is designed to provide a  standard
59       mechanism  for  building  Tcl  commands  that allocate and access table
60       entries based on an entry index.  The tables are expanded when  needed,
61       consequently  pointers  to  entries  should  not  be kept, as they will
62       become invalid when the table is expanded.  If the  table  entries  are
63       large  or  pointers  must  be kept to the entries, then the the entries
64       should be allocated separately and pointers kept in the  handle  table.
65       A use count is kept on the table.  This use count is intended to deter‐
66       mine when a table shared by multiple commands is to be release.
67
68   Tcl_HandleTblInit
69       Create and initialize a Tcl dynamic handle table.  The use count on the
70       table is set to one.
71
72       Parameters:
73         o  handleBase  -  The  base  name  of  the handle, the handle will be
74         returned in the form "baseNN", where NN is the table entry number.
75         o entrySize - The size of an entry, in bytes.
76         o initEntries - Initial size of the table, in entries.
77
78       Returns:
79         A pointer to the table header.
80
81   Tcl_HandleTblUseCount
82       Alter the handle table use count by the specified amount, which can  be
83       positive or negative.  Amount may be zero to retrieve the use count.
84
85       Parameters:
86         o headerPtr - Pointer to the table header.
87         o amount - The amount to alter the use count by.
88
89       Returns:
90         The resulting use count.
91
92   Tcl_HandleTblRelease
93       Decrement  the  use  count on a Tcl dynamic handle table.  If the count
94       goes to zero or negative, then release the table.
95
96       Parameters:
97         o headerPtr - Pointer to the table header.
98
99   Tcl_HandleAlloc
100       Allocate an entry and associate a handle with it.
101
102       Parameters:
103         o headerPtr - A pointer to the table header.
104         o handlePtr - Buffer to return handle in. It must be  big  enough  to
105         hold the name.
106
107       Returns:
108         A pointer to the allocated entry (user part).
109
110   Tcl_HandleXlate
111       Translate a handle to a entry pointer.
112
113       Parameters:
114         o interp - A error message may be returned in result.
115         o headerPtr - A pointer to the table header.
116
117         o handle - The handle assigned to the entry.
118
119       Returns:
120         A pointer to the entry, or NULL if an error occurred.
121
122   Tcl_HandleWalk
123       Walk through and find every allocated entry in a table.  Entries may be
124       deallocated during a walk, but should not be allocated.
125
126       Parameters:
127         o headerPtr - A pointer to the table header.
128         o walkKeyPtr - Pointer to a variable to use  to  keep  track  of  the
129         place  in the table.  The variable should be initialized to -1 before
130         the first call.
131       Returns:
132         A pointer to the next allocated entry, or NULL if there are not more.
133
134   Tcl_WalkKeyToHandle
135       Convert a walk key, as returned from a call to  Tcl_HandleWalk  into  a
136       handle.  The Tcl_HandleWalk must have succeeded.
137
138       Parameters:
139         o headerPtr - A pointer to the table header.
140         o walkKey - The walk key.
141         o  handlePtr  -  Buffer to return handle in. It must be big enough to
142         hold the name.
143
144   Tcl_HandleFree
145       Frees a handle table entry.
146
147       Parameters:
148         o headerPtr - A pointer to the table header.
149         o entryPtr - Entry to free.
150
151
152
153
154
155Tcl                                                               Handles(TCL)
Impressum