tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

zip.h (2923B)


      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 /* Open a new ZIP file.  Takes the name of the zip file and an optional
     44 * comment to be included in the file.  Returns a new ZIPfile structure
     45 * which is used by JzipAdd and JzipClose
     46 */
     47 ZIPfile *JzipOpen(char *filename, char *comment);
     48 
     49 /* Add a file to a ZIP archive.  Fullname is the path relative to the
     50 * current directory.  Filename is what the name will be stored as in the
     51 * archive, and thus what it will be restored as.  zipfile is a structure
     52 * returned from a previous call to JzipOpen.
     53 *
     54 * Non-zero return code means error (although usually the function will
     55 * call exit() rather than return an error--gotta fix this).
     56 */
     57 int JzipAdd(char *fullname, char *filename, ZIPfile *zipfile,
     58            int compression_level);
     59 
     60 /* Finalize a ZIP archive.  Adds all the footer information to the end of
     61 * the file and closes it.  Also DELETES THE ZIPFILE STRUCTURE that was
     62 * passed in.  So you never have to allocate or free a ZIPfile yourself.
     63 *
     64 * Non-zero return code means error (although usually the function will
     65 * call exit() rather than return an error--gotta fix this).
     66 */
     67 int JzipClose(ZIPfile *zipfile);
     68 
     69 #endif /* ZIP_H */