summaryrefslogtreecommitdiffstats
path: root/unix
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
parent5625494c13f92f83294785e3691a89450f40c21a (diff)
downloadtcl-7074d76f2ba74ea9a53f47fb4815145982285625.zip
tcl-7074d76f2ba74ea9a53f47fb4815145982285625.tar.gz
tcl-7074d76f2ba74ea9a53f47fb4815145982285625.tar.bz2
load internals refactoring
Diffstat (limited to 'unix')
-rw-r--r--unix/tclLoadAout.c33
-rw-r--r--unix/tclLoadDl.c54
-rw-r--r--unix/tclLoadDld.c29
-rw-r--r--unix/tclLoadDyld.c69
-rw-r--r--unix/tclLoadNext.c44
-rw-r--r--unix/tclLoadOSF.c33
-rw-r--r--unix/tclLoadShl.c53
7 files changed, 141 insertions, 174 deletions
diff --git a/unix/tclLoadAout.c b/unix/tclLoadAout.c
index afd956c..c4d6254 100644
--- a/unix/tclLoadAout.c
+++ b/unix/tclLoadAout.c
@@ -14,7 +14,7 @@
* and Design Engineering (MADE) Initiative through ARPA contract
* F33615-94-C-4400.
*
- * RCS: @(#) $Id: tclLoadAout.c,v 1.10 2002/02/15 14:28:50 dkf Exp $
+ * RCS: @(#) $Id: tclLoadAout.c,v 1.11 2002/07/17 20:00:46 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -141,17 +141,11 @@ static void UnlinkSymbolTable _ANSI_ARGS_((void));
*/
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 (UTF-8). */
- 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
+ TclLoadHandle *loadHandle; /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr;
@@ -172,12 +166,9 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
struct exec relocatedHead; /* Header of the relocated text */
unsigned long relocatedSize; /* Size of the relocated text */
char * startAddress; /* Starting address of the module */
- DictFn dictionary; /* Dictionary function in the load module */
int status; /* Status return from Tcl_ calls */
char * p;
- *clientDataPtr = NULL;
-
/* Find the file that contains the symbols for the run-time link. */
if (SymbolTableFile != NULL) {
@@ -317,15 +308,21 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
SymbolTableFile = ckalloc (strlen (relocatedFileName) + 1);
strcpy (SymbolTableFile, relocatedFileName);
- /* Look up the entry points in the load module's dictionary. */
-
- dictionary = (DictFn) startAddress;
- *proc1Ptr = dictionary (sym1);
- *proc2Ptr = dictionary (sym2);
-
+ *loadHandle = startAddress;
return TCL_OK;
}
+TclpFindSymbol(interp, loadHandle, symbol)
+ Tcl_Interp *interp;
+ TclLoadHandle loadHandle;
+ CONST char *symbol;
+{
+ /* Look up the entry point in the load module's dictionary. */
+ DictFn dictionary = (DictFn) loadHandle;
+ return (Tcl_PackageInitProc*) dictionary(sym1);
+}
+
+
/*
*------------------------------------------------------------------------
*
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;
}
/*
diff --git a/unix/tclLoadDld.c b/unix/tclLoadDld.c
index f1c1589..99fee26 100644
--- a/unix/tclLoadDld.c
+++ b/unix/tclLoadDld.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDld.c,v 1.8 2002/01/10 22:03:12 kennykb Exp $
+ * RCS: @(#) $Id: tclLoadDld.c,v 1.9 2002/07/17 20:00:46 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -49,17 +49,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;
@@ -73,7 +67,7 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
/*
* The dld package needs to know the pathname to the tcl binary.
- * If that's not know, return an error.
+ * If that's not known, return an error.
*/
if (firstTime) {
@@ -99,14 +93,21 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
"\": ", dld_strerror(returnCode), (char *) NULL);
return TCL_ERROR;
}
- *proc1Ptr = (Tcl_PackageInitProc *) dld_get_func(sym1);
- *proc2Ptr = (Tcl_PackageInitProc *) dld_get_func(sym2);
- *clientDataPtr = strcpy(
+ *loadHandle = strcpy(
(char *) ckalloc((unsigned) (strlen(fileName) + 1)), fileName);
*unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
+Tcl_PackageInitProc*
+TclpFindSymbol(interp, loadHandle, symbol)
+ Tcl_Interp *interp;
+ TclLoadHandle loadHandle;
+ CONST char *symbol;
+{
+ return (Tcl_PackageInitProc *) dld_get_func(symbol);
+}
+
/*
*----------------------------------------------------------------------
*
diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c
index 8541416..9eefd91 100644
--- a/unix/tclLoadDyld.c
+++ b/unix/tclLoadDyld.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDyld.c,v 1.8 2002/02/25 15:21:59 das Exp $
+ * RCS: @(#) $Id: tclLoadDyld.c,v 1.9 2002/07/17 20:00:46 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -40,17 +40,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;
@@ -58,9 +52,7 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
* function which should be used for
* this file. */
{
- NSSymbol symbol;
const struct mach_header *dyld_lib;
- Tcl_DString newName, ds;
char *native;
native = Tcl_FSGetNativePath(pathPtr);
@@ -75,46 +67,41 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
Tcl_AppendResult(interp, msg, (char *) NULL);
return TCL_ERROR;
}
-
+ *loadHandle = (TclLoadHandle)dyld_lib;
*unloadProcPtr = &TclpUnloadFile;
-
+ return TCL_OK;
+}
+
+Tcl_PackageInitProc*
+TclpFindSymbol(interp, loadHandle, symbol)
+ Tcl_Interp *interp;
+ TclLoadHandle loadHandle;
+ CONST char *symbol;
+{
+ NSSymbol nsSymbol;
+ CONST char *native;
+ Tcl_DString newName, ds;
+ Tcl_PackageInitProc* proc = NULL;
+ const struct mach_header *dyld_lib = (mach_header *)loadHandle;
/*
* dyld adds an underscore to the beginning of symbol names.
*/
- native = Tcl_UtfToExternalDString(NULL, sym1, -1, &ds);
+ native = Tcl_UtfToExternalDString(NULL, symbol, -1, &ds);
Tcl_DStringInit(&newName);
Tcl_DStringAppend(&newName, "_", 1);
native = Tcl_DStringAppend(&newName, native, -1);
- symbol = NSLookupSymbolInImage(dyld_lib, native,
- NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW |
- NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
- if(symbol) {
- *proc1Ptr = NSAddressOfSymbol(symbol);
- *clientDataPtr = NSModuleForSymbol(symbol);
- } else {
- *proc1Ptr=NULL;
- *clientDataPtr=NULL;
+ nsSymbol = NSLookupSymbolInImage(dyld_lib, native,
+ NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW |
+ NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ if(nsSymbol) {
+ proc = NSAddressOfSymbol(nsSymbol);
+ /* *clientDataPtr = NSModuleForSymbol(nsSymbol); */
}
Tcl_DStringFree(&newName);
Tcl_DStringFree(&ds);
-
- native = Tcl_UtfToExternalDString(NULL, sym2, -1, &ds);
- Tcl_DStringInit(&newName);
- Tcl_DStringAppend(&newName, "_", 1);
- native = Tcl_DStringAppend(&newName, native, -1);
- symbol = NSLookupSymbolInImage(dyld_lib, native,
- NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW |
- NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
- if(symbol) {
- *proc2Ptr = NSAddressOfSymbol(symbol);
- } else {
- *proc2Ptr=NULL;
- }
- Tcl_DStringFree(&newName);
- Tcl_DStringFree(&ds);
-
- return TCL_OK;
+
+ return proc;
}
/*
diff --git a/unix/tclLoadNext.c b/unix/tclLoadNext.c
index d19b22e..cb09d38 100644
--- a/unix/tclLoadNext.c
+++ b/unix/tclLoadNext.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: tclLoadNext.c,v 1.7 2002/01/09 19:09:28 kennykb Exp $
+ * RCS: @(#) $Id: tclLoadNext.c,v 1.8 2002/07/17 20:00:46 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -39,17 +39,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;
@@ -72,25 +66,27 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
}
NXCloseMemory(errorStream,NX_FREEBUFFER);
- *proc1Ptr=NULL;
- if(sym1) {
- char sym[strlen(sym1)+2];
- sym[0]='_'; sym[1]=0; strcat(sym,sym1);
- rld_lookup(NULL,sym,(unsigned long *)proc1Ptr);
- }
-
- *proc2Ptr=NULL;
- if(sym2) {
- char sym[strlen(sym2)+2];
- sym[0]='_'; sym[1]=0; strcat(sym,sym2);
- rld_lookup(NULL,sym,(unsigned long *)proc2Ptr);
- }
- *clientDataPtr = NULL;
+ *loadHandle = (TclLoadHandle)1; /* A dummy non-NULL value */
*unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
+Tcl_PackageInitProc*
+TclpFindSymbol(interp, loadHandle, symbol)
+ Tcl_Interp *interp;
+ TclLoadHandle loadHandle;
+ CONST char *symbol;
+{
+ Tcl_PackageInitProc *proc=NULL;
+ if(symbol) {
+ char sym[strlen(symbol)+2];
+ sym[0]='_'; sym[1]=0; strcat(sym,symbol);
+ rld_lookup(NULL,sym,(unsigned long *)&proc);
+ }
+ return proc;
+}
+
/*
*----------------------------------------------------------------------
*
diff --git a/unix/tclLoadOSF.c b/unix/tclLoadOSF.c
index 76c0c7c..8740feb 100644
--- a/unix/tclLoadOSF.c
+++ b/unix/tclLoadOSF.c
@@ -31,7 +31,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadOSF.c,v 1.7 2002/01/09 19:09:28 kennykb Exp $
+ * RCS: @(#) $Id: tclLoadOSF.c,v 1.8 2002/07/17 20:00:46 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -60,17 +60,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;
@@ -99,16 +93,25 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
* I build loadable modules with a makefile rule like
* ld ... -export $@: -o $@ $(OBJS)
*/
- if ((pkg = strrchr(fileName, '/')) == NULL)
- pkg = fileName;
- else
+ if ((pkg = strrchr(fileName, '/')) == NULL) {
+ pkg = fileName;
+ } else {
pkg++;
- *proc1Ptr = ldr_lookup_package(pkg, sym1);
- *proc2Ptr = ldr_lookup_package(pkg, sym2);
+ }
+ *loadHandle = pkg;
*unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
+Tcl_PackageInitProc*
+TclpFindSymbol(interp, loadHandle, symbol)
+ Tcl_Interp *interp;
+ TclLoadHandle loadHandle;
+ CONST char *symbol;
+{
+ return ldr_lookup_package((char *)loadHandle, symbol);
+}
+
/*
*----------------------------------------------------------------------
*
diff --git a/unix/tclLoadShl.c b/unix/tclLoadShl.c
index cb222bb..14e5b2d 100644
--- a/unix/tclLoadShl.c
+++ b/unix/tclLoadShl.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: tclLoadShl.c,v 1.9 2002/01/09 19:09:28 kennykb Exp $
+ * RCS: @(#) $Id: tclLoadShl.c,v 1.10 2002/07/17 20:00:46 vincentdarley Exp $
*/
#include <dl.h>
@@ -47,17 +47,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;
@@ -66,7 +60,6 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
* this file. */
{
shl_t handle;
- Tcl_DString newName;
char *fileName = Tcl_GetString(pathPtr);
/*
@@ -87,38 +80,38 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
"\": ", Tcl_PosixError(interp), (char *) NULL);
return TCL_ERROR;
}
- *clientDataPtr = (ClientData) handle;
-
+ *loadHandle = (TclLoadHandle) handle;
+ *unloadProcPtr = &TclpUnloadFile;
+ return TCL_OK;
+}
+
+Tcl_PackageInitProc*
+TclpFindSymbol(interp, loadHandle, symbol)
+ Tcl_Interp *interp;
+ TclLoadHandle loadHandle;
+ CONST char *symbol;
+{
+ Tcl_DString newName;
+ Tcl_PackageInitProc *proc=NULL;
+ shl_t handle = (shl_t)loadHandle;
/*
* Some versions of the HP system software still use "_" at the
* beginning of exported symbols while others don't; try both
* forms of each name.
*/
- if (shl_findsym(&handle, sym1, (short) TYPE_PROCEDURE, (void *) proc1Ptr)
+ if (shl_findsym(&handle, symbol, (short) TYPE_PROCEDURE, (void *) &proc)
!= 0) {
Tcl_DStringInit(&newName);
Tcl_DStringAppend(&newName, "_", 1);
- Tcl_DStringAppend(&newName, sym1, -1);
+ Tcl_DStringAppend(&newName, symbol, -1);
if (shl_findsym(&handle, Tcl_DStringValue(&newName),
- (short) TYPE_PROCEDURE, (void *) proc1Ptr) != 0) {
- *proc1Ptr = NULL;
+ (short) TYPE_PROCEDURE, (void *) &proc) != 0) {
+ proc = NULL;
}
Tcl_DStringFree(&newName);
}
- if (shl_findsym(&handle, sym2, (short) TYPE_PROCEDURE, (void *) proc2Ptr)
- != 0) {
- Tcl_DStringInit(&newName);
- Tcl_DStringAppend(&newName, "_", 1);
- Tcl_DStringAppend(&newName, sym2, -1);
- if (shl_findsym(&handle, Tcl_DStringValue(&newName),
- (short) TYPE_PROCEDURE, (void *) proc2Ptr) != 0) {
- *proc2Ptr = NULL;
- }
- Tcl_DStringFree(&newName);
- }
- *unloadProcPtr = &TclpUnloadFile;
- return TCL_OK;
+ return proc;
}
/*