1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef _ZIPFILE_ZIPFILE_H 18#define _ZIPFILE_ZIPFILE_H 19 20#include <stddef.h> 21 22#ifdef __cplusplus 23extern "C" { 24#endif 25 26typedef void* zipfile_t; 27typedef void* zipentry_t; 28 29// Provide a buffer. Returns NULL on failure. 30zipfile_t init_zipfile(const void* data, size_t size); 31 32// Release the zipfile resources. 33void release_zipfile(zipfile_t file); 34 35// Get a named entry object. Returns NULL if it doesn't exist 36// or if we won't be able to decompress it. The zipentry_t is 37// freed by release_zipfile() 38zipentry_t lookup_zipentry(zipfile_t file, const char* entryName); 39 40// Return the size of the entry. 41size_t get_zipentry_size(zipentry_t entry); 42 43// return the filename of this entry, you own the memory returned 44char* get_zipentry_name(zipentry_t entry); 45 46// The buffer must be 1.001 times the buffer size returned 47// by get_zipentry_size. Returns nonzero on failure. 48int decompress_zipentry(zipentry_t entry, void* buf, int bufsize); 49 50// iterate through the entries in the zip file. pass a pointer to 51// a void* initialized to NULL to start. Returns NULL when done 52zipentry_t iterate_zipfile(zipfile_t file, void** cookie); 53 54#ifdef __cplusplus 55} // extern "C" 56#endif 57 58#endif // _ZIPFILE_ZIPFILE_H 59