079165422356221e0596abb9312eb3bcbdfa310e
[platform/upstream/libzip.git] / man / zip_fdopen.mdoc
1 .\" zip_fdopen.mdoc -- open zip archive using existing file descriptor
2 .\" Copyright (C) 2009-2015 Dieter Baron and Thomas Klausner
3 .\"
4 .\" This file is part of libzip, a library to manipulate ZIP archives.
5 .\" The authors can be contacted at <libzip@nih.at>
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in
14 .\"    the documentation and/or other materials provided with the
15 .\"    distribution.
16 .\" 3. The names of the authors may not be used to endorse or promote
17 .\"    products derived from this software without specific prior
18 .\"    written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
21 .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
24 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26 .\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
28 .\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .\"
32 .Dd February 13, 2012
33 .Dt ZIP_FDOPEN 3
34 .Os
35 .Sh NAME
36 .Nm zip_fdopen
37 .Nd open zip archive using open file descriptor
38 .Sh LIBRARY
39 libzip (-lzip)
40 .Sh SYNOPSIS
41 .In zip.h
42 .Ft zip_t *
43 .Fn zip_fdopen "int fd" "int flags" "int *errorp"
44 .Sh DESCRIPTION
45 The zip archive specified by the open file descriptor
46 .Ar fd
47 is opened and a pointer to a
48 .Ft struct zip ,
49 used to manipulate the archive, is returned.
50 In contrast to
51 .Xr zip_open 3 ,
52 using
53 .Nm zip_fdopen
54 the archive can only be opened in read-only mode.
55 The
56 .Ar fd
57 argument may not be used any longer after calling
58 .Nm zip_fdopen .
59 The
60 .Fa flags
61 are specified by
62 .Em or Ns No 'ing
63 the following values, or 0 for none of them.
64 .Bl -tag -offset indent -width ZIP_CHECKCONS
65 .It Dv ZIP_CHECKCONS
66 Perform additional stricter consistency checks on the archive, and
67 error if they fail.
68 .El
69 .Pp
70 If an error occurs and
71 .Ar errorp
72 is
73 .No non- Ns Dv NULL ,
74 it will be set to the corresponding error code.
75 .Sh RETURN VALUES
76 Upon successful completion
77 .Fn zip_fdopen
78 returns a
79 .Ft struct zip
80 pointer, and
81 .Ar fd
82 should not be used any longer, nor passed to
83 .Xr close 2 .
84 Otherwise,
85 .Dv NULL
86 is returned and
87 .Ar *errorp
88 is set to indicate the error.
89 In the error case,
90 .Ar fd
91 remains unchanged.
92 .Sh ERRORS
93 The file specified by
94 .Ar fd
95 is prepared for use by
96 .Xr libzip 3
97 unless:
98 .Bl -tag -width Er
99 .It Bq Er ZIP_ER_INCONS
100 Inconsistencies were found in the file specified by
101 .Ar path .
102 This error is often caused by specifying
103 .Dv ZIP_CHECKCONS
104 but can also happen without it.
105 .It Bq Er ZIP_ER_INVAL
106 The
107 .Ar flags
108 argument is invalid.
109 Not all
110 .Xr zip_open 3
111 flags are allowed for
112 .Nm zip_fdopen ,
113 see
114 .Sx DESCRIPTION .
115 .It Bq Er ZIP_ER_MEMORY
116 Required memory could not be allocated.
117 .It Bq Er ZIP_ER_NOZIP
118 The file specified by
119 .Ar fd
120 is not a zip archive.
121 .It Bq Er ZIP_ER_OPEN
122 The file specified by
123 .Ar fd
124 could not be prepared for use by
125 .Xr libzip 3 .
126 .It Bq Er ZIP_ER_READ
127 A read error occurred; see
128 .Va errno
129 for details.
130 .It Bq Er ZIP_ER_SEEK
131 The file specified by
132 .Ar fd
133 does not allow seeks.
134 .El
135 .Sh SEE ALSO
136 .Xr libzip 3 ,
137 .Xr zip_close 3 ,
138 .Xr zip_error_to_str 3 ,
139 .Xr zip_open 3
140 .Sh AUTHORS
141 .An -nosplit
142 .An Dieter Baron Aq Mt dillo@nih.at
143 and
144 .An Thomas Klausner Aq Mt tk@giga.or.at