ReactOS  0.4.15-dev-439-g292f67a
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 728 of file chmc.c.

729 {
730  struct chmcItsfHeader *itsf;
731  struct chmcSect0 *sect0;
732  struct chmcItspHeader *itsp;
733  struct chmcTreeNode *ctrl;
734  UInt32 str_index;
735  const char *val;
736 
737  assert(chm);
738 
739  itsf = &chm->itsf;
740  sect0 = &chm->sect0;
741  itsp = &chm->itsp;
742 
743  chmc_add_dir(chm, "/");
744 
745  ctrl = chmc_add_meta(chm, "::DataSpace/Storage/MSCompressed/Transform/List",
747  sizeof(chmc_transform_list));
748  if (ctrl)
749  ctrl->flags |= CHMC_TNFL_STATIC;
750 
751  chmc_system_done(chm);
752 
753  if (chm->config != NULL && chm->config->deftopic != NULL)
754  val = chm->config->deftopic;
755  else
756  val = "index.htm";
757 
758  str_index = chmc_strings_add(chm, val);
759 
760 #if 0
761  // FIXME just a test
762  {
763  UChar *p;
764  int len;
765  struct chmcTopicEntry topicEntry;
766  // struct chmcUrlStrEntry urlStrEntry;
767 
768  p = malloc(4096);
769  if (p) {
770  memset(p, 0, 4096);
771  len = 0;
772 
773  topicEntry.tocidx_offset = 4096;
774  topicEntry.strings_offset = -1;
775  topicEntry.urltbl_offset = 0;
776  topicEntry.in_content = 6;
777  topicEntry.unknown = 0;
778 
779  memcpy(p, &topicEntry, sizeof(struct chmcTopicEntry));
780  len += sizeof(struct chmcTopicEntry);
781 
782  chm->idxhdr.num_of_topic++;
783 
784  chmc_add_meta(chm, "/#TOPICS", 1, (UChar *)p, len);
785  } else
786  BUG_ON("FIXME: %s: %d\n", __FILE__, __LINE__);
787  }
788 #endif
789 
790  ctrl = chmc_add_meta(chm, "/#IDXHDR", 1, (void *)&chm->idxhdr,
791  sizeof(struct chmcIndexHeader));
792  if (ctrl)
793  ctrl->flags |= CHMC_TNFL_STATIC;
794 
795  {
796  UInt32 *p;
797  p = malloc(8+196);
798  if (p) {
799  const char *val;
800  memset(p+2, 0, 196);
801 
802  p[0] = 1;
803  p[1] = 196;
804 
805  p[2+0] = 196;
806  // p[2+2] = 1;
807  // p[2+3] = 0x00000532;
808  // p[2+4] = 0x00062520;
809 
810  // p[2+8] = 86;
811  // p[2+9] = 51;
812  // p[2+10] = 872;
813  // p[2+11] = 558;
814 
815  // p[2+19] = 220;
816 
817  // p[2+27] = 0x00000041;
818  // p[2+28] = 14462;
819 
820  if (chm->config != NULL && chm->config->title != NULL)
821  val = chm->config->title;
822  else
823  val = "untitled";
824  p[2+5] = chmc_strings_add(chm, val);
825 
826  if (chm->config != NULL && chm->config->hhc != NULL)
827  val = chm->config->hhc;
828  else
829  val = "toc.hhc";
830  p[2+24] = chmc_strings_add(chm, val);
831 
832  if (chm->config != NULL && chm->config->hhk != NULL)
833  val = chm->config->hhc;
834  else
835  val = "toc.hhk";
836  p[2+25] = chmc_strings_add(chm, val);
837  p[2+26] = str_index;
838 
839  chmc_add_meta(chm, "/#WINDOWS", 1, (UChar *)p, 8+196);
840  } else
841  BUG_ON("FIXME: %s: %d\n", __FILE__, __LINE__);
842  }
843 
844  ctrl = chmc_add_meta(chm, "/#STRINGS", 1, (void *)chm->strings,
845  chm->strings_len);
846  if (ctrl)
847  ctrl->flags |= CHMC_TNFL_STATIC;
848 
849 #if 0
850  // FIXME just a test
851  {
852  UChar *p;
853  int len;
854  struct chmcUrlStrEntry urlStrEntry;
855 
856  urlStrEntry.url_offset = 0;
857  urlStrEntry.framename_offset = 0;
858 
859  p = malloc(4096);
860  if (p) {
861  memset(p, 0, 4096);
862  *p = 0x42;
863  len = 1;
864 
865  memcpy(p + len, &urlStrEntry, sizeof(struct chmcUrlStrEntry));
866  len += sizeof(struct chmcUrlStrEntry);
867  len += sprintf(p + len, "index.htm" ) + 1;
868 
869  memcpy(p + len, &urlStrEntry, sizeof(struct chmcUrlStrEntry));
870  len += sizeof(struct chmcUrlStrEntry);
871  len += sprintf(p + len, "test.htm" ) + 1;
872 
873  chmc_add_meta(chm, "/#URLSTR", 1, (UChar *)p, len);
874  } else
875  BUG_ON("FIXME: %s: %d\n", __FILE__, __LINE__);
876  }
877 #endif
878 
879  // chmc_add_entry(chm, "/#URLTBL", 0, 1, NULL, 0, 0);
880  // chmc_add_entry(chm, "/#TOPICS", 0, 1, NULL, 0, 0);
881 
882  // NOTE NOTE NOTE add any meta compressed before crunch ;-)
883 
884  chmc_crunch_lzx(chm, 1);
885 
888 
889  chmc_add_empty(chm, "/#ITBITS");
890 
891  // NOTE in this implementation compressed Content should be the last file
892  // added to section 0
893 
894  chmc_add_meta(chm, "::DataSpace/Storage/MSCompressed/Content", 0, NULL,
895  chm->sections[1]->offset);
896 
897  chmc_entries_qsort(chm);
899  chmc_pmgl_done(chm);
900 
901  chmc_pmgi_done(chm);
902 
903  itsf->dir_len = _CHMC_ITSP_V1_LEN
904  + (_CHMC_CHUNK_LEN * itsp->num_blocks);
905 
909  + (_CHMC_CHUNK_LEN * itsp->num_blocks);
910 
911  sect0->file_len += _CHMC_CHUNK_LEN * itsp->num_blocks;
912 
913  chmc_write(chm);
914 
915  {
916  struct chmcSection *section;
917  struct list_head *pos;
918  UChar buf[4096];
919 
921  section = list_entry(pos, struct chmcSection, list);
922  chmc_appendfile(chm, section->filename, buf, 4096);
923  }
924  }
925 
926  return CHMC_NOERR;
927 }
static const short chmc_transform_list[]
Definition: chmc.c:128
int chmc_reset_table_done(struct chmcFile *chm)
Definition: chmc.c:1159
int chmc_pmgi_done(struct chmcFile *chm)
Definition: chmc.c:1490
int chmc_write(struct chmcFile *chm)
Definition: chmc.c:1623
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:1660
#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:1143
#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:1757
GLuint GLfloat * val
Definition: glext.h:7180
UInt32 url_offset
Definition: chmc.h:238
int chmc_uncompressed_done(struct chmcFile *chm)
Definition: chmc.c:1238
#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:929
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:1208
#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:1260

Referenced by main().