|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 /* zip.h |
|
6 * Structures and functions for creating ZIP archives. |
|
7 */ |
|
8 #ifndef ZIP_H |
|
9 #define ZIP_H |
|
10 |
|
11 /* For general information on ZIP formats, you can look at jarfile.h |
|
12 * in ns/security/lib/jar. Or look it up on the web... |
|
13 */ |
|
14 |
|
15 /* One entry in a ZIPfile. This corresponds to one file in the archive. |
|
16 * We have to save this information because first all the files go into |
|
17 * the archive with local headers; then at the end of the file we have to |
|
18 * put the central directory entries for each file. |
|
19 */ |
|
20 typedef struct ZIPentry_s { |
|
21 struct ZipLocal local; /* local header info */ |
|
22 struct ZipCentral central; /* central directory info */ |
|
23 char *filename; /* name of file */ |
|
24 char *comment; /* comment for this file -- optional */ |
|
25 |
|
26 struct ZIPentry_s *next; |
|
27 } ZIPentry; |
|
28 |
|
29 /* This structure contains the necessary data for putting a ZIP file |
|
30 * together. Has some overall information and a list of ZIPentrys. |
|
31 */ |
|
32 typedef struct ZIPfile_s { |
|
33 char *filename; /* ZIP file name */ |
|
34 char *comment; /* ZIP file comment -- may be NULL */ |
|
35 PRFileDesc *fp; /* ZIP file pointer */ |
|
36 ZIPentry *list; /* one entry for each file in the archive */ |
|
37 unsigned int time; /* the GMT time of creation, in DOS format */ |
|
38 unsigned int date; /* the GMT date of creation, in DOS format */ |
|
39 unsigned long central_start; /* starting offset of central directory */ |
|
40 unsigned long central_end; /*index right after the last byte of central*/ |
|
41 } ZIPfile; |
|
42 |
|
43 |
|
44 /* Open a new ZIP file. Takes the name of the zip file and an optional |
|
45 * comment to be included in the file. Returns a new ZIPfile structure |
|
46 * which is used by JzipAdd and JzipClose |
|
47 */ |
|
48 ZIPfile* JzipOpen(char *filename, char *comment); |
|
49 |
|
50 /* Add a file to a ZIP archive. Fullname is the path relative to the |
|
51 * current directory. Filename is what the name will be stored as in the |
|
52 * archive, and thus what it will be restored as. zipfile is a structure |
|
53 * returned from a previous call to JzipOpen. |
|
54 * |
|
55 * Non-zero return code means error (although usually the function will |
|
56 * call exit() rather than return an error--gotta fix this). |
|
57 */ |
|
58 int JzipAdd(char *fullname, char *filename, ZIPfile *zipfile, |
|
59 int compression_level); |
|
60 |
|
61 /* Finalize a ZIP archive. Adds all the footer information to the end of |
|
62 * the file and closes it. Also DELETES THE ZIPFILE STRUCTURE that was |
|
63 * passed in. So you never have to allocate or free a ZIPfile yourself. |
|
64 * |
|
65 * Non-zero return code means error (although usually the function will |
|
66 * call exit() rather than return an error--gotta fix this). |
|
67 */ |
|
68 int JzipClose (ZIPfile *zipfile); |
|
69 |
|
70 |
|
71 #endif /* ZIP_H */ |