11be7981c4736051dba5b8c114ba9193a1d6c39c
[profile/ivi/navit.git] / navit / navit / zipfile.h
1 /**
2  * Navit, a modular navigation system.
3  * Copyright (C) 2005-2008 Navit Team
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef __ZIPFILE_H__
21 #define __ZIPFILE_H__
22
23 #ifdef HAVE_PRAGMA_PACK
24 #pragma pack(push)
25 #pragma pack(1)
26 #endif
27
28 #ifdef  __GNUC__
29 #define ATTRIBUTE_PACKED __attribute__ ((packed))
30 #else
31 #define ATTRIBUTE_PACKED
32 #endif
33
34 #define zip_split_sig 0x08074b50
35 #define zip_split_sig_rev 0x504b0708
36
37 struct zip_split {
38         int zipsplitsig;
39 };
40
41 #define zip_lfh_sig 0x04034b50
42 #define zip_lfh_sig_rev 0x504b0304
43
44 struct zip_lfh {
45         int ziplocsig;
46         short zipver;           // 4
47         short zipgenfld;        // 6
48         short zipmthd;          // 8
49         short ziptime;          // 10
50         short zipdate;          // 12
51         int zipcrc;             // 14
52         unsigned int zipsize;  // 18
53         unsigned int zipuncmp; // 22
54         unsigned short zipfnln; // 26
55         unsigned short zipxtraln; // 30
56         char zipname[0]; // 34
57 } ATTRIBUTE_PACKED;
58
59 #define zip_cd_sig 0x02014b50
60 #define zip_cd_sig_rev 0x504b0102
61
62 struct zip_cd {
63         int zipcensig;
64         char zipcver;
65         char zipcos;
66         char zipcvxt;
67         char zipcexos;
68         short zipcflg;
69         short zipcmthd;
70         short ziptim;
71         short zipdat;
72         int zipccrc;
73         unsigned int zipcsiz;
74         unsigned int zipcunc;
75         unsigned short zipcfnl;
76         unsigned short zipcxtl;
77         unsigned short zipccml;
78         unsigned short zipdsk;
79         unsigned short zipint;
80         unsigned int zipext;
81         unsigned int zipofst;
82         char zipcfn[0]; 
83 } ATTRIBUTE_PACKED;
84
85 struct zip_cd_ext {
86         short tag;
87         short size;
88         unsigned long long zipofst;
89 } ATTRIBUTE_PACKED;
90
91 struct zip_enc {
92         short efield_header;
93         short efield_size;
94         short version;
95         char vendor_id1,vendor_id2;
96         char encryption_strength;
97         short compress_method; 
98 } ATTRIBUTE_PACKED;
99
100 #define zip_eoc_sig 0x6054b50
101 #define zip_eoc_sig_rev 0x504b0506
102
103 struct zip_eoc {
104         int zipesig;            /* end of central dir signature */
105         unsigned short zipedsk; /* number of this disk */
106         unsigned short zipecen; /* number of the disk with the start of the central directory */
107         unsigned short zipenum; /* total number of entries in the central directory on this disk */
108         unsigned short zipecenn; /* total number of entries in the central directory */
109         unsigned int zipecsz;   /* size of the central directory */
110         unsigned int zipeofst;  /* offset of start of central directory with respect to the starting disk number */
111         short zipecoml;         /* .ZIP file comment length */
112         char zipecom[0];        /* .ZIP file comment */
113 } ATTRIBUTE_PACKED;
114
115 #define zip64_eoc_sig 0x6064b50
116 #define zip64_eoc_sig_rev 0x504b0606
117
118 struct zip64_eoc {
119         int zip64esig;                  /* zip64 end of central dir signature */
120         unsigned long long zip64esize;  /* size of zip64 end of central directory record */
121         unsigned short zip64ever;       /* version made by */
122         unsigned short zip64eneed;      /* version needed to extract */
123         unsigned int zip64edsk;         /* number of this disk */
124         unsigned int zip64ecen;         /* number of the disk with the start of the central directory */
125         unsigned long long zip64enum;   /* total number of entries in the central directory on this disk */
126         unsigned long long zip64ecenn;  /* total number of entries in the central directory */
127         unsigned long long zip64ecsz;   /* size of the central directory */
128         unsigned long long zip64eofst;  /* offset of start of central directory with respect to the starting disk number */
129         char zip64ecom[0];              /* zip64 extensible data sector */
130 } ATTRIBUTE_PACKED;
131
132 #define zip64_eocl_sig 0x07064b50
133
134 struct zip64_eocl {
135         int zip64lsig;
136         int zip64ldsk;
137         long long zip64lofst;
138         int zip74lnum;
139 } ATTRIBUTE_PACKED;
140
141 struct zip_alignment_check {
142         int x[sizeof(struct zip_cd) == 46 ? 1:-1];
143 };
144
145 #ifdef HAVE_PRAGMA_PACK
146 #pragma pack(pop)
147 #endif
148 #endif