diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIOUtil.c | 44 | ||||
-rw-r--r-- | generic/tclInt.h | 13 | ||||
-rw-r--r-- | generic/tclLoadNone.c | 29 |
3 files changed, 71 insertions, 15 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 5b82f7e..c875292 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOUtil.c,v 1.55 2002/07/15 14:16:43 vincentdarley Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.56 2002/07/17 20:00:44 vincentdarley Exp $ */ #include "tclInt.h" @@ -2626,6 +2626,48 @@ Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, Tcl_SetErrno(ENOENT); return -1; } +/* + * This function used to be in the platform specific directories, but it + * has now been made to work cross-platform + */ +int +TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, + clientDataPtr, 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 + * file which will be passed back to + * (*unloadProcPtr)() to unload the file. */ + Tcl_FSUnloadFileProc **unloadProcPtr; + /* Filled with address of Tcl_FSUnloadFileProc + * function which should be used for + * this file. */ +{ + TclLoadHandle handle = NULL; + int res; + + res = TclpDlopen(interp, pathPtr, &handle, unloadProcPtr); + + if (res != TCL_OK) { + return res; + } + + if (handle == NULL) { + return TCL_ERROR; + } + + *clientDataPtr = (ClientData)handle; + + *proc1Ptr = TclpFindSymbol(interp, handle, sym1); + *proc2Ptr = TclpFindSymbol(interp, handle, sym2); + return TCL_OK; +} /* *--------------------------------------------------------------------------- diff --git a/generic/tclInt.h b/generic/tclInt.h index 3fca93b..ba9ebc3 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -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: tclInt.h,v 1.101 2002/07/17 10:36:23 msofer Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.102 2002/07/17 20:00:45 vincentdarley Exp $ */ #ifndef _TCLINT @@ -1563,7 +1563,8 @@ typedef struct TclFile_ *TclFile; * Opaque names for platform specific types. */ -typedef struct TclpTime_t_ *TclpTime_t; +typedef struct TclpTime_t_ *TclpTime_t; +typedef struct TclLoadHandle_ *TclLoadHandle; /* * The "globParameters" argument of the function TclGlob is an @@ -1829,8 +1830,14 @@ EXTERN void TclTransferResult _ANSI_ARGS_((Tcl_Interp *sourceInterp, int result, Tcl_Interp *targetInterp)); EXTERN Tcl_Obj* TclpNativeToNormalized _ANSI_ARGS_((ClientData clientData)); -EXTERN Tcl_Obj* TclpFilesystemPathType +EXTERN Tcl_Obj* TclpFilesystemPathType _ANSI_ARGS_((Tcl_Obj* pathObjPtr)); +EXTERN Tcl_PackageInitProc* TclpFindSymbol _ANSI_ARGS_((Tcl_Interp *interp, + TclLoadHandle loadHandle, CONST char *symbol)); +EXTERN int TclpDlopen _ANSI_ARGS_((Tcl_Interp *interp, + Tcl_Obj *pathPtr, + TclLoadHandle *loadHandle, + Tcl_FSUnloadFileProc **unloadProcPtr)); /* *---------------------------------------------------------------- diff --git a/generic/tclLoadNone.c b/generic/tclLoadNone.c index ee79130..9d93ba1 100644 --- a/generic/tclLoadNone.c +++ b/generic/tclLoadNone.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: tclLoadNone.c,v 1.8 2002/01/21 22:47:52 davygrvy Exp $ + * RCS: @(#) $Id: tclLoadNone.c,v 1.9 2002/07/17 20:00:46 vincentdarley Exp $ */ #include "tclInt.h" @@ -35,19 +35,17 @@ */ 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 - * TclpUnloadFile() to unload the file. */ - Tcl_FSUnloadFileProc **unloadProcPtr; + * (*unloadProcPtr)() to unload the file. */ + Tcl_FSUnloadFileProc **unloadProcPtr; + /* Filled with address of Tcl_FSUnloadFileProc + * function which should be used for + * this file. */ { Tcl_SetResult(interp, "dynamic loading is not currently available on this system", @@ -55,6 +53,15 @@ TclpLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr, unl return TCL_ERROR; } +Tcl_PackageInitProc* +TclpFindSymbol(interp, loadHandle, symbol) + Tcl_Interp *interp; + TclLoadHandle loadHandle; + CONST char *symbol; +{ + return NULL; +} + /* *---------------------------------------------------------------------- * |