1ZIP_SOURCE_LAYERED(3) BSD Library Functions Manual ZIP_SOURCE_LAYERED(3)
2
4 zip_source_layered, zip_source_layered_create — create layered data
5 source from function
6
8 libzip (-lzip)
9
11 #include <zip.h>
12
13 zip_source_t *
14 zip_source_layered(zip_t *archive, zip_source_t *source,
15 zip_source_layered_callback fn, void *userdata);
16
17 zip_source_t *
18 zip_source_layered_create(zip_source_t *source,
19 zip_source_layered_callback fn, void *userdata, zip_error_t *error);
20
22 The functions zip_source_layered() and zip_source_layered_create() create
23 a layered zip source from the user-provided function fn, which must be of
24 the following type:
25
26 typedef zip_int64_t (*ip_source_layered_callback)(zip_source_t *source,
27 void *userdata, void *data, zip_uint64_t length, zip_source_cmd_t cmd)
28
29 archive or error are used for reporting errors and can be NULL.
30
31 When called by the library, the first argument is the source of the lower
32 layer, the second argument is the userdata argument supplied to the func‐
33 tion. The next two arguments are a buffer data of size length when data
34 is passed in or expected to be returned, or else NULL and 0. The last
35 argument, cmd, specifies which action the function should perform.
36
37 See zip_source_function(3) for a description of the commands.
38
39 A layered source transforms the data or metadata of the source below in
40 some way. Layered sources can't support writing and are not sufficient
41 to cleanly add support for additional compression or encryption methods.
42 This may be revised in a later release of libzip.
43
44 On success, the layered source takes ownership of source. The caller
45 should not free it.
46
47 The interaction with the lower layer depends on the command:
48
49 ZIP_SOURCE_ACCEPT_EMPTY
50 If the layered source supports this command, the lower layer is not called
51 automatically. Otherwise, the return value of the lower source is used.
52
53 ZIP_SOURCE_CLOSE
54 The lower layer is closed after the callback returns.
55
56 ZIP_SOURCE_ERROR
57 The lower layer is not called automatically. If you need to retrieve error
58 information from the lower layer, use zip_error_set_from_source(3) or
59 zip_source_pass_to_lower_layer(3).
60
61 ZIP_SOURCE_FREE
62 The lower layer is freed after the callback returns.
63
64 ZIP_SOURCE_GET_FILE_ATTRIBUTES
65 The attributes of the lower layer are merged with the attributes returned
66 by the callback: information set by the callback wins over the lower layer,
67 with the following exceptions: the higher version_needed is used, and
68 general_purpose_bit_flags are only overwritten if the corresponding bit is
69 set in general_purpose_bit_mask.
70
71 ZIP_SOURCE_OPEN
72 The lower layer is opened before the callback is called.
73
74 ZIP_SOURCE_READ
75 The lower layer is not called automatically.
76
77 ZIP_SOURCE_SEEK
78 The lower layer is not called automatically.
79
80 ZIP_SOURCE_STAT
81 data contains the stat information from the lower layer when the callback
82 is called.
83
84 ZIP_SOURCE_SUPPORTS
85 data contains the bitmap of commands supported by the lower layer when the
86 callback is called. Since layered sources can't support writing, all com‐
87 mands related to writing are stripped from the returned support bitmap.
88
89 ZIP_SOURCE_TELL
90 The lower layer is not called automatically.
91
93 Upon successful completion, the created source is returned. Otherwise,
94 NULL is returned and the error code in archive or error is set to indi‐
95 cate the error (unless it is NULL).
96
98 zip_source_layered() fails if:
99
100 [ZIP_ER_MEMORY] Required memory could not be allocated.
101
103 libzip(3), zip_file_add(3), zip_file_attributes_init(3),
104 zip_file_replace(3), zip_source(3), zip_source_function(3),
105 zip_source_pass_to_lower_layer(3)
106
108 zip_source_layered() and zip_source_layered_create() were added in libzip
109 1.10.
110
112 Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
113
114BSD January 20, 2023 BSD