Imported Upstream version 0.10.1
[platform/upstream/libzip.git] / man / zip_fopen.man
1 .\" zip_fopen.mdoc \-- open file in zip archive for reading
2 .\" Copyright (C) 2003-2011 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 .TH ZIP_FOPEN 3 "February 14, 2011" NiH
33 .SH "NAME"
34 zip_fopen , \- .Nm zip_fopen_index
35 open file in zip archive for reading
36 .SH "LIBRARY"
37 libzip (-lzip)
38 .SH "SYNOPSIS"
39 #include <zip.h>
40 .PP
41 struct zip_file *
42 zip_fopen(struct zip *archive, const char *fname, int flags);
43 .PP
44 struct zip_file *
45 zip_fopen_index(struct zip *archive, zip_uint64_t index, int flags);
46 .SH "DESCRIPTION"
47 The
48 zip_fopen
49 function opens the file name
50 \fBfname\fR
51 in
52 \fBarchive.\fR
53 The
54 \fBflags\fR
55 argument specifies how the name lookup should be done, according to
56 the values are described in
57 zip_name_locate(3).
58 Also, the following values may be
59 .I or'ed
60 to it.
61 .RS
62 .TP 19
63 \fBZIP_FL_COMPRESSED\fR
64 Read the compressed data.
65 Otherwise the data is uncompressed by
66 zip_fread.
67 .TP 19
68 \fBZIP_FL_UNCHANGED\fR
69 Read the original data from the zip archive, ignoring any changes made
70 to the file.
71 .RE
72 .PP
73 The
74 zip_fopen_index
75 function opens the file at position
76 \fBindex.\fR
77 .PP
78 If encrypted data is encountered, the functions call
79 zip_fopen_encrypted(3)
80 or
81 zip_fopen_index_encrypted(3)
82 respectively, using the default password set with
83 zip_set_default_password(3).
84 .SH "RETURN VALUES"
85 Upon successful completion, a
86 .PP
87 struct zip_file
88 pointer is returned.
89 Otherwise,
90 \fBNULL\fR
91 is returned and the error code in
92 \fBarchive\fR
93 is set to indicate the error.
94 .SH "ERRORS"
95 .RS
96 .TP 4
97 [ZIP_ER_CHANGED]
98 The file data has been changed.
99 .TP 4
100 [ZIP_ER_COMPNOTSUPP]
101 The compression method used is not supported.
102 .TP 4
103 [ZIP_ER_ENCRNOTSUPP]
104 The encryption method used is not supported.
105 .TP 4
106 [ZIP_ER_MEMORY]
107 Required memory could not be allocated.
108 .TP 4
109 [ZIP_ER_READ]
110 A file read error occurred.
111 .TP 4
112 [ZIP_ER_SEEK]
113 A file seek error occurred.
114 .TP 4
115 [ZIP_ER_ZLIB]
116 Initializing the zlib stream failed.
117 .RE
118 .PP
119 The function
120 zip_fopen
121 may also fail and set
122 .Va zip_err
123 for any of the errors specified for the routine
124 zip_name_locate(3).
125 .PP
126 The function
127 zip_fopen_index
128 may also fail with
129 ZIP_ER_INVAL
130 if
131 \fBindex\fR
132 is invalid.
133 .SH "SEE ALSO"
134 libzip(3),
135 zip_fclose(3),
136 zip_fread(3),
137 zip_get_num_entries(3),
138 zip_name_locate(3),
139 zip_set_default_password(3)
140 .SH "AUTHORS"
141
142 Dieter Baron <dillo@giga.or.at>
143 and
144 Thomas Klausner <tk@giga.or.at>