Author: bfreisen Date: Sat Aug 22 11:16:50 2015 New Revision: 68792
URL: http://svn.reactos.org/svn/reactos?rev=68792&view=rev Log: [HHPCOMP] Improve functionality of Windows MSVC build. Based on a WIP patch by Michael Fritscher. See CORE-10019.
Modified: trunk/reactos/tools/hhpcomp/chmc/chmc.c trunk/reactos/tools/hhpcomp/hhpcomp.cpp trunk/reactos/tools/hhpcomp/port/mkstemps.c
Modified: trunk/reactos/tools/hhpcomp/chmc/chmc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/hhpcomp/chmc/chmc.c?r... ============================================================================== --- trunk/reactos/tools/hhpcomp/chmc/chmc.c [iso-8859-1] (original) +++ trunk/reactos/tools/hhpcomp/chmc/chmc.c [iso-8859-1] Sat Aug 22 11:16:50 2015 @@ -44,6 +44,11 @@ #include "../lzx_compress/lzx_compress.h"
#define PACKAGE_STRING "hhpcomp development version" + +/* if O_BINARY is not defined, the system is probably not expecting any such flag */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif
int chmc_section_add(struct chmcFile *chm, const char *name); struct chmcSection * chmc_section_create(struct chmcFile *chm, @@ -133,7 +138,7 @@ chm->config = config;
if (strcmp(filename, "-") != 0) { - chm->fd = creat(filename, 0644); + chm->fd = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0644); if (chm->fd < 0) { chmcerr_set(errno, strerror(errno)); chmcerr_return_msg("creat file '%s'", filename); @@ -978,7 +983,9 @@ struct chmcLzxInfo *lzx_info = (struct chmcLzxInfo *)arg; struct chmcSect0 *sect0 = &lzx_info->chm->sect0; int wx; - + static int counter = 0; + + counter += n; wx = write(lzx_info->section->fd, buf, n); sect0->file_len += wx; lzx_info->section->len += wx; @@ -1025,7 +1032,7 @@ // need to keep current entry file and offset trought blocks // until last entry while (todo) { - // end of entris reached? + // end of entries reached? if (lzx_info->pos == &chm->entries_list) { lzx_info->eof = 1; break; @@ -1046,7 +1053,7 @@ else if (lzx_info->fd == -1) { // open file if it isn't - lzx_info->fd = open(node->name, O_RDONLY); + lzx_info->fd = open(node->name, O_RDONLY | O_BINARY); if (lzx_info->fd < 0) { chmc_error("%s: %d: error %d: '%s' %s\n", __FILE__, __LINE__, @@ -1073,7 +1080,8 @@ { rx = read(lzx_info->fd, (char *)buf + (n - todo), toread); if (rx <= 0) { - chmc_error("read error\n"); + int temp = errno; + chmc_error("read error %s \n", strerror(temp)); lzx_info->error = 2; break; } @@ -1610,18 +1618,24 @@
assert(chm);
+ chmc_dump("write itsf %d\n", _CHMC_ITSF_V3_LEN); write(chm->fd, itsf, _CHMC_ITSF_V3_LEN); + chmc_dump("write sect0 %d\n", _CHMC_SECT0_LEN); write(chm->fd, sect0, _CHMC_SECT0_LEN); + chmc_dump("write itsp %d\n", _CHMC_ITSP_V1_LEN); write(chm->fd, itsp, _CHMC_ITSP_V1_LEN);
list_for_each(pos, &chm->pmgl_list) { pmgl = list_entry(pos, struct chmcPmglChunkNode, list); + chmc_dump("write pmgl %d\n", _CHMC_CHUNK_LEN); write(chm->fd, &pmgl->chunk, _CHMC_CHUNK_LEN); }
+ chmc_dump("itsp->num_blocks %d", itsp->num_blocks); if (itsp->num_blocks > 1) { list_for_each( pos, &chm->pmgi_list ) { pmgi = list_entry(pos, struct chmcPmgiChunkNode, list); + chmc_dump("write pmgi %d\n", _CHMC_CHUNK_LEN); write(chm->fd, &pmgi->chunk, _CHMC_CHUNK_LEN); } } @@ -1640,7 +1654,7 @@ if (stat(filename, &statbuf) < 0) return errno;
- in = open(filename, O_RDONLY); + in = open(filename, O_RDONLY | O_BINARY); if (in >= 0) { todo = statbuf.st_size;
Modified: trunk/reactos/tools/hhpcomp/hhpcomp.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/hhpcomp/hhpcomp.cpp?r... ============================================================================== --- trunk/reactos/tools/hhpcomp/hhpcomp.cpp [iso-8859-1] (original) +++ trunk/reactos/tools/hhpcomp/hhpcomp.cpp [iso-8859-1] Sat Aug 22 11:16:50 2015 @@ -62,11 +62,14 @@ struct chmcFile chm; struct chmcConfig chm_config;
+ memset(&chm, 0, sizeof(struct chmcFile)); + memset(&chm_config, 0, sizeof(struct chmcConfig)); chm_config.title = project_file.get_title_string().c_str(); chm_config.hhc = project_file.get_contents_file_string().c_str(); chm_config.hhk = project_file.get_index_file_string().c_str(); chm_config.deftopic = project_file.get_default_topic_string().c_str(); chm_config.language = project_file.get_language_code(); + chm_config.tmpdir = ".";
int err; err = chmc_init(&chm, replace_backslashes(project_file.get_compiled_file_string()).c_str(), &chm_config);
Modified: trunk/reactos/tools/hhpcomp/port/mkstemps.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/hhpcomp/port/mkstemps... ============================================================================== --- trunk/reactos/tools/hhpcomp/port/mkstemps.c [iso-8859-1] (original) +++ trunk/reactos/tools/hhpcomp/port/mkstemps.c [iso-8859-1] Sat Aug 22 11:16:50 2015 @@ -46,6 +46,11 @@ #define TMP_MAX 16384 #endif
+/* if O_BINARY is not defined, the system is probably not expecting any such flag */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + /*
@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len}) @@ -87,6 +92,7 @@ if ((int) len < 6 + suffix_len || strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6)) { + printf("wrong parameter\n"); return -1; }
@@ -121,7 +127,7 @@ #ifdef VMS fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600, "fop=tmd"); #else - fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600); + fd = open (template, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0600); #endif if (fd >= 0) /* The file does not exist. */