* src/vm/suck.c: Moved to .cpp.
[cacao.git] / src / vm / zip.h
1 /* src/vm/zip.c - ZIP file handling for bootstrap classloader
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _ZIP_H
27 #define _ZIP_H
28
29 #include "config.h"
30 #include "vm/types.h"
31
32 #include "toolbox/hashtable.h"
33
34 #include "vm/class.h"
35 #include "vm/global.h"
36 #include "vm/loader.hpp"
37 #include "vm/suck.hpp"
38 #include "vm/utf8.h"
39
40
41 /* Local file header ***********************************************************
42
43    local file header signature     4 bytes  (0x04034b50)
44    version needed to extract       2 bytes
45    general purpose bit flag        2 bytes
46    compression method              2 bytes
47    last mod file time              2 bytes
48    last mod file date              2 bytes
49    crc-32                          4 bytes
50    compressed size                 4 bytes
51    uncompressed size               4 bytes
52    file name length                2 bytes
53    extra field length              2 bytes
54
55    file name (variable size)
56    extra field (variable size)
57
58 *******************************************************************************/
59
60 #define LFH_HEADER_SIZE              30
61
62 #define LFH_SIGNATURE                0x04034b50
63 #define LFH_FILE_NAME_LENGTH         26
64 #define LFH_EXTRA_FIELD_LENGTH       28
65
66 typedef struct lfh lfh;
67
68 struct lfh {
69         u2 compressionmethod;
70         u4 compressedsize;
71         u4 uncompressedsize;
72         u2 filenamelength;
73         u2 extrafieldlength;
74 };
75
76 /* hashtable_zipfile_entry ****************************************************/
77
78 typedef struct hashtable_zipfile_entry hashtable_zipfile_entry;
79
80 struct hashtable_zipfile_entry {
81         utf                     *filename;
82         u2                       compressionmethod;
83         u4                       compressedsize;
84         u4                       uncompressedsize;
85         u1                      *data;
86         hashtable_zipfile_entry *hashlink;
87 };
88
89
90 /* function prototypes ********************************************************/
91
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95
96 hashtable *zip_open(char *path);
97 hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u);
98 classbuffer *zip_get(list_classpath_entry *lce, classinfo *c);
99
100 #ifdef __cplusplus
101 }
102 #endif
103
104 #endif /* _ZIP_H */
105
106
107 /*
108  * These are local overrides for various environment variables in Emacs.
109  * Please do not remove this and leave it at the end of the file, where
110  * Emacs will automagically detect them.
111  * ---------------------------------------------------------------------
112  * Local variables:
113  * mode: c
114  * indent-tabs-mode: t
115  * c-basic-offset: 4
116  * tab-width: 4
117  * End:
118  */