Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

chm_lib.h

Go to the documentation of this file.
00001 /* $Id: chm_lib.h,v 1.2 2005/05/05 14:39:34 pohly Exp $ */
00002 /***************************************************************************
00003  *             chm_lib.h - CHM archive manipulation routines               *
00004  *                           -------------------                           *
00005  *                                                                         *
00006  *  author:     Jed Wing <jedwin@ugcs.caltech.edu>                         *
00007  *  version:    0.3                                                        *
00008  *  notes:      These routines are meant for the manipulation of microsoft *
00009  *              .chm (compiled html help) files, but may likely be used    *
00010  *              for the manipulation of any ITSS archive, if ever ITSS     *
00011  *              archives are used for any other purpose.                   *
00012  *                                                                         *
00013  *              Note also that the section names are statically handled.   *
00014  *              To be entirely correct, the section names should be read   *
00015  *              from the section names meta-file, and then the various     *
00016  *              content sections and the "transforms" to apply to the data *
00017  *              they contain should be inferred from the section name and  *
00018  *              the meta-files referenced using that name; however, all of *
00019  *              the files I've been able to get my hands on appear to have *
00020  *              only two sections: Uncompressed and MSCompressed.          *
00021  *              Additionally, the ITSS.DLL file included with Windows does *
00022  *              not appear to handle any different transforms than the     *
00023  *              simple LZX-transform.  Furthermore, the list of transforms *
00024  *              to apply is broken, in that only half the required space   *
00025  *              is allocated for the list.  (It appears as though the      *
00026  *              space is allocated for ASCII strings, but the strings are  *
00027  *              written as unicode.  As a result, only the first half of   *
00028  *              the string appears.)  So this is probably not too big of   *
00029  *              a deal, at least until CHM v4 (MS .lit files), which also  *
00030  *              incorporate encryption, of some description.               *
00031  ***************************************************************************/
00032 
00033 /***************************************************************************
00034  *                                                                         *
00035  *   This program is free software; you can redistribute it and/or modify  *
00036  *   it under the terms of the GNU Lesser General Public License as        *
00037  *   published by the Free Software Foundation; either version 2.1 of the  *
00038  *   License, or (at your option) any later version.                       *
00039  *                                                                         *
00040  ***************************************************************************/
00041 
00042 #ifndef INCLUDED_CHMLIB_H
00043 #define INCLUDED_CHMLIB_H
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 #ifdef WIN32
00050 typedef unsigned __int64 LONGUINT64;
00051 typedef __int64          LONGINT64;
00052 #else
00053 typedef unsigned long long LONGUINT64;
00054 typedef long long          LONGINT64;
00055 #endif
00056 
00057 /* the two available spaces in a CHM file                      */
00058 /* N.B.: The format supports arbitrarily many spaces, but only */
00059 /*       two appear to be used at present.                     */
00060 #define CHM_UNCOMPRESSED (0)
00061 #define CHM_COMPRESSED   (1)
00062 
00063 /* structure representing an ITS (CHM) file stream             */
00064 struct chmFile;
00065 
00066 /* structure representing an element from an ITS file stream   */
00067 #define CHM_MAX_PATHLEN  (256)
00068 struct chmUnitInfo
00069 {
00070     LONGUINT64         start;
00071     LONGUINT64         length;
00072     int                space;
00073     char               path[CHM_MAX_PATHLEN+1];
00074 };
00075 
00076 /* open an ITS archive */
00077 struct chmFile* chm_open(const char *filename);
00078 
00079 /* close an ITS archive */
00080 void chm_close(struct chmFile *h);
00081 
00082 /* methods for ssetting tuning parameters for particular file */
00083 #define CHM_PARAM_MAX_BLOCKS_CACHED 0
00084 void chm_set_param(struct chmFile *h,
00085                    int paramType,
00086                    int paramVal);
00087 
00088 /* resolve a particular object from the archive */
00089 #define CHM_RESOLVE_SUCCESS (0)
00090 #define CHM_RESOLVE_FAILURE (1)
00091 int chm_resolve_object(struct chmFile *h,
00092                        const char *objPath,
00093                        struct chmUnitInfo *ui);
00094 
00095 /* retrieve part of an object from the archive */
00096 LONGINT64 chm_retrieve_object(struct chmFile *h,
00097                               struct chmUnitInfo *ui,
00098                               unsigned char *buf,
00099                               LONGUINT64 addr,
00100                               LONGINT64 len);
00101 
00102 /* enumerate the objects in the .chm archive */
00103 typedef int (*CHM_ENUMERATOR)(struct chmFile *h,
00104                               struct chmUnitInfo *ui,
00105                               void *context);
00106 #define CHM_ENUMERATE_NORMAL    (1)
00107 #define CHM_ENUMERATE_META      (2)
00108 #define CHM_ENUMERATE_SPECIAL   (4)
00109 #define CHM_ENUMERATE_FILES     (8)
00110 #define CHM_ENUMERATE_DIRS      (16)
00111 #define CHM_ENUMERATE_ALL       (31)
00112 #define CHM_ENUMERATOR_FAILURE  (0)
00113 #define CHM_ENUMERATOR_CONTINUE (1)
00114 #define CHM_ENUMERATOR_SUCCESS  (2)
00115 int chm_enumerate(struct chmFile *h,
00116                   int what,
00117                   CHM_ENUMERATOR e,
00118                   void *context);
00119 
00120 int chm_enumerate_dir(struct chmFile *h,
00121                       const char *prefix,
00122                       int what,
00123                       CHM_ENUMERATOR e,
00124                       void *context);
00125 
00126 int chm_resolve_location(struct chmFile *h,
00127                        unsigned long pos,
00128                          struct chmUnitInfo *ui);
00129 
00130 #ifdef __cplusplus
00131 }
00132 #endif
00133 
00134 #endif /* INCLUDED_CHMLIB_H */

Generated on Sat Nov 5 16:16:54 2005 for OPIE by  doxygen 1.4.2