summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2019-05-01 13:52:26 (GMT)
committerdgp <dgp@users.sourceforge.net>2019-05-01 13:52:26 (GMT)
commitd1faa9b2b18b2357320288e318922ba2522289e6 (patch)
tree3557f8551e42629b73d42a6762fd7398c48143b3 /generic
parentb3676ba87cb737e7954dd8c6ad6515ae6a872674 (diff)
downloadtcl-d1faa9b2b18b2357320288e318922ba2522289e6.zip
tcl-d1faa9b2b18b2357320288e318922ba2522289e6.tar.gz
tcl-d1faa9b2b18b2357320288e318922ba2522289e6.tar.bz2
now testing....
Diffstat (limited to 'generic')
-rw-r--r--generic/tclZipfs.c44
1 files changed, 5 insertions, 39 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 0fd65a4..340aa91 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -997,7 +997,6 @@ ZipFSFindTOC(
if (interp) {
Tcl_SetErrorCode(interp, "TCL", "ZIPFS", "END_SIG", NULL);
}
-fprintf(stdout, "TOC FAIL 1\n"); fflush(stdout);
goto error;
}
zf->numFiles = ZipReadShort(p + ZIP_CENTRAL_ENTS_OFFS);
@@ -1010,7 +1009,6 @@ fprintf(stdout, "TOC FAIL 1\n"); fflush(stdout);
if (interp) {
Tcl_SetErrorCode(interp, "TCL", "ZIPFS", "EMPTY", NULL);
}
-fprintf(stdout, "TOC FAIL 2\n"); fflush(stdout);
goto error;
}
q = zf->data + ZipReadInt(p + ZIP_CENTRAL_DIRSTART_OFFS);
@@ -1025,7 +1023,6 @@ fprintf(stdout, "TOC FAIL 2\n"); fflush(stdout);
if (interp) {
Tcl_SetErrorCode(interp, "TCL", "ZIPFS", "NO_DIR", NULL);
}
-fprintf(stdout, "TOC FAIL 3\n"); fflush(stdout);
goto error;
}
zf->baseOffset = zf->passOffset = p - q;
@@ -1039,7 +1036,6 @@ fprintf(stdout, "TOC FAIL 3\n"); fflush(stdout);
if (interp) {
Tcl_SetErrorCode(interp, "TCL", "ZIPFS", "HDR_LEN", NULL);
}
-fprintf(stdout, "TOC FAIL 4\n"); fflush(stdout);
goto error;
}
if (ZipReadInt(q) != ZIP_CENTRAL_HEADER_SIG) {
@@ -1047,7 +1043,6 @@ fprintf(stdout, "TOC FAIL 4\n"); fflush(stdout);
if (interp) {
Tcl_SetErrorCode(interp, "TCL", "ZIPFS", "HDR_SIG", NULL);
}
-fprintf(stdout, "TOC FAIL 5\n"); fflush(stdout);
goto error;
}
pathlen = ZipReadShort(q + ZIP_CENTRAL_PATHLEN_OFFS);
@@ -1118,7 +1113,6 @@ ZipFSOpenArchive(
zf->passBuf[0] = 0;
zf->chan = Tcl_OpenFileChannel(interp, zipname, "rb", 0);
if (!zf->chan) {
-fprintf(stdout, "OA FAIL 1\n"); fflush(stdout);
return TCL_ERROR;
}
if (Tcl_GetChannelHandle(zf->chan, TCL_READABLE, &handle) != TCL_OK) {
@@ -1195,12 +1189,10 @@ fprintf(stdout, "OA FAIL 1\n"); fflush(stdout);
}
#endif /* _WIN32 */
}
-fprintf(stdout, "OA END\n"); fflush(stdout);
return ZipFSFindTOC(interp, needZip, zf);
error:
ZipFSCloseArchive(interp, zf);
-fprintf(stdout, "OA FAIL 2\n"); fflush(stdout);
return TCL_ERROR;
}
@@ -1295,6 +1287,7 @@ ZipFSCatalogFilesystem(
*zf = *zf0;
zf->mountPoint = Tcl_GetHashKey(&ZipFS.zipHash, hPtr);
+ Tcl_CreateExitHandler(ZipfsExitHandler, (ClientData)zf);
zf->mountPointLen = strlen(zf->mountPoint);
zf->nameLength = strlen(zipname);
zf->name = ckalloc(zf->nameLength + 1);
@@ -1638,8 +1631,6 @@ TclZipfs_Mount(
{
ZipFile *zf;
-fprintf(stdout, "MOUNT CALLED\n"); fflush(stdout);
-
ReadLock();
if (!ZipFS.initialized) {
ZipfsSetup();
@@ -1682,28 +1673,23 @@ fprintf(stdout, "MOUNT CALLED\n"); fflush(stdout);
}
}
zf = attemptckalloc(sizeof(ZipFile) + strlen(mountPoint) + 1);
-fprintf(stdout, "ALLOC %p\n", zf); fflush(stdout);
if (!zf) {
if (interp) {
Tcl_AppendResult(interp, "out of memory", (char *) NULL);
Tcl_SetErrorCode(interp, "TCL", "MALLOC", NULL);
}
-fprintf(stdout, "MOUNT FAIL A\n"); fflush(stdout);
return TCL_ERROR;
}
if (ZipFSOpenArchive(interp, zipname, 1, zf) != TCL_OK) {
-fprintf(stdout, "MOUNT FAIL B\n"); fflush(stdout);
ckfree(zf);
return TCL_ERROR;
}
if (ZipFSCatalogFilesystem(interp, zf, mountPoint, passwd, zipname)
!= TCL_OK) {
-fprintf(stdout, "MOUNT FAIL C\n"); fflush(stdout);
ckfree(zf);
return TCL_ERROR;
}
-fprintf(stdout, "MOUNT END\n"); fflush(stdout);
- Tcl_CreateExitHandler(ZipfsExitHandler, (ClientData)mountPoint);
+ ckfree(zf);
return TCL_OK;
}
@@ -1829,11 +1815,8 @@ TclZipfs_Unmount(
Tcl_DString dsm;
int ret = TCL_OK, unmounted = 0;
-fprintf(stdout, "UNMOUNT CALLED\n"); fflush(stdout);
WriteLock();
-fprintf(stdout, "A\n"); fflush(stdout);
if (!ZipFS.initialized) {
-fprintf(stdout, "NOT INIT\n"); fflush(stdout);
goto done;
}
@@ -1842,24 +1825,19 @@ fprintf(stdout, "NOT INIT\n"); fflush(stdout);
* But an absolute name is needed as mount point here.
*/
-fprintf(stdout, "B\n"); fflush(stdout);
Tcl_DStringInit(&dsm);
mountPoint = CanonicalPath("", mountPoint, &dsm, 1);
-fprintf(stdout, "C\n"); fflush(stdout);
hPtr = Tcl_FindHashEntry(&ZipFS.zipHash, mountPoint);
/* don't report no-such-mount as an error */
if (!hPtr) {
-fprintf(stdout, "D\n"); fflush(stdout);
goto done;
}
-fprintf(stdout, "E\n"); fflush(stdout);
zf = Tcl_GetHashValue(hPtr);
if (zf->numOpen > 0) {
ZIPFS_ERROR(interp, "filesystem is busy");
ret = TCL_ERROR;
-fprintf(stdout, "BUSY\n"); fflush(stdout);
goto done;
}
Tcl_DeleteHashEntry(hPtr);
@@ -1875,7 +1853,7 @@ fprintf(stdout, "BUSY\n"); fflush(stdout);
ckfree(z);
}
ZipFSCloseArchive(interp, zf);
-fprintf(stdout, "FREE %p\n", zf); fflush(stdout);
+ Tcl_DeleteExitHandler(ZipfsExitHandler, (ClientData)zf);
ckfree(zf);
unmounted = 1;
done:
@@ -4873,10 +4851,9 @@ static void
ZipfsExitHandler(
ClientData clientData)
{
- char *mountpoint = (char *)clientData;
+ ZipFile *zf = (ZipFile *)clientData;
-fprintf(stdout, "UNMOUNT\n"); fflush(stdout);
- if (TCL_OK != TclZipfs_Unmount(NULL, mountpoint)) {
+ if (TCL_OK != TclZipfs_Unmount(NULL, zf->mountPoint)) {
Tcl_Panic("tried to unmount busy filesystem");
}
}
@@ -4903,27 +4880,19 @@ TclZipfs_AppHook(
{
char *archive;
-fprintf(stdout, "HOOK CALLED\n"); fflush(stdout);
Tcl_FindExecutable((*argvPtr)[0]);
-fprintf(stdout, "FOUND\n"); fflush(stdout);
archive = (char *) Tcl_GetNameOfExecutable();
-fprintf(stdout, "NAME: '%s'\n", archive); fflush(stdout);
TclZipfs_Init(NULL);
-fprintf(stdout, "INIT\n"); fflush(stdout);
/*
* Look for init.tcl in one of the locations mounted later in this
* function.
*/
-fprintf(stdout, "START\n"); fflush(stdout);
if (!TclZipfs_Mount(NULL, ZIPFS_APP_MOUNT, archive, NULL)) {
int found;
Tcl_Obj *vfsInitScript;
-fprintf(stdout, "MOUNTED\n"); fflush(stdout);
-
-// Tcl_CreateExitHandler(ZipfsExitHandler, (ClientData)ZIPFS_APP_MOUNT);
TclNewLiteralStringObj(vfsInitScript, ZIPFS_APP_MOUNT "/main.tcl");
Tcl_IncrRefCount(vfsInitScript);
@@ -4986,8 +4955,6 @@ fprintf(stdout, "MOUNTED\n"); fflush(stdout);
int found;
Tcl_Obj *vfsInitScript;
-// Tcl_CreateExitHandler(ZipfsExitHandler, (ClientData)ZIPFS_APP_MOUNT);
-
TclNewLiteralStringObj(vfsInitScript, ZIPFS_APP_MOUNT "/main.tcl");
Tcl_IncrRefCount(vfsInitScript);
if (Tcl_FSAccess(vfsInitScript, F_OK) == 0) {
@@ -5015,7 +4982,6 @@ fprintf(stdout, "MOUNTED\n"); fflush(stdout);
#endif /* _WIN32 */
#endif /* SUPPORT_BUILTIN_ZIP_INSTALL */
}
-fprintf(stdout, "END\n"); fflush(stdout);
return TCL_OK;
}