Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'To build chmdump under 10.4.x / Darwin 8' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
To build chmdump under 10.4.x / Darwin 8
Authored by: victory on May 05, '05 06:49:40PM
UNcomment line 23 of the chmlib.h (Yeah, the one that tell's you it was previously commmented out to build correctly under an earlier OS version):

typedef unsigned short ushort;

Under 10.4.x w/GCC 3.3/4.0 you'll get a bunch of compile warnings (mostly due to mismatched prototypes), but the app should build and work ok.

Of course, I'm not sure why anyone would be messing with this utility anymore, considering the handful of really nice Aqua-native .CHM viewers now available. But there it is...

[ Reply to This | # ]

To build chmdump under 10.4.x / Darwin 8
Authored by: qu1j0t3 on Apr 08, '10 04:13:03AM

Here is a more comprehensive diff that makes chmdump portable to 32/64 bit Intel as well. It also fixes the warnings.


diff -Naur chmtools-0.1/Makefile chmtools/Makefile
--- chmtools-0.1/Makefile 2002-01-08 15:03:47.000000000 +1100
+++ chmtools/Makefile 2010-04-08 20:19:47.000000000 +1000
@@ -1,9 +1,9 @@
LIBOBJS = chmlib.o lzx.o
-CFLAGS = -DDEBUG
+CFLAGS = -DDEBUG -g
PROGS = chmdump

chmdump: $(LIBOBJS) chmdump.o
$(LINK.c) -o $@ $^

clean:
- rm -f *.o *~ \#* core $(PROGS)
\ No newline at end of file
+ rm -f *.o *~ \#* core $(PROGS)
diff -Naur chmtools-0.1/chmlib.c chmtools/chmlib.c
--- chmtools-0.1/chmlib.c 2001-10-15 06:37:30.000000000 +1000
+++ chmtools/chmlib.c 2010-04-08 20:19:47.000000000 +1000
@@ -18,9 +18,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

-#include <stdlib.h>
#include "chmlib.h"
-#include "fixendian.h"

#define FILELEN_HSECT 0
#define DIR_HSECT 1
@@ -39,15 +37,17 @@
#define DPRINTF while (0) fprintf
#endif

-static void
-get_guid(ubyte *buf, guid_t *guid)
-{
- memcpy(guid, buf, sizeof(guid_t));
- FIXENDIAN32(guid->guid1);
- FIXENDIAN16(guid->guid2[0]);
- FIXENDIAN16(guid->guid2[1]);
+ulong le32(ubyte *p){
+ return (p[3]<<24) | (p[2]<<16) | (p[1]<<8) | p[0];
+}
+
+ushort le16(ubyte *p){
+ return (p[1]<<8) | p[0];
}

+#define FIXENDIAN16(x) ((x) = le16((ubyte*)&(x)))
+#define FIXENDIAN32(x) ((x) = le32((ubyte*)&(x)))
+
static void
make_guid_string(guid_t *guid, char *s)
{
@@ -57,7 +57,7 @@
guid->guid3[4], guid->guid3[5], guid->guid3[6], guid->guid3[7]);
}

-static void guid_fix_endian(guid_t *guid)
+static void guid_fix_endian(guid_t *guid)
{
FIXENDIAN32(guid->guid1);
FIXENDIAN16(guid->guid2[0]);
diff -Naur chmtools-0.1/chmlib.h chmtools/chmlib.h
--- chmtools-0.1/chmlib.h 2002-01-08 15:01:31.000000000 +1100
+++ chmtools/chmlib.h 2010-04-08 20:19:47.000000000 +1000
@@ -19,9 +19,15 @@
*/

#include <stdio.h>
-typedef unsigned long ulong;
-// typedef unsigned short ushort; Already defined for Darwin
-typedef unsigned char ubyte;
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+// int is 4 bytes on 32-bit and 64-bit OS X; long is not.
+// see: http://developer.apple.com/Mac/library/documentation/Darwin/Conceptual/64bitPorting/transition/transition.html#//apple_ref/doc/uid/TP40001064-CH207-SW1
+typedef uint32_t ulong;
+typedef uint16_t ushort; //Already defined for Darwin
+typedef uint8_t ubyte;

typedef struct guid_t
{
diff -Naur chmtools-0.1/fixendian.h chmtools/fixendian.h
--- chmtools-0.1/fixendian.h 2001-10-14 13:29:33.000000000 +1000
+++ chmtools/fixendian.h 1970-01-01 10:00:00.000000000 +1000
@@ -1,15 +0,0 @@
-#ifdef BIG_ENDIAN
-#define EREV32(x) ((((x)&0xFF000000)>>24) | \
- (((x)&0x00FF0000)>> 8) | \
- (((x)&0x0000FF00)<< 8) | \
- (((x)&0x000000FF)<<24))
-#define FIXENDIAN32(x) (x)=EREV32((ulong)x)
-#define FIXENDIAN16(x) (x)= ((((ushort)(x))>>8) | ((ushort)((x)<<8)))
-#define COPYENDIAN32(x) EREV32((ulong)x)
-#define COPYENDIAN16(x) ((((ushort)(x))>>8) | ((ushort)((x)<<8)))
-#else
-#define FIXENDIAN32(x)
-#define FIXENDIAN16(x)
-#define COPYENDIAN32(x) x
-#define COPYENDIAN16(x) x
-#endif
diff -Naur chmtools-0.1/lzx.h chmtools/lzx.h
--- chmtools-0.1/lzx.h 2001-10-14 14:34:41.000000000 +1000
+++ chmtools/lzx.h 2010-04-08 20:19:47.000000000 +1000
@@ -1,9 +1,12 @@
-#define UBYTE unsigned char
-#define UWORD unsigned short
-#define ULONG unsigned long
-#define BYTE signed char
-#define WORD short
-#define LONG long
+#include <stdint.h>
+#include <string.h>
+
+typedef uint8_t UBYTE;
+typedef uint16_t UWORD;
+typedef uint32_t ULONG;
+typedef int8_t BYTE;
+typedef int16_t WORD;
+typedef int32_t LONG;

int LZXinit(int window);
int LZXdecompress(UBYTE *inbuf, UBYTE *outbuf, ULONG inlen, ULONG outlen);



[ Reply to This | # ]