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