1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/cmd/signtool/zip.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/* zip.h 1.9 + * Structures and functions for creating ZIP archives. 1.10 + */ 1.11 +#ifndef ZIP_H 1.12 +#define ZIP_H 1.13 + 1.14 +/* For general information on ZIP formats, you can look at jarfile.h 1.15 + * in ns/security/lib/jar. Or look it up on the web... 1.16 + */ 1.17 + 1.18 +/* One entry in a ZIPfile. This corresponds to one file in the archive. 1.19 + * We have to save this information because first all the files go into 1.20 + * the archive with local headers; then at the end of the file we have to 1.21 + * put the central directory entries for each file. 1.22 + */ 1.23 +typedef struct ZIPentry_s { 1.24 + struct ZipLocal local; /* local header info */ 1.25 + struct ZipCentral central; /* central directory info */ 1.26 + char *filename; /* name of file */ 1.27 + char *comment; /* comment for this file -- optional */ 1.28 + 1.29 + struct ZIPentry_s *next; 1.30 +} ZIPentry; 1.31 + 1.32 +/* This structure contains the necessary data for putting a ZIP file 1.33 + * together. Has some overall information and a list of ZIPentrys. 1.34 + */ 1.35 +typedef struct ZIPfile_s { 1.36 + char *filename; /* ZIP file name */ 1.37 + char *comment; /* ZIP file comment -- may be NULL */ 1.38 + PRFileDesc *fp; /* ZIP file pointer */ 1.39 + ZIPentry *list; /* one entry for each file in the archive */ 1.40 + unsigned int time; /* the GMT time of creation, in DOS format */ 1.41 + unsigned int date; /* the GMT date of creation, in DOS format */ 1.42 + unsigned long central_start; /* starting offset of central directory */ 1.43 + unsigned long central_end; /*index right after the last byte of central*/ 1.44 +} ZIPfile; 1.45 + 1.46 + 1.47 +/* Open a new ZIP file. Takes the name of the zip file and an optional 1.48 + * comment to be included in the file. Returns a new ZIPfile structure 1.49 + * which is used by JzipAdd and JzipClose 1.50 + */ 1.51 +ZIPfile* JzipOpen(char *filename, char *comment); 1.52 + 1.53 +/* Add a file to a ZIP archive. Fullname is the path relative to the 1.54 + * current directory. Filename is what the name will be stored as in the 1.55 + * archive, and thus what it will be restored as. zipfile is a structure 1.56 + * returned from a previous call to JzipOpen. 1.57 + * 1.58 + * Non-zero return code means error (although usually the function will 1.59 + * call exit() rather than return an error--gotta fix this). 1.60 + */ 1.61 +int JzipAdd(char *fullname, char *filename, ZIPfile *zipfile, 1.62 + int compression_level); 1.63 + 1.64 +/* Finalize a ZIP archive. Adds all the footer information to the end of 1.65 + * the file and closes it. Also DELETES THE ZIPFILE STRUCTURE that was 1.66 + * passed in. So you never have to allocate or free a ZIPfile yourself. 1.67 + * 1.68 + * Non-zero return code means error (although usually the function will 1.69 + * call exit() rather than return an error--gotta fix this). 1.70 + */ 1.71 +int JzipClose (ZIPfile *zipfile); 1.72 + 1.73 + 1.74 +#endif /* ZIP_H */