Subversion Repositories SvarDOS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1661 mateusz.vi 1
/*
2
 * Function to iterate through files in a ZIP archive.
3
 *
4
 * This file is part of the Mateusz' DOS Routines (MDR): http://mdr.osdn.io
5
 * Published under the terms of the MIT License, as stated below.
6
 *
7
 * Copyright (C) 2012-2022 Mateusz Viste
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to
11
 * deal in the Software without restriction, including without limitation the
12
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
13
 * sell copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
 * IN THE SOFTWARE.
26
 */
27
 
28
#ifndef MDR_UNZIP
29
#define MDR_UNZIP
30
 
31
#include <stdio.h> /* FILE * */
32
 
33
#define ZIP_FLAG_ISADIR    1
34
#define ZIP_FLAG_ENCRYPTED 2
35
 
36
#define ZIP_METH_STORE 0
37
#define ZIP_METH_DEFLATE 8
38
 
39
struct mdr_zip_item {
40
  unsigned long filelen;
41
  unsigned long compressedfilelen;
42
  unsigned long crc32;
43
  unsigned long dataoffset;    /* offset in the file where compressed data starts */
44
  unsigned long nextidxoffset; /* offset in the file of the next zip record, used by mdr_zip_iter() */
45
  unsigned short dosdate;      /* datestamp of the file (DOS packed format) */
46
  unsigned short dostime;      /* timestamp of the file (DOS packed format) */
47
  unsigned short compmethod;   /* compression method (ZIP_METH_xxx) */
48
  unsigned char flags;         /* see ZIP_FLAG_xxx above */
49
  char fname[256];             /* filename */
50
};
51
 
52
/* returns next item found in zip file. this is supposed to be called
53
 * iteratively, passing the previous mdr_zipitem struct each time (z must be
54
 * all zeroed out on first call).
55
 * returns 0 on success, neg on error, 1 on end of archive */
56
int mdr_zip_iter(struct mdr_zip_item *z, FILE *fd);
57
 
58
#endif