Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 3 | <!-- This is an automatically generated file. Do not edit. |
| 4 | zip_source_function.mdoc -- create data source from function |
| 5 | Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner |
| 6 | |
| 7 | This file is part of libzip, a library to manipulate ZIP archives. |
| 8 | The authors can be contacted at <libzip@nih.at> |
| 9 | |
| 10 | Redistribution and use in source and binary forms, with or without |
| 11 | modification, are permitted provided that the following conditions |
| 12 | are met: |
| 13 | 1. Redistributions of source code must retain the above copyright |
| 14 | notice, this list of conditions and the following disclaimer. |
| 15 | 2. Redistributions in binary form must reproduce the above copyright |
| 16 | notice, this list of conditions and the following disclaimer in |
| 17 | the documentation and/or other materials provided with the |
| 18 | distribution. |
| 19 | 3. The names of the authors may not be used to endorse or promote |
| 20 | products derived from this software without specific prior |
| 21 | written permission. |
| 22 | |
| 23 | THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS |
| 24 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY |
| 27 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 29 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 30 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 31 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 32 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 33 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | --> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 35 | <head> |
| 36 | <meta charset="utf-8"/> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 37 | <link rel="stylesheet" href="../nih-man.css" type="text/css" media="all"/> |
| 38 | <title>ZIP_SOURCE_FUNCTION(3)</title> |
| 39 | </head> |
| 40 | <body> |
| 41 | <table class="head"> |
| 42 | <tr> |
| 43 | <td class="head-ltitle">ZIP_SOURCE_FUNCTION(3)</td> |
| 44 | <td class="head-vol">Library Functions Manual</td> |
| 45 | <td class="head-rtitle">ZIP_SOURCE_FUNCTION(3)</td> |
| 46 | </tr> |
| 47 | </table> |
| 48 | <div class="manual-text"> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 49 | <h1 class="Sh" title="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1> |
| 50 | <code class="Nm" title="Nm">zip_source_function</code>, |
| 51 | <code class="Nm" title="Nm">zip_source_function_create</code> — |
| 52 | <div class="Nd" title="Nd">create data source from function</div> |
| 53 | <h1 class="Sh" title="Sh" id="LIBRARY"><a class="permalink" href="#LIBRARY">LIBRARY</a></h1> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 54 | libzip (-lzip) |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 55 | <h1 class="Sh" title="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1> |
| 56 | <code class="In" title="In">#include |
| 57 | <<a class="In" title="In">zip.h</a>></code> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 58 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 59 | <var class="Ft" title="Ft">zip_source_t *</var> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 60 | <br/> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 61 | <code class="Fn" title="Fn">zip_source_function</code>(<var class="Fa" title="Fa" style="white-space: nowrap;">zip_t |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 62 | *archive</var>, |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 63 | <var class="Fa" title="Fa" style="white-space: nowrap;">zip_source_callback |
| 64 | fn</var>, <var class="Fa" title="Fa" style="white-space: nowrap;">void |
| 65 | *userdata</var>); |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 66 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 67 | <var class="Ft" title="Ft">zip_source_t *</var> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 68 | <br/> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 69 | <code class="Fn" title="Fn">zip_source_function_create</code>(<var class="Fa" title="Fa" style="white-space: nowrap;">zip_source_callback |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 70 | fn</var>, <var class="Fa" title="Fa" style="white-space: nowrap;">void |
| 71 | *userdata</var>, |
| 72 | <var class="Fa" title="Fa" style="white-space: nowrap;">zip_error_t |
| 73 | *error</var>); |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 74 | <h1 class="Sh" title="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1> |
| 75 | The functions <code class="Fn" title="Fn">zip_source_function</code>() and |
| 76 | <code class="Fn" title="Fn">zip_source_function_create</code>() creates a zip |
| 77 | source from the user-provided function <var class="Ar" title="Ar">fn</var>, |
| 78 | which must be of the following type: |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 79 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 80 | <var class="Ft" title="Ft">typedef zip_int64_t</var> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 81 | <code class="Fn" title="Fn">(*zip_source_callback)</code>(<var class="Fa" title="Fa">void |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 82 | *userdata</var>, <var class="Fa" title="Fa">void *data</var>, |
| 83 | <var class="Fa" title="Fa">zip_uint64_t len</var>, |
| 84 | <var class="Fa" title="Fa">zip_source_cmd_t cmd</var>); |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 85 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 86 | <var class="Ar" title="Ar">archive</var> or |
| 87 | <var class="Ar" title="Ar">error</var> are used for reporting errors and can |
| 88 | be <code class="Dv" title="Dv">NULL</code>. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 89 | <div class="Pp"></div> |
| 90 | When called by the library, the first argument is the |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 91 | <var class="Ar" title="Ar">userdata</var> argument supplied to the function. |
| 92 | The next two arguments are a buffer <var class="Ar" title="Ar">data</var> of |
| 93 | size <var class="Ar" title="Ar">len</var> when data is passed in or expected |
| 94 | to be returned, or else <code class="Dv" title="Dv">NULL</code> and 0. The |
| 95 | last argument, <var class="Ar" title="Ar">cmd</var>, specifies which action |
| 96 | the function should perform. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 97 | <div class="Pp"></div> |
| 98 | Depending on the uses, there are three useful sets of commands to be supported |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 99 | by a <code class="Fn" title="Fn">zip_source_callback</code>(): |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 100 | <dl class="Bl-tag"> |
| 101 | <dt> </dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 102 | <dd> </dd> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 103 | <dt>read source</dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 104 | <dd>Providing streamed data (for file data added to archives). Must support |
| 105 | <code class="Dv" title="Dv">ZIP_SOURCE_OPEN</code>, |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 106 | <code class="Dv" title="Dv">ZIP_SOURCE_READ</code>, |
| 107 | <code class="Dv" title="Dv">ZIP_SOURCE_CLOSE</code>, |
| 108 | <code class="Dv" title="Dv">ZIP_SOURCE_STAT</code>, and |
| 109 | <code class="Dv" title="Dv">ZIP_SOURCE_ERROR</code>.</dd> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 110 | <dt> </dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 111 | <dd> </dd> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 112 | <dt>seekable read source</dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 113 | <dd>Same as previous, but from a source allowing reading from arbitrary |
| 114 | offsets (also for read-only zip archive). Must additionally support |
| 115 | <code class="Dv" title="Dv">ZIP_SOURCE_SEEK</code>, |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 116 | <code class="Dv" title="Dv">ZIP_SOURCE_TELL</code>, and |
| 117 | <code class="Dv" title="Dv">ZIP_SOURCE_SUPPORTS</code>.</dd> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 118 | <dt> </dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 119 | <dd> </dd> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 120 | <dt>read/write source</dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 121 | <dd>Same as previous, but additionally allowing writing (also for writable zip |
| 122 | archives). Must additionally support |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 123 | <code class="Dv" title="Dv">ZIP_SOURCE_BEGIN_WRITE</code>, |
| 124 | <code class="Dv" title="Dv">ZIP_SOURCE_COMMIT_WRITE</code>, |
| 125 | <code class="Dv" title="Dv">ZIP_SOURCE_ROLLBACK_WRITE</code>, |
| 126 | <code class="Dv" title="Dv">ZIP_SOURCE_SEEK_WRITE</code>, |
| 127 | <code class="Dv" title="Dv">ZIP_SOURCE_TELL_WRITE</code>, and |
| 128 | <code class="Dv" title="Dv">ZIP_SOURCE_REMOVE</code>.</dd> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 129 | </dl> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 130 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_BEGIN_WRITE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 131 | Prepare the source for writing. Use this to create any temporary file(s). |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 132 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_BEGIN_WRITE_CLONING</code></h2> |
| 133 | Prepare the source for writing, keeping the first |
| 134 | <var class="Ar" title="Ar">len</var> bytes of the original file. Only |
| 135 | implement this command if it is more efficient than copying the data, and if |
| 136 | it does not destructively overwrite the original file (you still have to be |
| 137 | able to execute <code class="Dv" title="Dv">ZIP_SOURCE_ROLLBACK_WRITE</code>). |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 138 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 139 | The next write should happen at byte <var class="Ar" title="Ar">offset</var>. |
| 140 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_CLOSE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 141 | Reading is done. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 142 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_COMMIT_WRITE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 143 | Finish writing to the source. Replace the original data with the newly written |
| 144 | data. Clean up temporary files or internal buffers. Subsequently opening and |
| 145 | reading from the source should return the newly written data. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 146 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_ERROR</code></h2> |
| 147 | Get error information. <var class="Ar" title="Ar">data</var> points to an array |
| 148 | of two ints, which should be filled with the libzip error code and the |
| 149 | corresponding system error code for the error that occurred. See |
| 150 | <a class="Xr" title="Xr" href="zip_errors.html">zip_errors(3)</a> for details |
| 151 | on the error codes. If the source stores error information in a zip_error_t, |
| 152 | use |
| 153 | <a class="Xr" title="Xr" href="zip_error_to_data.html">zip_error_to_data(3)</a> |
| 154 | and return its return value. Otherwise, return 2 * sizeof(int). |
| 155 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_FREE</code></h2> |
| 156 | Clean up and free all resources, including |
| 157 | <var class="Ar" title="Ar">userdata</var>. The callback function will not be |
| 158 | called again. |
| 159 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_OPEN</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 160 | Prepare for reading. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 161 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_READ</code></h2> |
| 162 | Read data into the buffer <var class="Ar" title="Ar">data</var> of size |
| 163 | <var class="Ar" title="Ar">len</var>. Return the number of bytes placed into |
| 164 | <var class="Ar" title="Ar">data</var> on success, and zero for end-of-file. |
| 165 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_REMOVE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 166 | Remove the underlying file. This is called if a zip archive is empty when |
| 167 | closed. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 168 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_ROLLBACK_WRITE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 169 | Abort writing to the source. Discard written data. Clean up temporary files or |
| 170 | internal buffers. Subsequently opening and reading from the source should |
| 171 | return the original data. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 172 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_SEEK</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 173 | Specify position to read next byte from, like |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 174 | <a class="Xr" title="Xr" href="fseek.html">fseek(3)</a>. Use |
| 175 | <a class="Xr" title="Xr" href="ZIP_SOURCE_GET_ARGS.html">ZIP_SOURCE_GET_ARGS(3)</a> |
| 176 | to decode the arguments into the following struct: |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 177 | <div class="Pp"></div> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 178 | <div class="Bd"> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 179 | <pre class="Li"> |
| 180 | struct zip_source_args_seek { |
| 181 | zip_int64_t offset; |
| 182 | int whence; |
| 183 | }; |
| 184 | </pre> |
| 185 | </div> |
| 186 | <div class="Pp"></div> |
| 187 | If the size of the source's data is known, use |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 188 | <a class="Xr" title="Xr" href="zip_source_seek_compute_offset.html">zip_source_seek_compute_offset(3)</a> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 189 | to validate the arguments and compute the new offset. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 190 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_SEEK_WRITE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 191 | Specify position to write next byte to, like |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 192 | <a class="Xr" title="Xr" href="fseek.html">fseek(3)</a>. See |
| 193 | <code class="Dv" title="Dv">ZIP_SOURCE_SEEK</code> for details. |
| 194 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_STAT</code></h2> |
| 195 | Get meta information for the input data. <var class="Ar" title="Ar">data</var> |
| 196 | points to an allocated <var class="Vt" title="Vt">struct zip_stat</var>, which |
| 197 | should be initialized using |
| 198 | <a class="Xr" title="Xr" href="zip_stat_init.html">zip_stat_init(3)</a> and |
| 199 | then filled in. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 200 | <div class="Pp"></div> |
| 201 | For uncompressed, unencrypted data, all information is optional. However, fill |
| 202 | in as much information as is readily available. |
| 203 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 204 | If the data is compressed, |
| 205 | <code class="Dv" title="Dv">ZIP_STAT_COMP_METHOD</code>, |
| 206 | <code class="Dv" title="Dv">ZIP_STAT_SIZE</code>, and |
| 207 | <code class="Dv" title="Dv">ZIP_STAT_CRC</code> must be filled in. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 208 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 209 | If the data is encrypted, |
| 210 | <code class="Dv" title="Dv">ZIP_STAT_ENCRYPTION_METHOD</code>, |
| 211 | <code class="Dv" title="Dv">ZIP_STAT_COMP_METHOD</code>, |
| 212 | <code class="Dv" title="Dv">ZIP_STAT_SIZE</code>, and |
| 213 | <code class="Dv" title="Dv">ZIP_STAT_CRC</code> must be filled in. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 214 | <div class="Pp"></div> |
| 215 | Information only available after the source has been read (e.g., size) can be |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 216 | omitted in an earlier call. <i class="Em" title="Em">NOTE</i>: |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 217 | <code class="Fn" title="Fn">zip_source_function</code>() may be called with |
| 218 | this argument even after being called with |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 219 | <code class="Dv" title="Dv">ZIP_SOURCE_CLOSE</code>. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 220 | <div class="Pp"></div> |
| 221 | Return sizeof(struct zip_stat) on success. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 222 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_SUPPORTS</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 223 | Return bitmap specifying which commands are supported. Use |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 224 | <a class="Xr" title="Xr" href="zip_source_make_command_bitmap.html">zip_source_make_command_bitmap(3)</a>. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 225 | If this command is not implemented, the source is assumed to be a read source |
| 226 | without seek support. |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 227 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_TELL</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 228 | Return the current read offset in the source, like |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 229 | <a class="Xr" title="Xr" href="ftell.html">ftell(3)</a>. |
| 230 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_TELL_WRITE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 231 | Return the current write offset in the source, like |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 232 | <a class="Xr" title="Xr" href="ftell.html">ftell(3)</a>. |
| 233 | <h2 class="Ss" title="Ss"><code class="Dv" title="Dv">ZIP_SOURCE_WRITE</code></h2> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 234 | Write data to the source. Return number of bytes written. |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 235 | <h2 class="Ss" title="Ss" id="Return_Values"><a class="permalink" href="#Return_Values">Return |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 236 | Values</a></h2> |
| 237 | Commands should return -1 on error. |
| 238 | <code class="Dv" title="Dv">ZIP_SOURCE_ERROR</code> will be called to retrieve |
| 239 | the error code. On success, commands return 0, unless specified otherwise in |
| 240 | the description above. |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 241 | <h2 class="Ss" title="Ss" id="Calling_Conventions"><a class="permalink" href="#Calling_Conventions">Calling |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 242 | Conventions</a></h2> |
| 243 | The library will always issue <code class="Dv" title="Dv">ZIP_SOURCE_OPEN</code> |
| 244 | before issuing <code class="Dv" title="Dv">ZIP_SOURCE_READ</code>, |
| 245 | <code class="Dv" title="Dv">ZIP_SOURCE_SEEK</code>, or |
| 246 | <code class="Dv" title="Dv">ZIP_SOURCE_TELL</code>. When it no longer wishes |
| 247 | to read from this source, it will issue |
| 248 | <code class="Dv" title="Dv">ZIP_SOURCE_CLOSE</code>. If the library wishes to |
| 249 | read the data again, it will issue |
| 250 | <code class="Dv" title="Dv">ZIP_SOURCE_OPEN</code> a second time. If the |
| 251 | function is unable to provide the data again, it should return -1. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 252 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 253 | <code class="Dv" title="Dv">ZIP_SOURCE_BEGIN_WRITE</code> or |
| 254 | <code class="Dv" title="Dv">ZIP_SOURCE_BEGIN_WRITE_CLONING</code> will be |
| 255 | called before <code class="Dv" title="Dv">ZIP_SOURCE_WRITE</code>, |
| 256 | <code class="Dv" title="Dv">ZIP_SOURCE_SEEK_WRITE</code>, or |
| 257 | <code class="Dv" title="Dv">ZIP_SOURCE_TELL_WRITE</code>. When writing is |
| 258 | complete, either <code class="Dv" title="Dv">ZIP_SOURCE_COMMIT_WRITE</code> or |
| 259 | <code class="Dv" title="Dv">ZIP_SOURCE_ROLLBACK_WRITE</code> will be called. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 260 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 261 | <code class="Dv" title="Dv">ZIP_SOURCE_STAT</code> can be issued at any time. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 262 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 263 | <code class="Dv" title="Dv">ZIP_SOURCE_ERROR</code> will only be issued in |
| 264 | response to the function returning -1. |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 265 | <div class="Pp"></div> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 266 | <code class="Dv" title="Dv">ZIP_SOURCE_FREE</code> will be the last command |
| 267 | issued; if <code class="Dv" title="Dv">ZIP_SOURCE_OPEN</code> was called and |
| 268 | succeeded, <code class="Dv" title="Dv">ZIP_SOURCE_CLOSE</code> will be called |
| 269 | before <code class="Dv" title="Dv">ZIP_SOURCE_FREE</code>, and similarly for |
| 270 | <code class="Dv" title="Dv">ZIP_SOURCE_BEGIN_WRITE</code> or |
| 271 | <code class="Dv" title="Dv">ZIP_SOURCE_BEGIN_WRITE_CLONING</code> and |
| 272 | <code class="Dv" title="Dv">ZIP_SOURCE_COMMIT_WRITE</code> or |
| 273 | <code class="Dv" title="Dv">ZIP_SOURCE_ROLLBACK_WRITE</code>. |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 274 | <h1 class="Sh" title="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 275 | VALUES</a></h1> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 276 | Upon successful completion, the created source is returned. Otherwise, |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 277 | <code class="Dv" title="Dv">NULL</code> is returned and the error code in |
| 278 | <var class="Ar" title="Ar">archive</var> or |
| 279 | <var class="Ar" title="Ar">error</var> is set to indicate the error (unless it |
| 280 | is <code class="Dv" title="Dv">NULL</code>). |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 281 | <h1 class="Sh" title="Sh" id="ERRORS"><a class="permalink" href="#ERRORS">ERRORS</a></h1> |
| 282 | <code class="Fn" title="Fn">zip_source_function</code>() fails if: |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 283 | <dl class="Bl-tag"> |
| 284 | <dt> </dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 285 | <dd> </dd> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 286 | <dt>[<a class="permalink" href="#ZIP_ER_MEMORY"><code class="Er" title="Er" id="ZIP_ER_MEMORY">ZIP_ER_MEMORY</code></a>]</dt> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 287 | <dd>Required memory could not be allocated.</dd> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 288 | </dl> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 289 | <h1 class="Sh" title="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 290 | ALSO</a></h1> |
| 291 | <a class="Xr" title="Xr" href="libzip.html">libzip(3)</a>, |
Thomas Klausner | 4c612cb | 2018-06-28 08:12:54 +0200 | [diff] [blame] | 292 | <a class="Xr" title="Xr" href="zip_file_add.html">zip_file_add(3)</a>, |
| 293 | <a class="Xr" title="Xr" href="zip_file_replace.html">zip_file_replace(3)</a>, |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 294 | <a class="Xr" title="Xr" href="zip_source.html">zip_source(3)</a>, |
| 295 | <a class="Xr" title="Xr" href="zip_stat_init.html">zip_stat_init(3)</a> |
Thomas Klausner | d4ec986 | 2018-05-19 20:35:35 +0200 | [diff] [blame] | 296 | <h1 class="Sh" title="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1> |
| 297 | <code class="Fn" title="Fn">zip_source_function</code>() and |
| 298 | <code class="Fn" title="Fn">zip_source_function_create</code>() were added in |
| 299 | libzip 1.0. |
| 300 | <h1 class="Sh" title="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1> |
Thomas Klausner | 0001d26 | 2018-04-14 22:34:06 +0200 | [diff] [blame] | 301 | <span class="An" title="An">Dieter Baron</span> |
| 302 | <<a class="Mt" title="Mt" href="mailto:dillo@nih.at">dillo@nih.at</a>> |
| 303 | and <span class="An" title="An">Thomas Klausner</span> |
| 304 | <<a class="Mt" title="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>></div> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 305 | <table class="foot"> |
| 306 | <tr> |
| 307 | <td class="foot-date">December 18, 2017</td> |
Thomas Klausner | ff55682 | 2018-12-23 19:58:03 +0100 | [diff] [blame^] | 308 | <td class="foot-os">NetBSD 8.99.27</td> |
Thomas Klausner | 37ca2c6 | 2018-04-10 12:40:44 +0200 | [diff] [blame] | 309 | </tr> |
| 310 | </table> |
| 311 | </body> |
| 312 | </html> |