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
14       zzip__new__ ZZIP_ENTRY *
15       zzip_entry_findfile(FILE * disk, char *filename,
16                           ZZIP_ENTRY * _zzip_restrict entry, zzip_strcmp_fn_t compare)
17
18       zzip__new__ ZZIP_ENTRY *
19       zzip_entry_findfirst(FILE * disk)
20
21       zzip__new__ ZZIP_ENTRY *
22       zzip_entry_findnext(ZZIP_ENTRY * _zzip_restrict entry)
23
24       int
25       zzip_entry_free(ZZIP_ENTRY * entry)
26
27       zzip__new__ ZZIP_ENTRY *
28       zzip_entry_findmatch(FILE * disk, char *filespec,
29                            ZZIP_ENTRY * _zzip_restrict entry,
30                            zzip_fnmatch_fn_t compare, int flags)
31
32
33
34

DESCRIPTION

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

AUTHOR

102        Guido Draheim <guidod@gmx.de>
103
104
105
107        Copyright (c) Guido Draheim, use under copyleft (LGPL,MPL)
108
109
110
111
112
113zziplib                             0.13.72             zzip_entry_findfile(3)
Impressum