1 |
dpavlin |
11 |
/* |
2 |
|
|
* HT Editor |
3 |
|
|
* configfile.h |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 1999-2002 Stefan Weyergraf |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License version 2 as |
9 |
|
|
* published by the Free Software Foundation. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef __CONFIGFILE_H__ |
22 |
|
|
#define __CONFIGFILE_H__ |
23 |
|
|
|
24 |
|
|
extern char *systemconfig_file; |
25 |
|
|
|
26 |
|
|
enum ConfigFileType { |
27 |
|
|
CONFIGFILE_BIN = 0, |
28 |
|
|
CONFIGFILE_TEXT = 1, |
29 |
|
|
CONFIGFILE_BIN_COMPRESSED = 2 |
30 |
|
|
}; |
31 |
|
|
|
32 |
|
|
/* SYSTEM CONFIG FILE VERSION HISTORY |
33 |
|
|
* Version 2: HT 0.4.4 |
34 |
|
|
* Version 3: HT 0.4.5 |
35 |
|
|
* Version 4: HT 0.5.0 |
36 |
|
|
* Version 5: HT 0.6.0 |
37 |
|
|
* Version 6: HT 0.8.0 |
38 |
|
|
*/ |
39 |
|
|
|
40 |
|
|
#define systemconfig_magic "HTCP" |
41 |
|
|
#define systemconfig_fileversion 6 |
42 |
|
|
|
43 |
|
|
/* FILE CONFIG FILE VERSION HISTORY |
44 |
|
|
* Version 1: HT 0.5.0 |
45 |
|
|
* Version 2: HT 0.6.0 |
46 |
|
|
* Version 3: HT 0.7.0 |
47 |
|
|
* Version 4: HT 0.8.0 |
48 |
|
|
*/ |
49 |
|
|
|
50 |
|
|
#define fileconfig_magic "HTCF" |
51 |
|
|
#define fileconfig_fileversion 4 |
52 |
|
|
|
53 |
|
|
/* PROJECT CONFIG FILE VERSION HISTORY |
54 |
|
|
* Version 1: HT 0.7.0 |
55 |
|
|
* Version 2: HT 0.8.0 |
56 |
|
|
*/ |
57 |
|
|
|
58 |
|
|
#define projectconfig_magic "HTPR" |
59 |
|
|
#define projectconfig_fileversion 2 |
60 |
|
|
|
61 |
|
|
class ConfigFileObjectStream: public ObjectStreamLayer { |
62 |
|
|
public: |
63 |
|
|
/** |
64 |
|
|
* Construct config file ObjectStream, that can read configuration data (Objects). |
65 |
|
|
*/ |
66 |
|
|
ConfigFileObjectStream(File *readable_file, bool own_rfile, char magic[4], uint32 version); |
67 |
|
|
/** |
68 |
|
|
* Construct config file ObjectStream, that can write configuration data (Objects). |
69 |
|
|
*/ |
70 |
|
|
ConfigFileObjectStream(File *writable_file, bool own_wfile, char magic[4], uint32 version, ConfigFileType type); |
71 |
|
|
}; |
72 |
|
|
|
73 |
|
|
#if 0 |
74 |
|
|
#include "common.h" |
75 |
|
|
#include "stream.h" |
76 |
|
|
|
77 |
|
|
enum loadstore_result { |
78 |
|
|
LS_OK, |
79 |
|
|
LS_ERROR_NOT_FOUND, |
80 |
|
|
LS_ERROR_READ, |
81 |
|
|
LS_ERROR_WRITE, |
82 |
|
|
LS_ERROR_MAGIC, |
83 |
|
|
LS_ERROR_VERSION, // sets error_info to version |
84 |
|
|
LS_ERROR_FORMAT, |
85 |
|
|
LS_ERROR_CORRUPTED |
86 |
|
|
}; |
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
/**/ |
91 |
|
|
|
92 |
|
|
extern char *systemconfig_file; |
93 |
|
|
loadstore_result save_systemconfig(); |
94 |
|
|
bool load_systemconfig(loadstore_result *result, int *error_info); |
95 |
|
|
|
96 |
|
|
typedef int (*load_fcfg_func)(ht_object_stream *f, void *context); |
97 |
|
|
typedef void (*store_fcfg_func)(ht_object_stream *f, void *context); |
98 |
|
|
|
99 |
|
|
loadstore_result save_fileconfig(char *fileconfig_file, const char *magic, UINT version, store_fcfg_func store_func, void *context); |
100 |
|
|
loadstore_result load_fileconfig(char *fileconfig_file, const char *magic, UINT version, load_fcfg_func load_func, void *context, int *error_info); |
101 |
|
|
#endif |
102 |
|
|
|
103 |
|
|
/* |
104 |
|
|
* INIT |
105 |
|
|
*/ |
106 |
|
|
|
107 |
|
|
bool initConfigFile(); |
108 |
|
|
|
109 |
|
|
/* |
110 |
|
|
* DONE |
111 |
|
|
*/ |
112 |
|
|
|
113 |
|
|
void doneConfigFile(); |
114 |
|
|
|
115 |
|
|
#endif /* !__CONFIGFILE_H__ */ |
116 |
|
|
|