1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2011, 2013 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #define ZIP_READER_H 1
28 COMPRESSION_STORED = 0,
35 FILE *fp; /* The stream from which the data is read */
36 uint32_t offset; /* Starting offset in file. */
37 uint32_t comp_size; /* Length of member file data, in bytes. */
38 uint32_t ucomp_size; /* Uncompressed length of member file data, in bytes. */
39 uint32_t expected_crc; /* CRC-32 of member file data.. */
40 char *name; /* Name of member file. */
42 enum compression compression;
44 size_t bytes_unread; /* Number of bytes left in the member available for reading */
52 bool (*init) (struct zip_member *);
53 int (*read) (struct zip_member *, void *, size_t);
54 void (*finish) (struct zip_member *);
58 void zm_dump (const struct zip_member *zm);
60 /* Create zip reader to read the file called FILENAME.
61 If ERRS is non-null if will be used to contain any error messages
62 which the reader wishes to report.
64 struct zip_reader *zip_reader_create (const char *filename, struct string *errs);
66 /* Destroy the zip reader */
67 void zip_reader_destroy (struct zip_reader *zr);
69 /* Return the zip member in the reader ZR, called MEMBER */
70 struct zip_member *zip_member_open (struct zip_reader *zr, const char *member);
72 /* Read upto N bytes from ZM, storing them in BUF.
73 Returns the number of bytes read, or -1 on error */
74 int zip_member_read (struct zip_member *zm, void *buf, size_t n);
76 /* Unref (and possibly destroy) the zip member ZM */
77 void zip_member_unref (struct zip_member *zm);
79 /* Ref the zip member */
80 void zip_member_ref (struct zip_member *zm);
82 void zip_member_finish (struct zip_member *zm);