blob: 8b1c8141d67e8de58e33544338ae3888c960c2d3 [file] [log] [blame]
Thomas Klausner39b5f9e2005-06-09 21:14:54 +00001.\" $NiH: zip_fopen.mdoc,v 1.13 2005/06/09 21:13:12 wiz Exp $
Dieter Baron68d238c2003-10-03 11:19:03 +00002.\"
Thomas Klausner596733b2005-01-11 18:38:17 +00003.\" zip_fopen.mdoc -- open file in zip archive for reading
Thomas Klausnerbe31d742005-06-09 19:51:23 +00004.\" Copyright (C) 2003, 2004, 2005 Dieter Baron and Thomas Klausner
Dieter Baron68d238c2003-10-03 11:19:03 +00005.\"
6.\" This file is part of libzip, a library to manipulate ZIP archives.
7.\" The authors can be contacted at <nih@giga.or.at>
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\" 3. The names of the authors may not be used to endorse or promote
19.\" products derived from this software without specific prior
20.\" written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
23.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
26.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33.\"
Dieter Baronb2ed74d2004-04-14 14:01:31 +000034.Dd April 14, 2004
Dieter Baron68d238c2003-10-03 11:19:03 +000035.Dt ZIP_FOPEN 3
36.Os
37.Sh NAME
38.Nm zip_fopen ,
39.Nm zip_fopen_index
Thomas Klausnera477cb92003-10-03 23:39:49 +000040.Nd open file in zip archive for reading
Dieter Baron68d238c2003-10-03 11:19:03 +000041.Sh LIBRARY
Dieter Baronff551f12003-10-03 12:04:09 +000042libzip (-lzip)
Dieter Baron68d238c2003-10-03 11:19:03 +000043.Sh SYNOPSIS
44.In zip.h
45.Ft struct zip_file *
Dieter Baronb2ed74d2004-04-14 14:01:31 +000046.Fn zip_fopen "struct zip *archive" "const char *fname" "int flags"
Dieter Baron68d238c2003-10-03 11:19:03 +000047.Ft struct zip_file *
Dieter Baronb2ed74d2004-04-14 14:01:31 +000048.Fn zip_fopen_index "struct zip *archive" "int index" "int flags"
Dieter Baron68d238c2003-10-03 11:19:03 +000049.Sh DESCRIPTION
50The
51.Fn zip_fopen
52function opens the file name
53.Ar fname
54in
55.Ar archive .
Dieter Baron6486c332003-10-06 16:37:07 +000056The
57.Ar flags
Dieter Baronb2ed74d2004-04-14 14:01:31 +000058argument specifies how the name lookup should be done, according to
59the values are described in
Dieter Baron6486c332003-10-06 16:37:07 +000060.Xr zip_name_locate 3 .
Dieter Baronb2ed74d2004-04-14 14:01:31 +000061Also, the following values may be
62.Em or Ns No 'ed
63to it.
64.Bl -tag -offset indent -width ZIP_FL_COMPRESSED
65.It Dv ZIP_FL_COMPRESSED
Thomas Klausner8d19d682005-06-09 18:54:24 +000066Read the compressed data.
67Otherwise the data is uncompressed by
Dieter Baronb2ed74d2004-04-14 14:01:31 +000068.Fn zip_fread .
69.It Dv ZIP_FL_UNCHANGED
70Read the original data from the zip archive, ignoring any changes made
71to the file.
72.El
Dieter Baron68d238c2003-10-03 11:19:03 +000073.Pp
74The
75.Fn zip_fopen_index
76function opens the file at position
77.Ar index .
78.Sh RETURN VALUES
79Upon successful completion, a
80.Ft struct zip_file
81pointer is returned.
82Otherwise,
83.Dv NULL
Dieter Baronb2ed74d2004-04-14 14:01:31 +000084is returned and the error code in
85.Ar archive
Dieter Baron68d238c2003-10-03 11:19:03 +000086is set to indicate the error.
87.Sh ERRORS
88.Bl -tag -width Er
Thomas Klausnerd0147e92004-11-17 21:55:17 +000089.It Bq Er ZIP_ER_CHANGED
Dieter Baronb2ed74d2004-04-14 14:01:31 +000090The file data has been changed.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000091.It Bq Er ZIP_ER_COMPNOTSUPP
Dieter Baron68d238c2003-10-03 11:19:03 +000092The compression method used is not supported.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000093.It Bq Er ZIP_ER_MEMORY
Dieter Baron68d238c2003-10-03 11:19:03 +000094Required memory could not be allocated.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000095.It Bq Er ZIP_ER_READ
Dieter Baron68d238c2003-10-03 11:19:03 +000096A file read error occurred.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000097.It Bq Er ZIP_ER_SEEK
Dieter Baron68d238c2003-10-03 11:19:03 +000098A file seek error occurred.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000099.It Bq Er ZIP_ER_ZLIB
Dieter Baronb2ed74d2004-04-14 14:01:31 +0000100Initializing the zlib stream failed.
Dieter Baron68d238c2003-10-03 11:19:03 +0000101.El
102.Pp
103The function
104.Fn zip_fopen
105may also fail and set
106.Va zip_err
107for any of the errors specified for the routine
Thomas Klausnerf2938cc2003-10-03 23:36:10 +0000108.Xr zip_name_locate 3 .
Dieter Baron68d238c2003-10-03 11:19:03 +0000109.Pp
110The function
111.Fn zip_fopen_index
Dieter Baronb2ed74d2004-04-14 14:01:31 +0000112may also fail with
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000113.Er ZIP_ER_INVAL
Dieter Baron68d238c2003-10-03 11:19:03 +0000114if
115.Ar index
116is invalid.
117.Sh SEE ALSO
Thomas Klausnerbec1cfe2005-06-09 18:50:27 +0000118.Xr libzip 3 ,
Dieter Baron68d238c2003-10-03 11:19:03 +0000119.Xr zip_fclose 3 ,
120.Xr zip_fread 3 ,
Thomas Klausnerf2938cc2003-10-03 23:36:10 +0000121.Xr zip_name_locate 3
Thomas Klausnera456cf52005-06-09 21:13:13 +0000122.Sh AUTHORS
123.An -nosplit
124.An Dieter Baron Aq dillo@giga.or.at
Thomas Klausner39b5f9e2005-06-09 21:14:54 +0000125and
Thomas Klausnera456cf52005-06-09 21:13:13 +0000126.An Thomas Klausner Aq tk@giga.or.at