1ZZIP_ENTRY_FINDFILE(3)       zziplib Function List      ZZIP_ENTRY_FINDFILE(3)
2
3
4

NAME

6       zzip_entry_findfile, zzip_entry_findfirst, zzip_entry_findnext,
7       zzip_entry_free, zzip_entry_findmatch - search for files in the
8       (fseeko) zip central directory
9

SYNOPSIS

11       #include <zzip/fseeko.h>
12
13       zzip__new__ ZZIP_ENTRY *
14                                                    zzip_entry_findfile((FILE * disk, char *filename, ZZIP_ENTRY * _zzip_restrict entry, zzip_strcmp_fn_t compare));
15
16       zzip__new__ ZZIP_ENTRY * zzip_entry_findfirst((FILE * disk));
17
18       zzip__new__ ZZIP_ENTRY *
19                                                    zzip_entry_findnext((ZZIP_ENTRY * _zzip_restrict entry));
20
21       int zzip_entry_free((ZZIP_ENTRY * entry));
22
23       zzip__new__ ZZIP_ENTRY *
24                                                     zzip_entry_findmatch((FILE * disk, char *filespec, ZZIP_ENTRY * _zzip_restrict entry, zzip_fnmatch_fn_t compare, int flags));
25

DESCRIPTION

27       The zzip_entry_findfile function is given a filename as an additional
28       argument, to find the disk_entry matching a given filename. The
29       compare-function is usually strcmp or strcasecmp or perhaps strcoll, if
30       null then strcmp is used. - use null as argument for "old"-entry when
31       searching the first matching entry, otherwise the last returned value
32       if you look for other entries with a special "compare" function (if
33       null then a doubled search is rather useless with this variant of
34       _findfile). If no further entry is found then null is returned and any
35       "old"-entry gets already free()d.
36
37       The zzip_entry_findfirst function is the first call of all the zip
38       access functions here. It contains the code to find the first entry of
39       the zip central directory. Here we require the stdio handle to
40       represent a real zip file where the disk_trailer is _last_ in the file
41       area, so that its position would be at a fixed offset from the end of
42       the file area if not for the comment field allowed to be of variable
43       length (which needs us to do a little search for the disk_tailer).
44       However, in this simple implementation we disregard any disk_trailer
45       info telling about multidisk archives, so we just return a pointer to
46       the first entry in the zip central directory of that file.
47
48       For an actual means, we are going to search backwards from the end of
49       the mmaped block looking for the PK-magic signature of a disk_trailer.
50       If we see one then we check the rootseek value to find the first
51       disk_entry of the root central directory. If we find the correct
52       PK-magic signature of a disk_entry over there then we assume we are
53       done and we are going to return a pointer to that label.
54
55       The return value is a pointer to the first zzip_disk_entry being
56       checked to be within the bounds of the file area specified by the
57       arguments. If no disk_trailer was found then null is returned, and
58       likewise we only accept a disk_trailer with a seekvalue that points to
59       a disk_entry and both parts have valid PK-magic parts. Beyond some
60       sanity check we try to catch a common brokeness with zip archives that
61       still allows us to find the start of the zip central directory.
62
63       The zzip_entry_findnext function takes an existing "entry" in the
64       central root directory (e.g. from zzip_entry_findfirst) and moves it to
65       point to the next entry. On error it returns 0, otherwise the old
66       entry. If no further match is found then null is returned and the entry
67       already free()d. If you want to stop searching for matches before that
68       case then please call zzip_entry_free on the cursor struct ZZIP_ENTRY.
69
70       the zzip_entry_free function releases the malloc()ed areas needed for
71       zzip_entry, the pointer is invalid afterwards. The zzip_entry_free
72       function has #define synonyms of zzip_entry_findlast(),
73       zzip_entry_findlastfile(), zzip_entry_findlastmatch()
74
75       The zzip_entry_findmatch function uses a compare-function with an
76       additional argument and it is called just like fnmatch(3) from POSIX.2
77       AD:1993), i.e. the argument filespec first and the ziplocal filename
78       second with the integer-flags put in as third to the indirect call. If
79       the platform has fnmatch available then null-compare will use that one
80       and otherwise we fall back to mere strcmp, so if you need fnmatch
81       searching then please provide an implementation somewhere else. - use
82       null as argument for "after"-entry when searching the first matching
83       entry, or the last disk_entry return-value to find the next entry
84       matching the given filespec. If no further entry is found then null is
85       returned and any "old"-entry gets already free()d.
86

AUTHOR

88       ยท   Guido Draheim <guidod@gmx.de>
89
91       Copyright (c) 2003,2004 Guido Draheim All rights reserved, use under
92       the restrictions of the Lesser GNU General Public License or
93       alternatively the restrictions of the Mozilla Public License 1.1
94
95
96
97zziplib                             0.13.62             ZZIP_ENTRY_FINDFILE(3)
Impressum