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_findfirst function Returns null on error (errno =
64       EINVAL|ENOMEM|EBADMSG|EBADF|ENOENT)
65
66       The zzip_entry_findnext function takes an existing "entry" in the
67       central root directory (e.g. from zzip_entry_findfirst) and moves it to
68       point to the next entry. On error it returns 0, otherwise the old
69       entry. If no further match is found then null is returned and the entry
70       already free()d. If you want to stop searching for matches before that
71       case then please call zzip_entry_free on the cursor struct ZZIP_ENTRY.
72
73       the zzip_entry_free function releases the malloc()ed areas needed for
74       zzip_entry, the pointer is invalid afterwards. The zzip_entry_free
75       function has #define synonyms of zzip_entry_findlast(),
76       zzip_entry_findlastfile(), zzip_entry_findlastmatch()
77
78       The zzip_entry_findmatch function uses a compare-function with an
79       additional argument and it is called just like fnmatch(3) from POSIX.2
80       AD:1993), i.e. the argument filespec first and the ziplocal filename
81       second with the integer-flags put in as third to the indirect call. If
82       the platform has fnmatch available then null-compare will use that one
83       and otherwise we fall back to mere strcmp, so if you need fnmatch
84       searching then please provide an implementation somewhere else. - use
85       null as argument for "after"-entry when searching the first matching
86       entry, or the last disk_entry return-value to find the next entry
87       matching the given filespec. If no further entry is found then null is
88       returned and any "old"-entry gets already free()d.
89

AUTHOR

91       ยท   Guido Draheim <guidod@gmx.de>
92
94       Copyright (c) Guido Draheim, use under copyleft (LGPL,MPL)
95
96
97
98zziplib                             0.13.69             ZZIP_ENTRY_FINDFILE(3)
Impressum