📄 load.n
字号:
'\"'\" 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.'\" '\" SCCS: @(#) load.n 1.9 97/08/22 18:51:18'\" .so man.macros.TH load n 7.5 Tcl "Tcl Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMEload \- Load machine code and initialize new commands..SH SYNOPSIS\fBload \fIfileName\fR.br\fBload \fIfileName packageName\fR.br\fBload \fIfileName packageName interp\fR.BE.SH DESCRIPTION.PPThis command loads binary code from a file into theapplication's address space and calls an initialization procedurein the package to incorporate it into an interpreter. \fIfileName\fRis the name of the file containing the code; its exact form variesfrom system to system but on most systems it is a shared library,such as a \fB.so\fR file under Solaris or a DLL under Windows.\fIpackageName\fR is the name of the package, and is used tocompute the name of an initialization procedure.\fIinterp\fR is the path name of the interpreter into which to loadthe package (see the \fBinterp\fR manual entry for details);if \fIinterp\fR is omitted, it defaults to theinterpreter in which the \fBload\fR command was invoked..PPOnce the file has been loaded into the application's address space,one of two initialization procedures will be invoked in the new code.Typically the initialization procedure will add new commands to aTcl interpreter.The name of the initialization procedure is determined by\fIpackageName\fR and whether or not the target interpreteris a safe one. For normal interpreters the name of the initializationprocedure will have the form \fIpkg\fB_Init\fR, where \fIpkg\fRis the same as \fIpackageName\fR except that the first letter isconverted to upper case and all other lettersare converted to lower case. For example, if \fIpackageName\fR is\fBfoo\fR or \fBFOo\fR, the initialization procedure's name willbe \fBFoo_Init\fR..PPIf the target interpreter is a safe interpreter, then the nameof the initialization procedure will be \fIpkg\fB_SafeInit\fRinstead of \fIpkg\fB_Init\fR.The \fIpkg\fB_SafeInit\fR function should be written carefully, so that itinitializes the safe interpreter only with partial functionality providedby the package that is safe for use by untrusted code. For more informationon Safe\-Tcl, see the \fBsafe\fR manual entry..PPThe initialization procedure must match the following prototype:.CStypedef int Tcl_PackageInitProc(Tcl_Interp *\fIinterp\fR);.CEThe \fIinterp\fR argument identifies the interpreter in which thepackage is to be loaded. The initialization procedure must return\fBTCL_OK\fR or \fBTCL_ERROR\fR to indicate whether or not it completedsuccessfully; in the event of an error it should set \fIinterp->result\fRto point to an error message. The result of the \fBload\fR commandwill be the result returned by the initialization procedure..PPThe actual loading of a file will only be done once for each \fIfileName\fRin an application. If a given \fIfileName\fR is loaded into multipleinterpreters, then the first \fBload\fR will load the code andcall the initialization procedure; subsequent \fBload\fRs willcall the initialization procedure without loading the code again.It is not possible to unload or reload a package..PPThe \fBload\fR command also supports packages that are staticallylinked with the application, if those packages have been registeredby calling the \fBTcl_StaticPackage\fR procedure.If \fIfileName\fR is an empty string, then \fIpackageName\fR mustbe specified..PPIf \fIpackageName\fR is omitted or specified as an empty string,Tcl tries to guess the name of the package.This may be done differently on different platforms.The default guess, which is used on most UNIX platforms, is totake the last element of \fIfileName\fR, strip off the firstthree characters if they are \fBlib\fR, and use any following.VSalphabetic and underline characters as the module name..VEFor example, the command \fBload libxyz4.2.so\fR uses the modulename \fBxyz\fR and the command \fBload bin/last.so {}\fR uses themodule name \fBlast\fR..VS "" br.PPIf \fIfileName\fR is an empty string, then \fIpackageName\fR mustbe specified.The \fBload\fR command first searches for a statically loaded package(one that has been registered by calling the \fBTcl_StaticPackage\fRprocedure) by that name; if one is found, it is used.Otherwise, the \fBload\fR command searches for a dynamically loadedpackage by that name, and uses it if it is found. If severaldifferent files have been \fBload\fRed with different versions ofthe package, Tcl picks the file that was loaded first..VE.SH BUGS.PPIf the same file is \fBload\fRed by different \fIfileName\fRs, it willbe loaded into the process's address space multiple times. Thebehavior of this varies from system to system (some systems maydetect the redundant loads, others may not)..SH "SEE ALSO"\fBinfo sharedlibextension\fR, Tcl_StaticPackage, safe(n).SH KEYWORDSbinary code, loading, safe interpreter, shared library
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -