summaryrefslogtreecommitdiffstats
path: root/include/zipfile/zipfile.h
blob: 0ae4ee4f94df05c6a326e78e9564f5bff65d48ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _ZIPFILE_ZIPFILE_H
#define _ZIPFILE_ZIPFILE_H

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void* zipfile_t;
typedef void* zipentry_t;

// Provide a buffer.  Returns NULL on failure.
zipfile_t init_zipfile(const void* data, size_t size);

// Release the zipfile resources.
void release_zipfile(zipfile_t file);

// Get a named entry object.  Returns NULL if it doesn't exist
// or if we won't be able to decompress it.  The zipentry_t is
// freed by release_zipfile()
zipentry_t lookup_zipentry(zipfile_t file, const char* entryName);

// Return the size of the entry.
size_t get_zipentry_size(zipentry_t entry);

// return the filename of this entry, you own the memory returned
char* get_zipentry_name(zipentry_t entry);

// The buffer must be 1.001 times the buffer size returned
// by get_zipentry_size.  Returns nonzero on failure.
int decompress_zipentry(zipentry_t entry, void* buf, int bufsize);

// iterate through the entries in the zip file.  pass a pointer to
// a void* initialized to NULL to start.  Returns NULL when done
zipentry_t iterate_zipfile(zipfile_t file, void** cookie);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _ZIPFILE_ZIPFILE_H