X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fzip-reader.h;h=6a65f58c1c95f13d8b7345662f33f796663483dd;hb=8ca7ae9f41dfaaa3f7e386238faea46809c17f40;hp=966bd5990f25adf1cc37c0879fad05aba3038b4e;hpb=32ee0e0402d6d56674f53a47d879ec5c07dabe09;p=pspp diff --git a/src/libpspp/zip-reader.h b/src/libpspp/zip-reader.h index 966bd5990f..6a65f58c1c 100644 --- a/src/libpspp/zip-reader.h +++ b/src/libpspp/zip-reader.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2011 Free Software Foundation, Inc. + Copyright (C) 2011, 2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,47 +18,10 @@ #ifndef ZIP_READER_H #define ZIP_READER_H 1 -#include - +struct zip_member; struct zip_reader; struct string; -enum compression - { - COMPRESSION_STORED = 0, -#if HAVE_ZLIB_H - COMPRESSION_INFLATE, -#endif - n_COMPRESSION - }; - -struct zip_member -{ - FILE *fp; /* The stream from which the data is read */ - uint32_t offset; /* Starting offset in file. */ - uint32_t comp_size; /* Length of member file data, in bytes. */ - uint32_t ucomp_size; /* Uncompressed length of member file data, in bytes. */ - uint32_t expected_crc; /* CRC-32 of member file data.. */ - char *name; /* Name of member file. */ - uint32_t crc; - enum compression compression; - - size_t bytes_unread; /* Number of bytes left in the member available for reading */ - int ref_cnt; - struct string *errs; - void *aux; -}; - -struct decompressor -{ - bool (*init) (struct zip_member *); - int (*read) (struct zip_member *, void *, size_t); - void (*finish) (struct zip_member *); -}; - - -void zm_dump (const struct zip_member *zm); - /* Create zip reader to read the file called FILENAME. If ERRS is non-null if will be used to contain any error messages which the reader wishes to report. @@ -68,20 +31,30 @@ struct zip_reader *zip_reader_create (const char *filename, struct string *errs) /* Destroy the zip reader */ void zip_reader_destroy (struct zip_reader *zr); +/* Returns the name of ZR's member IDX, IDX >= 0. Returns NULL if ZR has fewer + than (IDX + 1) members. */ +const char *zip_reader_get_member_name(const struct zip_reader *zr, + size_t idx); + +/* Returns true if ZR contains a member named MEMBER, false otherwise. */ +bool zip_reader_contains_member (const struct zip_reader *zr, + const char *member); + /* Return the zip member in the reader ZR, called MEMBER */ struct zip_member *zip_member_open (struct zip_reader *zr, const char *member); -/* Read upto N bytes from ZM, storing them in BUF. +/* Read up to N bytes from ZM, storing them in BUF. Returns the number of bytes read, or -1 on error */ int zip_member_read (struct zip_member *zm, void *buf, size_t n); -/* Unref (and possibly destroy) the zip member ZM */ -void zip_member_unref (struct zip_member *zm); - -/* Ref the zip member */ -void zip_member_ref (struct zip_member *zm); +/* Read all of ZM into memory, storing the data in *DATAP and its size in *NP. + Returns NULL if successful, otherwise an error string that the caller + must eventually free(). */ +char *zip_member_read_all (struct zip_reader *, const char *member_name, + void **datap, size_t *np) WARN_UNUSED_RESULT; void zip_member_finish (struct zip_member *zm); + #endif