Merge pull request #4011 from fritsch/vdpau-settings
[vuplus_xbmc] / lib / UnrarXLib / headers.hpp
1 #ifndef _RAR_HEADERS_
2 #define _RAR_HEADERS_
3
4 #define  SIZEOF_MARKHEAD         7
5 #define  SIZEOF_OLDMHD           7
6 #define  SIZEOF_NEWMHD          13
7 #define  SIZEOF_OLDLHD          21
8 #define  SIZEOF_NEWLHD          32
9 #define  SIZEOF_SHORTBLOCKHEAD   7
10 #define  SIZEOF_LONGBLOCKHEAD   11
11 #define  SIZEOF_SUBBLOCKHEAD    14
12 #define  SIZEOF_COMMHEAD        13
13 #define  SIZEOF_PROTECTHEAD     26
14 #define  SIZEOF_AVHEAD          14
15 #define  SIZEOF_SIGNHEAD        15
16 #define  SIZEOF_UOHEAD          18
17 #define  SIZEOF_MACHEAD         22
18 #define  SIZEOF_EAHEAD          24
19 #define  SIZEOF_BEEAHEAD        24
20 #define  SIZEOF_STREAMHEAD      26
21
22 #define  PACK_VER               29
23 #define  PACK_CRYPT_VER         29
24 #define  UNP_VER                29
25 #define  CRYPT_VER              29
26 #define  AV_VER                 20
27 #define  PROTECT_VER            20
28
29 #define  MHD_VOLUME         0x0001
30 #define  MHD_COMMENT        0x0002
31 #define  MHD_LOCK           0x0004
32 #define  MHD_SOLID          0x0008
33 #define  MHD_PACK_COMMENT   0x0010
34 #define  MHD_NEWNUMBERING   0x0010
35 #define  MHD_AV             0x0020
36 #define  MHD_PROTECT        0x0040
37 #define  MHD_PASSWORD       0x0080
38 #define  MHD_FIRSTVOLUME    0x0100
39
40 #define  LHD_SPLIT_BEFORE   0x0001
41 #define  LHD_SPLIT_AFTER    0x0002
42 #define  LHD_PASSWORD       0x0004
43 #define  LHD_COMMENT        0x0008
44 #define  LHD_SOLID          0x0010
45
46 #define  LHD_WINDOWMASK     0x00e0
47 #define  LHD_WINDOW64       0x0000
48 #define  LHD_WINDOW128      0x0020
49 #define  LHD_WINDOW256      0x0040
50 #define  LHD_WINDOW512      0x0060
51 #define  LHD_WINDOW1024     0x0080
52 #define  LHD_WINDOW2048     0x00a0
53 #define  LHD_WINDOW4096     0x00c0
54 #define  LHD_DIRECTORY      0x00e0
55
56 #define  LHD_LARGE          0x0100
57 #define  LHD_UNICODE        0x0200
58 #define  LHD_SALT           0x0400
59 #define  LHD_VERSION        0x0800
60 #define  LHD_EXTTIME        0x1000
61 #define  LHD_EXTFLAGS       0x2000
62
63 #define  SKIP_IF_UNKNOWN    0x4000
64 #define  LONG_BLOCK         0x8000
65
66 #define  EARC_NEXT_VOLUME   0x0001
67 #define  EARC_DATACRC       0x0002
68 #define  EARC_REVSPACE      0x0004
69 #define  EARC_VOLNUMBER     0x0008
70
71 enum HEADER_TYPE {
72   MARK_HEAD=0x72,MAIN_HEAD=0x73,FILE_HEAD=0x74,COMM_HEAD=0x75,AV_HEAD=0x76,
73   SUB_HEAD=0x77,PROTECT_HEAD=0x78,SIGN_HEAD=0x79,NEWSUB_HEAD=0x7a,
74   ENDARC_HEAD=0x7b
75 };
76
77 enum { EA_HEAD=0x100,UO_HEAD=0x101,MAC_HEAD=0x102,BEEA_HEAD=0x103,
78        NTACL_HEAD=0x104,STREAM_HEAD=0x105 };
79
80 enum HOST_SYSTEM {
81   HOST_MSDOS=0,HOST_OS2=1,HOST_WIN32=2,HOST_UNIX=3,HOST_MACOS=4,
82   HOST_BEOS=5,HOST_MAX
83 };
84
85 #define SUBHEAD_TYPE_CMT      "CMT"
86 #define SUBHEAD_TYPE_ACL      "ACL"
87 #define SUBHEAD_TYPE_STREAM   "STM"
88 #define SUBHEAD_TYPE_UOWNER   "UOW"
89 #define SUBHEAD_TYPE_AV       "AV"
90 #define SUBHEAD_TYPE_RR       "RR"
91 #define SUBHEAD_TYPE_OS2EA    "EA2"
92 #define SUBHEAD_TYPE_BEOSEA   "EABE"
93
94 /* new file inherits a subblock when updating a host file */
95 #define SUBHEAD_FLAGS_INHERITED    0x80000000
96
97 #define SUBHEAD_FLAGS_CMT_UNICODE  0x00000001
98
99 struct OldMainHeader
100 {
101   byte Mark[4];
102   ushort HeadSize;
103   byte Flags;
104 };
105
106
107 struct OldFileHeader
108 {
109   uint PackSize;
110   uint UnpSize;
111   ushort FileCRC;
112   ushort HeadSize;
113   uint FileTime;
114   byte FileAttr;
115   byte Flags;
116   byte UnpVer;
117   byte NameSize;
118   byte Method;
119 };
120
121
122 struct MarkHeader
123 {
124   byte Mark[7];
125 };
126
127
128 struct BaseBlock
129 {
130   ushort HeadCRC;
131   HEADER_TYPE HeadType;//byte
132   ushort Flags;
133   ushort HeadSize;
134
135   bool IsSubBlock()
136   {
137     if (HeadType==SUB_HEAD)
138       return(true);
139     if (HeadType==NEWSUB_HEAD && (Flags & LHD_SOLID)!=0)
140       return(true);
141     return(false);
142   }
143 };
144
145 struct BlockHeader:BaseBlock
146 {
147   union {
148     uint DataSize;
149     uint PackSize;
150   };
151 };
152
153
154 struct MainHeader:BlockHeader
155 {
156   ushort HighPosAV;
157   uint PosAV;
158 };
159
160
161 #define SALT_SIZE     8
162
163 struct FileHeader:BlockHeader
164 {
165   uint UnpSize;
166   byte HostOS;
167   uint FileCRC;
168   uint FileTime;
169   byte UnpVer;
170   byte Method;
171   ushort NameSize;
172   union {
173     uint FileAttr;
174     uint SubFlags;
175   };
176 /* optional */
177   uint HighPackSize;
178   uint HighUnpSize;
179 /* names */
180   char FileName[NM];
181   wchar FileNameW[NM];
182 /* optional */
183   Array<byte> SubData;
184   byte Salt[SALT_SIZE];
185
186   RarTime mtime;
187   RarTime ctime;
188   RarTime atime;
189   RarTime arctime;
190 /* dummy */
191   Int64 FullPackSize;
192   Int64 FullUnpSize;
193
194   void Clear(int SubDataSize)
195   {
196     SubData.Alloc(SubDataSize);
197     Flags=LONG_BLOCK;
198     SubFlags=0;
199   }
200
201   bool CmpName(const char *Name)
202   {
203     return(strcmp(FileName,Name)==0);
204   }
205
206   FileHeader& operator = (FileHeader &hd)
207   {
208     SubData.Reset();
209     memcpy(this,&hd,sizeof(*this));
210     SubData.CleanData();
211     SubData=hd.SubData;
212     return(*this);
213   }
214 };
215
216
217 struct EndArcHeader:BaseBlock
218 {
219   uint ArcDataCRC;
220   ushort VolNumber;
221 };
222
223
224 struct SubBlockHeader:BlockHeader
225 {
226   ushort SubType;
227   byte Level;
228 };
229
230
231 struct CommentHeader:BaseBlock
232 {
233   ushort UnpSize;
234   byte UnpVer;
235   byte Method;
236   ushort CommCRC;
237 };
238
239
240 struct ProtectHeader:BlockHeader
241 {
242   byte Version;
243   ushort RecSectors;
244   uint TotalBlocks;
245   byte Mark[8];
246 };
247
248
249 struct AVHeader:BaseBlock
250 {
251   byte UnpVer;
252   byte Method;
253   byte AVVer;
254   uint AVInfoCRC;
255 };
256
257
258 struct SignHeader:BaseBlock
259 {
260   uint CreationTime;
261   ushort ArcNameSize;
262   ushort UserNameSize;
263 };
264
265
266 struct UnixOwnersHeader:SubBlockHeader
267 {
268   ushort OwnerNameSize;
269   ushort GroupNameSize;
270 /* dummy */
271   char OwnerName[NM];
272   char GroupName[NM];
273 };
274
275
276 struct EAHeader:SubBlockHeader
277 {
278   uint UnpSize;
279   byte UnpVer;
280   byte Method;
281   uint EACRC;
282 };
283
284
285 struct StreamHeader:SubBlockHeader
286 {
287   uint UnpSize;
288   byte UnpVer;
289   byte Method;
290   uint StreamCRC;
291   ushort StreamNameSize;
292 /* dummy */
293   byte StreamName[NM];
294 };
295
296
297 struct MacFInfoHeader:SubBlockHeader
298 {
299   uint fileType;
300   uint fileCreator;
301 };
302
303
304 #endif