nss: import at 3.0.1 beta 1
[mozilla-nss.git] / security / nss / cmd / signtool / zip.h
blobc1cd5df5baab8ad25ee7d5cb0178fec41c62d409
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
37 /* zip.h
38 * Structures and functions for creating ZIP archives.
40 #ifndef ZIP_H
41 #define ZIP_H
43 /* For general information on ZIP formats, you can look at jarfile.h
44 * in ns/security/lib/jar. Or look it up on the web...
47 /* One entry in a ZIPfile. This corresponds to one file in the archive.
48 * We have to save this information because first all the files go into
49 * the archive with local headers; then at the end of the file we have to
50 * put the central directory entries for each file.
52 typedef struct ZIPentry_s {
53 struct ZipLocal local; /* local header info */
54 struct ZipCentral central; /* central directory info */
55 char *filename; /* name of file */
56 char *comment; /* comment for this file -- optional */
58 struct ZIPentry_s *next;
59 } ZIPentry;
61 /* This structure contains the necessary data for putting a ZIP file
62 * together. Has some overall information and a list of ZIPentrys.
64 typedef struct ZIPfile_s {
65 char *filename; /* ZIP file name */
66 char *comment; /* ZIP file comment -- may be NULL */
67 PRFileDesc *fp; /* ZIP file pointer */
68 ZIPentry *list; /* one entry for each file in the archive */
69 unsigned int time; /* the GMT time of creation, in DOS format */
70 unsigned int date; /* the GMT date of creation, in DOS format */
71 unsigned long central_start; /* starting offset of central directory */
72 unsigned long central_end; /*index right after the last byte of central*/
73 } ZIPfile;
76 /* Open a new ZIP file. Takes the name of the zip file and an optional
77 * comment to be included in the file. Returns a new ZIPfile structure
78 * which is used by JzipAdd and JzipClose
80 ZIPfile* JzipOpen(char *filename, char *comment);
82 /* Add a file to a ZIP archive. Fullname is the path relative to the
83 * current directory. Filename is what the name will be stored as in the
84 * archive, and thus what it will be restored as. zipfile is a structure
85 * returned from a previous call to JzipOpen.
87 * Non-zero return code means error (although usually the function will
88 * call exit() rather than return an error--gotta fix this).
90 int JzipAdd(char *fullname, char *filename, ZIPfile *zipfile,
91 int compression_level);
93 /* Finalize a ZIP archive. Adds all the footer information to the end of
94 * the file and closes it. Also DELETES THE ZIPFILE STRUCTURE that was
95 * passed in. So you never have to allocate or free a ZIPfile yourself.
97 * Non-zero return code means error (although usually the function will
98 * call exit() rather than return an error--gotta fix this).
100 int JzipClose (ZIPfile *zipfile);
103 #endif /* ZIP_H */