summaryrefslogtreecommitdiffstats
path: root/generic/tclZipfs.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-07-10 05:51:56 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-07-10 05:51:56 (GMT)
commit2a3d586a796e62f522303b3ab71c84743a73bf89 (patch)
tree75ee68f89422b10ec42523bafa46fae061c6489d /generic/tclZipfs.c
parentd409a29e57b2d4ced1bad4b0bb5bb1e2387f4120 (diff)
parent6cf70a8d484881c9886d7d0cd5d2b9b6feac10fb (diff)
downloadtcl-2a3d586a796e62f522303b3ab71c84743a73bf89.zip
tcl-2a3d586a796e62f522303b3ab71c84743a73bf89.tar.gz
tcl-2a3d586a796e62f522303b3ab71c84743a73bf89.tar.bz2
Merge 8.7, and continue implementation. Almost done
Diffstat (limited to 'generic/tclZipfs.c')
-rw-r--r--generic/tclZipfs.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 6a568fe..983d62f 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -283,7 +283,7 @@ static struct {
* For password rotation.
*/
-static const char pwrot[16] =
+static const char pwrot[17] =
"\x00\x80\x40\xC0\x20\xA0\x60\xE0"
"\x10\x90\x50\xD0\x30\xB0\x70\xF0";
@@ -845,7 +845,7 @@ ZipFSLookup(
hPtr = Tcl_FindHashEntry(&ZipFS.fileHash, filename);
if (hPtr) {
- z = Tcl_GetHashValue(hPtr);
+ z = (ZipEntry *)Tcl_GetHashValue(hPtr);
}
return z;
}
@@ -933,7 +933,7 @@ ZipFSCloseArchive(
#else /* !_WIN32 */
if ((zf->data != MAP_FAILED) && !zf->ptrToFree) {
munmap(zf->data, zf->length);
- zf->data = MAP_FAILED;
+ zf->data = (unsigned char *)MAP_FAILED;
}
#endif /* _WIN32 */
@@ -1103,7 +1103,7 @@ ZipFSOpenArchive(
zf->data = NULL;
zf->mountHandle = INVALID_HANDLE_VALUE;
#else /* !_WIN32 */
- zf->data = MAP_FAILED;
+ zf->data = (unsigned char *)MAP_FAILED;
#endif /* _WIN32 */
zf->length = 0;
zf->numFiles = 0;
@@ -1132,7 +1132,7 @@ ZipFSOpenArchive(
ZIPFS_POSIX_ERROR(interp, "seek error");
goto error;
}
- zf->ptrToFree = zf->data = attemptckalloc(zf->length);
+ zf->ptrToFree = zf->data = (unsigned char *)attemptckalloc(zf->length);
if (!zf->ptrToFree) {
ZIPFS_ERROR(interp, "out of memory");
if (interp) {
@@ -1263,7 +1263,7 @@ ZipFSCatalogFilesystem(
hPtr = Tcl_CreateHashEntry(&ZipFS.zipHash, mountPoint, &isNew);
if (!isNew) {
if (interp) {
- zf = Tcl_GetHashValue(hPtr);
+ zf = (ZipFile *)Tcl_GetHashValue(hPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s is already mounted on %s", zf->name, mountPoint));
Tcl_SetErrorCode(interp, "TCL", "ZIPFS", "MOUNTED", NULL);
@@ -1272,7 +1272,7 @@ ZipFSCatalogFilesystem(
ZipFSCloseArchive(interp, zf0);
return TCL_ERROR;
}
- zf = attemptckalloc(sizeof(ZipFile) + strlen(mountPoint) + 1);
+ zf = (ZipFile *)attemptckalloc(sizeof(ZipFile) + strlen(mountPoint) + 1);
if (!zf) {
if (interp) {
Tcl_AppendResult(interp, "out of memory", (char *) NULL);
@@ -1285,11 +1285,11 @@ ZipFSCatalogFilesystem(
Unlock();
*zf = *zf0;
- zf->mountPoint = Tcl_GetHashKey(&ZipFS.zipHash, hPtr);
+ zf->mountPoint = (char *)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);
+ zf->name = (char *)ckalloc(zf->nameLength + 1);
memcpy(zf->name, zipname, zf->nameLength + 1);
zf->entries = NULL;
zf->topEnts = NULL;
@@ -1308,7 +1308,7 @@ ZipFSCatalogFilesystem(
if (mountPoint[0] != '\0') {
hPtr = Tcl_CreateHashEntry(&ZipFS.fileHash, mountPoint, &isNew);
if (isNew) {
- z = ckalloc(sizeof(ZipEntry));
+ z = (ZipEntry *)ckalloc(sizeof(ZipEntry));
Tcl_SetHashValue(hPtr, z);
z->tnext = NULL;
@@ -1322,7 +1322,7 @@ ZipFSCatalogFilesystem(
z->numBytes = z->numCompressedBytes = 0;
z->compressMethod = ZIP_COMPMETH_STORED;
z->data = NULL;
- z->name = Tcl_GetHashKey(&ZipFS.fileHash, hPtr);
+ z->name = (char *)Tcl_GetHashKey(&ZipFS.fileHash, hPtr);
z->next = zf->entries;
zf->entries = z;
}
@@ -1403,7 +1403,7 @@ ZipFSCatalogFilesystem(
}
Tcl_DStringSetLength(&fpBuf, 0);
fullpath = CanonicalPath(mountPoint, path, &fpBuf, 1);
- z = ckalloc(sizeof(ZipEntry));
+ z = (ZipEntry *)ckalloc(sizeof(ZipEntry));
z->name = NULL;
z->tnext = NULL;
z->depth = CountSlashes(fullpath);
@@ -1435,7 +1435,7 @@ ZipFSCatalogFilesystem(
ckfree(z);
} else {
Tcl_SetHashValue(hPtr, z);
- z->name = Tcl_GetHashKey(&ZipFS.fileHash, hPtr);
+ z->name = (char *)Tcl_GetHashKey(&ZipFS.fileHash, hPtr);
z->next = zf->entries;
zf->entries = z;
if (isdir && (mountPoint[0] == '\0') && (z->depth == 1)) {
@@ -1457,7 +1457,7 @@ ZipFSCatalogFilesystem(
if (!isNew) {
break;
}
- zd = ckalloc(sizeof(ZipEntry));
+ zd = (ZipEntry *)ckalloc(sizeof(ZipEntry));
zd->name = NULL;
zd->tnext = NULL;
zd->depth = CountSlashes(dir);
@@ -1471,7 +1471,7 @@ ZipFSCatalogFilesystem(
zd->compressMethod = ZIP_COMPMETH_STORED;
zd->data = NULL;
Tcl_SetHashValue(hPtr, zd);
- zd->name = Tcl_GetHashKey(&ZipFS.fileHash, hPtr);
+ zd->name = (char *)Tcl_GetHashKey(&ZipFS.fileHash, hPtr);
zd->next = zf->entries;
zf->entries = zd;
if ((mountPoint[0] == '\0') && (zd->depth == 1)) {
@@ -1557,7 +1557,7 @@ ListMountPoints(
if (!interp) {
return TCL_OK;
}
- zf = Tcl_GetHashValue(hPtr);
+ zf = (ZipFile *)Tcl_GetHashValue(hPtr);
Tcl_AppendElement(interp, zf->mountPoint);
Tcl_AppendElement(interp, zf->name);
}
@@ -1594,7 +1594,7 @@ DescribeMounted(
if (interp) {
hPtr = Tcl_FindHashEntry(&ZipFS.zipHash, mountPoint);
if (hPtr) {
- zf = Tcl_GetHashValue(hPtr);
+ zf = (ZipFile *)Tcl_GetHashValue(hPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(zf->name, -1));
return TCL_OK;
}
@@ -1671,7 +1671,7 @@ TclZipfs_Mount(
return TCL_ERROR;
}
}
- zf = attemptckalloc(sizeof(ZipFile) + strlen(mountPoint) + 1);
+ zf = (ZipFile *)attemptckalloc(sizeof(ZipFile) + strlen(mountPoint) + 1);
if (!zf) {
if (interp) {
Tcl_AppendResult(interp, "out of memory", (char *) NULL);
@@ -1752,7 +1752,7 @@ TclZipfs_MountBuffer(
* Have both a mount point and data to mount there.
*/
- zf = attemptckalloc(sizeof(ZipFile) + strlen(mountPoint) + 1);
+ zf = (ZipFile *)attemptckalloc(sizeof(ZipFile) + strlen(mountPoint) + 1);
if (!zf) {
if (interp) {
Tcl_AppendResult(interp, "out of memory", (char *) NULL);
@@ -1763,7 +1763,7 @@ TclZipfs_MountBuffer(
zf->isMemBuffer = 1;
zf->length = datalen;
if (copy) {
- zf->data = attemptckalloc(datalen);
+ zf->data = (unsigned char *)attemptckalloc(datalen);
if (!zf->data) {
if (interp) {
Tcl_AppendResult(interp, "out of memory", (char *) NULL);
@@ -1833,7 +1833,7 @@ TclZipfs_Unmount(
goto done;
}
- zf = Tcl_GetHashValue(hPtr);
+ zf = (ZipFile *)Tcl_GetHashValue(hPtr);
if (zf->numOpen > 0) {
ZIPFS_ERROR(interp, "filesystem is busy");
ret = TCL_ERROR;
@@ -2371,7 +2371,7 @@ ZipAddFile(
return TCL_ERROR;
}
- z = ckalloc(sizeof(ZipEntry));
+ z = (ZipEntry *)ckalloc(sizeof(ZipEntry));
Tcl_SetHashValue(hPtr, z);
z->name = NULL;
z->tnext = NULL;
@@ -2386,7 +2386,7 @@ ZipAddFile(
z->numCompressedBytes = nbytecompr;
z->compressMethod = compMeth;
z->data = NULL;
- z->name = Tcl_GetHashKey(fileHash, hPtr);
+ z->name = (char *)Tcl_GetHashKey(fileHash, hPtr);
z->next = NULL;
/*
@@ -2561,7 +2561,7 @@ ZipFSMkZipOrImgObjCmd(
WriteLock();
for (hPtr = Tcl_FirstHashEntry(&ZipFS.zipHash, &search); hPtr;
hPtr = Tcl_NextHashEntry(&search)) {
- zf = Tcl_GetHashValue(hPtr);
+ zf = (ZipFile *)Tcl_GetHashValue(hPtr);
if (strcmp(zf->name, imgName) == 0) {
isMounted = 1;
zf->numOpen++;
@@ -2722,7 +2722,7 @@ ZipFSMkZipOrImgObjCmd(
if (!hPtr) {
continue;
}
- z = Tcl_GetHashValue(hPtr);
+ z = (ZipEntry *)Tcl_GetHashValue(hPtr);
len = strlen(z->name);
ZipWriteInt(buf + ZIP_CENTRAL_SIG_OFFS, ZIP_CENTRAL_HEADER_SIG);
ZipWriteShort(buf + ZIP_CENTRAL_VERSIONMADE_OFFS, ZIP_MIN_VERSION);
@@ -2777,7 +2777,7 @@ ZipFSMkZipOrImgObjCmd(
Tcl_DecrRefCount(list);
for (hPtr = Tcl_FirstHashEntry(&fileHash, &search); hPtr;
hPtr = Tcl_NextHashEntry(&search)) {
- z = Tcl_GetHashValue(hPtr);
+ z = (ZipEntry *)Tcl_GetHashValue(hPtr);
ckfree(z);
Tcl_DeleteHashEntry(hPtr);
}
@@ -3117,7 +3117,7 @@ ZipFSListObjCmd(
if (pattern) {
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- ZipEntry *z = Tcl_GetHashValue(hPtr);
+ ZipEntry *z = (ZipEntry *)Tcl_GetHashValue(hPtr);
if (Tcl_StringMatch(z->name, pattern)) {
Tcl_ListObjAppendElement(interp, result,
@@ -3127,7 +3127,7 @@ ZipFSListObjCmd(
} else if (regexp) {
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr; hPtr = Tcl_NextHashEntry(&search)) {
- ZipEntry *z = Tcl_GetHashValue(hPtr);
+ ZipEntry *z = (ZipEntry *)Tcl_GetHashValue(hPtr);
if (Tcl_RegExpExec(interp, regexp, z->name, z->name)) {
Tcl_ListObjAppendElement(interp, result,
@@ -3137,7 +3137,7 @@ ZipFSListObjCmd(
} else {
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr; hPtr = Tcl_NextHashEntry(&search)) {
- ZipEntry *z = Tcl_GetHashValue(hPtr);
+ ZipEntry *z = (ZipEntry *)Tcl_GetHashValue(hPtr);
Tcl_ListObjAppendElement(interp, result,
Tcl_NewStringObj(z->name, -1));
@@ -3312,7 +3312,7 @@ ZipChannelClose(
void *instanceData,
Tcl_Interp *interp) /* Current interpreter. */
{
- ZipChannel *info = instanceData;
+ ZipChannel *info = (ZipChannel *)instanceData;
if (info->iscompr && info->ubuf) {
ckfree(info->ubuf);
@@ -3324,7 +3324,7 @@ ZipChannelClose(
}
if (info->isWriting) {
ZipEntry *z = info->zipEntryPtr;
- unsigned char *newdata = attemptckrealloc(info->ubuf, info->numRead);
+ unsigned char *newdata = (unsigned char *)attemptckrealloc(info->ubuf, info->numRead);
if (newdata) {
if (z->data) {
@@ -3675,7 +3675,7 @@ ZipChannelOpen(
} else {
flags = TCL_WRITABLE;
}
- info = attemptckalloc(sizeof(ZipChannel));
+ info = (ZipChannel *)attemptckalloc(sizeof(ZipChannel));
if (!info) {
ZIPFS_ERROR(interp, "out of memory");
if (interp) {
@@ -3693,7 +3693,7 @@ ZipChannelOpen(
info->maxWrite = ZipFS.wrmax;
info->iscompr = 0;
info->isEncrypted = 0;
- info->ubuf = attemptckalloc(info->maxWrite);
+ info->ubuf = (unsigned char *)attemptckalloc(info->maxWrite);
if (!info->ubuf) {
merror0:
if (info->ubuf) {
@@ -3751,7 +3751,7 @@ ZipChannelOpen(
unsigned int j;
stream.avail_in -= 12;
- cbuf = attemptckalloc(stream.avail_in);
+ cbuf = (unsigned char *)attemptckalloc(stream.avail_in);
if (!cbuf) {
goto merror0;
}
@@ -3851,7 +3851,7 @@ ZipChannelOpen(
stream.avail_in = z->numCompressedBytes;
if (info->isEncrypted) {
stream.avail_in -= 12;
- ubuf = attemptckalloc(stream.avail_in);
+ ubuf = (unsigned char *)attemptckalloc(stream.avail_in);
if (!ubuf) {
info->ubuf = NULL;
goto merror;
@@ -3864,7 +3864,7 @@ ZipChannelOpen(
} else {
stream.next_in = info->ubuf;
}
- stream.next_out = info->ubuf = attemptckalloc(info->numBytes);
+ stream.next_out = info->ubuf = (unsigned char *)attemptckalloc(info->numBytes);
if (!info->ubuf) {
merror:
if (ubuf) {
@@ -4225,7 +4225,7 @@ ZipFSMatchInDirectoryProc(
}
for (hPtr = Tcl_FirstHashEntry(&ZipFS.zipHash, &search); hPtr;
hPtr = Tcl_NextHashEntry(&search)) {
- ZipFile *zf = Tcl_GetHashValue(hPtr);
+ ZipFile *zf = (ZipFile *)Tcl_GetHashValue(hPtr);
if (zf->mountPointLen == 0) {
ZipEntry *z;
@@ -4276,7 +4276,7 @@ ZipFSMatchInDirectoryProc(
if (!pattern || (pattern[0] == '\0')) {
hPtr = Tcl_FindHashEntry(&ZipFS.fileHash, path);
if (hPtr) {
- ZipEntry *z = Tcl_GetHashValue(hPtr);
+ ZipEntry *z = (ZipEntry *)Tcl_GetHashValue(hPtr);
if ((dirOnly < 0) || (!dirOnly && !z->isDirectory)
|| (dirOnly && z->isDirectory)) {
@@ -4296,7 +4296,7 @@ ZipFSMatchInDirectoryProc(
}
l = strlen(pattern);
- pat = ckalloc(len + l + 2);
+ pat = (char *)ckalloc(len + l + 2);
memcpy(pat, path, len);
while ((len > 1) && (pat[len - 1] == '/')) {
--len;
@@ -4309,7 +4309,7 @@ ZipFSMatchInDirectoryProc(
scnt = CountSlashes(pat);
for (hPtr = Tcl_FirstHashEntry(&ZipFS.fileHash, &search);
hPtr; hPtr = Tcl_NextHashEntry(&search)) {
- ZipEntry *z = Tcl_GetHashValue(hPtr);
+ ZipEntry *z = (ZipEntry *)Tcl_GetHashValue(hPtr);
if ((dirOnly >= 0) && ((dirOnly && !z->isDirectory)
|| (!dirOnly && z->isDirectory))) {
@@ -4385,7 +4385,7 @@ ZipFSPathInFilesystemProc(
for (hPtr = Tcl_FirstHashEntry(&ZipFS.zipHash, &search); hPtr;
hPtr = Tcl_NextHashEntry(&search)) {
- ZipFile *zf = Tcl_GetHashValue(hPtr);
+ ZipFile *zf = (ZipFile *)Tcl_GetHashValue(hPtr);
if (zf->mountPointLen == 0) {
ZipEntry *z;