aboutsummaryrefslogtreecommitdiff
path: root/project/src/lib-rarc.h
blob: 329bf66b062ad45d262bcdbfd4546835ac42d574 (plain) (blame)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

/***************************************************************************
 *                         _______ _______ _______                         *
 *                        |  ___  |____   |  ___  |                        *
 *                        | |   |_|    / /| |   |_|                        *
 *                        | |_____    / / | |_____                         *
 *                        |_____  |  / /  |_____  |                        *
 *                         _    | | / /    _    | |                        *
 *                        | |___| |/ /____| |___| |                        *
 *                        |_______|_______|_______|                        *
 *                                                                         *
 *                            Wiimms SZS Tools                             *
 *                          https://szs.wiimm.de/                          *
 *                                                                         *
 ***************************************************************************
 *                                                                         *
 *   This file is part of the SZS project.                                 *
 *   Visit https://szs.wiimm.de/ for project details and sources.          *
 *                                                                         *
 *   Copyright (c) 2011-2020 by Dirk Clemens <wiimm@wiimm.de>              *
 *                                                                         *
 ***************************************************************************
 *                                                                         *
 *   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.                          *
 *                                                                         *
 *   See file gpl-2.0.txt or http://www.gnu.org/licenses/gpl-2.0.txt       *
 *                                                                         *
 ***************************************************************************/

// all about SZS, YAZ0 and U8 files:
//	http://wiki.tockdom.de/index.php?title=SZS
//	http://wiki.tockdom.de/index.php?title=YAZ0
//	http://wiki.tockdom.de/index.php?title=U8

///////////////////////////////////////////////////////////////////////////////

#ifndef SZS_LIB_RARC_H
#define SZS_LIB_RARC_H 1

#include "lib-szs.h"

//
///////////////////////////////////////////////////////////////////////////////
///////////////			RARC support			///////////////
///////////////////////////////////////////////////////////////////////////////

#define RARC_MAGIC		"RARC"
#define RARC_MAGIC_NUM		0x52415243

///////////////////////////////////////////////////////////////////////////////
// http://hitmen.c02.at/files/yagcd/yagcd/chap15.html#sec15.3

typedef struct rarc_file_header_t
{
 /* 0x00 */   be32_t	magic;		// = RARC_MAGIC_NUM
 /* 0x04 */   be32_t	file_size;	// size of file
 /* 0x08 */   be32_t	header_off;	// offset of 'rarc_header_t'
 /* 0x0c */   be32_t	header_size;	// size of header

 /* 0x10 */   be32_t	unknown_10;	// perhaps padding
 /* 0x14 */   be32_t	unknown_14;	//   "
 /* 0x18 */   be32_t	unknown_18;	//   "
 /* 0x1c */   be32_t	unknown_1c;	//   "
}
__attribute__ ((packed)) rarc_file_header_t;

//-----------------------------------------------------------------------------

typedef struct rarc_header_t
{
 /* 0x00 */   be32_t	n_node;		// number of nodes
 /* 0x04 */   be32_t	root_off;	// offset of root
 /* 0x08 */   be32_t	n_entry;	// total number of entires
 /* 0x0c */   be32_t	entry_off;	// offset of file entries
 /* 0x10 */   be32_t	str_pool_size;	// size of string pool
 /* 0x14 */   be32_t	str_pool_off;	// offset of the string pool

 /* 0x18 */   be16_t	unknown_18;	// maybe == 'n_entry'
 /* 0x1a */   be16_t	unknown_1a;
 /* 0x1c */   be32_t	unknown_1c;
}
__attribute__ ((packed)) rarc_header_t;

//-----------------------------------------------------------------------------

typedef struct rarc_node_t
{
 /* 0x00 */   char	name[4];	// uppercase of first 4 chars of filename
					// 'ROOT' for very first node
 /* 0x04 */   be32_t	name_off;	// offset into string pool
 /* 0x08 */   be16_t	unknown_08;
 /* 0x0a */   be16_t	n_entry;	// number of entires
 /* 0x0c */   be32_t	entry_index;	// index of first entry
}
__attribute__ ((packed)) rarc_node_t;

//-----------------------------------------------------------------------------

typedef struct rarc_entry_t
{
 /* 0x00 */   be16_t	id;		// file: index of file == entry_number
					// dir:  0xffff
 /* 0x02 */   be16_t	unknown_02;	// ? checksum over filename
 /* 0x04 */   be16_t	unknown_04;	// ? file mode
					//  - 0200 : directories
					//  - 1100 : plain files
 /* 0x06 */   be16_t	name_off;	// offset into string pool
 /* 0x08 */   be32_t	data_off;	// file: offset of data,
					// dir:  index of node
 /* 0x0c */   be32_t	data_size;	// file: size of data
 /* 0x10 */   be32_t	unknown_10;	// ? always 0
}
__attribute__ ((packed)) rarc_entry_t;

//
///////////////////////////////////////////////////////////////////////////////
///////////////			RARC interface			///////////////
///////////////////////////////////////////////////////////////////////////////

int IterateFilesRARC
(
    struct szs_iterator_t	*it,	// iterator struct with all infos
    bool			term	// true: termination hint
);

//
///////////////////////////////////////////////////////////////////////////////
///////////////			    END				///////////////
///////////////////////////////////////////////////////////////////////////////

#endif // SZS_LIB_RARC_H