1Tcl_StaticPackage(3) Tcl Library Procedures Tcl_StaticPackage(3)
2
3
4
5______________________________________________________________________________
6
8 Tcl_StaticPackage - make a statically linked package available via the
9 'load' command
10
12 #include <tcl.h>
13
14 Tcl_StaticPackage(interp, prefix, initProc, safeInitProc)
15
17 Tcl_Interp *interp (in) If not NULL, points to
18 an interpreter into
19 which the package has
20 already been loaded
21 (i.e., the caller has
22 already invoked the ap‐
23 propriate initializa‐
24 tion procedure). NULL
25 means the package has
26 not yet been incorpo‐
27 rated into any inter‐
28 preter.
29
30 const char *prefix (in) Prefix for library ini‐
31 tialization function;
32 should be properly cap‐
33 italized (first letter
34 upper-case, all others
35 lower-case).
36
37 Tcl_PackageInitProc *initProc (in) Procedure to invoke to
38 incorporate this pack‐
39 age into a trusted in‐
40 terpreter.
41
42 Tcl_PackageInitProc *safeInitProc (in) Procedure to call to
43 incorporate this pack‐
44 age into a safe inter‐
45 preter (one that will
46 execute untrusted
47 scripts). NULL means
48 the package cannot be
49 used in safe inter‐
50 preters.
51______________________________________________________________________________
52
54 This procedure may be invoked to announce that a package has been
55 linked statically with a Tcl application and, optionally, that it has
56 already been loaded into an interpreter. Once Tcl_StaticPackage has
57 been invoked for a package, it may be loaded into interpreters using
58 the load command. Tcl_StaticPackage is normally invoked only by the
59 Tcl_AppInit procedure for the application, not by packages for them‐
60 selves (Tcl_StaticPackage should only be invoked for statically loaded
61 packages, and code in the package itself should not need to know
62 whether the package is dynamically or statically loaded).
63
64 When the load command is used later to load the package into an inter‐
65 preter, one of initProc and safeInitProc will be invoked, depending on
66 whether the target interpreter is safe or not. initProc and safeInit‐
67 Proc must both match the following prototype:
68
69 typedef int Tcl_PackageInitProc(
70 Tcl_Interp *interp);
71
72 The interp argument identifies the interpreter in which the package is
73 to be loaded. The initialization procedure must return TCL_OK or
74 TCL_ERROR to indicate whether or not it completed successfully; in the
75 event of an error it should set the interpreter's result to point to an
76 error message. The result or error from the initialization procedure
77 will be returned as the result of the load command that caused the ini‐
78 tialization procedure to be invoked.
79
81 initialization procedure, package, static linking
82
84 load(n), package(n), Tcl_PkgRequire(3)
85
86
87
88Tcl 7.5 Tcl_StaticPackage(3)