Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RAR.h - github.com/mpc-hc/rarfilesource.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/RAR.h
blob: 40f28cae28c063324af837ef1531c89502d8e705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * Copyright (C) 2008-2012, OctaneSnail <os@v12pwr.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef RAR_H
#define RAR_H

#include "RAR_defines.h"

#define HEADER_TYPE_MARKER		0x72
#define HEADER_TYPE_ARCHIVE		0x73
#define HEADER_TYPE_FILE		0x74
#define HEADER_TYPE_SUBBLOCK	0x77
#define HEADER_TYPE_RECOVERY	0x78
#define HEADER_TYPE_NEWSUBLOCK	0x7a
#define HEADER_TYPE_END			0x7b

#pragma pack (push, 1)

// Fixed size parts of the in file headers.

typedef struct
{
	WORD crc;
	BYTE type;
	WORD flags;
	WORD size;
} fixed_header_t;

typedef struct
{
	DWORD packedSize;
	DWORD size;
	BYTE  os;
	DWORD crc;
	DWORD timestamp;
	BYTE  version;
	BYTE  method;
	WORD  name_len;
	DWORD attributes;
} fixed_file_header_t;

#pragma pack (pop)

// In memory representation

typedef struct
{
	WORD crc;
	BYTE type;
	WORD flags;
	LARGE_INTEGER size;
} common_header_t;

typedef struct
{
	WORD reserved1;
	DWORD reserved2;
} archive_header_t;

typedef struct
{
	LARGE_INTEGER size;

	DWORD   crc;
	DWORD   timestamp;
	DWORD   timestamp_ext;
	DWORD   attributes;
	DWORD   name_len;

	char    *filename;

	BYTE    os;
	BYTE    version;
	BYTE    method;

} file_header_t;

typedef struct
{
	DWORD crc;
	WORD  volume_number;
} end_header_t;

typedef struct
{
	common_header_t ch;

	union
	{
		archive_header_t ah;
		file_header_t fh;
		end_header_t eh;
	};

	LARGE_INTEGER bytesRemaining;
} rar_header_t;

DWORD ReadHeader (HANDLE file, rar_header_t *dest);

#endif // RAR_H