Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/CrtSlave.3 @ 35

Last change on this file since 35 was 25, checked in by landauf, 18 years ago

added tcl to libs

File size: 10.0 KB
Line 
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
13Tcl_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
18int
19\fBTcl_IsSafe\fR(\fIinterp\fR)
20.sp
21int
22\fBTcl_MakeSafe\fR(\fIinterp\fR)
23.sp
24Tcl_Interp *
25\fBTcl_CreateSlave\fR(\fIinterp, slaveName, isSafe\fR)
26.sp
27Tcl_Interp *
28\fBTcl_GetSlave\fR(\fIinterp, slaveName\fR)
29.sp
30Tcl_Interp *
31\fBTcl_GetMaster\fR(\fIinterp\fR)
32.sp
33int
34\fBTcl_GetInterpPath\fR(\fIaskingInterp, slaveInterp\fR)
35.sp
36int
37\fBTcl_CreateAlias\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd,
38                argc, argv\fR)
39.sp
40int
41\fBTcl_CreateAliasObj\fR(\fIslaveInterp, slaveCmd, targetInterp, targetCmd,
42                   objc, objv\fR)
43.sp
44int
45\fBTcl_GetAlias\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr,
46             argcPtr, argvPtr\fR)
47.sp
48int
49\fBTcl_GetAliasObj\fR(\fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr,
50                objcPtr, objvPtr\fR)
51.sp
52int
53\fBTcl_ExposeCommand\fR(\fIinterp, hiddenCmdName, cmdName\fR)
54.sp
55int
56\fBTcl_HideCommand\fR(\fIinterp, cmdName, hiddenCmdName\fR)
57.SH ARGUMENTS
58.AS "const char *const" **targetInterpPtr out
59.AP Tcl_Interp *interp in
60Interpreter in which to execute the specified command.
61.AP "const char" *slaveName in
62Name of slave interpreter to create or manipulate.
63.AP int isSafe in
64If non-zero, a
65.QW safe
66slave that is suitable for running untrusted code
67is created, otherwise a trusted slave is created.
68.AP Tcl_Interp *slaveInterp in
69Interpreter to use for creating the source command for an alias (see
70below).
71.AP "const char" *slaveCmd in
72Name of source command for alias.
73.AP Tcl_Interp *targetInterp in
74Interpreter that contains the target command for an alias.
75.AP "const char" *targetCmd in
76Name of target command for alias in \fItargetInterp\fR.
77.AP int argc in
78Count of additional arguments to pass to the alias command.
79.AP "const char *const" *argv in
80Vector of strings, the additional arguments to pass to the alias command.
81This storage is owned by the caller.
82.AP int objc in
83Count of additional object arguments to pass to the alias object command.
84.AP Tcl_Obj **objv in
85Vector of Tcl_Obj structures, the additional object arguments to pass to
86the alias object command.
87This storage is owned by the caller.
88.AP Tcl_Interp **targetInterpPtr in
89Pointer to location to store the address of the interpreter where a target
90command is defined for an alias.
91.AP "const char" **targetCmdPtr out
92Pointer to location to store the address of the name of the target command
93for an alias.
94.AP int *argcPtr out
95Pointer to location to store count of additional arguments to be passed to
96the alias. The location is in storage owned by the caller.
97.AP "const char" ***argvPtr out
98Pointer to location to store a vector of strings, the additional arguments
99to pass to an alias. The location is in storage owned by the caller, the
100vector of strings is owned by the called function.
101.AP int *objcPtr out
102Pointer to location to store count of additional object arguments to be
103passed to the alias. The location is in storage owned by the caller.
104.AP Tcl_Obj ***objvPtr out
105Pointer to location to store a vector of Tcl_Obj structures, the additional
106arguments to pass to an object alias command. The location is in storage
107owned by the caller, the vector of Tcl_Obj structures is owned by the
108called function.
109.AP "const char" *cmdName in
110Name of an exposed command to hide or create.
111.AP "const char" *hiddenCmdName in
112Name under which a hidden command is stored and with which it can be
113exposed or invoked.
114.BE
115
116.SH DESCRIPTION
117.PP
118These procedures are intended for access to the multiple interpreter
119facility from inside C programs. They enable managing multiple interpreters
120in a hierarchical relationship, and the management of aliases, commands
121that when invoked in one interpreter execute a command in another
122interpreter. The return value for those procedures that return an \fBint\fR
123is either \fBTCL_OK\fR or \fBTCL_ERROR\fR. If \fBTCL_ERROR\fR is returned
124then 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.
127It also creates a slave command named \fIslaveName\fR in \fIinterp\fR which
128allows \fIinterp\fR to manipulate the new slave.
129If \fIisSafe\fR is zero, the command creates a trusted slave in which Tcl
130code has access to all the Tcl commands.
131If it is \fB1\fR, the command creates a
132.QW safe
133slave in which Tcl code has access only to set of Tcl commands defined as
134.QW "Safe Tcl" ;
135see the manual entry for the Tcl \fBinterp\fR command for details.
136If 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 ,
145so that future
146calls to \fBTcl_IsSafe\fR will return 1.  It also removes all known
147potentially-unsafe core functionality (both commands and variables)
148from \fIinterp\fR.  However, it cannot know what parts of an extension
149or application are safe and does not make any attempt to remove those
150parts, so safety is not guaranteed after calling \fBTcl_MakeSafe\fR.
151Callers will want to take care with their use of \fBTcl_MakeSafe\fR
152to avoid false claims of safety.  For many situations, \fBTcl_CreateSlave\fR
153may 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.
157If 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
161top-level interpreter) then \fBNULL\fR is returned.
162.PP
163\fBTcl_GetInterpPath\fR sets the \fIresult\fR field in \fIaskingInterp\fR
164to the relative path between \fIaskingInterp\fR and \fIslaveInterp\fR;
165\fIslaveInterp\fR must be a slave of \fIaskingInterp\fR. If the computation
166of 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
172to be invoked in \fItargetInterp\fR. The arguments specified by the strings
173contained in \fIargv\fR are always prepended to any arguments supplied in the
174invocation of \fIslaveCmd\fR and passed to \fItargetCmd\fR.
175This operation returns \fBTCL_OK\fR if it succeeds, or \fBTCL_ERROR\fR if
176it fails; in that case, an error message is left in the object result
177of \fIslaveInterp\fR.
178Note that there are no restrictions on the ancestry relationship (as
179created by \fBTcl_CreateSlave\fR) between \fIslaveInterp\fR and
180\fItargetInterp\fR. Any two interpreters can be used, without any
181restrictions on how they are related.
182.PP
183\fBTcl_CreateAliasObj\fR is similar to \fBTcl_CreateAlias\fR except
184that it takes a vector of objects to pass as additional arguments instead
185of a vector of strings.
186.PP
187\fBTcl_GetAlias\fR returns information about an alias \fIaliasName\fR
188in \fIinterp\fR. Any of the result fields can be \fBNULL\fR, in
189which case the corresponding datum is not returned. If a result field is
190non\-\fBNULL\fR, the address indicated is set to the corresponding datum.
191For example, if \fItargetNamePtr\fR is non\-\fBNULL\fR it is set to a
192pointer 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
195returns a pointer to a vector of Tcl_Obj structures instead of a vector of
196strings.
197.PP
198\fBTcl_ExposeCommand\fR moves the command named \fIhiddenCmdName\fR from
199the set of hidden commands to the set of exposed commands, putting
200it under the name
201\fIcmdName\fR.
202\fIHiddenCmdName\fR must be the name of an existing hidden
203command, or the operation will return \fBTCL_ERROR\fR and leave an error
204message in the \fIresult\fR field in \fIinterp\fR.
205If an exposed command named \fIcmdName\fR already exists,
206the operation returns \fBTCL_ERROR\fR and leaves an error message in the
207object result of \fIinterp\fR.
208If the operation succeeds, it returns \fBTCL_OK\fR.
209After 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
213exposed commands to the set of hidden commands, under the name
214\fIhiddenCmdName\fR.
215\fICmdName\fR must be the name of an existing exposed
216command, or the operation will return \fBTCL_ERROR\fR and leave an error
217message in the object result of \fIinterp\fR.
218Currently both \fIcmdName\fR and \fIhiddenCmdName\fR must not contain
219namespace qualifiers, or the operation will return \fBTCL_ERROR\fR and
220leave an error message in the object result of \fIinterp\fR.
221The \fICmdName\fR will be looked up in the global namespace, and not
222relative to the current namespace, even if the current namespace is not the
223global one.
224If a hidden command whose name is \fIhiddenCmdName\fR already
225exists, the operation also returns \fBTCL_ERROR\fR and the \fIresult\fR
226field in \fIinterp\fR contains an error message.
227If the operation succeeds, it returns \fBTCL_OK\fR.
228After 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
231For a description of the Tcl interface to multiple interpreters, see
232\fIinterp(n)\fR.
233.SH "SEE ALSO"
234interp
235
236.SH KEYWORDS
237alias, command, exposed commands, hidden commands, interpreter, invoke,
238master, slave
Note: See TracBrowser for help on using the repository browser.