michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* zip.h michael@0: * Structures and functions for creating ZIP archives. michael@0: */ michael@0: #ifndef ZIP_H michael@0: #define ZIP_H michael@0: michael@0: /* For general information on ZIP formats, you can look at jarfile.h michael@0: * in ns/security/lib/jar. Or look it up on the web... michael@0: */ michael@0: michael@0: /* One entry in a ZIPfile. This corresponds to one file in the archive. michael@0: * We have to save this information because first all the files go into michael@0: * the archive with local headers; then at the end of the file we have to michael@0: * put the central directory entries for each file. michael@0: */ michael@0: typedef struct ZIPentry_s { michael@0: struct ZipLocal local; /* local header info */ michael@0: struct ZipCentral central; /* central directory info */ michael@0: char *filename; /* name of file */ michael@0: char *comment; /* comment for this file -- optional */ michael@0: michael@0: struct ZIPentry_s *next; michael@0: } ZIPentry; michael@0: michael@0: /* This structure contains the necessary data for putting a ZIP file michael@0: * together. Has some overall information and a list of ZIPentrys. michael@0: */ michael@0: typedef struct ZIPfile_s { michael@0: char *filename; /* ZIP file name */ michael@0: char *comment; /* ZIP file comment -- may be NULL */ michael@0: PRFileDesc *fp; /* ZIP file pointer */ michael@0: ZIPentry *list; /* one entry for each file in the archive */ michael@0: unsigned int time; /* the GMT time of creation, in DOS format */ michael@0: unsigned int date; /* the GMT date of creation, in DOS format */ michael@0: unsigned long central_start; /* starting offset of central directory */ michael@0: unsigned long central_end; /*index right after the last byte of central*/ michael@0: } ZIPfile; michael@0: michael@0: michael@0: /* Open a new ZIP file. Takes the name of the zip file and an optional michael@0: * comment to be included in the file. Returns a new ZIPfile structure michael@0: * which is used by JzipAdd and JzipClose michael@0: */ michael@0: ZIPfile* JzipOpen(char *filename, char *comment); michael@0: michael@0: /* Add a file to a ZIP archive. Fullname is the path relative to the michael@0: * current directory. Filename is what the name will be stored as in the michael@0: * archive, and thus what it will be restored as. zipfile is a structure michael@0: * returned from a previous call to JzipOpen. michael@0: * michael@0: * Non-zero return code means error (although usually the function will michael@0: * call exit() rather than return an error--gotta fix this). michael@0: */ michael@0: int JzipAdd(char *fullname, char *filename, ZIPfile *zipfile, michael@0: int compression_level); michael@0: michael@0: /* Finalize a ZIP archive. Adds all the footer information to the end of michael@0: * the file and closes it. Also DELETES THE ZIPFILE STRUCTURE that was michael@0: * passed in. So you never have to allocate or free a ZIPfile yourself. michael@0: * michael@0: * Non-zero return code means error (although usually the function will michael@0: * call exit() rather than return an error--gotta fix this). michael@0: */ michael@0: int JzipClose (ZIPfile *zipfile); michael@0: michael@0: michael@0: #endif /* ZIP_H */