summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadDl.c
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2002-07-17 20:00:44 (GMT)
committervincentdarley <vincentdarley>2002-07-17 20:00:44 (GMT)
commit7074d76f2ba74ea9a53f47fb4815145982285625 (patch)
tree7bf708f2c17514ad40291886268bc3cf73d95ddc /unix/tclLoadDl.c
parent5625494c13f92f83294785e3691a89450f40c21a (diff)
downloadtcl-7074d76f2ba74ea9a53f47fb4815145982285625.zip
tcl-7074d76f2ba74ea9a53f47fb4815145982285625.tar.gz
tcl-7074d76f2ba74ea9a53f47fb4815145982285625.tar.bz2
load internals refactoring
Diffstat (limited to 'unix/tclLoadDl.c')
-rw-r--r--unix/tclLoadDl.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c
index 3578695..951a8cb 100644
--- a/unix/tclLoadDl.c
+++ b/unix/tclLoadDl.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDl.c,v 1.8 2002/01/09 19:09:28 kennykb Exp $
+ * RCS: @(#) $Id: tclLoadDl.c,v 1.9 2002/07/17 20:00:46 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -57,17 +57,11 @@
*/
int
-TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
- clientDataPtr, unloadProcPtr)
+TclpDlopen(interp, pathPtr, loadHandle, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
- * code. */
- CONST char *sym1, *sym2; /* Names of two procedures to look up in
- * the file's symbol table. */
- Tcl_PackageInitProc **proc1Ptr, **proc2Ptr;
- /* Where to return the addresses corresponding
- * to sym1 and sym2. */
- ClientData *clientDataPtr; /* Filled with token for dynamically loaded
+ * code (UTF-8). */
+ TclLoadHandle *loadHandle; /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr;
@@ -76,14 +70,11 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
* this file. */
{
VOID *handle;
- Tcl_DString newName, ds;
CONST char *native;
native = Tcl_FSGetNativePath(pathPtr);
handle = dlopen(native, RTLD_NOW | RTLD_GLOBAL); /* INTL: Native. */
- *clientDataPtr = (ClientData) handle;
-
if (handle == NULL) {
Tcl_AppendResult(interp, "couldn't load file \"",
Tcl_GetString(pathPtr),
@@ -92,40 +83,39 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
}
*unloadProcPtr = &TclpUnloadFile;
-
+ *loadHandle = (TclLoadHandle)handle;
+}
+
+Tcl_PackageInitProc*
+TclpFindSymbol(interp, loadHandle, symbol)
+ Tcl_Interp *interp;
+ TclLoadHandle loadHandle;
+ CONST char *symbol;
+{
+ CONST char *native;
+ Tcl_DString newName, ds;
+ VOID *handle = (VOID*)loadHandle;
+ Tcl_PackageInitProc *proc;
/*
* Some platforms still add an underscore to the beginning of symbol
* names. If we can't find a name without an underscore, try again
* with the underscore.
*/
- native = Tcl_UtfToExternalDString(NULL, sym1, -1, &ds);
- *proc1Ptr = (Tcl_PackageInitProc *) dlsym(handle, /* INTL: Native. */
+ native = Tcl_UtfToExternalDString(NULL, symbol, -1, &ds);
+ proc = (Tcl_PackageInitProc *) dlsym(handle, /* INTL: Native. */
native);
- if (*proc1Ptr == NULL) {
+ if (proc == NULL) {
Tcl_DStringInit(&newName);
Tcl_DStringAppend(&newName, "_", 1);
native = Tcl_DStringAppend(&newName, native, -1);
- *proc1Ptr = (Tcl_PackageInitProc *) dlsym(handle, /* INTL: Native. */
+ proc = (Tcl_PackageInitProc *) dlsym(handle, /* INTL: Native. */
native);
Tcl_DStringFree(&newName);
}
Tcl_DStringFree(&ds);
- native = Tcl_UtfToExternalDString(NULL, sym2, -1, &ds);
- *proc2Ptr = (Tcl_PackageInitProc *) dlsym(handle, /* INTL: Native. */
- native);
- if (*proc2Ptr == NULL) {
- Tcl_DStringInit(&newName);
- Tcl_DStringAppend(&newName, "_", 1);
- native = Tcl_DStringAppend(&newName, native, -1);
- *proc2Ptr = (Tcl_PackageInitProc *) dlsym(handle, /* INTL: Native. */
- native);
- Tcl_DStringFree(&newName);
- }
- Tcl_DStringFree(&ds);
-
- return TCL_OK;
+ return proc;
}
/*