aboutsummaryrefslogtreecommitdiff
path: root/project/src/lib-xbmg.h
blob: a21c8a605facc7501a8cb4534aa5b8b3ceec3c60 (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
140
141
142
143
144
145
146
147
148
149

/***************************************************************************
 *                         _______ _______ _______                         *
 *                        |  ___  |____   |  ___  |                        *
 *                        | |   |_|    / /| |   |_|                        *
 *                        | |_____    / / | |_____                         *
 *                        |_____  |  / /  |_____  |                        *
 *                         _    | | / /    _    | |                        *
 *                        | |___| |/ /____| |___| |                        *
 *                        |_______|_______|_______|                        *
 *                                                                         *
 *                            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-2023 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 BMG files:
//	https://wiki.tockdom.de/index.php?title=BMG

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

#ifndef SZS_LIB_BMG_H
#define SZS_LIB_BMG_H 1

#include "lib-bmg.h"
#include "lib-std.h"

//
///////////////////////////////////////////////////////////////////////////////
///////////////			struct bmg_t			///////////////
///////////////////////////////////////////////////////////////////////////////

void SetupBMG ( ccp opt_msg );

enumError LoadXBMG
(
    bmg_t		* bmg,		// pointer to valid bmg
    bool		initialize,	// true: initialize 'bmg'
    ccp			fname,		// filename of source
    bool		allow_archive,	// true: concat BMGs of archives to 1 source
    bool		ignore_no_file	// ignore if file does not exists
					// and return warning ERR_NOT_EXISTS
);

struct raw_data_t;
enumError ScanRawDataBMG
(
    bmg_t		* bmg,		// BMG data structure
    bool		init_bmg,	// true: initialize 'bmg' first
    struct raw_data_t	* raw		// valid raw data
);

static inline file_format_t GetFF_BMG ( const bmg_t * bmg )
{
    DASSERT(bmg);
    return bmg->is_text_src ? FF_BMG_TXT : FF_BMG;
}

static inline ccp GetNameFF_BMG ( const bmg_t * bmg )
{
    DASSERT(bmg);
    return GetNameFF( bmg->is_text_src ? FF_BMG_TXT : FF_BMG, 0 );
}

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

enumError SaveRawXBMG
(
    bmg_t		* bmg,		// pointer to valid bmg
    ccp			fname,		// filename of destination
    bool		set_time	// true: set time stamps
);

enumError SaveTextXBMG
(
    bmg_t		* bmg,		// pointer to valid bmg
    ccp			fname,		// filename of destination
    bool		set_time	// true: set time stamps
);

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

extern int have_bmg_patch_count;

int ScanOptPatchMessage ( ccp arg );
int ScanOptMacroBMG ( ccp arg );
enumError SetupPatchingListBMG();
void ResetPatchingListBMG();
enumError UsePatchingListBMG ( bmg_t * dest );
uint ListPatchingListBMG ( FILE *f, int indent, ccp title );
ccp GetPatchNameBMG ( uint cmd );


enumError DiffBMG
(
    const bmg_t		* bmg1,		// first bmg
    const bmg_t		* bmg2,		// second bmg
    bool		quiet,		// true: be quiet
    int			width		// width out output lines
);

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

int ScanOptBmgEndian	( ccp arg );
int ScanOptBmgEncoding	( ccp arg );
int ScanOptBmgInfSize	( ccp arg, bool is_wbmgt );
int ScanOptBmgMid	( ccp arg );
int ScanOptForceAttrib	( ccp arg );
int ScanOptDefAttrib	( ccp arg );
int ScanOptLoadBMG	( ccp arg );

extern bmg_t opt_load_bmg;
extern bool opt_patch_names;

int ScanOptFilterBMG ( ccp arg );

#define MAX_FILTER_MSG 0x10000
extern u8 * filter_message; // NULL or field with 'MAX_FILTER_MSG' elements

enumError cmd_bmg_cat ( bool mix );
enumError cmd_bmg_identifier();

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

#endif // SZS_LIB_BMG_H