1ZZIP_DISK_FINDFILE(3) zziplib Function List ZZIP_DISK_FINDFILE(3)
2
3
4
6 zzip_disk_findfile, zzip_disk_findfirst, zzip_disk_findnext,
7 zzip_disk_findmatch - search for files in the (mmapped) zip central
8 directory
9
11 #include <zzip/mmapped.h>
12
13 struct zzip_disk_entry *
14 zzip_disk_findfile((ZZIP_DISK * disk, char *filename, struct zzip_disk_entry *after, zzip_strcmp_fn_t compare));
15
16 struct zzip_disk_entry * zzip_disk_findfirst((ZZIP_DISK * disk));
17
18 struct zzip_disk_entry *
19 zzip_disk_findnext((ZZIP_DISK * disk, struct zzip_disk_entry *entry));
20
21 struct zzip_disk_entry *
22 zzip_disk_findmatch((ZZIP_DISK * disk, char *filespec, struct zzip_disk_entry *after, zzip_fnmatch_fn_t compare, int flags));
23
25 The zzip_disk_findfile function is given a filename as an additional
26 argument, to find the disk_entry matching a given filename. The
27 compare-function is usually strcmp or strcasecmp or perhaps strcoll, if
28 null then strcmp is used. - use null as argument for "after"-entry when
29 searching the first matching entry, otherwise the last returned value
30 if you look for other entries with a special "compare" function (if
31 null then a doubled search is rather useless with this variant of
32 _findfile).
33
34 The zzip_disk_findfirst function is the first call of all the zip
35 access functions here. It contains the code to find the first entry of
36 the zip central directory. Here we require the mmapped block to
37 represent a real zip file where the disk_trailer is _last_ in the file
38 area, so that its position would be at a fixed offset from the end of
39 the file area if not for the comment field allowed to be of variable
40 length (which needs us to do a little search for the disk_tailer).
41 However, in this simple implementation we disregard any disk_trailer
42 info telling about multidisk archives, so we just return a pointer to
43 the zip central directory.
44
45 For an actual means, we are going to search backwards from the end of
46 the mmaped block looking for the PK-magic signature of a disk_trailer.
47 If we see one then we check the rootseek value to find the first
48 disk_entry of the root central directory. If we find the correct
49 PK-magic signature of a disk_entry over there then we assume we are
50 done and we are going to return a pointer to that label.
51
52 The return value is a pointer to the first zzip_disk_entry being
53 checked to be within the bounds of the file area specified by the
54 arguments. If no disk_trailer was found then null is returned, and
55 likewise we only accept a disk_trailer with a seekvalue that points to
56 a disk_entry and both parts have valid PK-magic parts. Beyond some
57 sanity check we try to catch a common brokeness with zip archives that
58 still allows us to find the start of the zip central directory.
59
60 The zzip_disk_findnext function takes an existing disk_entry in the
61 central root directory (e.g. from zzip_disk_findfirst) and returns the
62 next entry within in the given bounds of the mmapped file area.
63
64 The zzip_disk_findmatch function uses a compare-function with an
65 additional argument and it is called just like fnmatch(3) from POSIX.2
66 AD:1993), i.e. the argument filespec first and the ziplocal filename
67 second with the integer-flags put in as third to the indirect call. If
68 the platform has fnmatch available then null-compare will use that one
69 and otherwise we fall back to mere strcmp, so if you need fnmatch
70 searching then please provide an implementation somewhere else. - use
71 null as argument for "after"-entry when searching the first matching
72 entry, or the last disk_entry return-value to find the next entry
73 matching the given filespec.
74
76 ยท Guido Draheim <guidod@gmx.de>
77
79 Copyright (c) 2003,2004,2006 Guido Draheim All rights reserved, use
80 under the restrictions of the Lesser GNU General Public License or
81 alternatively the restrictions of the Mozilla Public License 1.1
82
83
84
85zziplib 0.13.62 ZZIP_DISK_FINDFILE(3)