blob: 5a541197e2d8f4d0e400573a992a598ee4226271 [file] [log] [blame]
Thomas Klausner9a0e7f52012-06-24 01:55:03 +02001.\" zip_file_extra_field_get.mdoc -- get extra field for file in zip
Thomas Klausnerdf77dc62016-12-31 13:40:32 +01002.\" Copyright (C) 2012-2016 Dieter Baron and Thomas Klausner
Thomas Klausner9a0e7f52012-06-24 01:55:03 +02003.\"
4.\" This file is part of libzip, a library to manipulate ZIP files.
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.\"
Thomas Klausner654157e2014-10-08 10:46:39 +020032.Dd October 8, 2014
Thomas Klausner9a0e7f52012-06-24 01:55:03 +020033.Dt ZIP_FILE_EXTRA_FIELD_GET 3
34.Os
35.Sh NAME
36.Nm zip_file_extra_field_get ,
37.Nm zip_file_extra_field_get_by_id
38.Nd get extra field for file in zip
39.Sh LIBRARY
40libzip (-lzip)
41.Sh SYNOPSIS
42.In zip.h
43.Ft const zip_uint8_t *
Thomas Klausner9874efb2016-12-30 01:32:09 +010044.Fn zip_file_extra_field_get "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_index" "zip_uint16_t *idp" "zip_uint16_t *lenp" "zip_flags_t flags"
Thomas Klausner9a0e7f52012-06-24 01:55:03 +020045.Ft const zip_uint8_t *
Thomas Klausner9874efb2016-12-30 01:32:09 +010046.Fn zip_file_extra_field_get_by_id "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_id" "zip_uint16_t extra_field_index" "zip_uint16_t *lenp" "zip_flags_t flags"
Thomas Klausner9a0e7f52012-06-24 01:55:03 +020047.Sh DESCRIPTION
48The
49.Fn zip_file_extra_field_get
50function returns the extra field with index
51.Ar extra_field_index
52for the file at position
53.Ar index
54in the zip archive.
55This pointer should not be modified or
56.Xr free 3 Ap d ,
57and becomes invalid when
58.Ar archive
59is closed.
60If
61.Ar idp
62is not
63.Dv NULL ,
64the integer to which it points will be set to the ID (two-byte
65signature) of the selected extra field.
66If
67.Ar lenp
68is not
69.Dv NULL ,
70the integer to which it points will be set to the length of the
71extra field.
72Generally speaking,
73.Ar lenp
74and
75.Ar idp
76should be passed since only the extra field data is returned (i.e.,
77neither the ID nor the length, if the
78.Ar idp
79and
80.Ar lenp
81arguments are not provided).
82.Pp
Thomas Klausner23c30322013-02-20 12:32:39 +010083The following
84.Ar flags
85are supported:
86.Bl -tag -width ZIP_FL_UNCHANGEDXX -offset indent
Thomas Klausner954d5912012-06-25 12:18:19 +020087.It Dv ZIP_FL_CENTRAL
Thomas Klausner23c30322013-02-20 12:32:39 +010088Return extra fields from the archive's central directory.
Thomas Klausner954d5912012-06-25 12:18:19 +020089.It Dv ZIP_FL_LOCAL
Thomas Klausner23c30322013-02-20 12:32:39 +010090Return extra fields from the local file headers.
Thomas Klausner03ead842012-06-25 12:35:35 +020091.It Dv ZIP_FL_UNCHANGED
Dieter Barona94f4ab2012-06-25 15:26:02 +020092Return the original unchanged extra fields, ignoring any changes made.
Thomas Klausner9a0e7f52012-06-24 01:55:03 +020093.El
94.Pp
95The
96.Fn zip_file_extra_field_get_by_id
97function returns the extra field with ID (two-byte signature)
98.Ar extra_field_id
99and index
100.Ar extra_field_index
101(in other words, the
102.Ar extra_field_index Ns No 'th
103extra field with ID
104.Ar extra_field_id )
105The other arguments are the same as for
106.Fn zip_file_extra_field_get .
107.Sh RETURN VALUES
108Upon successful completion, a pointer to an extra field is returned,
109or
110.Dv NULL
111if there is no extra field with that
112.Ar extra_field_index
113for the file with index
114.Ar index .
115In case of an error,
116.Dv NULL
117is returned and the error code in
118.Ar archive
119is set to indicate the error.
120.Sh ERRORS
121.Fn zip_file_extra_field_get
122and
123.Fn zip_file_extra_field_get_by_id
124fail if:
125.Bl -tag -width Er
126.It Bq Er ZIP_ER_NOENT
127.Ar index
128is not a valid file index in
129.Ar archive ,
130or
131.Ar extra_field_index
132is not a valid extra file index (for ID
133.Ar extra_field_id ) .
134.El
135.Sh SEE ALSO
136.Xr libzip 3 ,
137.Xr zip_file_extra_field_delete 3 ,
138.Xr zip_file_extra_field_set 3 ,
139.Xr zip_file_extra_fields_count 3
140.Sh AUTHORS
141.An -nosplit
Thomas Klausner0acbab42013-07-28 23:29:08 +0200142.An Dieter Baron Aq Mt dillo@nih.at
Thomas Klausner9a0e7f52012-06-24 01:55:03 +0200143and
Thomas Klausner0acbab42013-07-28 23:29:08 +0200144.An Thomas Klausner Aq Mt tk@giga.or.at
Thomas Klausner654157e2014-10-08 10:46:39 +0200145.Sh CAVEATS
146Please note that the extra field IDs 0x0001 (ZIP64 extension),
1470x6375 (Infozip UTF-8 comment), and
1480x7075 (Infozip UTF-8 file name) can not be read using
149.Fn zip_file_extra_field_get
150since they are used by
151.Xr libzip 3
152internally.