CrtSlave.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:10k
- '"
- '" 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.
- '"
- '" RCS: @(#) $Id: CrtSlave.3,v 1.8.2.2 2003/07/18 15:20:51 dgp Exp $
- '"
- .so man.macros
- .TH Tcl_CreateSlave 3 7.6 Tcl "Tcl Library Procedures"
- .BS
- .SH NAME
- 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.
- .SH SYNOPSIS
- .nf
- fB#include <tcl.h>fR
- .sp
- int
- fBTcl_IsSafefR(fIinterpfR)
- .sp
- int
- fBTcl_MakeSafefR(fIinterpfR)
- .sp
- Tcl_Interp *
- fBTcl_CreateSlavefR(fIinterp, slaveName, isSafefR)
- .sp
- Tcl_Interp *
- fBTcl_GetSlavefR(fIinterp, slaveNamefR)
- .sp
- Tcl_Interp *
- fBTcl_GetMasterfR(fIinterpfR)
- .sp
- int
- fBTcl_GetInterpPathfR(fIaskingInterp, slaveInterpfR)
- .sp
- .VS
- int
- fBTcl_CreateAliasfR(fIslaveInterp, slaveCmd, targetInterp, targetCmd, argc, argvfR)
- .sp
- int
- fBTcl_CreateAliasObjfR(fIslaveInterp, slaveCmd, targetInterp, targetCmd, objc, objvfR)
- .VE
- .sp
- int
- fBTcl_GetAliasfR(fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, argcPtr, argvPtrfR)
- .sp
- .VS
- int
- fBTcl_GetAliasObjfR(fIinterp, slaveCmd, targetInterpPtr, targetCmdPtr, objcPtr, objvPtrfR)
- .sp
- int
- fBTcl_ExposeCommandfR(fIinterp, hiddenCmdName, cmdNamefR)
- .sp
- int
- fBTcl_HideCommandfR(fIinterp, cmdName, hiddenCmdNamefR)
- .SH ARGUMENTS
- .AS Tcl_InterpDeleteProc **hiddenCmdName
- .AP Tcl_Interp *interp in
- Interpreter in which to execute the specified command.
- .AP "CONST char" *slaveName in
- Name of slave interpreter to create or manipulate.
- .AP int isSafe in
- If non-zero, a ``safe'' slave that is suitable for running untrusted code
- is created, otherwise a trusted slave is created.
- .AP Tcl_Interp *slaveInterp in
- Interpreter to use for creating the source command for an alias (see
- below).
- .AP "CONST char" *slaveCmd in
- Name of source command for alias.
- .AP Tcl_Interp *targetInterp in
- Interpreter that contains the target command for an alias.
- .AP "CONST char" *targetCmd in
- Name of target command for alias in fItargetInterpfR.
- .AP int argc in
- Count of additional arguments to pass to the alias command.
- .AP "CONST char * CONST" *argv in
- Vector of strings, the additional arguments to pass to the alias command.
- This storage is owned by the caller.
- .AP int objc in
- Count of additional object arguments to pass to the alias object command.
- .AP Tcl_Object **objv in
- Vector of Tcl_Obj structures, the additional object arguments to pass to
- the alias object command.
- This storage is owned by the caller.
- .AP Tcl_Interp **targetInterpPtr in
- Pointer to location to store the address of the interpreter where a target
- command is defined for an alias.
- .AP "CONST char" **targetCmdPtr out
- Pointer to location to store the address of the name of the target command
- for an alias.
- .AP int *argcPtr out
- Pointer to location to store count of additional arguments to be passed to
- the alias. The location is in storage owned by the caller.
- .AP "CONST char" ***argvPtr out
- Pointer to location to store a vector of strings, the additional arguments
- to pass to an alias. The location is in storage owned by the caller, the
- vector of strings is owned by the called function.
- .AP int *objcPtr out
- Pointer to location to store count of additional object arguments to be
- passed to the alias. The location is in storage owned by the caller.
- .AP Tcl_Obj ***objvPtr out
- Pointer to location to store a vector of Tcl_Obj structures, the additional
- arguments to pass to an object alias command. The location is in storage
- owned by the caller, the vector of Tcl_Obj structures is owned by the
- called function.
- .VS
- .VS 8.4
- .AP "CONST char" *cmdName in
- .VE
- Name of an exposed command to hide or create.
- .VS 8.4
- .AP "CONST char" *hiddenCmdName in
- .VE
- Name under which a hidden command is stored and with which it can be
- exposed or invoked.
- .VE
- .BE
- .SH DESCRIPTION
- .PP
- These procedures are intended for access to the multiple interpreter
- facility from inside C programs. They enable managing multiple interpreters
- in a hierarchical relationship, and the management of aliases, commands
- that when invoked in one interpreter execute a command in another
- interpreter. The return value for those procedures that return an fBintfR
- is either fBTCL_OKfR or fBTCL_ERRORfR. If fBTCL_ERRORfR is returned
- then the fBresultfR field of the interpreter contains an error message.
- .PP
- fBTcl_CreateSlavefR creates a new interpreter as a slave of fIinterpfR.
- It also creates a slave command named fIslaveNamefR in fIinterpfR which
- allows fIinterpfR to manipulate the new slave.
- If fIisSafefR is zero, the command creates a trusted slave in which Tcl
- code has access to all the Tcl commands.
- If it is fB1fR, the command creates a ``safe'' slave in which Tcl code
- has access only to set of Tcl commands defined as ``Safe Tcl''; see the
- manual entry for the Tcl fBinterpfR command for details.
- If the creation of the new slave interpreter failed, fBNULLfR is returned.
- .PP
- fBTcl_IsSafefR returns fB1fR if fIinterpfR is ``safe'' (was created
- with the fBTCL_SAFE_INTERPRETERfR flag specified),
- fB0fR otherwise.
- .PP
- fBTcl_MakeSafefR marks fIinterpfR as ``safe'', so that future
- calls to fBTcl_IsSafefR will return 1. It also removes all known
- potentially-unsafe core functionality (both commands and variables)
- from fIinterpfR. However, it cannot know what parts of an extension
- or application are safe and does not make any attempt to remove those
- parts, so safety is not guaranteed after calling fBTcl_MakeSafefR.
- Callers will want to take care with their use of fBTcl_MakeSafefR
- to avoid false claims of safety. For many situations, fBTcl_CreateSlavefR
- may be a better choice, since it creates interpreters in a known-safe state.
- .PP
- fBTcl_GetSlavefR returns a pointer to a slave interpreter of
- fIinterpfR. The slave interpreter is identified by fIslaveNamefR.
- If no such slave interpreter exists, fBNULLfR is returned.
- .PP
- fBTcl_GetMasterfR returns a pointer to the master interpreter of
- fIinterpfR. If fIinterpfR has no master (it is a
- top-level interpreter) then fBNULLfR is returned.
- .PP
- fBTcl_GetInterpPathfR sets the fIresultfR field in fIaskingInterpfR
- to the relative path between fIaskingInterpfR and fIslaveInterpfR;
- fIslaveInterpfR must be a slave of fIaskingInterpfR. If the computation
- of the relative path succeeds, fBTCL_OKfR is returned, else
- fBTCL_ERRORfR is returned and the fIresultfR field in
- fIaskingInterpfR contains the error message.
- .PP
- .VS
- fBTcl_CreateAliasfR creates an object command named fIslaveCmdfR in
- fIslaveInterpfR that when invoked, will cause the command fItargetCmdfR
- to be invoked in fItargetInterpfR. The arguments specified by the strings
- contained in fIargvfR are always prepended to any arguments supplied in the
- invocation of fIslaveCmdfR and passed to fItargetCmdfR.
- This operation returns fBTCL_OKfR if it succeeds, or fBTCL_ERRORfR if
- it fails; in that case, an error message is left in the object result
- of fIslaveInterpfR.
- Note that there are no restrictions on the ancestry relationship (as
- created by fBTcl_CreateSlavefR) between fIslaveInterpfR and
- fItargetInterpfR. Any two interpreters can be used, without any
- restrictions on how they are related.
- .PP
- fBTcl_CreateAliasObjfR is similar to fBTcl_CreateAliasfR except
- that it takes a vector of objects to pass as additional arguments instead
- of a vector of strings.
- .VE
- .PP
- fBTcl_GetAliasfR returns information about an alias fIaliasNamefR
- in fIinterpfR. Any of the result fields can be fBNULLfR, in
- which case the corresponding datum is not returned. If a result field is
- non-fBNULLfR, the address indicated is set to the corresponding datum.
- For example, if fItargetNamePtrfR is non-fBNULLfR it is set to a
- pointer to the string containing the name of the target command.
- .VS
- .PP
- fBTcl_GetAliasObjfR is similar to fBTcl_GetAliasfR except that it
- returns a pointer to a vector of Tcl_Obj structures instead of a vector of
- strings.
- .PP
- fBTcl_ExposeCommandfR moves the command named fIhiddenCmdNamefR from
- the set of hidden commands to the set of exposed commands, putting
- it under the name
- fIcmdNamefR.
- fIHiddenCmdNamefR must be the name of an existing hidden
- command, or the operation will return fBTCL_ERRORfR and leave an error
- message in the fIresultfR field in fIinterpfR.
- If an exposed command named fIcmdNamefR already exists,
- the operation returns fBTCL_ERRORfR and leaves an error message in the
- object result of fIinterpfR.
- If the operation succeeds, it returns fBTCL_OKfR.
- After executing this command, attempts to use fIcmdNamefR in a call to
- fBTcl_EvalfR or with the Tcl fBevalfR command will again succeed.
- .PP
- fBTcl_HideCommandfR moves the command named fIcmdNamefR from the set of
- exposed commands to the set of hidden commands, under the name
- fIhiddenCmdNamefR.
- fICmdNamefR must be the name of an existing exposed
- command, or the operation will return fBTCL_ERRORfR and leave an error
- message in the object result of fIinterpfR.
- Currently both fIcmdNamefR and fIhiddenCmdNamefR must not contain
- namespace qualifiers, or the operation will return fBTCL_ERRORfR and
- leave an error message in the object result of fIinterpfR.
- The fICmdNamefR will be looked up in the global namespace, and not
- relative to the current namespace, even if the current namespace is not the
- global one.
- If a hidden command whose name is fIhiddenCmdNamefR already
- exists, the operation also returns fBTCL_ERRORfR and the fIresultfR
- field in fIinterpfR contains an error message.
- If the operation succeeds, it returns fBTCL_OKfR.
- After executing this command, attempts to use fIcmdNamefR in a call to
- fBTcl_EvalfR or with the Tcl fBevalfR command will fail.
- .PP
- For a description of the Tcl interface to multiple interpreters, see
- fIinterp(n)fR.
- .SH "SEE ALSO"
- interp
- .SH KEYWORDS
- alias, command, exposed commands, hidden commands, interpreter, invoke,
- master, slave