Diff
Not logged in

Differences From Artifact [b9f1498f00]:

To Artifact [ef88c8bd4a]:


53
54
55
56
57
58
59

60
61
62
63

64
65
66
67
68
69
70
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72







+




+







instead of \fIpkg\fB_Init\fR.
The \fIpkg\fB_SafeInit\fR function should be written carefully, so that it
initializes the safe interpreter only with partial functionality provided
by the package that is safe for use by untrusted code. For more information
on Safe\-Tcl, see the \fBsafe\fR manual entry.
.PP
The initialization procedure must match the following prototype:
.PP
.CS
typedef int \fBTcl_PackageInitProc\fR(
        Tcl_Interp *\fIinterp\fR);
.CE
.PP
The \fIinterp\fR argument identifies the interpreter in which the
package is to be loaded.  The initialization procedure must return
\fBTCL_OK\fR or \fBTCL_ERROR\fR to indicate whether or not it completed
successfully;  in the event of an error it should set the interpreter's result
to point to an error message.  The result of the \fBload\fR command
will be the result returned by the initialization procedure.
.PP
115
116
117
118
119
120
121


122
123
124

125
126
127
128
129
130
131
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136







+
+



+







type
.QW "dumpbin -imports <dllname>"
in a DOS console to see what the library must import.
When loading a DLL in the current directory, Windows will ignore
.QW ./
as a path specifier and use a search heuristic to find the DLL instead.
To avoid this, load the DLL with:
.RS
.PP
.CS
\fBload\fR [file join [pwd] mylib.DLL]
.CE
.RE
.SH BUGS
.PP
If the same file is \fBload\fRed by different \fIfileName\fRs, it will
be loaded into the process's address space multiple times.  The
behavior of this varies from system to system (some systems may
detect the redundant loads, others may not).
.SH EXAMPLE
153
154
155
156
157
158
159
160
161
162
163
164
165






166
167
168
169
170
171
172

173
174




158
159
160
161
162
163
164






165
166
167
168
169
170
171
172
173
174
175
176

177
178

179
180
181
182







-
-
-
-
-
-
+
+
+
+
+
+






-
+

-
+
+
+
+
When built into a shared/dynamic library with a suitable name
(e.g. \fBfoo.dll\fR on Windows, \fBlibfoo.so\fR on Solaris and Linux)
it can then be loaded into Tcl with the following:
.PP
.CS
# Load the extension
switch $tcl_platform(platform) {
   windows {
      \fBload\fR [file join [pwd] foo.dll]
   }
   unix {
      \fBload\fR [file join [pwd] libfoo[info sharedlibextension]]
   }
    windows {
        \fBload\fR [file join [pwd] foo.dll]
    }
    unix {
        \fBload\fR [file join [pwd] libfoo[info sharedlibextension]]
    }
}

# Now execute the command defined by the extension
foo
.CE
.SH "SEE ALSO"
info sharedlibextension, Tcl_StaticPackage(3), safe(n)
info sharedlibextension, package(n), Tcl_StaticPackage(3), safe(n)
.SH KEYWORDS
binary code, loading, safe interpreter, shared library
binary code, dynamic library, load, safe interpreter, shared library
'\"Local Variables:
'\"mode: nroff
'\"End: