mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 18:01:36 +00:00
[HHPCOMP] Re-enable and (hopefully) fix build. Patch by Michael Fritscher (CORE-10013) with some changes by me to make the program work again (on Linux)
svn path=/trunk/; revision=68693
This commit is contained in:
parent
80443d48dc
commit
f2c87c42b2
12 changed files with 227 additions and 40 deletions
|
@ -15,7 +15,7 @@ add_executable(utf16le utf16le/utf16le.cpp)
|
|||
|
||||
add_subdirectory(cabman)
|
||||
add_subdirectory(cdmake)
|
||||
# add_subdirectory(hhpcomp)
|
||||
add_subdirectory(hhpcomp)
|
||||
add_subdirectory(hpp)
|
||||
add_subdirectory(kbdtool)
|
||||
add_subdirectory(mkhive)
|
||||
|
|
|
@ -6,10 +6,11 @@ list(APPEND SOURCE
|
|||
chmc/chmc.c
|
||||
chmc/err.c
|
||||
lzx_compress/lz_nonslide.c
|
||||
lzx_compress/lzx_layer.c)
|
||||
lzx_compress/lzx_layer.c
|
||||
port/mkstemps.c)
|
||||
|
||||
# used by lzx_compress
|
||||
add_definitions(-DNONSLIDE)
|
||||
|
||||
add_executable(hhpcomp ${SOURCE})
|
||||
target_link_libraries(hhpcomp m)
|
||||
target_link_libraries(hhpcomp)
|
||||
|
|
|
@ -25,7 +25,19 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef __GNUC__
|
||||
typedef int (*__compar_fn_t)(const void *, const void *);
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "err.h"
|
||||
|
||||
|
||||
|
@ -277,7 +289,7 @@ struct chmcSection *chmc_section_create(struct chmcFile *chm,
|
|||
else
|
||||
strcat(section->filename, "chmcUXXXXXX");
|
||||
|
||||
section->fd = mkstemp(section->filename);
|
||||
section->fd = mkstemps(section->filename, 0);
|
||||
fprintf(stderr, "temp file: %s\n", section->filename);
|
||||
if (section->fd < 0) {
|
||||
chmcerr_set(errno, strerror(errno));
|
||||
|
@ -608,7 +620,7 @@ static inline void *chmc_syscat_mem(void *d, void *s, unsigned long len)
|
|||
{
|
||||
memcpy(d, s, len);
|
||||
|
||||
return d + len;
|
||||
return (char *)d + len;
|
||||
}
|
||||
|
||||
static void *chmc_syscat_entry(Int16 code, void *d, void *s, Int16 len)
|
||||
|
@ -691,7 +703,7 @@ int chmc_system_done(struct chmcFile *chm)
|
|||
val = 0;
|
||||
p = chmc_syscat_entry(SIEC_INFOCHKSUM, p, &val, sizeof(val));
|
||||
|
||||
system->_size = p - sysp;
|
||||
system->_size = (char *)p - (char *)sysp;
|
||||
chmc_add_meta(chm, "/#SYSTEM", 0, sysp, system->_size);
|
||||
return CHMC_NOERR;
|
||||
}
|
||||
|
@ -973,7 +985,7 @@ static int _lzx_put_bytes(void *arg, int n, void *buf)
|
|||
{
|
||||
struct chmcLzxInfo *lzx_info = (struct chmcLzxInfo *)arg;
|
||||
struct chmcSect0 *sect0 = &lzx_info->chm->sect0;
|
||||
ssize_t wx;
|
||||
int wx;
|
||||
|
||||
wx = write(lzx_info->section->fd, buf, n);
|
||||
sect0->file_len += wx;
|
||||
|
@ -1062,12 +1074,12 @@ static int _lzx_get_bytes(void *arg, int n, void *buf)
|
|||
|
||||
// read input
|
||||
if (node->buf) {
|
||||
memcpy(buf + (n - todo), &node->buf[lzx_info->fd_offset], toread);
|
||||
memcpy((char *)buf + (n - todo), &node->buf[lzx_info->fd_offset], toread);
|
||||
rx = toread;
|
||||
}
|
||||
else
|
||||
{
|
||||
rx = read(lzx_info->fd, buf + (n - todo), toread);
|
||||
rx = read(lzx_info->fd, (char *)buf + (n - todo), toread);
|
||||
if (rx <= 0) {
|
||||
chmc_error("read error\n");
|
||||
lzx_info->error = 2;
|
||||
|
@ -1149,7 +1161,7 @@ int chmc_reset_table_done(struct chmcFile *chm)
|
|||
if (reset_table) {
|
||||
memcpy(reset_table, §ion->reset_table_header,
|
||||
_CHMC_LZXC_RESETTABLE_V1_LEN);
|
||||
at = (void *)reset_table + _CHMC_LZXC_RESETTABLE_V1_LEN;
|
||||
at = (void *)((char *)reset_table + _CHMC_LZXC_RESETTABLE_V1_LEN);
|
||||
|
||||
i = 0;
|
||||
list_for_each(pos, §ion->mark_list) {
|
||||
|
@ -1212,7 +1224,7 @@ int chmc_uncompressed_done(struct chmcFile *chm)
|
|||
struct chmcSect0 *sect0 = &chm->sect0;
|
||||
struct chmcTreeNode *node;
|
||||
struct list_head *pos;
|
||||
ssize_t wx;
|
||||
int wx;
|
||||
|
||||
list_for_each(pos, &chm->entries_list) {
|
||||
node = list_entry( pos, struct chmcTreeNode, list );
|
||||
|
@ -1312,8 +1324,8 @@ int chmc_pmgl_add_entry(struct chmcFile *chm, struct chmcTreeNode *entry)
|
|||
p = (void *)&chunk->data[pmgl->data_len];
|
||||
|
||||
if (should_idx) {
|
||||
idx = (void *)&chunk->data[CHMC_PMGL_DATA_LEN] - pmgl->index_len;
|
||||
*idx = (void *)p - (void *)&chunk->data;
|
||||
idx = (void *)((char *)&chunk->data[CHMC_PMGL_DATA_LEN] - pmgl->index_len);
|
||||
*idx = (char *)p - (char *)&chunk->data;
|
||||
}
|
||||
|
||||
p += chmc_encint(name_len, p);
|
||||
|
@ -1558,8 +1570,8 @@ int chmc_pmgi_add_entry(struct chmcFile *chm, const char *name, int pmgl_id)
|
|||
p = (void *)&chunk->data[pmgi->data_len];
|
||||
|
||||
if (should_idx) {
|
||||
idx = (void *)&chunk->data[CHMC_PMGI_DATA_LEN] - pmgi->index_len;
|
||||
*idx = (void *)p - (void *)&chunk->data;
|
||||
idx = (void *)((char *)&chunk->data[CHMC_PMGI_DATA_LEN] - pmgi->index_len);
|
||||
*idx = (char *)p - (char *)&chunk->data;
|
||||
}
|
||||
|
||||
p += chmc_encint(name_len, p);
|
||||
|
@ -1629,7 +1641,7 @@ int chmc_appendfile(struct chmcFile *chm, const char *filename, void *buf,
|
|||
struct stat statbuf;
|
||||
int in;
|
||||
off_t todo, toread;
|
||||
ssize_t rx;
|
||||
int rx;
|
||||
|
||||
if (stat(filename, &statbuf) < 0)
|
||||
return errno;
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include "chm.h"
|
||||
#include "list.h"
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 260
|
||||
#endif
|
||||
|
||||
#define CHMC_DIR_UUID \
|
||||
"\x10\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\x00\xa0\xc9\x22\xe6\xec"
|
||||
#define CHMC_STREAM_UUID \
|
||||
|
@ -256,6 +260,6 @@ void chmc_sections_done(struct chmcFile *chm);
|
|||
void chmc_term(struct chmcFile *chm);
|
||||
int chmc_tree_done(struct chmcFile *chm);
|
||||
|
||||
#define chmc_dump(fmt, args...) fprintf(stderr, fmt , ##args)
|
||||
#define chmc_dump(fmt, ...) fprintf(stderr, fmt , ## __VA_ARGS__)
|
||||
|
||||
#endif /* CHMC_CHMC_H */
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
#define CHMC_ERR_H
|
||||
|
||||
#include <stdio.h>
|
||||
#define chmcerr_printf(fmt,args...) fprintf (stderr, fmt , ##args)
|
||||
#define chmcerr_printf(fmt, ...) fprintf (stderr, fmt , ## __VA_ARGS__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#define BUG_ON(fmt, args...) \
|
||||
#define BUG_ON(fmt, ...) \
|
||||
do { \
|
||||
fprintf (stderr, "%s:%d: ", __FILE__, __LINE__); \
|
||||
fprintf (stderr, fmt , ##args); \
|
||||
fprintf (stderr, fmt , ## __VA_ARGS__); \
|
||||
abort (); \
|
||||
} while (0)
|
||||
|
||||
|
@ -45,28 +45,28 @@ void chmcerr_clean(void);
|
|||
int chmcerr_code(void);
|
||||
const char *chmcerr_message(void);
|
||||
|
||||
#define chmc_error(fmt, args...) fprintf (stdout, fmt , ##args)
|
||||
#define chmc_error(fmt, ...) fprintf (stdout, fmt , ## __VA_ARGS__)
|
||||
|
||||
#define chmcerr_return_msg(fmt,args...) \
|
||||
#define chmcerr_return_msg(fmt,...) \
|
||||
do { \
|
||||
chmcerr_printf ( "%s: %d: ", __FILE__, __LINE__ ); \
|
||||
chmcerr_printf ( "error %d: ", chmcerr_code () ); \
|
||||
chmcerr_printf ( fmt , ##args ); \
|
||||
chmcerr_printf ( fmt , ## __VA_ARGS__ ); \
|
||||
chmcerr_printf ( ": %s\n", chmcerr_message () ); \
|
||||
return chmcerr_code (); \
|
||||
} while (0)
|
||||
|
||||
#define chmcerr_msg(fmt,args...) \
|
||||
#define chmcerr_msg(fmt,...) \
|
||||
do { \
|
||||
chmcerr_printf ("%s: %d: ", __FILE__, __LINE__); \
|
||||
chmcerr_printf ("error %d: ", chmcerr_code ()); \
|
||||
chmcerr_printf (fmt , ##args ); \
|
||||
chmcerr_printf (fmt , ## __VA_ARGS__ ); \
|
||||
chmcerr_printf (": %s\n", chmcerr_message ()); \
|
||||
} while (0)
|
||||
|
||||
#define chmcerr_set_return(code,fmt,args...) \
|
||||
#define chmcerr_set_return(code,fmt,...) \
|
||||
do { \
|
||||
chmcerr_set ( (code), (fmt), ##args ); \
|
||||
chmcerr_set ( (code), (fmt), ## __VA_ARGS__ ); \
|
||||
return (code); \
|
||||
} while (0)
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ void hhp_reader::compute_unique_file_pathes_set()
|
|||
{
|
||||
for (list<string>::iterator it = files->filenames.begin(); it != files->filenames.end(); ++it)
|
||||
{
|
||||
unique_file_pathes.insert(replace_backslashes(realpath(it->c_str())));
|
||||
unique_file_pathes.insert(replace_backslashes(real_path(it->c_str())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,16 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "hhp_reader.h"
|
||||
#include "utils.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "chmc/chmc.h"
|
||||
#include "chmc/err.h"
|
||||
|
@ -48,7 +53,7 @@ int main(int argc, char** argv)
|
|||
exit(0);
|
||||
}
|
||||
|
||||
string absolute_name = replace_backslashes(realpath(argv[1]));
|
||||
string absolute_name = replace_backslashes(real_path(argv[1]));
|
||||
int prefixlen = absolute_name.find_last_of('/');
|
||||
clog << prefixlen << endl;
|
||||
chdir(absolute_name.substr(0, prefixlen).c_str()); // change to the project file's directory
|
||||
|
|
|
@ -22,10 +22,16 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <strings.h>
|
||||
#ifdef DEBUG_PERF
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#ifdef DEBUG_PERF
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "lz_nonslide.h"
|
||||
|
||||
|
@ -132,7 +138,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
__inline__ int lz_left_to_process(lz_info *lzi)
|
||||
__inline int lz_left_to_process(lz_info *lzi)
|
||||
{
|
||||
return lzi->chars_in_buf - lzi->block_loc;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
typedef unsigned char u_char;
|
||||
#endif
|
||||
|
||||
typedef struct lz_info lz_info;
|
||||
typedef int (*get_chars_t)(lz_info *lzi, int n, u_char *buf);
|
||||
typedef int (*output_match_t)(lz_info *lzi, int match_pos, int match_len);
|
||||
|
|
139
reactos/tools/hhpcomp/port/mkstemps.c
Normal file
139
reactos/tools/hhpcomp/port/mkstemps.c
Normal file
|
@ -0,0 +1,139 @@
|
|||
/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
|
||||
This file is derived from mkstemp.c from the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_PROCESS_H
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
/* We need to provide a type for gcc_uint64_t. */
|
||||
#ifdef __GNUC__
|
||||
__extension__ typedef unsigned long long gcc_uint64_t;
|
||||
#else
|
||||
typedef unsigned long gcc_uint64_t;
|
||||
#endif
|
||||
|
||||
#ifndef TMP_MAX
|
||||
#define TMP_MAX 16384
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len})
|
||||
|
||||
Generate a unique temporary file name from @var{template}.
|
||||
@var{template} has the form:
|
||||
|
||||
@example
|
||||
@var{path}/ccXXXXXX@var{suffix}
|
||||
@end example
|
||||
|
||||
@var{suffix_len} tells us how long @var{suffix} is (it can be zero
|
||||
length). The last six characters of @var{template} before @var{suffix}
|
||||
must be @samp{XXXXXX}; they are replaced with a string that makes the
|
||||
filename unique. Returns a file descriptor open on the file for
|
||||
reading and writing.
|
||||
|
||||
@end deftypefn
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
mkstemps (
|
||||
char *template,
|
||||
int suffix_len)
|
||||
{
|
||||
static const char letters[]
|
||||
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
static gcc_uint64_t value;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval tv;
|
||||
#endif
|
||||
char *XXXXXX;
|
||||
size_t len;
|
||||
int count;
|
||||
|
||||
len = strlen (template);
|
||||
|
||||
if ((int) len < 6 + suffix_len
|
||||
|| strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
XXXXXX = &template[len - 6 - suffix_len];
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* Get some more or less random data. */
|
||||
gettimeofday (&tv, NULL);
|
||||
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
|
||||
#else
|
||||
value += getpid ();
|
||||
#endif
|
||||
|
||||
for (count = 0; count < TMP_MAX; ++count)
|
||||
{
|
||||
gcc_uint64_t v = value;
|
||||
int fd;
|
||||
|
||||
/* Fill in the random bits. */
|
||||
XXXXXX[0] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[1] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[2] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[3] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[4] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[5] = letters[v % 62];
|
||||
|
||||
#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);
|
||||
#endif
|
||||
if (fd >= 0)
|
||||
/* The file does not exist. */
|
||||
return fd;
|
||||
|
||||
/* This is a random value. It is only necessary that the next
|
||||
TMP_MAX values generated by adding 7777 to VALUE are different
|
||||
with (module 2^32). */
|
||||
value += 7777;
|
||||
}
|
||||
|
||||
/* We return the null string if we can't find a unique file name. */
|
||||
template[0] = '\0';
|
||||
return -1;
|
||||
}
|
|
@ -21,7 +21,12 @@
|
|||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <unistd.h>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h> // for GetFullPathNameA
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std;
|
||||
|
@ -33,13 +38,23 @@ string to_upper(string s)
|
|||
return temp;
|
||||
}
|
||||
|
||||
string realpath(const char* path)
|
||||
string real_path(const char* path)
|
||||
{
|
||||
char* temp = realpath(path, NULL);
|
||||
char* temp = NULL;
|
||||
#if defined(_WIN32)
|
||||
char temp2[MAX_PATH];
|
||||
if (GetFullPathNameA(path, MAX_PATH, temp2, NULL)) {
|
||||
temp = temp2;
|
||||
}
|
||||
#else
|
||||
temp = realpath(path, NULL);
|
||||
#endif
|
||||
if (temp == NULL)
|
||||
throw runtime_error("realpath failed");
|
||||
string result(temp);
|
||||
free(temp);
|
||||
#if !defined(_WIN32)
|
||||
free(temp);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
string to_upper(string s);
|
||||
|
||||
string realpath(const char* path);
|
||||
string real_path(const char* path);
|
||||
|
||||
string replace_backslashes(string s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue