summaryrefslogtreecommitdiff
blob: da27558c96a4d90a2e92e67ed805167af2f3b1bb (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
59
60
61
62
63
64
65
66
#ifndef ARTIFEX_EXTRACT_ZIP
#define ARTIFEX_EXTRACT_ZIP

/* Only for internal use by extract code.  */

#include "../include/extract_buffer.h"

#include <stddef.h>


/* Support for creating zip file content.

Content is compressed using deflate.

Unless otherwise stated, all functions return 0 on success or -1 with errno
set.
*/

typedef struct extract_zip_t extract_zip_t;
/* Abstract handle for zipfile state. */


int extract_zip_open(extract_buffer_t* buffer, extract_zip_t** o_zip);
/* Creates an extract_zip_t that writes to specified buffer.

We reuse <buffer>'s allocator for zlib's allocation needs.

buffer:
    Destination for zip file content.
o_zip:
    Out-param.
*/

int extract_zip_write_file(
        extract_zip_t*  zip,
        const void*     data,
        size_t          data_length,
        const char*     name
        );
/* Writes specified data into the zip file.

Returns same as extract_buffer_write(): 0 on success, +1 if short write due to
EOF or -1 with errno set.

zip:
    From extract_zip_open().
data:
    File contents.
data_length:
    Length in bytes of file contents.
name:
    Name of file within the zip file.
*/


int extract_zip_close(extract_zip_t** pzip);
/* Finishes writing the zip file (e.g. appends Central directory file headers
and End of central directory record).

Does not call extract_buffer_close().

zip:
    From extract_zip_open().
*/

#endif