~ubuntu-branches/ubuntu/wily/luatex/wily

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/zziplib/zzip/memdisk.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-04-29 00:47:19 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100429004719-o42etkqe90n97b9e
Tags: 0.60.1-1
* new upstream release, adapt build-script patch
* disable patch: upstream-epstopdf_cc_no_xpdf_patching, included upstream
* disable patch: libpoppler-0.12, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __ZZIP_MEMDISK_H
2
 
#define __ZZIP_MEMDISK_H
3
 
 
4
 
/* NOTE: this is part of libzzipmmapped (i.e. it is not libzzip). */
5
 
 
6
 
#include <zzip/types.h>
7
 
#include <zzip/mmapped.h>
8
 
 
9
 
typedef struct _zzip_mem_disk ZZIP_MEM_DISK;
10
 
typedef struct _zzip_mem_entry ZZIP_MEM_ENTRY;
11
 
 
12
 
struct _zzip_mem_disk {
13
 
    ZZIP_DISK* disk;
14
 
    ZZIP_MEM_ENTRY* list;
15
 
    ZZIP_MEM_ENTRY* last;
16
 
};
17
 
 
18
 
#ifndef zzip_mem_disk_extern
19
 
#define zzip_mem_disk_extern
20
 
#endif
21
 
 
22
 
zzip_mem_disk_extern zzip__new__ ZZIP_MEM_DISK*
23
 
zzip_mem_disk_new (void);
24
 
zzip_mem_disk_extern zzip__new__ ZZIP_MEM_DISK*
25
 
zzip_mem_disk_open (char* filename);
26
 
zzip_mem_disk_extern zzip__new__ ZZIP_MEM_DISK*
27
 
zzip_mem_disk_fdopen (int fd);
28
 
zzip_mem_disk_extern void 
29
 
zzip_mem_disk_close (ZZIP_MEM_DISK* _zzip_restrict dir);
30
 
 
31
 
zzip_mem_disk_extern long
32
 
zzip_mem_disk_load (ZZIP_MEM_DISK* dir, ZZIP_DISK* disk);
33
 
zzip_mem_disk_extern void 
34
 
zzip_mem_disk_unload (ZZIP_MEM_DISK* dir);
35
 
ZZIP_EXTRA_BLOCK*
36
 
zzip_mem_entry_extra_block (ZZIP_MEM_ENTRY* entry, short datatype);
37
 
 
38
 
#ifdef USE_INLINE
39
 
_zzip_inline ZZIP_DISK* zzip_disk (ZZIP_MEM_DISK* dir) { return dir->disk; }
40
 
#else
41
 
#define zzip_disk(_X_) ((_X_)->disk)
42
 
#endif
43
 
 
44
 
 
45
 
/* these functions are much faster than the orgiinal zzip_disk_ functions */
46
 
 
47
 
/* zzip_mem_entry <is similar to> zzip_disk_entry */
48
 
struct _zzip_mem_entry {
49
 
    struct _zzip_mem_entry* zz_next;
50
 
    char*            zz_name;      /* zero-terminated (from "filename") */
51
 
    zzip_byte_t*     zz_data;      /* compressed content start (mmap addr) */
52
 
    int              zz_flags;     /* (from "z_flags") */
53
 
    int              zz_compr;     /* (from "z_compr") */
54
 
    long             zz_mktime;    /* (from "z_dostime") */
55
 
    long             zz_crc32;     /* (from "z_crc32") */
56
 
    zzip_off_t       zz_csize;     /* (from "z_csize")  overridden by zip64 */
57
 
    zzip_off_t       zz_usize;     /* (from "z_usize")  overridden by zip64 */
58
 
    zzip_off_t       zz_offset;    /* (from "z_offset") overridden by zip64 */
59
 
    int              zz_diskstart; /* (from "z_diskstart") rridden by zip64 */
60
 
    int              zz_filetype;  /* (from "z_filetype") */
61
 
    char*            zz_comment;   /* zero-terminated (from "comment") */
62
 
    ZZIP_EXTRA_BLOCK* zz_ext[3];   /* terminated by null in z_datatype */
63
 
};                                 /* the extra blocks are NOT converted */
64
 
     
65
 
#define _zzip_mem_disk_findfirst(_d_) ((_d_)->list)
66
 
#define _zzip_mem_disk_findnext(_d_,_e_) (!(_e_)?(_d_)->list:(_e_)->zz_next)
67
 
#define _zzip_mem_entry_findnext(_e_) ((_e_)->zz_next)
68
 
 
69
 
#ifndef USE_INLINE
70
 
#define zzip_mem_disk_findfirst _zzip_mem_disk_findfirst
71
 
#define zzip_mem_disk_findnext _zzip_mem_disk_findnext
72
 
#define zzip_mem_entry_findnext _zzip_mem_entry_findnext
73
 
#else
74
 
 
75
 
_zzip_inline ZZIP_MEM_ENTRY*
76
 
zzip_mem_disk_findfirst(ZZIP_MEM_DISK* dir) {
77
 
    if (! dir) return 0;
78
 
    return _zzip_mem_disk_findfirst(dir); }
79
 
_zzip_inline ZZIP_MEM_ENTRY*
80
 
zzip_mem_disk_findnext(ZZIP_MEM_DISK* dir, ZZIP_MEM_ENTRY* entry) {
81
 
    if (! dir) return 0;
82
 
    return _zzip_mem_disk_findnext(dir, entry); }
83
 
_zzip_inline ZZIP_MEM_ENTRY*
84
 
zzip_mem_entry_findnext(ZZIP_MEM_ENTRY* entry) {
85
 
    if (! entry) return 0;
86
 
    return _zzip_mem_entry_findnext(entry); }
87
 
#endif
88
 
 
89
 
#define _zzip_mem_entry_to_name(_e_) ((_e_)->zz_name)
90
 
#define _zzip_mem_entry_to_comment(_e_) ((_e_)->zz_comment)
91
 
#define _zzip_mem_entry_strdup_name(_e_) (strdup((_e_)->zz_name))
92
 
#define _zzip_mem_entry_to_data(_e_) ((_e_)->zz_data)
93
 
 
94
 
#ifndef USE_INLINE
95
 
#define zzip_mem_entry_to_name _zzip_mem_entry_to_name
96
 
#define zzip_mem_entry_to_comment _zzip_mem_entry_to_comment
97
 
#define zzip_mem_entry_strdup_name _zzip_mem_entry_strdup_name
98
 
#define zzip_mem_entry_to_data _zzip_mem_entry_to_data
99
 
#else
100
 
_zzip_inline char*
101
 
zzip_mem_entry_to_name(ZZIP_MEM_ENTRY* entry) {
102
 
    if (! entry) return 0;
103
 
    return _zzip_mem_entry_to_name(entry); }
104
 
_zzip_inline char*
105
 
zzip_mem_entry_to_comment(ZZIP_MEM_ENTRY* entry) {
106
 
    if (! entry) return 0;
107
 
    return _zzip_mem_entry_to_comment(entry); }
108
 
zzip__new__
109
 
_zzip_inline char*
110
 
zzip_mem_entry_strdup_name(ZZIP_MEM_ENTRY* entry) {
111
 
    if (! entry) return 0;
112
 
    return _zzip_mem_entry_strdup_name(entry); }
113
 
_zzip_inline zzip_byte_t*
114
 
zzip_mem_entry_to_data(ZZIP_MEM_ENTRY* entry) {
115
 
    if (! entry) return 0;
116
 
    return _zzip_mem_entry_to_data(entry); }
117
 
#endif
118
 
 
119
 
ZZIP_MEM_ENTRY*
120
 
zzip_mem_disk_findfile(ZZIP_MEM_DISK* dir, 
121
 
                       char* filename, ZZIP_MEM_ENTRY* after,
122
 
                       zzip_strcmp_fn_t compare);
123
 
 
124
 
ZZIP_MEM_ENTRY*
125
 
zzip_mem_disk_findmatch(ZZIP_MEM_DISK* dir, 
126
 
                        char* filespec, ZZIP_MEM_ENTRY* after,
127
 
                        zzip_fnmatch_fn_t compare, int flags);
128
 
 
129
 
/* named access -------------------------------------------------------- */
130
 
#define zzip_mem_entry_usize(_e_) ((_e_)->zz_usize)
131
 
#define zzip_mem_entry_csize(_e_) ((_e_)->zz_csize)
132
 
#define zzip_mem_entry_data_encrypted(_e_) ZZIP_IS_ENCRYPTED((_e_)->zz_flags)
133
 
#define zzip_mem_entry_data_streamed(_e_) ZZIP_IS_STREAMED((_e_)->zz_flags)
134
 
#define zzip_mem_entry_data_comprlevel(_e_) ((_e_)->zz_compr)
135
 
#define zzip_mem_entry_data_stored(_e_) ((_e_)->zz_compr == ZZIP_IS_STORED)
136
 
#define zzip_mem_entry_data_deflated(_e_) ((_e_)->zz_compr == ZZIP_IS_DEFLATED)
137
 
 
138
 
/* zzip_mem_disk_file -------------------------------------------------- */
139
 
 
140
 
/* since only the header data is being cached, all the real data
141
 
 * operations are actually the same as in mmapped.h - just fopen makes
142
 
 * access to the header data in memory instead of the zip archive.
143
 
 */
144
 
 
145
 
typedef ZZIP_DISK_FILE ZZIP_MEM_DISK_FILE;
146
 
 
147
 
zzip__new__ ZZIP_MEM_DISK_FILE*
148
 
zzip_mem_entry_fopen (ZZIP_MEM_DISK* dir, ZZIP_MEM_ENTRY* entry);
149
 
zzip__new__ ZZIP_MEM_DISK_FILE*
150
 
zzip_mem_disk_fopen (ZZIP_MEM_DISK* dir, char* filename);
151
 
_zzip_size_t
152
 
zzip_mem_disk_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb,
153
 
                     ZZIP_MEM_DISK_FILE* file);
154
 
int
155
 
zzip_mem_disk_fclose (ZZIP_MEM_DISK_FILE* file);
156
 
int
157
 
zzip_mem_disk_feof (ZZIP_MEM_DISK_FILE* file);
158
 
 
159
 
/* convert dostime of entry to unix time_t */
160
 
long zzip_disk_entry_get_mktime(ZZIP_DISK_ENTRY* entry);
161
 
 
162
 
#endif