Compare commits
160
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8729900f69 | ||
|
|
93fe453205 | ||
|
|
215b5dd08d | ||
|
|
1d768f7890 | ||
|
|
80206cc113 | ||
|
|
f851263f52 | ||
|
|
3ddad4402a | ||
|
|
42259830ab | ||
|
|
8f2cdcfe32 | ||
|
|
3e94587dff | ||
|
|
8270c03fac | ||
|
|
0420e8dd91 | ||
|
|
c433e9b60a | ||
|
|
a64be34c0b | ||
|
|
310ee501e8 | ||
|
|
0104227d89 | ||
|
|
43778c199d | ||
|
|
d7023c5bf4 | ||
|
|
d1f1107ccd | ||
|
|
202ffed8ed | ||
|
|
4e74fe9243 | ||
|
|
fe6c8e39c5 | ||
|
|
39394a7c8c | ||
|
|
db323b6992 | ||
|
|
f803ae2b11 | ||
|
|
174f55c044 | ||
|
|
a270140a3e | ||
|
|
841c04fbac | ||
|
|
232349c3de | ||
|
|
fb2b7d4615 | ||
|
|
b645469c95 | ||
|
|
e295641767 | ||
|
|
c3a18ac8f4 | ||
|
|
f9dda45e97 | ||
|
|
a5c310f993 | ||
|
|
80d9aa777b | ||
|
|
c745f44e3a | ||
|
|
21d4596064 | ||
|
|
5f738db586 | ||
|
|
76bb4d1ea4 | ||
|
|
4db368d595 | ||
|
|
e9e40f5f02 | ||
|
|
c3c935369d | ||
|
|
bd1370959e | ||
|
|
9a7f1bd48c | ||
|
|
47cb19c83f | ||
|
|
f4cc5617a6 | ||
|
|
e48602d674 | ||
|
|
e9a8c42972 | ||
|
|
5bcc7fa342 | ||
|
|
b0c45c3ad0 | ||
|
|
e1e49c9dd1 | ||
|
|
18ba46bf37 | ||
|
|
5b719a2281 | ||
|
|
edbf30e23a | ||
|
|
395d0889b0 | ||
|
|
ba0d107038 | ||
|
|
763f9dff55 | ||
|
|
bbcef5b648 | ||
|
|
25d1f4aa03 | ||
|
|
22f5c55560 | ||
|
|
3cf33e9e9f | ||
|
|
a288c5e54a | ||
|
|
c3e9d3205f | ||
|
|
227fbec0fc | ||
|
|
dc21089720 | ||
|
|
f6bb864fc7 | ||
|
|
982211da16 | ||
|
|
a1740d9766 | ||
|
|
e9795fb407 | ||
|
|
299924e512 | ||
|
|
a03e74efc1 | ||
|
|
3c03a492f9 | ||
|
|
56c5833c4a | ||
|
|
63b07461da | ||
|
|
1c3288f038 | ||
|
|
8ecd6aeb5b | ||
|
|
4d00715902 | ||
|
|
95aeb2a3d6 | ||
|
|
b0a98f480d | ||
|
|
cb73551e8d | ||
|
|
4d946107e7 | ||
|
|
c795f44ea5 | ||
|
|
ecd9567624 | ||
|
|
d6fdfa4624 | ||
|
|
58ace2b1dc | ||
|
|
8f6089f225 | ||
|
|
19627fed47 | ||
|
|
83145e2bb1 | ||
|
|
621c76324a | ||
|
|
e961e1c08a | ||
|
|
e740674cb8 | ||
|
|
23ced66a6b | ||
|
|
b637222a5d | ||
|
|
9a0f7dd2c8 | ||
|
|
440e5fc7dc | ||
|
|
74ed7238b0 | ||
|
|
38d734ddcf | ||
|
|
cbeed9da92 | ||
|
|
a369d46795 | ||
|
|
4594b4f27a | ||
|
|
ff3f0131bd | ||
|
|
5b793fef99 | ||
|
|
13aa1642ac | ||
|
|
d905cc4737 | ||
|
|
d954f3c4ee | ||
|
|
c770024ce1 | ||
|
|
c1f95640c4 | ||
|
|
48ef2b50eb | ||
|
|
071aa09c6e | ||
|
|
10cd3c906d | ||
|
|
0fca37f803 | ||
|
|
9dd94f7396 | ||
|
|
ce65c7b396 | ||
|
|
a80a084de9 | ||
|
|
ddc625f2fe | ||
|
|
842b15b839 | ||
|
|
4506b4536b | ||
|
|
dbe627594e | ||
|
|
130fe11f2b | ||
|
|
3bce1ab6f2 | ||
|
|
fe773c0a46 | ||
|
|
ecc90e3787 | ||
|
|
6e0d4b6761 | ||
|
|
53ad2ab17d | ||
|
|
a2a59dfb75 | ||
|
|
829af34165 | ||
|
|
1579eae899 | ||
|
|
6fcdce9c74 | ||
|
|
ac785323be | ||
|
|
d68207f7ca | ||
|
|
ddc615491d | ||
|
|
b1031c0d07 | ||
|
|
83da0d6374 | ||
|
|
e886aae69e | ||
|
|
adceea62b6 | ||
|
|
348f13ad57 | ||
|
|
dd60d52814 | ||
|
|
428c3163c5 | ||
|
|
410178bb88 | ||
|
|
18eed1d727 | ||
|
|
ce72e40607 | ||
|
|
f038b7fc3d | ||
|
|
30dbc0a75b | ||
|
|
57d33c5027 | ||
|
|
e1c5526cb2 | ||
|
|
290c2ef84f | ||
|
|
073618d375 | ||
|
|
5ddf03d324 | ||
|
|
ac98be85ce | ||
|
|
048fae9de6 | ||
|
|
81735df1fa | ||
|
|
9c32ab0d8b | ||
|
|
861e75f503 | ||
|
|
e891120584 | ||
|
|
2045bb3c21 | ||
|
|
a498488c59 | ||
|
|
dd43ee3dbf | ||
|
|
39ad9eb8f3 | ||
|
|
b30ba5a92b |
Executable → Regular
+61
@@ -0,0 +1,61 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2015 Jan Nijtmans <jan.nijtmans@gmail.com>
|
||||
'\" Copyright (c) 2015 Christian Werner <chw@ch-werner.de>
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH Tclzipfs 3 8.7 Tcl "Tcl Library Procedures"
|
||||
.so man.macros
|
||||
.BS
|
||||
.SH NAME
|
||||
Tclzipfs_Init, Tclzipfs_SafeInit, Tclzipfs_Mount, Tclzipfs_Unmount \- handle ZIP files as VFS
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fB#include <tclZipfs.h>\fR
|
||||
.sp
|
||||
int
|
||||
\fBTclzipfs_Init\fR(\fIinterp\fR)
|
||||
.sp
|
||||
int
|
||||
\fBTclzipfs_SafeInit\fR(\fIinterp\fR)
|
||||
.sp
|
||||
int
|
||||
\fBTclzipfs_Mount\fR(\fIinterp, zipname, mntpt, passwd\fR)
|
||||
.sp
|
||||
int
|
||||
\fBTclzipfs_Unmount\fR(\fIinterp, zipname\fR)
|
||||
.SH ARGUMENTS
|
||||
.AS Tcl_Interp **termPtr
|
||||
.AP Tcl_Interp *interp in
|
||||
Interpreter in which the zip file system is mounted. The interpreter's result is
|
||||
modified to hold the result or error message from the script.
|
||||
.AP "const char" *zipname in
|
||||
Name of a zipfile.
|
||||
.AP "const char" *mntpt in
|
||||
Name of a mount point.
|
||||
.AP "const char" *passwd in
|
||||
An (optional) password.
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
\fBTclzipfs_Init()\fR performs one-time initialization of the file system
|
||||
and registers it process wide. Additionally, a package named \fIzipfs\fR
|
||||
is provided and supplemental Tcl commands are created in the given
|
||||
interpreter \fIinterp\fR.
|
||||
.PP
|
||||
\fBTclzipfs_SafeInit()\fR is the version of \fBTclzipfs_Init()\fR for
|
||||
safe interpreters. It exposes only uncritical supplemental Tcl commands
|
||||
in the given interpreter \fIinterp\fR.
|
||||
.PP
|
||||
\fBTclzipfs_Mount()\fR mount the ZIP archive \fIzipname\fR on the mount
|
||||
point given in \fImntpt\fR using the optional ZIP password \fIpasswd\fR.
|
||||
Errors during that process are reported in the interpreter \fIinterp\fR.
|
||||
If \fIzipname\fR is a NULL pointer, information on all currently mounted
|
||||
ZIP file systems is written into \fIinterp\fR's result as a sequence of
|
||||
mount points and ZIP file names.
|
||||
.PP
|
||||
\fBTclzipfs_Unmount()\fR undoes the effect of \fBTclzipfs_Mount()\fR,
|
||||
i.e. it unmounts the mounted ZIP archive file \fIzipname\fR. Errors are
|
||||
reported in the interpreter \fIinterp\fR.
|
||||
.SH KEYWORDS
|
||||
compress, filesystem, zip
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
'\"
|
||||
'\" Copyright (c) 2015 Jan Nijtmans <jan.nijtmans@gmail.com>
|
||||
'\" Copyright (c) 2015 Christian Werner <chw@ch-werner.de>
|
||||
'\"
|
||||
'\" See the file "license.terms" for information on usage and redistribution
|
||||
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
'\"
|
||||
.TH zipfs n 1.0 Zipfs "zipfs Commands"
|
||||
.so man.macros
|
||||
.BS
|
||||
'\" Note: do not modify the .SH NAME line immediately below!
|
||||
.SH NAME
|
||||
zipfs \- Mount and work with ZIP files within Tcl
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
\fBpackage require zipfs \fR?\fB1.0\fR?
|
||||
.sp
|
||||
\fBzipfs exists\fR \fIfilename\fR
|
||||
\fBzipfs find\fR \fIdir\fR
|
||||
\fBzipfs info\fR \fIfilename\fR
|
||||
\fBzipfs list\fR \fB?(-glob|-regexp)?\fR \fI?pattern?\fR
|
||||
\fBzipfs mkimg\fR \fIoutfile\fR \fIindir\fR \fI?strip?\fR \fI?password?\fR \fI?infile?\fR
|
||||
\fBzipfs mkkey\fR \fIpassword\fR
|
||||
\fBzipfs mkzip\fR \fIoutfile\fR \fIindir\fR \fI?strip?\fR \fI?password?\fR
|
||||
\fBzipfs mount\fR \fI?zipfile?\fR \fI?mountpoint?\fR \fI?password?\fR
|
||||
\fBzipfs unmount\fR \fIzipfile\fR
|
||||
.fi
|
||||
.BE
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The \fBzipfs\fR package provides tcl with the ability to mount
|
||||
the contents of a zip file as a virtual file system.
|
||||
.TP
|
||||
\fBzipfs exists\fR \fIfilename\fR
|
||||
.
|
||||
Return 1 if the given filename exists in the mounted zipfs and 0 if it does not.
|
||||
.TP
|
||||
\fBzipfs find\fR \fIdir\fR
|
||||
.
|
||||
Recursively lists files including and below the directory \fIdir\fR.
|
||||
The result list consists of relative path names starting from the
|
||||
given directory. This command is also used by the \fBzipfs mkzip\fR
|
||||
and \fBzipfs mkimg\fR commands.
|
||||
.TP
|
||||
\fBzipfs info\fR \fIfile\fR
|
||||
.
|
||||
Return information about the given file in the mounted zipfs. The information
|
||||
consists of (1) the name of the ZIP archive file that contains the file,
|
||||
(2) the size of the file after decompressions, (3) the compressed size of
|
||||
the file, and (4) the offset of the compressed data in the ZIP archive file.
|
||||
.RS
|
||||
.PP
|
||||
Note: querying the mount point gives the start of zip data offset in (4),
|
||||
which can be used to truncate the zip info off an executable.
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs list\fR \fB?(-glob|-regexp)?\fR \fI?pattern?\fR
|
||||
.
|
||||
Return a list of all files in the mounted zipfs. The order of the names
|
||||
in the list is arbitrary.
|
||||
.TP
|
||||
\fBzipfs mkimg\fR \fIoutfile\fR \fIindir\fR \fI?strip?\fR \fI?password?\fR \fI?infile?\fR
|
||||
.
|
||||
Creates an image (potentially a new executable file) similar to
|
||||
\fBzipfs mkzip\fR. If the \fIinfile\fR parameter is specified,
|
||||
this file is prepended in front of the ZIP archive, otherwise the file
|
||||
returned by \fBTcl_NameOfExecutable(3)\fR (i.e. the executable file of
|
||||
the running process) is used. If the \fIpassword\fR parameter is not empty,
|
||||
an obfuscated version of that password is placed between the image and ZIP
|
||||
chunks of the output file and the contents of the ZIP chunk are protected
|
||||
with that password.
|
||||
.RS
|
||||
.PP
|
||||
Caution: highly experimental, not usable on Android, only partially tested
|
||||
on Linux and Windows.
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs mkkey\fR \fIpassword\fR
|
||||
.
|
||||
For the clear text \fIpassword\fR argument an obfuscated string version
|
||||
is returned with the same format used in the \fBzipfs mkimg\fR command.
|
||||
.TP
|
||||
\fBzipfs mkzip\fR \fIoutfile\fR \fIindir\fR \fI?strip?\fR \fI?password?\fR
|
||||
.
|
||||
Creates a ZIP archive file named \fIoutfile\fR from the contents of the input
|
||||
directory \fIindir\fR (contained regular files only) with optional ZIP
|
||||
password \fIpassword\fR. While processing the files below \fIindir\fR the
|
||||
optional file name prefix given in \fIstrip\fR is stripped off the beginning
|
||||
of the respective file name.
|
||||
.RS
|
||||
.PP
|
||||
Caution: the choice of the \fIindir\fR parameter
|
||||
(less the optional stripped prefix) determines the later root name of the
|
||||
archive's content.
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs mount ?\fIzipfile\fR? ?\fImountpoint\fR? ?\fIpassword\fR?
|
||||
.
|
||||
The \fBzipfs mount\fR command mounts a ZIP archive file as a VFS.
|
||||
After this command executes, files contained in \fIzipfile\fR
|
||||
will appear to Tcl to be regular files at the mount point.
|
||||
.RS
|
||||
.PP
|
||||
With no \fImountpoint\fR, returns the mount point for \fIzipfile\fR.
|
||||
With no \fIzipfile\fR, return all zipfile/mount point pairs.
|
||||
If \fImountpoint\fR is specified as an empty string, the mount point
|
||||
will be the current directory. If \fIpassword\fR is specified, files from
|
||||
\fIzipfile\fR are decrypted using this password when read.
|
||||
.RE
|
||||
.TP
|
||||
\fBzipfs unmount \fIzipfile\fR
|
||||
.
|
||||
Unmounts a previously mounted ZIP archive file \fIzipfile\fR.
|
||||
.SH "SEE ALSO"
|
||||
tclsh(1), file(n), zlib(n)
|
||||
.SH "KEYWORDS"
|
||||
compress, filesystem, zip
|
||||
'\" Local Variables:
|
||||
'\" mode: nroff
|
||||
'\" End:
|
||||
@@ -189,6 +189,8 @@ const Tcl_Filesystem tclNativeFilesystem = {
|
||||
TclpObjChdir
|
||||
};
|
||||
|
||||
MODULE_SCOPE Tcl_Filesystem zipfsFilesystem;
|
||||
|
||||
/*
|
||||
* Define the tail of the linked list. Note that for unconventional uses of
|
||||
* Tcl without a native filesystem, we may in the future wish to modify the
|
||||
@@ -1408,6 +1410,22 @@ TclFSNormalizeToUniquePath(
|
||||
|
||||
Claim();
|
||||
for (fsRecPtr=firstFsRecPtr; fsRecPtr!=NULL; fsRecPtr=fsRecPtr->nextPtr) {
|
||||
if (fsRecPtr->fsPtr == &zipfsFilesystem) {
|
||||
ClientData clientData = NULL;
|
||||
/*
|
||||
* Allow mounted zipfs filesystem to overtake entire normalisation.
|
||||
* This is needed on unix for mounts on symlinks right below root.
|
||||
*/
|
||||
|
||||
if (fsRecPtr->fsPtr->pathInFilesystemProc != NULL) {
|
||||
if (fsRecPtr->fsPtr->pathInFilesystemProc(pathPtr,
|
||||
&clientData)!=-1) {
|
||||
TclFSSetPathDetails(pathPtr, fsRecPtr->fsPtr, clientData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (fsRecPtr->fsPtr != &tclNativeFilesystem) {
|
||||
continue;
|
||||
}
|
||||
@@ -1432,6 +1450,9 @@ TclFSNormalizeToUniquePath(
|
||||
if (fsRecPtr->fsPtr == &tclNativeFilesystem) {
|
||||
continue;
|
||||
}
|
||||
if (fsRecPtr->fsPtr == &zipfsFilesystem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fsRecPtr->fsPtr->normalizePathProc != NULL) {
|
||||
startAt = fsRecPtr->fsPtr->normalizePathProc(interp, pathPtr,
|
||||
@@ -2912,6 +2933,19 @@ Tcl_FSChdir(
|
||||
}
|
||||
|
||||
fsPtr = Tcl_FSGetFileSystemForPath(pathPtr);
|
||||
|
||||
if ((fsPtr != NULL) && (fsPtr != &tclNativeFilesystem)) {
|
||||
/*
|
||||
* Watch out for tilde substitution.
|
||||
* Only valid in native filesystem.
|
||||
*/
|
||||
char *name = Tcl_GetString(pathPtr);
|
||||
|
||||
if ((name != NULL) && (*name == '~')) {
|
||||
fsPtr = &tclNativeFilesystem;
|
||||
}
|
||||
}
|
||||
|
||||
if (fsPtr != NULL) {
|
||||
if (fsPtr->chdirProc != NULL) {
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* tclZipfs.h --
|
||||
*
|
||||
* This header file describes the interface of the ZIPFS filesystem
|
||||
*
|
||||
* Copyright (c) 2013-2015 Christian Werner <chw@ch-werner.de>
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution of
|
||||
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
*/
|
||||
|
||||
#ifndef _ZIPFS_H
|
||||
#define _ZIPFS_H
|
||||
|
||||
#include "tcl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef ZIPFSAPI
|
||||
# define ZIPFSAPI extern
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_tcl
|
||||
# undef ZIPFSAPI
|
||||
# define ZIPFSAPI DLLEXPORT
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ZIPFS_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 4
|
||||
* fill-column: 78
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,131 @@
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
The encryption/decryption parts of this source code (as opposed to the
|
||||
non-echoing password parts) were originally written in Europe. The
|
||||
whole source package can be freely distributed, including from the USA.
|
||||
(Prior to January 2000, re-export from the US was a violation of US law.)
|
||||
|
||||
This encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||
version without encryption capabilities).
|
||||
|
||||
If you don't need crypting in your application, just define symbols
|
||||
NOCRYPT and NOUNCRYPT.
|
||||
|
||||
This code support the "Traditional PKWARE Encryption".
|
||||
|
||||
The new AES encryption added on Zip format by Winzip (see the page
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const unsigned int* pcrc_32_tab)
|
||||
{
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int update_keys(unsigned long* pkeys,const unsigned int* pcrc_32_tab,int c)
|
||||
{
|
||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
||||
{
|
||||
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
||||
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned int* pcrc_32_tab)
|
||||
{
|
||||
*(pkeys+0) = 305419896L;
|
||||
*(pkeys+1) = 591751049L;
|
||||
*(pkeys+2) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
#define zdecode(pkeys,pcrc_32_tab,c) \
|
||||
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
||||
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
||||
|
||||
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
||||
|
||||
#define RAND_HEAD_LEN 12
|
||||
/* "last resort" source for second part of crypt seed pattern */
|
||||
# ifndef ZCR_SEED2
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static int crypthead(const char* passwd, /* password string */
|
||||
unsigned char* buf, /* where to write header */
|
||||
int bufSize,
|
||||
unsigned long* pkeys,
|
||||
const unsigned int* pcrc_32_tab,
|
||||
unsigned long crcForCrypting)
|
||||
{
|
||||
int n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
int c; /* random byte */
|
||||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
||||
static unsigned calls = 0; /* ensure different random header each time */
|
||||
|
||||
if (bufSize<RAND_HEAD_LEN)
|
||||
return 0;
|
||||
|
||||
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
||||
* output of rand() to get less predictability, since rand() is
|
||||
* often poorly implemented.
|
||||
*/
|
||||
if (++calls == 1)
|
||||
{
|
||||
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
||||
}
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
c = (rand() >> 7) & 0xff;
|
||||
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
||||
}
|
||||
/* Encrypt random header (last two bytes is high word of crc) */
|
||||
init_keys(passwd, pkeys, pcrc_32_tab);
|
||||
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
||||
{
|
||||
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||
}
|
||||
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
||||
+3437
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
||||
# The file tests the tclZlib.c file.
|
||||
#
|
||||
# This file contains a collection of tests for one or more of the Tcl built-in
|
||||
# commands. Sourcing this file into Tcl runs the tests and generates output
|
||||
# for errors. No output means no errors were found.
|
||||
#
|
||||
# Copyright (c) 1996-1998 by Sun Microsystems, Inc.
|
||||
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
||||
#
|
||||
# See the file "license.terms" for information on usage and redistribution of
|
||||
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
|
||||
if {"::tcltest" ni [namespace children]} {
|
||||
package require tcltest 2.1
|
||||
namespace import -force ::tcltest::*
|
||||
}
|
||||
|
||||
testConstraint zipfs [expr {[llength [info commands zlib]] && [regexp tcltest [info nameofexecutable]]}]
|
||||
|
||||
test zipfs-1.1 {zipfs basics} -constraints zipfs -body {
|
||||
load {} zipfs
|
||||
} -result {}
|
||||
|
||||
test zipfs-1.2 {zipfs basics} -constraints zipfs -body {
|
||||
package require zipfs
|
||||
} -result {1.0}
|
||||
|
||||
test zipfs-1.3 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs mount a b c d e f
|
||||
} -result {wrong # args: should be "zipfs mount ?zipfile? ?mountpoint? ?password?"}
|
||||
|
||||
test zipfs-1.4 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs unmount a b c d e f
|
||||
} -result {wrong # args: should be "zipfs unmount zipfile"}
|
||||
|
||||
test zipfs-1.5 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs mkkey a b c d e f
|
||||
} -result {wrong # args: should be "zipfs mkkey password"}
|
||||
|
||||
test zipfs-1.6 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs mkimg a b c d e f
|
||||
} -result {wrong # args: should be "zipfs mkimg outfile indir ?strip? ?password? ?infile?"}
|
||||
|
||||
test zipfs-1.7 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs mkzip a b c d e f
|
||||
} -result {wrong # args: should be "zipfs mkzip outfile indir ?strip? ?password?"}
|
||||
|
||||
test zipfs-1.8 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs exists a b c d e f
|
||||
} -result {wrong # args: should be "zipfs exists filename"}
|
||||
|
||||
test zipfs-1.9 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs info a b c d e f
|
||||
} -result {wrong # args: should be "zipfs info filename"}
|
||||
|
||||
test zipfs-1.10 {zipfs basics} -constraints zipfs -returnCodes error -body {
|
||||
zipfs list a b c d e f
|
||||
} -result {wrong # args: should be "zipfs list ?(-glob|-regexp)? ?pattern?"}
|
||||
|
||||
|
||||
test zipfs-2.1 {zipfs mkzip empty archive} -constraints zipfs -returnCodes error -body {
|
||||
zipfs mkzip abc.zip [file join [file normalize $tcl_library] xxxx]
|
||||
} -result {empty archive}
|
||||
|
||||
test zipfs-2.2 {zipfs mkzip} -constraints zipfs -body {
|
||||
set pwd [pwd]
|
||||
cd [file join [file normalize $tcl_library] encoding]
|
||||
zipfs mkzip abc.zip .
|
||||
zipfs mount abc.zip /abc
|
||||
zipfs list -glob /abc/cp850.*
|
||||
} -cleanup {
|
||||
cd $pwd
|
||||
} -result {/abc/cp850.enc}
|
||||
|
||||
test zipfs-2.3 {zipfs unmount} -constraints zipfs -body {
|
||||
lrange [zipfs info /abc/cp850.enc] 0 2
|
||||
} -result [list \
|
||||
[file join [file normalize $tcl_library] encoding abc.zip] 1090 527]
|
||||
|
||||
test zipfs-2.4 {zipfs unmount} -constraints zipfs -body {
|
||||
set f [open /abc/cp850.enc]
|
||||
read $f
|
||||
} -result {# Encoding file: cp850, single-byte
|
||||
S
|
||||
003F 0 1
|
||||
00
|
||||
0000000100020003000400050006000700080009000A000B000C000D000E000F
|
||||
0010001100120013001400150016001700180019001A001B001C001D001E001F
|
||||
0020002100220023002400250026002700280029002A002B002C002D002E002F
|
||||
0030003100320033003400350036003700380039003A003B003C003D003E003F
|
||||
0040004100420043004400450046004700480049004A004B004C004D004E004F
|
||||
0050005100520053005400550056005700580059005A005B005C005D005E005F
|
||||
0060006100620063006400650066006700680069006A006B006C006D006E006F
|
||||
0070007100720073007400750076007700780079007A007B007C007D007E007F
|
||||
00C700FC00E900E200E400E000E500E700EA00EB00E800EF00EE00EC00C400C5
|
||||
00C900E600C600F400F600F200FB00F900FF00D600DC00F800A300D800D70192
|
||||
00E100ED00F300FA00F100D100AA00BA00BF00AE00AC00BD00BC00A100AB00BB
|
||||
2591259225932502252400C100C200C000A9256325512557255D00A200A52510
|
||||
25142534252C251C2500253C00E300C3255A25542569256625602550256C00A4
|
||||
00F000D000CA00CB00C8013100CD00CE00CF2518250C2588258400A600CC2580
|
||||
00D300DF00D400D200F500D500B500FE00DE00DA00DB00D900FD00DD00AF00B4
|
||||
00AD00B1201700BE00B600A700F700B800B000A800B700B900B300B225A000A0
|
||||
}
|
||||
|
||||
test zipfs-2.5 {zipfs exists} -constraints zipfs -body {
|
||||
zipfs unmount abc.zip
|
||||
zipfs exists /abc/cp850.enc
|
||||
} -cleanup {
|
||||
file delete abc.zip
|
||||
} -result 1
|
||||
|
||||
::tcltest::cleanupTests
|
||||
return
|
||||
|
||||
# Local Variables:
|
||||
# mode: tcl
|
||||
# End:
|
||||
+8
-2
@@ -310,7 +310,7 @@ GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
|
||||
tclStrToD.o tclThread.o \
|
||||
tclThreadAlloc.o tclThreadJoin.o tclThreadStorage.o tclStubInit.o \
|
||||
tclTimer.o tclTrace.o tclUtf.o tclUtil.o tclVar.o tclZlib.o \
|
||||
tclTomMathInterface.o
|
||||
tclTomMathInterface.o zipfs.o
|
||||
|
||||
OO_OBJS = tclOO.o tclOOBasic.o tclOOCall.o tclOODefineCmds.o tclOOInfo.o \
|
||||
tclOOMethod.o tclOOStubInit.o
|
||||
@@ -375,6 +375,7 @@ GENERIC_HDRS = \
|
||||
$(GENERIC_DIR)/tclInt.h \
|
||||
$(GENERIC_DIR)/tclIntDecls.h \
|
||||
$(GENERIC_DIR)/tclIntPlatDecls.h \
|
||||
$(GENERIC_DIR)/tclZipfs.h \
|
||||
$(GENERIC_DIR)/tclTomMath.h \
|
||||
$(GENERIC_DIR)/tclTomMathDecls.h \
|
||||
$(GENERIC_DIR)/tclOO.h \
|
||||
@@ -465,7 +466,8 @@ GENERIC_SRCS = \
|
||||
$(GENERIC_DIR)/tclUtil.c \
|
||||
$(GENERIC_DIR)/tclVar.c \
|
||||
$(GENERIC_DIR)/tclAssembly.c \
|
||||
$(GENERIC_DIR)/tclZlib.c
|
||||
$(GENERIC_DIR)/tclZlib.c \
|
||||
$(GENERIC_DIR)/zipfs.c
|
||||
|
||||
OO_SRCS = \
|
||||
$(GENERIC_DIR)/tclOO.c \
|
||||
@@ -954,6 +956,7 @@ install-headers:
|
||||
@for i in $(GENERIC_DIR)/tcl.h $(GENERIC_DIR)/tclDecls.h \
|
||||
$(GENERIC_DIR)/tclOO.h $(GENERIC_DIR)/tclOODecls.h \
|
||||
$(GENERIC_DIR)/tclPlatDecls.h \
|
||||
$(GENERIC_DIR)/tclZipfs.h \
|
||||
$(GENERIC_DIR)/tclTomMath.h \
|
||||
$(GENERIC_DIR)/tclTomMathDecls.h ; \
|
||||
do \
|
||||
@@ -1323,6 +1326,9 @@ tclVar.o: $(GENERIC_DIR)/tclVar.c
|
||||
tclZlib.o: $(GENERIC_DIR)/tclZlib.c
|
||||
$(CC) -c $(CC_SWITCHES) $(ZLIB_INCLUDE) $(GENERIC_DIR)/tclZlib.c
|
||||
|
||||
zipfs.o: $(GENERIC_DIR)/zipfs.c
|
||||
$(CC) -c $(CC_SWITCHES) $(ZLIB_INCLUDE) $(GENERIC_DIR)/zipfs.c
|
||||
|
||||
tclTest.o: $(GENERIC_DIR)/tclTest.c $(IOHDR) $(TCLREHDRS)
|
||||
$(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tclTest.c
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "tcl.h"
|
||||
|
||||
#ifdef TCL_TEST
|
||||
#include "tclZipfs.h"
|
||||
extern Tcl_PackageInitProc Tcltest_Init;
|
||||
extern Tcl_PackageInitProc Tcltest_SafeInit;
|
||||
#endif /* TCL_TEST */
|
||||
@@ -123,6 +124,10 @@ Tcl_AppInit(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init, Tcltest_SafeInit);
|
||||
if (Tclzipfs_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_StaticPackage(interp, "zipfs", Tclzipfs_Init, Tclzipfs_SafeInit);
|
||||
#endif /* TCL_TEST */
|
||||
|
||||
/*
|
||||
|
||||
+4
-2
@@ -302,7 +302,8 @@ GENERIC_OBJS = \
|
||||
tclUtf.$(OBJEXT) \
|
||||
tclUtil.$(OBJEXT) \
|
||||
tclVar.$(OBJEXT) \
|
||||
tclZlib.$(OBJEXT)
|
||||
tclZlib.$(OBJEXT) \
|
||||
zipfs.$(OBJEXT)
|
||||
|
||||
TOMMATH_OBJS = \
|
||||
bncore.${OBJEXT} \
|
||||
@@ -635,6 +636,7 @@ install-libraries: libraries install-tzdata install-msgs
|
||||
@echo "Installing header files";
|
||||
@for i in "$(GENERIC_DIR)/tcl.h" "$(GENERIC_DIR)/tclDecls.h" \
|
||||
"$(GENERIC_DIR)/tclOO.h" "$(GENERIC_DIR)/tclOODecls.h" \
|
||||
"$(GENERIC_DIR)/tclZipfs.h" \
|
||||
"$(GENERIC_DIR)/tclPlatDecls.h" \
|
||||
"$(GENERIC_DIR)/tclTomMath.h" \
|
||||
"$(GENERIC_DIR)/tclTomMathDecls.h"; \
|
||||
@@ -749,7 +751,7 @@ clean: cleanhelp clean-packages
|
||||
|
||||
distclean: distclean-packages clean
|
||||
$(RM) Makefile config.status config.cache config.log tclConfig.sh \
|
||||
tcl.hpj config.status.lineno
|
||||
tcl.hpj config.status.lineno tclsh.exe.manifest
|
||||
|
||||
#
|
||||
# Bundled package targets
|
||||
|
||||
+6
-1
@@ -235,7 +235,8 @@ COREOBJS = \
|
||||
$(TMP_DIR)\tclUtf.obj \
|
||||
$(TMP_DIR)\tclUtil.obj \
|
||||
$(TMP_DIR)\tclVar.obj \
|
||||
$(TMP_DIR)\tclZlib.obj
|
||||
$(TMP_DIR)\tclZlib.obj \
|
||||
$(TMP_DIR)\zipfs.obj
|
||||
|
||||
ZLIBOBJS = \
|
||||
$(TMP_DIR)\adler32.obj \
|
||||
@@ -683,6 +684,9 @@ $(TMP_DIR)\tclWinTest.obj: $(WINDIR)\tclWinTest.c
|
||||
$(TMP_DIR)\tclZlib.obj: $(GENERICDIR)\tclZlib.c
|
||||
$(cc32) $(pkgcflags) -I$(COMPATDIR)\zlib -Fo$@ $?
|
||||
|
||||
$(TMP_DIR)\zipfs.obj: $(GENERICDIR)\zipfs.c
|
||||
$(cc32) $(TCL_CFLAGS) -I$(COMPATDIR)\zlib -DBUILD_tcl -Fo$@ $?
|
||||
|
||||
$(TMP_DIR)\tclPkgConfig.obj: $(GENERICDIR)\tclPkgConfig.c
|
||||
$(cc32) $(pkgcflags) \
|
||||
-DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR:\=\\)\"" \
|
||||
@@ -832,6 +836,7 @@ install-libraries: tclConfig tcl-nmake install-msgs install-tzdata
|
||||
@$(CPY) "$(GENERICDIR)\tclDecls.h" "$(INCLUDE_INSTALL_DIR)\"
|
||||
@$(CPY) "$(GENERICDIR)\tclOO.h" "$(INCLUDE_INSTALL_DIR)\"
|
||||
@$(CPY) "$(GENERICDIR)\tclOODecls.h" "$(INCLUDE_INSTALL_DIR)\"
|
||||
@$(CPY) "$(GENERICDIR)\tclZipfs.h" "$(INCLUDE_INSTALL_DIR)\"
|
||||
@$(CPY) "$(GENERICDIR)\tclPlatDecls.h" "$(INCLUDE_INSTALL_DIR)\"
|
||||
@$(CPY) "$(GENERICDIR)\tclTomMath.h" "$(INCLUDE_INSTALL_DIR)\"
|
||||
@$(CPY) "$(GENERICDIR)\tclTomMathDecls.h" "$(INCLUDE_INSTALL_DIR)\"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <tchar.h>
|
||||
|
||||
#ifdef TCL_TEST
|
||||
#include "tclZipfs.h"
|
||||
extern Tcl_PackageInitProc Tcltest_Init;
|
||||
extern Tcl_PackageInitProc Tcltest_SafeInit;
|
||||
#endif /* TCL_TEST */
|
||||
@@ -176,6 +177,10 @@ Tcl_AppInit(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init, Tcltest_SafeInit);
|
||||
if (Tclzipfs_Init(interp) == TCL_ERROR) {
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_StaticPackage(interp, "zipfs", Tclzipfs_Init, Tclzipfs_SafeInit);
|
||||
#endif /* TCL_TEST */
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user