summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/chm_lib.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/chm_lib.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/chm_lib.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/chm_lib.h b/noncore/apps/opie-reader/chm_lib.h
new file mode 100644
index 0000000..5f9b567
--- a/dev/null
+++ b/noncore/apps/opie-reader/chm_lib.h
@@ -0,0 +1,134 @@
1/* $Id$ */
2/***************************************************************************
3 * chm_lib.h - CHM archive manipulation routines *
4 * ------------------- *
5 * *
6 * author: Jed Wing <jedwin@ugcs.caltech.edu> *
7 * version: 0.3 *
8 * notes: These routines are meant for the manipulation of microsoft *
9 * .chm (compiled html help) files, but may likely be used *
10 * for the manipulation of any ITSS archive, if ever ITSS *
11 * archives are used for any other purpose. *
12 * *
13 * Note also that the section names are statically handled. *
14 * To be entirely correct, the section names should be read *
15 * from the section names meta-file, and then the various *
16 * content sections and the "transforms" to apply to the data *
17 * they contain should be inferred from the section name and *
18 * the meta-files referenced using that name; however, all of *
19 * the files I've been able to get my hands on appear to have *
20 * only two sections: Uncompressed and MSCompressed. *
21 * Additionally, the ITSS.DLL file included with Windows does *
22 * not appear to handle any different transforms than the *
23 * simple LZX-transform. Furthermore, the list of transforms *
24 * to apply is broken, in that only half the required space *
25 * is allocated for the list. (It appears as though the *
26 * space is allocated for ASCII strings, but the strings are *
27 * written as unicode. As a result, only the first half of *
28 * the string appears.) So this is probably not too big of *
29 * a deal, at least until CHM v4 (MS .lit files), which also *
30 * incorporate encryption, of some description. *
31 ***************************************************************************/
32
33/***************************************************************************
34 * *
35 * This program is free software; you can redistribute it and/or modify *
36 * it under the terms of the GNU Lesser General Public License as *
37 * published by the Free Software Foundation; either version 2.1 of the *
38 * License, or (at your option) any later version. *
39 * *
40 ***************************************************************************/
41
42#ifndef INCLUDED_CHMLIB_H
43#define INCLUDED_CHMLIB_H
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#ifdef WIN32
50typedef unsigned __int64 LONGUINT64;
51typedef __int64 LONGINT64;
52#else
53typedef unsigned long long LONGUINT64;
54typedef long long LONGINT64;
55#endif
56
57/* the two available spaces in a CHM file */
58/* N.B.: The format supports arbitrarily many spaces, but only */
59/* two appear to be used at present. */
60#define CHM_UNCOMPRESSED (0)
61#define CHM_COMPRESSED (1)
62
63/* structure representing an ITS (CHM) file stream */
64struct chmFile;
65
66/* structure representing an element from an ITS file stream */
67#define CHM_MAX_PATHLEN (256)
68struct chmUnitInfo
69{
70 LONGUINT64 start;
71 LONGUINT64 length;
72 int space;
73 char path[CHM_MAX_PATHLEN+1];
74};
75
76/* open an ITS archive */
77struct chmFile* chm_open(const char *filename);
78
79/* close an ITS archive */
80void chm_close(struct chmFile *h);
81
82/* methods for ssetting tuning parameters for particular file */
83#define CHM_PARAM_MAX_BLOCKS_CACHED 0
84void chm_set_param(struct chmFile *h,
85 int paramType,
86 int paramVal);
87
88/* resolve a particular object from the archive */
89#define CHM_RESOLVE_SUCCESS (0)
90#define CHM_RESOLVE_FAILURE (1)
91int chm_resolve_object(struct chmFile *h,
92 const char *objPath,
93 struct chmUnitInfo *ui);
94
95/* retrieve part of an object from the archive */
96LONGINT64 chm_retrieve_object(struct chmFile *h,
97 struct chmUnitInfo *ui,
98 unsigned char *buf,
99 LONGUINT64 addr,
100 LONGINT64 len);
101
102/* enumerate the objects in the .chm archive */
103typedef int (*CHM_ENUMERATOR)(struct chmFile *h,
104 struct chmUnitInfo *ui,
105 void *context);
106#define CHM_ENUMERATE_NORMAL (1)
107#define CHM_ENUMERATE_META (2)
108#define CHM_ENUMERATE_SPECIAL (4)
109#define CHM_ENUMERATE_FILES (8)
110#define CHM_ENUMERATE_DIRS (16)
111#define CHM_ENUMERATE_ALL (31)
112#define CHM_ENUMERATOR_FAILURE (0)
113#define CHM_ENUMERATOR_CONTINUE (1)
114#define CHM_ENUMERATOR_SUCCESS (2)
115int chm_enumerate(struct chmFile *h,
116 int what,
117 CHM_ENUMERATOR e,
118 void *context);
119
120int chm_enumerate_dir(struct chmFile *h,
121 const char *prefix,
122 int what,
123 CHM_ENUMERATOR e,
124 void *context);
125
126int chm_resolve_location(struct chmFile *h,
127 unsigned long pos,
128 struct chmUnitInfo *ui);
129
130#ifdef __cplusplus
131}
132#endif
133
134#endif /* INCLUDED_CHMLIB_H */