diff options
author | hypnotoad <yoda@etoyoc.com> | 2017-09-25 16:23:56 (GMT) |
---|---|---|
committer | hypnotoad <yoda@etoyoc.com> | 2017-09-25 16:23:56 (GMT) |
commit | da869353bd4824d69fa3756a5336f08db6b7e997 (patch) | |
tree | fbf974444e657477f32f2d0b74772f8c13dd70ab | |
parent | cd7269ab4485bfd59094b17245b3ab9c943c6ff2 (diff) | |
download | tcl-core_zip_vfs.zip tcl-core_zip_vfs.tar.gz tcl-core_zip_vfs.tar.bz2 |
Improvements to Tip#430 based on community input. Added a forward declaration of TclZipfs_Init. Added TclZipfs_Mount() and TclZifs_Unmount to stubs table.core_zip_vfs
-rw-r--r-- | generic/tcl.decls | 9 | ||||
-rw-r--r-- | generic/tclBasic.c | 2 | ||||
-rw-r--r-- | generic/tclDecls.h | 13 | ||||
-rw-r--r-- | generic/tclInt.h | 4 | ||||
-rw-r--r-- | generic/tclStubInit.c | 2 | ||||
-rw-r--r-- | generic/tclZipfs.c | 62 | ||||
-rw-r--r-- | generic/tclZipfs.h | 8 |
7 files changed, 63 insertions, 37 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls index b2b91a9..c19bf68 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -2335,7 +2335,14 @@ declare 631 { # ----- BASELINE -- FOR -- 8.7.0 ----- # - +# TIP #430 +declare 632 { + int TclZipfs_Mount(Tcl_Interp *interp, const char *zipname, const char *mntpt, + const char *passwd) +} +declare 633 { + int TclZipfs_Unmount(Tcl_Interp *interp, const char *zipname) +} ############################################################################## diff --git a/generic/tclBasic.c b/generic/tclBasic.c index f798a3d..3e6ad56 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -990,7 +990,7 @@ Tcl_CreateInterp(void) if (TclZlibInit(interp) != TCL_OK) { Tcl_Panic("%s", TclGetString(Tcl_GetObjResult(interp))); } - if (TclZipfsInit(interp) != TCL_OK) { + if (TclZipfs_Init(interp) != TCL_OK) { Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp))); } #endif diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 464fc0f..24a22c3 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -1831,6 +1831,13 @@ EXTERN Tcl_Channel Tcl_OpenTcpServerEx(Tcl_Interp *interp, unsigned int flags, Tcl_TcpAcceptProc *acceptProc, ClientData callbackData); +/* 632 */ +EXTERN int TclZipfs_Mount(Tcl_Interp *interp, + const char *zipname, const char *mntpt, + const char *passwd); +/* 633 */ +EXTERN int TclZipfs_Unmount(Tcl_Interp *interp, + const char *zipname); typedef struct { const struct TclPlatStubs *tclPlatStubs; @@ -2498,6 +2505,8 @@ typedef struct TclStubs { int (*tcl_FSUnloadFile) (Tcl_Interp *interp, Tcl_LoadHandle handlePtr); /* 629 */ void (*tcl_ZlibStreamSetCompressionDictionary) (Tcl_ZlibStream zhandle, Tcl_Obj *compressionDictionaryObj); /* 630 */ Tcl_Channel (*tcl_OpenTcpServerEx) (Tcl_Interp *interp, const char *service, const char *host, unsigned int flags, Tcl_TcpAcceptProc *acceptProc, ClientData callbackData); /* 631 */ + int (*tclZipfs_Mount) (Tcl_Interp *interp, const char *zipname, const char *mntpt, const char *passwd); /* 632 */ + int (*tclZipfs_Unmount) (Tcl_Interp *interp, const char *zipname); /* 633 */ } TclStubs; extern const TclStubs *tclStubsPtr; @@ -3792,6 +3801,10 @@ extern const TclStubs *tclStubsPtr; (tclStubsPtr->tcl_ZlibStreamSetCompressionDictionary) /* 630 */ #define Tcl_OpenTcpServerEx \ (tclStubsPtr->tcl_OpenTcpServerEx) /* 631 */ +#define TclZipfs_Mount \ + (tclStubsPtr->tclZipfs_Mount) /* 632 */ +#define TclZipfs_Unmount \ + (tclStubsPtr->tclZipfs_Unmount) /* 633 */ #endif /* defined(USE_TCL_STUBS) */ diff --git a/generic/tclInt.h b/generic/tclInt.h index be93f16..8339fb1 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3215,6 +3215,10 @@ MODULE_SCOPE void TclpThreadSetMasterTSD(void *tsdKeyPtr, void *ptr); MODULE_SCOPE void * TclpThreadGetMasterTSD(void *tsdKeyPtr); MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, const char *msg, int length); +/* Tip 430 */ +MODULE_SCOPE int TclZipfs_Init(Tcl_Interp *interp); +MODULE_SCOPE int TclZipfs_SafeInit(Tcl_Interp *interp); + /* *---------------------------------------------------------------- diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index ebd2086..f251a57 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -1536,6 +1536,8 @@ const TclStubs tclStubs = { Tcl_FSUnloadFile, /* 629 */ Tcl_ZlibStreamSetCompressionDictionary, /* 630 */ Tcl_OpenTcpServerEx, /* 631 */ + TclZipfs_Mount, /* 632 */ + TclZipfs_Unmount, /* 633 */ }; /* !END!: Do not edit above this line. */ diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 01d46c6..9d74890 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -505,19 +505,19 @@ CanonicalPath(const char *root, const char *tail, Tcl_DString *dsPtr,int ZIPFSPA int i, j, c, isunc = 0, isvfs=0, n=0; #if HAS_DRIVES int zipfspath=1; - if ((tail[0] != '\0') && (strchr(drvletters, tail[0]) != NULL) && - (tail[1] == ':')) { + if ((tail[0] != '\0') && (strchr(drvletters, tail[0]) != NULL) && + (tail[1] == ':')) { tail += 2; zipfspath=0; - } - /* UNC style path */ - if (tail[0] == '\\') { - root = ""; + } + /* UNC style path */ + if (tail[0] == '\\') { + root = ""; ++tail; zipfspath=0; - } - if (tail[0] == '\\') { - root = "/"; + } + if (tail[0] == '\\') { + root = "/"; ++tail; zipfspath=0; } @@ -571,7 +571,7 @@ CanonicalPath(const char *root, const char *tail, Tcl_DString *dsPtr,int ZIPFSPA } else if(isvfs==2) { Tcl_DStringSetLength(dsPtr, j); path = Tcl_DStringValue(dsPtr); - memcpy(path, tail, j); + memcpy(path, tail, j); } else { if (ZIPFSPATH) { Tcl_DStringSetLength(dsPtr, i + j + ZIPFS_VOLUME_LEN); @@ -586,12 +586,12 @@ CanonicalPath(const char *root, const char *tail, Tcl_DString *dsPtr,int ZIPFSPA memcpy(path + i, tail, j); } } -#if HAS_DRIVES - for (i = 0; path[i] != '\0'; i++) { - if (path[i] == '\\') { - path[i] = '/'; +#if HAS_DRIVES + for (i = 0; path[i] != '\0'; i++) { + if (path[i] == '\\') { + path[i] = '/'; } - } + } #endif if(ZIPFSPATH) { n=ZIPFS_VOLUME_LEN; @@ -706,7 +706,7 @@ static ZipEntry * ZipFSLookup(char *filename) { char *realname; - + Tcl_HashEntry *hPtr; ZipEntry *z; Tcl_DString ds; @@ -1030,7 +1030,7 @@ error: /* *------------------------------------------------------------------------- * - * TclZipfsMount -- + * TclZipfs_Mount -- * * This procedure is invoked to mount a given ZIP archive file on * a given mountpoint with optional ZIP password. @@ -1046,7 +1046,7 @@ error: */ int -TclZipfsMount(Tcl_Interp *interp, const char *zipname, const char *mntpt, +TclZipfs_Mount(Tcl_Interp *interp, const char *zipname, const char *mntpt, const char *passwd) { char *realname, *p; @@ -1379,7 +1379,7 @@ nextent: /* *------------------------------------------------------------------------- * - * TclZipfsUnmount -- + * TclZipfs_Unmount -- * * This procedure is invoked to unmount a given ZIP archive. * @@ -1393,7 +1393,7 @@ nextent: */ int -TclZipfsUnmount(Tcl_Interp *interp, const char *zipname) +TclZipfs_Unmount(Tcl_Interp *interp, const char *zipname) { char *realname; ZipFile *zf; @@ -1471,7 +1471,7 @@ ZipFSMountObjCmd(ClientData clientData, Tcl_Interp *interp, "?zipfile? ?mountpoint? ?password?"); return TCL_ERROR; } - return TclZipfsMount(interp, (objc > 1) ? Tcl_GetString(objv[1]) : NULL, + return TclZipfs_Mount(interp, (objc > 1) ? Tcl_GetString(objv[1]) : NULL, (objc > 2) ? Tcl_GetString(objv[2]) : NULL, (objc > 3) ? Tcl_GetString(objv[3]) : NULL); } @@ -1500,7 +1500,7 @@ ZipFSUnmountObjCmd(ClientData clientData, Tcl_Interp *interp, Tcl_WrongNumArgs(interp, 1, objv, "zipfile"); return TCL_ERROR; } - return TclZipfsUnmount(interp, Tcl_GetString(objv[1])); + return TclZipfs_Unmount(interp, Tcl_GetString(objv[1])); } /* @@ -2271,7 +2271,7 @@ ZipFSCanonicalObjCmd(ClientData clientData, Tcl_Interp *interp, } mntpoint = Tcl_GetString(objv[1]); filename = Tcl_GetString(objv[2]); - result=CanonicalPath(mntpoint,filename,&dPath,zipfs); + result=CanonicalPath(mntpoint,filename,&dPath,zipfs); } Tcl_SetObjResult(interp,Tcl_NewStringObj(result,-1)); return TCL_OK; @@ -3430,7 +3430,7 @@ Zip_FSPathInFilesystemProc(Tcl_Obj *pathPtr, ClientData *clientDataPtr) if(strncmp(path,ZIPFS_VOLUME,ZIPFS_VOLUME_LEN)!=0) { return -1; } - + Tcl_DStringInit(&ds); path = CanonicalPath("",path, &ds, 1); len = Tcl_DStringLength(&ds); @@ -3793,7 +3793,7 @@ const Tcl_Filesystem zipfsFilesystem = { /* *------------------------------------------------------------------------- * - * TclZipfsInit -- + * TclZipfs_Init -- * * Perform per interpreter initialization of this module. * @@ -3808,7 +3808,7 @@ const Tcl_Filesystem zipfsFilesystem = { */ int -TclZipfsInit(Tcl_Interp *interp) +TclZipfs_Init(Tcl_Interp *interp) { #ifdef HAVE_ZLIB /* one-time initialization */ @@ -3884,7 +3884,7 @@ TclZipfsInit(Tcl_Interp *interp) /* *------------------------------------------------------------------------- * - * TclZipfsMount, TclZipfsUnmount -- + * TclZipfs_Mount, TclZipfs_Unmount -- * * Dummy version when no ZLIB support available. * @@ -3892,16 +3892,16 @@ TclZipfsInit(Tcl_Interp *interp) */ int -TclZipfsMount(Tcl_Interp *interp, const char *zipname, const char *mntpt, +TclZipfs_Mount(Tcl_Interp *interp, const char *zipname, const char *mntpt, const char *passwd) { - return TclZipFsInit(interp, 1); + return TclZipfs_Init(interp, 1); } int -TclZipfsUnmount(Tcl_Interp *interp, const char *zipname) +TclZipfs_Unmount(Tcl_Interp *interp, const char *zipname) { - return TclZipFsInit(interp, 1); + return TclZipfs_Init(interp, 1); } #endif diff --git a/generic/tclZipfs.h b/generic/tclZipfs.h index 01c9e96..f7da3bd 100644 --- a/generic/tclZipfs.h +++ b/generic/tclZipfs.h @@ -27,11 +27,11 @@ extern "C" { # define ZIPFSAPI DLLEXPORT #endif -ZIPFSAPI int Tclzipfs_Mount(Tcl_Interp *interp, const char *zipname, +ZIPFSAPI int TclZipfs_Mount(Tcl_Interp *interp, const char *zipname, const char *mntpt, const char *passwd); -ZIPFSAPI int Tclzipfs_Unmount(Tcl_Interp *interp, const char *zipname); -ZIPFSAPI int Tclzipfs_Init(Tcl_Interp *interp); -ZIPFSAPI int Tclzipfs_SafeInit(Tcl_Interp *interp); +ZIPFSAPI int TclZipfs_Unmount(Tcl_Interp *interp, const char *zipname); +ZIPFSAPI int TclZipfs_Init(Tcl_Interp *interp); +ZIPFSAPI int TclZipfs_SafeInit(Tcl_Interp *interp); #ifdef __cplusplus } |