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
21 #include "libpspp/compiler.h"
27 /* Create zip reader to read the file called FILENAME. If successful, stores
28 the new zip_reader in *ZRP and returns NULL; on error, returns an error
29 message that the caller must free and stores NULL in *ZRP. */
30 char *zip_reader_create (const char *filename, struct zip_reader **zrp)
33 /* Destroy the zip reader */
34 void zip_reader_destroy (struct zip_reader *zr);
36 /* Returns the name of ZR's member IDX, IDX >= 0. Returns NULL if ZR has fewer
37 than (IDX + 1) members. */
38 const char *zip_reader_get_member_name(const struct zip_reader *zr,
41 /* Returns true if ZR contains a member named MEMBER, false otherwise. */
42 bool zip_reader_contains_member (const struct zip_reader *zr,
45 /* Opens the zip member named MEMBER in ZR. If successful, stores the new
46 zip_member in *ZMP and returns NULL; on error, returns an error message that
47 the caller must free and stores NULL in *ZMP. */
48 char *zip_member_open (struct zip_reader *zr, const char *member,
49 struct zip_member **zmp) WARN_UNUSED_RESULT;
51 /* Read up to N bytes from ZM, storing them in BUF. Returns the number of
52 bytes read, or -1 on error. On error, zip_member_steal_error() may be used
53 to obtain an error message. */
54 int zip_member_read (struct zip_member *zm, void *buf, size_t n);
56 /* Read all of ZM into memory, storing the data in *DATAP and its size in *NP.
57 Returns NULL if successful, otherwise an error string that the caller
58 must eventually free(). */
59 char *zip_member_read_all (struct zip_reader *, const char *member_name,
60 void **datap, size_t *np) WARN_UNUSED_RESULT;
62 /* Returns the error message in ZM (and clears it out of ZM). The caller must
63 eventually free the returned string. */
64 char *zip_member_steal_error (struct zip_member *zm) WARN_UNUSED_RESULT;
66 void zip_member_finish (struct zip_member *zm);