aboutsummaryrefslogtreecommitdiff
path: root/project/src/lib-pack.h
blob: aa6ab754e98e2022504aa5e4445541f92635d4af (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

/***************************************************************************
 *                         _______ _______ _______                         *
 *                        |  ___  |____   |  ___  |                        *
 *                        | |   |_|    / /| |   |_|                        *
 *                        | |_____    / / | |_____                         *
 *                        |_____  |  / /  |_____  |                        *
 *                         _    | | / /    _    | |                        *
 *                        | |___| |/ /____| |___| |                        *
 *                        |_______|_______|_______|                        *
 *                                                                         *
 *                            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-2022 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       *
 *                                                                         *
 ***************************************************************************/

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

#ifndef SZS_LIB_PACK_H
#define SZS_LIB_PACK_H 1

#include "lib-szs.h"

//
///////////////////////////////////////////////////////////////////////////////
///////////////			PACK support			///////////////
///////////////////////////////////////////////////////////////////////////////

#define PACK_MAGIC		"PACK"
#define PACK_MAGIC_NUM		0x5041434b

#define PACK_METRIC_ALIGN	0x10
#define PACK_SUBFILE_ALIGN	0x20

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

typedef struct pack_header_t
{
    u32		magic;			// := PACK_MAGIC_NUM
    u32		file_size;		// total size of pack file
    u32		n_files;		// total number of subfiles
    u32		offset_metric;		// offset to (offset,size) table
    char	name_pool[0];		// pool with names
}
__attribute__ ((packed)) pack_header_t;

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

typedef struct pack_metric_t
{
    u32		offset;			// offset of subfile
    u32		size;			// size of subfile
}
__attribute__ ((packed)) pack_metric_t;

//
///////////////////////////////////////////////////////////////////////////////
///////////////			PACK interface			///////////////
///////////////////////////////////////////////////////////////////////////////

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

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

enumError CreatePACK
(
    szs_file_t		* szs,		// valid szs
    ccp			source_dir,	// NULL or path to source dir
    u8			* source_data,	// NULL or source data
    u32			total_size,	// total file size
    SetupParam_t	* setup_param	// NULL or setup parameters
);

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

#endif // SZS_LIB_PACK_H