ReactOS  0.4.14-dev-599-g2d4d3f5
chmc.h File Reference
#include <stdlib.h>
#include <limits.h>
#include "chm.h"
#include "list.h"
Include dependency graph for chmc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  chmcIndexHeader
 
struct  chmcSystemEntry
 
struct  chmcSystemEntryNode
 
struct  chmcSystemInfo
 
struct  chmcSystem
 
struct  chmcPmglChunk
 
struct  chmcPmglChunkNode
 
struct  chmcPmgiChunk
 
struct  chmcPmgiChunkNode
 
struct  chmcTreeNode
 
struct  chmcStringChunk
 
struct  chmcConfig
 
struct  chmcFile
 
struct  chmcSection
 
struct  chmcResetTableMark
 
struct  chmcUrlStrEntry
 
struct  chmcUtlTblEntry
 
struct  chmcTopicEntry
 

Macros

#define PATH_MAX   260
 
#define CHMC_DIR_UUID   "\x10\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\x00\xa0\xc9\x22\xe6\xec"
 
#define CHMC_STREAM_UUID   "\x11\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\x00\xa0\xc9\x22\xe6\xec"
 
#define CHMC_SYSTEM_UUID   "\x6a\x92\x02\x5d\x2e\x21\xd0\x11\x9d\xf9\x00\xa0\xc9\x22\xe6\xec"
 
#define SIEC_DEFTOPIC   2
 
#define SIEC_TITLE   3
 
#define SIEC_LCASEFILE   6
 
#define SIEC_DEFWINDOW   5
 
#define SIEC_HAVE_BINDX   7
 
#define SIEC_NUMOFINFOT   12
 
#define SIEC_IDXHDR   13
 
#define SIEC_INFOCHKSUM   15
 
#define SIEC_DEFFONT   16
 
#define SIEC_TIMESTAMP   10
 
#define SIEC_COMPVER   9
 
#define SIEC_SYSINFO   4
 
#define _CHMC_SYS_ENTRY_HDR_LEN   (sizeof(UInt16)*2)
 
#define _CHMC_SYS_ENTRY_NODE_HDR_LEN   (sizeof(struct chmcSystemEntryNode *)+_CHMC_SYS_ENTRY_HDR_LEN)
 
#define _CHMC_SYS_INFO_V4_72_7294_LEN   (28)
 
#define _CHMC_SYS_INFO_V4_72_8086_LEN   (36)
 
#define CHMC_MS_LCID_EN_US   (0x0409)
 
#define _CHMC_SYSTEM_HDR_LEN   (sizeof(Int32)+sizeof(struct chmcSystemInfo))
 
#define _CHMC_CHUNK_LEN   (4096)
 
#define CHMC_PMGL_DATA_LEN   (_CHMC_CHUNK_LEN - _CHMC_PMGL_LEN - 2)
 
#define CHMC_PMGI_DATA_LEN   (_CHMC_CHUNK_LEN - _CHMC_PMGI_LEN - 2)
 
#define CHMC_TNFL_STATIC   (1 << 0) /* don't free() */
 
#define CHMC_SECTNAME_MAXLEN   (64)
 
#define _CHMC_RSTTBL_MARK   (sizeof(struct chmcResetTableMark))
 
#define chmc_dump(fmt, ...)   fprintf(stderr, fmt , ## __VA_ARGS__)
 

Functions

int chmc_init (struct chmcFile *chm, const char *filename, struct chmcConfig *config)
 
void chmc_sections_done (struct chmcFile *chm)
 
void chmc_term (struct chmcFile *chm)
 
int chmc_tree_done (struct chmcFile *chm)
 

Macro Definition Documentation

◆ _CHMC_CHUNK_LEN

#define _CHMC_CHUNK_LEN   (4096)

Definition at line 133 of file chmc.h.

◆ _CHMC_RSTTBL_MARK

#define _CHMC_RSTTBL_MARK   (sizeof(struct chmcResetTableMark))

Definition at line 230 of file chmc.h.

◆ _CHMC_SYS_ENTRY_HDR_LEN

#define _CHMC_SYS_ENTRY_HDR_LEN   (sizeof(UInt16)*2)

Definition at line 88 of file chmc.h.

◆ _CHMC_SYS_ENTRY_NODE_HDR_LEN

#define _CHMC_SYS_ENTRY_NODE_HDR_LEN   (sizeof(struct chmcSystemEntryNode *)+_CHMC_SYS_ENTRY_HDR_LEN)

Definition at line 96 of file chmc.h.

◆ _CHMC_SYS_INFO_V4_72_7294_LEN

#define _CHMC_SYS_INFO_V4_72_7294_LEN   (28)

Definition at line 105 of file chmc.h.

◆ _CHMC_SYS_INFO_V4_72_8086_LEN

#define _CHMC_SYS_INFO_V4_72_8086_LEN   (36)

Definition at line 107 of file chmc.h.

◆ _CHMC_SYSTEM_HDR_LEN

#define _CHMC_SYSTEM_HDR_LEN   (sizeof(Int32)+sizeof(struct chmcSystemInfo))

Definition at line 123 of file chmc.h.

◆ CHMC_DIR_UUID

#define CHMC_DIR_UUID   "\x10\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\x00\xa0\xc9\x22\xe6\xec"

Definition at line 34 of file chmc.h.

◆ chmc_dump

#define chmc_dump (   fmt,
  ... 
)    fprintf(stderr, fmt , ## __VA_ARGS__)

Definition at line 263 of file chmc.h.

◆ CHMC_MS_LCID_EN_US

#define CHMC_MS_LCID_EN_US   (0x0409)

Definition at line 121 of file chmc.h.

◆ CHMC_PMGI_DATA_LEN

#define CHMC_PMGI_DATA_LEN   (_CHMC_CHUNK_LEN - _CHMC_PMGI_LEN - 2)

Definition at line 149 of file chmc.h.

◆ CHMC_PMGL_DATA_LEN

#define CHMC_PMGL_DATA_LEN   (_CHMC_CHUNK_LEN - _CHMC_PMGL_LEN - 2)

Definition at line 134 of file chmc.h.

◆ CHMC_SECTNAME_MAXLEN

#define CHMC_SECTNAME_MAXLEN   (64)

Definition at line 215 of file chmc.h.

◆ CHMC_STREAM_UUID

#define CHMC_STREAM_UUID   "\x11\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\x00\xa0\xc9\x22\xe6\xec"

Definition at line 36 of file chmc.h.

◆ CHMC_SYSTEM_UUID

#define CHMC_SYSTEM_UUID   "\x6a\x92\x02\x5d\x2e\x21\xd0\x11\x9d\xf9\x00\xa0\xc9\x22\xe6\xec"

Definition at line 38 of file chmc.h.

◆ CHMC_TNFL_STATIC

#define CHMC_TNFL_STATIC   (1 << 0) /* don't free() */

Definition at line 164 of file chmc.h.

◆ PATH_MAX

#define PATH_MAX   260

Definition at line 31 of file chmc.h.

◆ SIEC_COMPVER

#define SIEC_COMPVER   9

Definition at line 84 of file chmc.h.

◆ SIEC_DEFFONT

#define SIEC_DEFFONT   16

Definition at line 81 of file chmc.h.

◆ SIEC_DEFTOPIC

#define SIEC_DEFTOPIC   2

Definition at line 66 of file chmc.h.

◆ SIEC_DEFWINDOW

#define SIEC_DEFWINDOW   5

Definition at line 69 of file chmc.h.

◆ SIEC_HAVE_BINDX

#define SIEC_HAVE_BINDX   7

Definition at line 74 of file chmc.h.

◆ SIEC_IDXHDR

#define SIEC_IDXHDR   13

Definition at line 78 of file chmc.h.

◆ SIEC_INFOCHKSUM

#define SIEC_INFOCHKSUM   15

Definition at line 80 of file chmc.h.

◆ SIEC_LCASEFILE

#define SIEC_LCASEFILE   6

Definition at line 68 of file chmc.h.

◆ SIEC_NUMOFINFOT

#define SIEC_NUMOFINFOT   12

Definition at line 75 of file chmc.h.

◆ SIEC_SYSINFO

#define SIEC_SYSINFO   4

Definition at line 85 of file chmc.h.

◆ SIEC_TIMESTAMP

#define SIEC_TIMESTAMP   10

Definition at line 83 of file chmc.h.

◆ SIEC_TITLE

#define SIEC_TITLE   3

Definition at line 67 of file chmc.h.

Function Documentation

◆ chmc_init()

int chmc_init ( struct chmcFile chm,
const char filename,
struct chmcConfig config 
)

Definition at line 133 of file chmc.c.

135 {
136  struct chmcItsfHeader *itsf = &chm->itsf;
137  struct chmcSect0 *sect0 = &chm->sect0;
138  struct chmcItspHeader *itsp = &chm->itsp;
139  struct chmcSystem *system = &chm->system;
140  struct chmcSystemInfo *sysinfo = &chm->system.info;
141  struct chmcIndexHeader *idxhdr = &chm->idxhdr;
142 
143  assert(chm);
144  assert(filename);
145 
146  chmcerr_clean();
147 
148  memset(chm, 0, sizeof(struct chmcFile));
149 
150  chm->config = config;
151 
152  if (strcmp(filename, "-") != 0) {
153  chm->fd = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0644);
154  if (chm->fd < 0) {
156  chmcerr_return_msg("creat file '%s'", filename);
157  }
158  } else {
159  chm->fd = fileno(stdout);
160  }
161 
162  memcpy(itsf->signature, "ITSF", 4);
163  itsf->version = 3;
165  itsf->unknown_000c = 1;
166 
167  itsf->lang_id = chm->config->language;
168  memcpy(itsf->dir_uuid, CHMC_DIR_UUID, 16);
169  memcpy(itsf->stream_uuid, CHMC_STREAM_UUID, 16);
171 
173  itsf->sect0_len = _CHMC_SECT0_LEN;
174 
175  sect0->file_len = _CHMC_ITSF_V3_LEN
178 
179  sect0->unknown_0000 = 510;
180 
181  memcpy(itsp->signature, "ITSP", 4);
182  itsp->version = 1;
184  itsp->unknown_000c = 10;
185  itsp->block_len = _CHMC_CHUNK_LEN;
187  itsp->index_depth = 2;
188 
189  itsp->unknown_0028 = -1;
190  itsp->lang_id = CHMC_MS_LCID_EN_US;
191  memcpy(itsp->system_uuid, CHMC_SYSTEM_UUID, 16);
193  memset(itsp->unknown_0048, -1, 12);
194 
195  system->version = 3;
196  system->_size = _CHMC_SYSTEM_HDR_LEN + sizeof(struct chmcIndexHeader);
197 
198  sysinfo->lcid = CHMC_MS_LCID_EN_US;
199 
200  memcpy(idxhdr->signature, "T#SM", 4);
201  idxhdr->unknown_4 = 28582569; // FIXME got from some chm
202  idxhdr->unknown_8 = 1;
203  // idxhdr->full_search = 1;
204  // idxhdr->klinks = 1;
205  // idxhdr->alinks = 0;
206  // idxhdr->timestamp = ???;
207 
208  // idxhdr->num_of_topic = 2; // sorry??
209  idxhdr->off_img_list = -1;
210  // idxhdr->img_type_folder;
211  idxhdr->background = -1;
212  idxhdr->foreground = -1;
213  idxhdr->off_font = -1;
214  idxhdr->win_style = -1;
215  idxhdr->ex_win_style = -1;
216  idxhdr->unknown_34 = -1;
217  idxhdr->off_frame_name = -1;
218  idxhdr->off_win_name = -1;
219  // idxhdr->num_of_info;
220  idxhdr->unknown_44 = 1;
221  // idxhdr->num_of_merge_files;
222  // idxhdr->unknown_4c;
223 
225  INIT_LIST_HEAD(&chm->pmgl_list);
227  INIT_LIST_HEAD(&chm->pmgi_list);
228 
229  chm->strings = malloc(4096);
230  memset(chm->strings, 0, 4096);
231  chm->strings_len = 4096;
232  chm->strings_offset = 1;
233 
234  if (chmc_section_add(chm, "Uncompressed") != CHMC_NOERR)
235  chmcerr_return_msg("adding section: Uncompressed");
236 
237  if (chmc_section_add(chm, "MSCompressed") != CHMC_NOERR)
238  chmcerr_return_msg("adding section: MSCompressed");
239 
240  chmc_sections_done(chm);
241 
242  return CHMC_NOERR;
243 }
struct list_head entries_list
Definition: chmc.h:202
Int32 off_font
Definition: chmc.h:52
struct config_s config
#define CHM_IDX_INTVL
Definition: chm.h:112
Int32 header_len
Definition: chm.h:90
UInt32 strings_offset
Definition: chmc.h:210
#define open
Definition: acwin.h:95
UInt32 lang_id
Definition: chm.h:93
struct list_head pmgi_list
Definition: chmc.h:205
struct chmcConfig * config
Definition: chmc.h:212
void chmcerr_set(int code, const char *fmt,...)
Definition: err.c:50
UInt32 strings_len
Definition: chmc.h:211
#define INIT_LIST_HEAD(ptr)
Definition: list.h:24
#define _CHMC_CHUNK_LEN
Definition: chmc.h:133
#define assert(x)
Definition: debug.h:53
Int32 unknown_44
Definition: chmc.h:59
int errno
void chmc_sections_done(struct chmcFile *chm)
Definition: chmc.c:348
#define chmcerr_return_msg(fmt,...)
Definition: err.h:50
Int32 win_style
Definition: chmc.h:53
int chmc_section_add(struct chmcFile *chm, const char *name)
Definition: chmc.c:245
const char * filename
Definition: ioapi.h:135
#define CHMC_MS_LCID_EN_US
Definition: chmc.h:121
const char * strerror(int err)
Definition: compat_str.c:23
#define CHMC_SYSTEM_UUID
Definition: chmc.h:38
FILE * stdout
int fd
Definition: chmc.h:193
Int32 unknown_000c
Definition: chm.h:91
#define _CHMC_ITSF_V3_LEN
Definition: chm.h:86
UInt32 lang_id
Definition: chm.h:129
Int32 unknown_000c
Definition: chm.h:120
char signature[4]
Definition: chm.h:117
Int32 unknown_4
Definition: chmc.h:43
Int32 unknown_0028
Definition: chm.h:127
int __cdecl system(_In_opt_z_ const char *_Command)
struct chmcSystem system
Definition: chmc.h:207
char signature[4]
Definition: chm.h:88
#define _CHMC_SYSTEM_HDR_LEN
Definition: chmc.h:123
void chmcerr_clean(void)
Definition: err.c:37
UInt64 sect0_offset
Definition: chm.h:96
UChar * strings
Definition: chmc.h:209
Int32 version
Definition: chm.h:118
_Check_return_ _CRTIMP int __cdecl fileno(_In_ FILE *_File)
Definition: chmc.h:192
Int32 off_frame_name
Definition: chmc.h:56
Int32 background
Definition: chmc.h:50
struct list_head sections_list
Definition: chmc.h:198
UChar stream_uuid[16]
Definition: chm.h:95
UInt32 lcid
Definition: chmc.h:109
Int32 off_img_list
Definition: chmc.h:47
Int32 ex_win_style
Definition: chmc.h:54
struct chmcIndexHeader idxhdr
Definition: chmc.h:208
#define CHMC_STREAM_UUID
Definition: chmc.h:36
Int32 foreground
Definition: chmc.h:51
#define _CHMC_SECT0_LEN
Definition: chm.h:103
struct chmcItsfHeader itsf
Definition: chmc.h:194
Definition: chm.h:104
UInt32 block_len
Definition: chm.h:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Int32 header_len
Definition: chm.h:119
#define O_TRUNC
Definition: acwin.h:112
#define O_BINARY
Definition: chmc.c:53
#define CHMC_NOERR
Definition: err.h:39
UChar system_uuid[16]
Definition: chm.h:130
Int32 unknown_0000
Definition: chm.h:105
UInt64 sect0_len
Definition: chm.h:97
char signature[4]
Definition: chmc.h:42
UInt32 header_len2
Definition: chm.h:131
struct chmcSect0 sect0
Definition: chmc.h:195
Int32 off_win_name
Definition: chmc.h:57
Int32 unknown_34
Definition: chmc.h:55
#define O_RDWR
Definition: fcntl.h:36
Int32 blockidx_intvl
Definition: chm.h:122
UInt64 file_len
Definition: chm.h:107
UChar dir_uuid[16]
Definition: chm.h:94
Int32 version
Definition: chm.h:89
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define malloc
Definition: debug_ros.c:4
Int32 index_depth
Definition: chm.h:123
UInt64 dir_offset
Definition: chm.h:98
#define memset(x, y, z)
Definition: compat.h:39
#define _CHMC_ITSP_V1_LEN
Definition: chm.h:115
#define O_CREAT
Definition: acwin.h:110
#define CHMC_DIR_UUID
Definition: chmc.h:34
struct chmcItspHeader itsp
Definition: chmc.h:196
UChar unknown_0048[12]
Definition: chm.h:132
struct list_head pmgl_list
Definition: chmc.h:200
Int32 unknown_8
Definition: chmc.h:44

Referenced by main().

◆ chmc_sections_done()

void chmc_sections_done ( struct chmcFile chm)

Definition at line 348 of file chmc.c.

349 {
350  int len;
351  int i;
352 
353  assert(chm);
354 
355  chm->sections = malloc(sizeof(struct chmcSection *) * chm->sections_num);
356  if (chm->sections) {
357  struct chmcSection *section;
358  struct list_head *pos;
359 
360  i = 0;
361  len = 4;
363  section = list_entry(pos, struct chmcSection, list);
364  len += 4 + strlen(section->name) * 2;
365  chm->sections[i++] = section;
366  }
368  } else
369  BUG_ON("FIXME: %s: %d\n", __FILE__, __LINE__);
370 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define assert(x)
Definition: debug.h:53
struct chmcSection ** sections
Definition: chmc.h:199
Definition: parser.c:55
#define list_entry(ptr, type, member)
Definition: list.h:185
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
const WCHAR * name
Definition: parser.c:57
Definition: list.h:15
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define list_for_each(entry, head)
Definition: list.h:36
#define BUG_ON(c)
Definition: module.h:253
struct list_head sections_list
Definition: chmc.h:198
int sections_num
Definition: chmc.h:197
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
#define malloc
Definition: debug_ros.c:4
int chmc_namelist_create(struct chmcFile *chm, int len)
Definition: chmc.c:372

Referenced by chmc_init().

◆ chmc_term()

void chmc_term ( struct chmcFile chm)

Definition at line 461 of file chmc.c.

462 {
463  assert(chm);
464  assert(chm->fd > -1);
465 
466  free(chm->strings);
467 
468  chmc_entries_free(chm);
469  chmc_pmgl_free(chm);
470  chmc_pmgi_free(chm);
471  if (chm->sections)
472  free(chm->sections);
473  chmc_sections_free(chm);
474 
475  if (chm->fd != fileno(stdout))
476  close(chm->fd);
477 }
#define free
Definition: debug_ros.c:5
void chmc_entries_free(struct chmcFile *chm)
Definition: chmc.c:542
#define assert(x)
Definition: debug.h:53
struct chmcSection ** sections
Definition: chmc.h:199
FILE * stdout
int fd
Definition: chmc.h:193
UChar * strings
Definition: chmc.h:209
_Check_return_ _CRTIMP int __cdecl fileno(_In_ FILE *_File)
void chmc_pmgl_free(struct chmcFile *chm)
Definition: chmc.c:528
void chmc_sections_free(struct chmcFile *chm)
Definition: chmc.c:479
#define close
Definition: acwin.h:98
void chmc_pmgi_free(struct chmcFile *chm)
Definition: chmc.c:514

Referenced by main().

◆ chmc_tree_done()

int chmc_tree_done ( struct chmcFile chm)

Definition at line 726 of file chmc.c.

727 {
728  struct chmcItsfHeader *itsf;
729  struct chmcSect0 *sect0;
730  struct chmcItspHeader *itsp;
731  struct chmcTreeNode *ctrl;
732  UInt32 str_index;
733  const char *val;
734 
735  assert(chm);
736 
737  itsf = &chm->itsf;
738  sect0 = &chm->sect0;
739  itsp = &chm->itsp;
740 
741  chmc_add_dir(chm, "/");
742 
743  ctrl = chmc_add_meta(chm, "::DataSpace/Storage/MSCompressed/Transform/List",
745  sizeof(chmc_transform_list));
746  if (ctrl)
747  ctrl->flags |= CHMC_TNFL_STATIC;
748 
749  chmc_system_done(chm);
750 
751  if (chm->config != NULL && chm->config->deftopic != NULL)
752  val = chm->config->deftopic;
753  else
754  val = "index.htm";
755 
756  str_index = chmc_strings_add(chm, val);
757 
758 #if 0
759  // FIXME just a test
760  {
761  UChar *p;
762  int len;
763  struct chmcTopicEntry topicEntry;
764  // struct chmcUrlStrEntry urlStrEntry;
765 
766  p = malloc(4096);
767  if (p) {
768  memset(p, 0, 4096);
769  len = 0;
770 
771  topicEntry.tocidx_offset = 4096;
772  topicEntry.strings_offset = -1;
773  topicEntry.urltbl_offset = 0;
774  topicEntry.in_content = 6;
775  topicEntry.unknown = 0;
776 
777  memcpy(p, &topicEntry, sizeof(struct chmcTopicEntry));
778  len += sizeof(struct chmcTopicEntry);
779 
780  chm->idxhdr.num_of_topic++;
781 
782  chmc_add_meta(chm, "/#TOPICS", 1, (UChar *)p, len);
783  } else
784  BUG_ON("FIXME: %s: %d\n", __FILE__, __LINE__);
785  }
786 #endif
787 
788  ctrl = chmc_add_meta(chm, "/#IDXHDR", 1, (void *)&chm->idxhdr,
789  sizeof(struct chmcIndexHeader));
790  if (ctrl)
791  ctrl->flags |= CHMC_TNFL_STATIC;
792 
793  {
794  UInt32 *p;
795  p = malloc(8+196);
796  if (p) {
797  const char *val;
798  memset(p+2, 0, 196);
799 
800  p[0] = 1;
801  p[1] = 196;
802 
803  p[2+0] = 196;
804  // p[2+2] = 1;
805  // p[2+3] = 0x00000532;
806  // p[2+4] = 0x00062520;
807 
808  // p[2+8] = 86;
809  // p[2+9] = 51;
810  // p[2+10] = 872;
811  // p[2+11] = 558;
812 
813  // p[2+19] = 220;
814 
815  // p[2+27] = 0x00000041;
816  // p[2+28] = 14462;
817 
818  if (chm->config != NULL && chm->config->title != NULL)
819  val = chm->config->title;
820  else
821  val = "untitled";
822  p[2+5] = chmc_strings_add(chm, val);
823 
824  if (chm->config != NULL && chm->config->hhc != NULL)
825  val = chm->config->hhc;
826  else
827  val = "toc.hhc";
828  p[2+24] = chmc_strings_add(chm, val);
829 
830  if (chm->config != NULL && chm->config->hhk != NULL)
831  val = chm->config->hhc;
832  else
833  val = "toc.hhk";
834  p[2+25] = chmc_strings_add(chm, val);
835  p[2+26] = str_index;
836 
837  chmc_add_meta(chm, "/#WINDOWS", 1, (UChar *)p, 8+196);
838  } else
839  BUG_ON("FIXME: %s: %d\n", __FILE__, __LINE__);
840  }
841 
842  ctrl = chmc_add_meta(chm, "/#STRINGS", 1, (void *)chm->strings,
843  chm->strings_len);
844  if (ctrl)
845  ctrl->flags |= CHMC_TNFL_STATIC;
846 
847 #if 0
848  // FIXME just a test
849  {
850  UChar *p;
851  int len;
852  struct chmcUrlStrEntry urlStrEntry;
853 
854  urlStrEntry.url_offset = 0;
855  urlStrEntry.framename_offset = 0;
856 
857  p = malloc(4096);
858  if (p) {
859  memset(p, 0, 4096);
860  *p = 0x42;
861  len = 1;
862 
863  memcpy(p + len, &urlStrEntry, sizeof(struct chmcUrlStrEntry));
864  len += sizeof(struct chmcUrlStrEntry);
865  len += sprintf(p + len, "index.htm" ) + 1;
866 
867  memcpy(p + len, &urlStrEntry, sizeof(struct chmcUrlStrEntry));
868  len += sizeof(struct chmcUrlStrEntry);
869  len += sprintf(p + len, "test.htm" ) + 1;
870 
871  chmc_add_meta(chm, "/#URLSTR", 1, (UChar *)p, len);
872  } else
873  BUG_ON("FIXME: %s: %d\n", __FILE__, __LINE__);
874  }
875 #endif
876 
877  // chmc_add_entry(chm, "/#URLTBL", 0, 1, NULL, 0, 0);
878  // chmc_add_entry(chm, "/#TOPICS", 0, 1, NULL, 0, 0);
879 
880  // NOTE NOTE NOTE add any meta compressed before crunch ;-)
881 
882  chmc_crunch_lzx(chm, 1);
883 
886 
887  chmc_add_empty(chm, "/#ITBITS");
888 
889  // NOTE in this implementation compressed Content should be the last file
890  // added to section 0
891 
892  chmc_add_meta(chm, "::DataSpace/Storage/MSCompressed/Content", 0, NULL,
893  chm->sections[1]->offset);
894 
895  chmc_entries_qsort(chm);
897  chmc_pmgl_done(chm);
898 
899  chmc_pmgi_done(chm);
900 
901  itsf->dir_len = _CHMC_ITSP_V1_LEN
902  + (_CHMC_CHUNK_LEN * itsp->num_blocks);
903 
907  + (_CHMC_CHUNK_LEN * itsp->num_blocks);
908 
909  sect0->file_len += _CHMC_CHUNK_LEN * itsp->num_blocks;
910 
911  chmc_write(chm);
912 
913  {
914  struct chmcSection *section;
915  struct list_head *pos;
916  UChar buf[4096];
917 
919  section = list_entry(pos, struct chmcSection, list);
920  chmc_appendfile(chm, section->filename, buf, 4096);
921  }
922  }
923 
924  return CHMC_NOERR;
925 }
static const short chmc_transform_list[]
Definition: chmc.c:128
int chmc_reset_table_done(struct chmcFile *chm)
Definition: chmc.c:1157
int chmc_pmgi_done(struct chmcFile *chm)
Definition: chmc.c:1488
int chmc_write(struct chmcFile *chm)
Definition: chmc.c:1621
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
struct chmcConfig * config
Definition: chmc.h:212
DWORD UInt32
Definition: chm_lib.c:104
UInt32 strings_len
Definition: chmc.h:211
UInt32 chmc_strings_add(struct chmcFile *chm, const char *s)
Definition: chmc.c:558
#define _CHMC_CHUNK_LEN
Definition: chmc.h:133
#define assert(x)
Definition: debug.h:53
struct chmcSection ** sections
Definition: chmc.h:199
BYTE UChar
Definition: chm_lib.c:100
Definition: parser.c:55
int chmc_appendfile(struct chmcFile *chm, const char *filename, void *buf, size_t size)
Definition: chmc.c:1658
#define list_entry(ptr, type, member)
Definition: list.h:185
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
Definition: list.h:15
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define list_for_each(entry, head)
Definition: list.h:36
int chmc_control_data_done(struct chmcFile *chm)
Definition: chmc.c:1141
#define _CHMC_ITSF_V3_LEN
Definition: chm.h:86
smooth NULL
Definition: ftsmooth.c:416
int chmc_system_done(struct chmcFile *chm)
Definition: chmc.c:647
#define ctrl
Definition: input.c:1762
GLuint GLfloat * val
Definition: glext.h:7180
UInt32 url_offset
Definition: chmc.h:238
int chmc_uncompressed_done(struct chmcFile *chm)
Definition: chmc.c:1236
#define BUG_ON(c)
Definition: module.h:253
struct chmcTreeNode * chmc_add_empty(struct chmcFile *chm, const char *file)
Definition: chmc.c:401
UChar * strings
Definition: chmc.h:209
#define CHMC_TNFL_STATIC
Definition: chmc.h:164
struct list_head sections_list
Definition: chmc.h:198
struct chmcIndexHeader idxhdr
Definition: chmc.h:208
#define _CHMC_SECT0_LEN
Definition: chm.h:103
struct chmcItsfHeader itsf
Definition: chmc.h:194
Definition: chm.h:104
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
UInt64 dir_len
Definition: chm.h:99
#define CHMC_NOERR
Definition: err.h:39
struct chmcTreeNode * chmc_add_dir(struct chmcFile *chm, const char *dir)
Definition: chmc.c:621
int chmc_crunch_lzx(struct chmcFile *chm, int sect_id)
Definition: chmc.c:927
struct chmcSect0 sect0
Definition: chmc.h:195
UInt64 data_offset
Definition: chm.h:100
UInt64 file_len
Definition: chm.h:107
void chmc_entries_qsort(struct chmcFile *chm)
Definition: chmc.c:1206
#define malloc
Definition: debug_ros.c:4
GLfloat GLfloat p
Definition: glext.h:8902
UInt32 num_blocks
Definition: chm.h:128
#define memset(x, y, z)
Definition: compat.h:39
struct chmcTreeNode * chmc_add_meta(struct chmcFile *chm, const char *metaname, int sect_id, UChar *buf, UInt64 len)
Definition: chmc.c:407
#define _CHMC_ITSP_V1_LEN
Definition: chm.h:115
struct chmcItspHeader itsp
Definition: chmc.h:196
void chmc_pmgl_done(struct chmcFile *chm)
Definition: chmc.c:1258

Referenced by main().