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       ssize_t (*zip_source_callback)(void *state,
21           void *data, size_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.
37
38              ZIP_SOURCE_STAT      Get  meta  information  for the input data.
39                                   data points to  a  struct  zip_stat,  which
40                                   should      be     filled     in.      (See
41                                   zip_stat_init(3).  )  Usually,  for  uncom‐
42                                   pressed  data, after zip_stat_init(3), only
43                                   the mtime and size struct members will need
44                                   to  be set.  Return sizeof(struct zip_stat)
45                                   on success, -1 on error.
46
47              ZIP_SOURCE_ERROR     Get error information.  data points  to  an
48                                   array  of  two ints, which should be filled
49                                   with the libzip error code and  the  corre‐
50                                   sponding  system  error  code for the error
51                                   that  occurred.   See   zip_errors(3)   for
52                                   details   on   the   error  codes.   Return
53                                   return(2 * sizeof(int)).
54
55              ZIP_SOURCE_FREE      Clean up and free all resources.  Return 0.
56
57       The  library  will  always   issue   ZIP_SOURCE_OPEN   before   issuing
58       ZIP_SOURCE_READ.  When it no longer wishes to read from this source, it
59       will issue ZIP_SOURCE_CLOSE.  If the library wishes to  read  the  data
60       again, it will issue ZIP_SOURCE_OPEN a second time.  If the function is
61       unable to provide the data again, it should return -1.
62
63       ZIP_SOURCE_STAT can be issued at any time.  ZIP_SOURCE_ERROR will  only
64       be  issued  in  response to the function returning -1.  ZIP_SOURCE_FREE
65       will be the last command issued.
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@giga.or.at> and Thomas Klausner <tk@giga.or.at>
85
86
87
88NiH                              March 4, 2007          ZIP_SOURCE_FUNCTION(3)
Impressum