1ZIP_SOURCE_FUNCTION(3)     Library Functions Manual     ZIP_SOURCE_FUNCTION(3)
2
3
4

NAME

6       zip_source_function - create data source from function
7

LIBRARY

9       libzip (-lzip)
10

SYNOPSIS

12       #include <zip.h>
13
14       struct    zip_source   *   zip_source_function(struct   zip   *archive,
15       zip_source_callback fn, void *userdata);
16

DESCRIPTION

18       The function zip_source_function creates a zip source  from  the  user-
19       provided  function  fn,  which  must  be of the following type: typedef
20       zip_int64_t (*zip_source_callback)(void *state,
21           void *data, zip_uint64_t len, enum zip_source_cmd cmd);
22
23       When called by the library, the first argument is the userdata argument
24       supplied  to  zip_source_function.  The next two arguments are a buffer
25       data of size len when data is expected to be returned, or else NULL and
26       0.   The last argument, cmd, specifies which action the function should
27       perform:
28
29              ZIP_SOURCE_OPEN      Prepare for reading.  Return 0 on  success,
30                                   -1 on error.
31
32              ZIP_SOURCE_READ      Read data into the buffer data of size len.
33                                   Return the number of bytes placed into data
34                                   on success, -1 on error.
35
36              ZIP_SOURCE_CLOSE     Reading is done.  Return 0.
37
38              ZIP_SOURCE_STAT      Get  meta  information  for the input data.
39                                   data points to an initialized which  should
40                                   be  filled  in.   (See  zip_stat_init(3). )
41                                   Information only available after the source
42                                   has been read (e.g. size) can be omitted in
43                                   an  earlier  call.   Return   sizeof(struct
44                                   zip_stat) on success, -1 on error.
45
46              ZIP_SOURCE_ERROR     Get  error  information.  data points to an
47                                   array of two ints, which should  be  filled
48                                   with  the  libzip error code and the corre‐
49                                   sponding system error code  for  the  error
50                                   that   occurred.    See  zip_errors(3)  for
51                                   details  on  the   error   codes.    Return
52                                   return(2 * sizeof(int)).
53
54              ZIP_SOURCE_FREE      Clean up and free all resources.  Return 0.
55
56       The   library   will   always   issue  ZIP_SOURCE_OPEN  before  issuing
57       ZIP_SOURCE_READ.  When it no longer wishes to read from this source, it
58       will  issue  ZIP_SOURCE_CLOSE.   If the library wishes to read the data
59       again, it will issue ZIP_SOURCE_OPEN a second time.  If the function is
60       unable to provide the data again, it should return -1.
61
62       ZIP_SOURCE_STAT  can be issued at any time.  ZIP_SOURCE_ERROR will only
63       be issued in response to the function  returning  -1.   ZIP_SOURCE_FREE
64       will be the last command issued; if ZIP_SOURCE_OPEN was called and suc‐
65       ceeded, ZIP_SOURCE_CLOSE will be called before ZIP_SOURCE_FREE.
66

RETURN VALUES

68       Upon successful completion, the created source is returned.  Otherwise,
69       NULL  is  returned and the error code in archive is set to indicate the
70       error.
71

ERRORS

73       zip_source_function fails if:
74
75              [ZIP_ER_MEMORY]
76                  Required memory could not be allocated.
77

SEE ALSO

79       libzip(3),    zip_add(3),     zip_replace(3),     zip_source_buffer(3),
80       zip_source_file(3),       zip_source_filep(3),      zip_source_free(3),
81       zip_source_zip(3), zip_stat_init(3)
82

AUTHORS

84       Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
85
86
87
88NiH                             March 30, 2009          ZIP_SOURCE_FUNCTION(3)
Impressum