1 | '\" |
---|
2 | '\" Copyright (c) 1995-1996 Sun Microsystems, Inc. |
---|
3 | '\" |
---|
4 | '\" See the file "license.terms" for information on usage and redistribution |
---|
5 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
6 | '\" |
---|
7 | '\" RCS: @(#) $Id: CrtSlave.3,v 1.20 2007/12/13 15:22:30 dgp Exp $ |
---|
8 | '\" |
---|
9 | .so man.macros |
---|
10 | .TH Tcl_CreateSlave 3 7.6 Tcl "Tcl Library Procedures" |
---|
11 | .BS |
---|
12 | .SH NAME |
---|
13 | Tcl_IsSafe, Tcl_MakeSafe, Tcl_CreateSlave, Tcl_GetSlave, Tcl_GetMaster, Tcl_GetInterpPath, Tcl_CreateAlias, Tcl_CreateAliasObj, Tcl_GetAlias, Tcl_GetAliasObj, Tcl_ExposeCommand, Tcl_HideCommand \- manage multiple Tcl interpreters, aliases and hidden commands |
---|
14 | .SH SYNOPSIS |
---|
15 | .nf |
---|
16 | \fB#include <tcl.h>\fR |
---|
17 | .sp |
---|
18 | int |
---|
19 | \fBTcl_IsSafe\fR(\fIinterp\fR) |
---|
20 | .sp |
---|
21 | int |
---|
22 | \fBTcl_MakeSafe\fR(\fIinterp\fR) |
---|
23 | .sp |
---|
24 | Tcl_Interp * |
---|
25 | \fBTcl_CreateSlave\fR(\fIinterp, slaveName, isSafe\fR) |
---|
26 | .sp |
---|
27 | Tcl_Interp * |
---|
28 | \fBTcl_GetSlave\fR(\fIinterp, slaveName\fR) |
---|
29 | .sp |
---|
30 | Tcl_Interp * |
---|
31 | \fBTcl_GetMaster\fR(\fIinterp\fR) |
---|
32 | .sp |
---|
33 | int |
---|
34 | \fBTcl_GetInterpPath\fR(\fIaskingInterp, slaveInterp\fR) |
---|
35 | .sp |
---|
36 | int |
---|
37 | \fBTcl_CreateAlias\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd, |
---|
38 | argc, argv\fR) |
---|
39 | .sp |
---|
40 | int |
---|
41 | \fBTcl_CreateAliasObj\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd, |
---|
42 | objc, objv\fR) |
---|
43 | .sp |
---|
44 | int |
---|
45 | \fBTcl_GetAlias\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, |
---|
46 | argcPtr, argvPtr\fR) |
---|
47 | .sp |
---|
48 | int |
---|
49 | \fBTcl_GetAliasObj\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, |
---|
50 | objcPtr, objvPtr\fR) |
---|
51 | .sp |
---|
52 | int |
---|
53 | \fBTcl_ExposeCommand\fR(\fIinterp, hiddenCmdName, cmdName\fR) |
---|
54 | .sp |
---|
55 | int |
---|
56 | \fBTcl_HideCommand\fR(\fIinterp, cmdName, hiddenCmdName\fR) |
---|
57 | .SH ARGUMENTS |
---|
58 | .AS "const char *const" **targetInterpPtr out |
---|
59 | .AP Tcl_Interp *interp in |
---|
60 | Interpreter in which to execute the specified command. |
---|
61 | .AP "const char" *slaveName in |
---|
62 | Name of slave interpreter to create or manipulate. |
---|
63 | .AP int isSafe in |
---|
64 | If non-zero, a |
---|
65 | .QW safe |
---|
66 | slave that is suitable for running untrusted code |
---|
67 | is created, otherwise a trusted slave is created. |
---|
68 | .AP Tcl_Interp *slaveInterp in |
---|
69 | Interpreter to use for creating the source command for an alias (see |
---|
70 | below). |
---|
71 | .AP "const char" *slaveCmd in |
---|
72 | Name of source command for alias. |
---|
73 | .AP Tcl_Interp *targetInterp in |
---|
74 | Interpreter that contains the target command for an alias. |
---|
75 | .AP "const char" *targetCmd in |
---|
76 | Name of target command for alias in \fItargetInterp\fR. |
---|
77 | .AP int argc in |
---|
78 | Count of additional arguments to pass to the alias command. |
---|
79 | .AP "const char *const" *argv in |
---|
80 | Vector of strings, the additional arguments to pass to the alias command. |
---|
81 | This storage is owned by the caller. |
---|
82 | .AP int objc in |
---|
83 | Count of additional object arguments to pass to the alias object command. |
---|
84 | .AP Tcl_Obj **objv in |
---|
85 | Vector of Tcl_Obj structures, the additional object arguments to pass to |
---|
86 | the alias object command. |
---|
87 | This storage is owned by the caller. |
---|
88 | .AP Tcl_Interp **targetInterpPtr in |
---|
89 | Pointer to location to store the address of the interpreter where a target |
---|
90 | command is defined for an alias. |
---|
91 | .AP "const char" **targetCmdPtr out |
---|
92 | Pointer to location to store the address of the name of the target command |
---|
93 | for an alias. |
---|
94 | .AP int *argcPtr out |
---|
95 | Pointer to location to store count of additional arguments to be passed to |
---|
96 | the alias. The location is in storage owned by the caller. |
---|
97 | .AP "const char" ***argvPtr out |
---|
98 | Pointer to location to store a vector of strings, the additional arguments |
---|
99 | to pass to an alias. The location is in storage owned by the caller, the |
---|
100 | vector of strings is owned by the called function. |
---|
101 | .AP int *objcPtr out |
---|
102 | Pointer to location to store count of additional object arguments to be |
---|
103 | passed to the alias. The location is in storage owned by the caller. |
---|
104 | .AP Tcl_Obj ***objvPtr out |
---|
105 | Pointer to location to store a vector of Tcl_Obj structures, the additional |
---|
106 | arguments to pass to an object alias command. The location is in storage |
---|
107 | owned by the caller, the vector of Tcl_Obj structures is owned by the |
---|
108 | called function. |
---|
109 | .AP "const char" *cmdName in |
---|
110 | Name of an exposed command to hide or create. |
---|
111 | .AP "const char" *hiddenCmdName in |
---|
112 | Name under which a hidden command is stored and with which it can be |
---|
113 | exposed or invoked. |
---|
114 | .BE |
---|
115 | |
---|
116 | .SH DESCRIPTION |
---|
117 | .PP |
---|
118 | These procedures are intended for access to the multiple interpreter |
---|
119 | facility from inside C programs. They enable managing multiple interpreters |
---|
120 | in a hierarchical relationship, and the management of aliases, commands |
---|
121 | that when invoked in one interpreter execute a command in another |
---|
122 | interpreter. The return value for those procedures that return an \fBint\fR |
---|
123 | is either \fBTCL_OK\fR or \fBTCL_ERROR\fR. If \fBTCL_ERROR\fR is returned |
---|
124 | then the \fBresult\fR field of the interpreter contains an error message. |
---|
125 | .PP |
---|
126 | \fBTcl_CreateSlave\fR creates a new interpreter as a slave of \fIinterp\fR. |
---|
127 | It also creates a slave command named \fIslaveName\fR in \fIinterp\fR which |
---|
128 | allows \fIinterp\fR to manipulate the new slave. |
---|
129 | If \fIisSafe\fR is zero, the command creates a trusted slave in which Tcl |
---|
130 | code has access to all the Tcl commands. |
---|
131 | If it is \fB1\fR, the command creates a |
---|
132 | .QW safe |
---|
133 | slave in which Tcl code has access only to set of Tcl commands defined as |
---|
134 | .QW "Safe Tcl" ; |
---|
135 | see the manual entry for the Tcl \fBinterp\fR command for details. |
---|
136 | If the creation of the new slave interpreter failed, \fBNULL\fR is returned. |
---|
137 | .PP |
---|
138 | \fBTcl_IsSafe\fR returns \fB1\fR if \fIinterp\fR is |
---|
139 | .QW safe |
---|
140 | (was created with the \fBTCL_SAFE_INTERPRETER\fR flag specified), |
---|
141 | \fB0\fR otherwise. |
---|
142 | .PP |
---|
143 | \fBTcl_MakeSafe\fR marks \fIinterp\fR as |
---|
144 | .QW safe , |
---|
145 | so that future |
---|
146 | calls to \fBTcl_IsSafe\fR will return 1. It also removes all known |
---|
147 | potentially-unsafe core functionality (both commands and variables) |
---|
148 | from \fIinterp\fR. However, it cannot know what parts of an extension |
---|
149 | or application are safe and does not make any attempt to remove those |
---|
150 | parts, so safety is not guaranteed after calling \fBTcl_MakeSafe\fR. |
---|
151 | Callers will want to take care with their use of \fBTcl_MakeSafe\fR |
---|
152 | to avoid false claims of safety. For many situations, \fBTcl_CreateSlave\fR |
---|
153 | may be a better choice, since it creates interpreters in a known-safe state. |
---|
154 | .PP |
---|
155 | \fBTcl_GetSlave\fR returns a pointer to a slave interpreter of |
---|
156 | \fIinterp\fR. The slave interpreter is identified by \fIslaveName\fR. |
---|
157 | If no such slave interpreter exists, \fBNULL\fR is returned. |
---|
158 | .PP |
---|
159 | \fBTcl_GetMaster\fR returns a pointer to the master interpreter of |
---|
160 | \fIinterp\fR. If \fIinterp\fR has no master (it is a |
---|
161 | top-level interpreter) then \fBNULL\fR is returned. |
---|
162 | .PP |
---|
163 | \fBTcl_GetInterpPath\fR sets the \fIresult\fR field in \fIaskingInterp\fR |
---|
164 | to the relative path between \fIaskingInterp\fR and \fIslaveInterp\fR; |
---|
165 | \fIslaveInterp\fR must be a slave of \fIaskingInterp\fR. If the computation |
---|
166 | of the relative path succeeds, \fBTCL_OK\fR is returned, else |
---|
167 | \fBTCL_ERROR\fR is returned and the \fIresult\fR field in |
---|
168 | \fIaskingInterp\fR contains the error message. |
---|
169 | .PP |
---|
170 | \fBTcl_CreateAlias\fR creates an object command named \fIslaveCmd\fR in |
---|
171 | \fIslaveInterp\fR that when invoked, will cause the command \fItargetCmd\fR |
---|
172 | to be invoked in \fItargetInterp\fR. The arguments specified by the strings |
---|
173 | contained in \fIargv\fR are always prepended to any arguments supplied in the |
---|
174 | invocation of \fIslaveCmd\fR and passed to \fItargetCmd\fR. |
---|
175 | This operation returns \fBTCL_OK\fR if it succeeds, or \fBTCL_ERROR\fR if |
---|
176 | it fails; in that case, an error message is left in the object result |
---|
177 | of \fIslaveInterp\fR. |
---|
178 | Note that there are no restrictions on the ancestry relationship (as |
---|
179 | created by \fBTcl_CreateSlave\fR) between \fIslaveInterp\fR and |
---|
180 | \fItargetInterp\fR. Any two interpreters can be used, without any |
---|
181 | restrictions on how they are related. |
---|
182 | .PP |
---|
183 | \fBTcl_CreateAliasObj\fR is similar to \fBTcl_CreateAlias\fR except |
---|
184 | that it takes a vector of objects to pass as additional arguments instead |
---|
185 | of a vector of strings. |
---|
186 | .PP |
---|
187 | \fBTcl_GetAlias\fR returns information about an alias \fIaliasName\fR |
---|
188 | in \fIinterp\fR. Any of the result fields can be \fBNULL\fR, in |
---|
189 | which case the corresponding datum is not returned. If a result field is |
---|
190 | non\-\fBNULL\fR, the address indicated is set to the corresponding datum. |
---|
191 | For example, if \fItargetNamePtr\fR is non\-\fBNULL\fR it is set to a |
---|
192 | pointer to the string containing the name of the target command. |
---|
193 | .PP |
---|
194 | \fBTcl_GetAliasObj\fR is similar to \fBTcl_GetAlias\fR except that it |
---|
195 | returns a pointer to a vector of Tcl_Obj structures instead of a vector of |
---|
196 | strings. |
---|
197 | .PP |
---|
198 | \fBTcl_ExposeCommand\fR moves the command named \fIhiddenCmdName\fR from |
---|
199 | the set of hidden commands to the set of exposed commands, putting |
---|
200 | it under the name |
---|
201 | \fIcmdName\fR. |
---|
202 | \fIHiddenCmdName\fR must be the name of an existing hidden |
---|
203 | command, or the operation will return \fBTCL_ERROR\fR and leave an error |
---|
204 | message in the \fIresult\fR field in \fIinterp\fR. |
---|
205 | If an exposed command named \fIcmdName\fR already exists, |
---|
206 | the operation returns \fBTCL_ERROR\fR and leaves an error message in the |
---|
207 | object result of \fIinterp\fR. |
---|
208 | If the operation succeeds, it returns \fBTCL_OK\fR. |
---|
209 | After executing this command, attempts to use \fIcmdName\fR in a call to |
---|
210 | \fBTcl_Eval\fR or with the Tcl \fBeval\fR command will again succeed. |
---|
211 | .PP |
---|
212 | \fBTcl_HideCommand\fR moves the command named \fIcmdName\fR from the set of |
---|
213 | exposed commands to the set of hidden commands, under the name |
---|
214 | \fIhiddenCmdName\fR. |
---|
215 | \fICmdName\fR must be the name of an existing exposed |
---|
216 | command, or the operation will return \fBTCL_ERROR\fR and leave an error |
---|
217 | message in the object result of \fIinterp\fR. |
---|
218 | Currently both \fIcmdName\fR and \fIhiddenCmdName\fR must not contain |
---|
219 | namespace qualifiers, or the operation will return \fBTCL_ERROR\fR and |
---|
220 | leave an error message in the object result of \fIinterp\fR. |
---|
221 | The \fICmdName\fR will be looked up in the global namespace, and not |
---|
222 | relative to the current namespace, even if the current namespace is not the |
---|
223 | global one. |
---|
224 | If a hidden command whose name is \fIhiddenCmdName\fR already |
---|
225 | exists, the operation also returns \fBTCL_ERROR\fR and the \fIresult\fR |
---|
226 | field in \fIinterp\fR contains an error message. |
---|
227 | If the operation succeeds, it returns \fBTCL_OK\fR. |
---|
228 | After executing this command, attempts to use \fIcmdName\fR in a call to |
---|
229 | \fBTcl_Eval\fR or with the Tcl \fBeval\fR command will fail. |
---|
230 | .PP |
---|
231 | For a description of the Tcl interface to multiple interpreters, see |
---|
232 | \fIinterp(n)\fR. |
---|
233 | .SH "SEE ALSO" |
---|
234 | interp |
---|
235 | |
---|
236 | .SH KEYWORDS |
---|
237 | alias, command, exposed commands, hidden commands, interpreter, invoke, |
---|
238 | master, slave |
---|