ReactOS  0.4.14-dev-599-g2d4d3f5
chmc.h
Go to the documentation of this file.
1 /*
2 
3  Copyright (C) 2010 Alex Andreotti <alex.andreotti@gmail.com>
4 
5  This file is part of chmc.
6 
7  chmc is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  chmc is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with chmc. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 #ifndef CHMC_CHMC_H
22 #define CHMC_CHMC_H
23 
24 #include <stdlib.h>
25 #include <limits.h>
26 
27 #include "chm.h"
28 #include "list.h"
29 
30 #ifndef PATH_MAX
31 #define PATH_MAX 260
32 #endif
33 
34 #define CHMC_DIR_UUID \
35  "\x10\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\x00\xa0\xc9\x22\xe6\xec"
36 #define CHMC_STREAM_UUID \
37  "\x11\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\x00\xa0\xc9\x22\xe6\xec"
38 #define CHMC_SYSTEM_UUID \
39  "\x6a\x92\x02\x5d\x2e\x21\xd0\x11\x9d\xf9\x00\xa0\xc9\x22\xe6\xec"
40 
42  char signature[4];
63 };
64 
65 /* Sys Info Entry codes */
66 #define SIEC_DEFTOPIC 2
67 #define SIEC_TITLE 3
68 #define SIEC_LCASEFILE 6
69 #define SIEC_DEFWINDOW 5
70 
71 /* present in files with Binary Index turned on. (eg: af 08 63 ac)
72  The entry in the #URLTBL file that points to the sitemap index had
73  the same first DWORD */
74 #define SIEC_HAVE_BINDX 7
75 #define SIEC_NUMOFINFOT 12
76 
77 /* The #IDXHDR file contains exactly the same bytes (len 4096) */
78 #define SIEC_IDXHDR 13
79 
80 #define SIEC_INFOCHKSUM 15
81 #define SIEC_DEFFONT 16
82 
83 #define SIEC_TIMESTAMP 10
84 #define SIEC_COMPVER 9
85 #define SIEC_SYSINFO 4
86 
87 /* NOTE use only as pointer */
88 #define _CHMC_SYS_ENTRY_HDR_LEN (sizeof(UInt16)*2)
90  UInt16 code; /* FIXME check unsigned */
91  UInt16 len; /* FIXME check unsigned */
92  UChar data[65535];
93 };
94 
95 /* NOTE use only as pointer */
96 #define _CHMC_SYS_ENTRY_NODE_HDR_LEN \
97  (sizeof(struct chmcSystemEntryNode *)+_CHMC_SYS_ENTRY_HDR_LEN)
98 
102 };
103 
104 /* HHA Version 4.72.7294 and earlier */
105 #define _CHMC_SYS_INFO_V4_72_7294_LEN (28)
106 /* HHA Version 4.72.8086 and later */
107 #define _CHMC_SYS_INFO_V4_72_8086_LEN (36)
115  UInt32 unknown_1c; // >= 8086 only
116  UInt32 unknown_20; // >= 8086 only
117 };
118 
119 
120 /* /usr/include/freetype2/freetype/ttnameid.h maybe useful */
121 #define CHMC_MS_LCID_EN_US (0x0409)
122 
123 #define _CHMC_SYSTEM_HDR_LEN (sizeof(Int32)+sizeof(struct chmcSystemInfo))
124 struct chmcSystem {
127 
128 /* private: */
130  UInt32 _size; /* keep track for alloc before save */
131 };
132 
133 #define _CHMC_CHUNK_LEN (4096)
134 #define CHMC_PMGL_DATA_LEN (_CHMC_CHUNK_LEN - _CHMC_PMGL_LEN - 2)
135 
140 };
141 
143  struct list_head list;
144  int data_len;
147 };
148 
149 #define CHMC_PMGI_DATA_LEN (_CHMC_CHUNK_LEN - _CHMC_PMGI_LEN - 2)
150 
155 };
156 
158  struct list_head list;
159  int data_len;
162 };
163 
164 #define CHMC_TNFL_STATIC (1 << 0) /* don't free() */
165 
166 struct chmcTreeNode {
167  struct list_head list;
170  char *name;
175 };
176 
178  struct list_head list;
180  UChar data[4096];
181 };
182 
183 struct chmcConfig {
184  const char *title;
185  const char *tmpdir;
186  const char *hhc;
187  const char *hhk;
188  const char *deftopic;
190 };
191 
192 struct chmcFile {
193  int fd;
195  struct chmcSect0 sect0;
213 };
214 
215 #define CHMC_SECTNAME_MAXLEN (64)
216 
217 struct chmcSection {
218  struct list_head list;
223  int fd;
228 };
229 
230 #define _CHMC_RSTTBL_MARK (sizeof(struct chmcResetTableMark))
231 
234  struct list_head list;
235 };
236 
240 };
241 
246 };
247 
252  short in_content;
253  short unknown;
254 };
255 
256 
257 int chmc_init(struct chmcFile *chm, const char *filename,
258  struct chmcConfig *config);
259 void chmc_sections_done(struct chmcFile *chm);
260 void chmc_term(struct chmcFile *chm);
261 int chmc_tree_done(struct chmcFile *chm);
262 
263 #define chmc_dump(fmt, ...) fprintf(stderr, fmt , ## __VA_ARGS__)
264 
265 #endif /* CHMC_CHMC_H */
void chmc_term(struct chmcFile *chm)
Definition: chmc.c:461
UInt32 tocidx_offset
Definition: chmc.h:249
UInt32 unknown_20
Definition: chmc.h:116
struct list_head entries_list
Definition: chmc.h:202
int mark_count
Definition: chmc.h:227
UInt16 entries_count
Definition: chmc.h:139
Int32 version
Definition: chmc.h:125
Int32 off_font
Definition: chmc.h:52
int entries_num
Definition: chmc.h:203
struct chmcLzxcControlData control_data
Definition: chmc.h:225
const char * hhc
Definition: chmc.h:186
Int32 num_of_info
Definition: chmc.h:58
UInt32 strings_offset
Definition: chmc.h:210
struct chmcPmgiChunkNode * pmgi_last
Definition: chmc.h:206
struct list_head pmgi_list
Definition: chmc.h:205
struct chmcConfig * config
Definition: chmc.h:212
DWORD UInt32
Definition: chm_lib.c:104
UInt32 strings_len
Definition: chmc.h:211
UInt32 urlstr_offset
Definition: chmc.h:245
ULONGLONG UInt64
Definition: chm_lib.c:106
UInt32 strings_offset
Definition: chmc.h:250
Int32 unknown_44
Definition: chmc.h:59
int chmc_init(struct chmcFile *chm, const char *filename, struct chmcConfig *config)
Definition: chmc.c:133
int fd
Definition: chmc.h:223
struct chmcSection ** sections
Definition: chmc.h:199
UInt32 sect_id
Definition: chmc.h:169
BYTE UChar
Definition: chm_lib.c:100
USHORT UInt16
Definition: chm_lib.c:102
Int32 win_style
Definition: chmc.h:53
const char * filename
Definition: ioapi.h:135
Int32 num_of_topic
Definition: chmc.h:45
struct chmcSystemEntry entry
Definition: chmc.h:101
UInt32 alinks
Definition: chmc.h:113
int fd
Definition: chmc.h:193
Definition: list.h:15
UInt32 urltbl_offset
Definition: chmc.h:251
UChar * buf
Definition: chmc.h:172
const char * tmpdir
Definition: chmc.h:185
UInt64 offset
Definition: chmc.h:173
const char * deftopic
Definition: chmc.h:188
Int32 unknown_10
Definition: chmc.h:46
Int32 unknown_4
Definition: chmc.h:43
UInt16 language
Definition: chmc.h:189
struct chmcSystemEntryNode * next
Definition: chmc.h:100
struct chmcSystem system
Definition: chmc.h:207
const char * hhk
Definition: chmc.h:187
Int32 num_of_merge_files
Definition: chmc.h:60
UInt32 topic_index
Definition: chmc.h:244
int chmc_tree_done(struct chmcFile *chm)
Definition: chmc.c:726
UInt32 url_offset
Definition: chmc.h:238
struct list_head mark_list
Definition: chmc.h:226
UChar * strings
Definition: chmc.h:209
UInt32 framename_offset
Definition: chmc.h:239
UInt16 entries_count
Definition: chmc.h:154
Int32 merge_files_offs[1004]
Definition: chmc.h:62
char * name
Definition: chmc.h:170
Definition: chmc.h:192
Int32 off_frame_name
Definition: chmc.h:56
Int32 background
Definition: chmc.h:50
UInt32 dbcs
Definition: chmc.h:110
struct list_head sections_list
Definition: chmc.h:198
UInt64 len
Definition: chmc.h:174
UInt32 lcid
Definition: chmc.h:109
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Int32 off_img_list
Definition: chmc.h:47
#define PATH_MAX
Definition: chmc.h:31
int sections_num
Definition: chmc.h:197
UInt64 offset
Definition: chmc.h:220
Int32 ex_win_style
Definition: chmc.h:54
struct chmcIndexHeader idxhdr
Definition: chmc.h:208
#define CHMC_SECTNAME_MAXLEN
Definition: chmc.h:215
Int32 foreground
Definition: chmc.h:51
Int32 unknown_18
Definition: chmc.h:48
struct chmcLzxcResetTable reset_table_header
Definition: chmc.h:224
Int32 unknown_4c
Definition: chmc.h:61
short unknown
Definition: chmc.h:253
void chmc_sections_done(struct chmcFile *chm)
Definition: chmc.c:348
struct chmcItsfHeader itsf
Definition: chmc.h:194
Definition: chm.h:104
Definition: _list.h:228
char signature[4]
Definition: chmc.h:42
Int32 img_type_folder
Definition: chmc.h:49
const char * title
Definition: chmc.h:184
UInt16 code
Definition: chmc.h:90
struct chmcSect0 sect0
Definition: chmc.h:195
Int32 off_win_name
Definition: chmc.h:57
UInt16 used
Definition: chmc.h:179
Int32 unknown_34
Definition: chmc.h:55
UInt32 flags
Definition: chmc.h:168
struct chmcPmglChunkNode * pmgl_last
Definition: chmc.h:201
#define CHMC_PMGI_DATA_LEN
Definition: chmc.h:149
UInt32 _size
Definition: chmc.h:130
struct chmcTreeNode ** sort_entries
Definition: chmc.h:204
LONG Int32
Definition: chm_lib.c:103
UInt64 len
Definition: chmc.h:221
UInt16 prefixlen
Definition: chmc.h:171
UInt16 len
Definition: chmc.h:91
Definition: name.c:38
UInt64 timestamp
Definition: chmc.h:114
short in_content
Definition: chmc.h:252
UInt32 full_search
Definition: chmc.h:111
UInt32 klinks
Definition: chmc.h:112
UInt32 unknown
Definition: chmc.h:243
UInt32 unknown_1c
Definition: chmc.h:115
#define CHMC_PMGL_DATA_LEN
Definition: chmc.h:134
struct chmcItspHeader itsp
Definition: chmc.h:196
struct list_head pmgl_list
Definition: chmc.h:200
struct chmcSystemEntryNode * _entries
Definition: chmc.h:129
Int32 unknown_8
Definition: chmc.h:44