Minor tweaks, primarily to get the Win32 build working.

This commit is contained in:
Andy McFadden 2002-10-10 23:45:56 +00:00
parent 6e51e34904
commit bd3eef768e
13 changed files with 146 additions and 21 deletions

View File

@ -33,7 +33,7 @@ Nu_bzalloc(void* opaque, int items, int size)
static void
Nu_bzfree(void* opaque, void* address)
{
return Nu_Free(opaque, address);
Nu_Free(opaque, address);
}

View File

@ -33,7 +33,7 @@ Nu_zalloc(voidpf opaque, uInt items, uInt size)
static void
Nu_zfree(voidpf opaque, voidpf address)
{
return Nu_Free(opaque, address);
Nu_Free(opaque, address);
}

View File

@ -20,7 +20,7 @@
#ifdef ENABLE_LZC
#define DEBUG_LZC
/*#define DEBUG_LZC*/
/*
* Selected definitions from compress.h.

View File

@ -5,6 +5,11 @@
# Run with "nmake /f Makefile.msc".
#
# To build without debugging info, use "nmake nodebug=1".
# To build with libz, use "nmake libz=1".
# To build with libbz2, use "nmake libbz2=1".
#
# For libz/libbz2, you need to have the appropriate header file(s) either
# in this directory or in a standard location that the compiler can find.
#
# Windows magic
@ -12,10 +17,11 @@ TARGETOS = BOTH
!include <ntwin32.mak>
# object files
OBJS1 = Archive.obj ArchiveIO.obj Compress.obj Crc16.obj Debug.obj Deferred.obj
OBJS2 = Entry.obj Expand.obj FileIO.obj Funnel.obj Lzw.obj MiscStuff.obj
OBJS3 = MiscUtils.obj Record.obj SourceSink.obj Thread.obj Value.obj Version.obj
OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
OBJS1 = Archive.obj ArchiveIO.obj Bzip2.obj Compress.obj Crc16.obj Debug.obj
OBJS2 = Deferred.obj Deflate.obj Entry.obj Expand.obj FileIO.obj Funnel.obj
OBJS3 = Lzc.obj Lzw.obj MiscStuff.obj MiscUtils.obj Record.obj SourceSink.obj
OBJS4 = Squeeze.obj Thread.obj Value.obj Version.obj
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4)
!ifdef NODEBUG
#OPT = $(cdebug) /D NDEBUG /ML
@ -26,6 +32,13 @@ OPT = $(cdebug) /MLd
BUILD_FLAGS = /W3 /GX /D "WIN32"
!ifdef LIBZ
BUILD_FLAGS = $(BUILD_FLAGS) /D "ENABLE_DEFLATE"
!endif
!ifdef LIBBZ2
BUILD_FLAGS = $(BUILD_FLAGS) /D "ENABLE_BZIP2"
!endif
# how to compile sources
.c.obj:
@$(cc) $(OPT) $(BUILD_FLAGS) $(cflags) $(cvars) -o $@ $<
@ -38,6 +51,12 @@ all: $(PRODUCT) samples
samples::
@echo -
@echo - Change to the samples directory and run $(MAKE) there.
!ifdef LIBZ
@echo - Remember to specify libz=1
!endif
!ifdef LIBBZ
@echo - Remember to specify libbz2=1
!endif
@echo -
# this isn't great, but it'll have to do
@ -48,6 +67,7 @@ Version.c: Version.c.in
@echo -
nufxlib.lib: $(OBJS)
if exist $(PRODUCT) del $(PRODUCT)
$(link) -lib /out:$(PRODUCT) $(OBJS) /nologo
clean::
@ -56,19 +76,23 @@ clean::
Archive.obj: Archive.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
ArchiveIO.obj: ArchiveIO.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Bzip2.obj: Bzip2.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Compress.obj: Compress.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Crc16.obj: Crc16.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Debug.obj: Debug.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Deferred.obj: Deferred.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Deflate.obj: Deflate.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Entry.obj: Entry.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Expand.obj: Expand.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
FileIO.obj: FileIO.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Funnel.obj: Funnel.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Lzc.obj: Lzc.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Lzw.obj: Lzw.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
MiscStuff.obj: MiscStuff.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
MiscUtils.obj: MiscUtils.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Record.obj: Record.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
SourceSink.obj: SourceSink.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Squeeze.obj: Squeeze.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Thread.obj: Thread.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Value.obj: Value.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h
Version.obj: Version.c NufxLibPriv.h NufxLib.h MiscStuff.h SysDefs.h

View File

@ -776,7 +776,7 @@ Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
numNodes = 0;
else
numNodes = sqState.treeHead - (kNuSQNumVals - 1);
err = Nu_SQWriteShort(fp, numNodes);
err = Nu_SQWriteShort(fp, (short) numNodes);
BailError(err);
compressedLen += 2;
@ -787,9 +787,9 @@ Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp,
r = sqState.node[i].rchild;
l = l < kNuSQNumVals ? -(l + 1) : sqState.treeHead - l;
r = r < kNuSQNumVals ? -(r + 1) : sqState.treeHead - r;
err = Nu_SQWriteShort(fp, l);
err = Nu_SQWriteShort(fp, (short) l);
BailError(err);
err = Nu_SQWriteShort(fp, r);
err = Nu_SQWriteShort(fp, (short) r);
BailError(err);
compressedLen += 4;

View File

@ -61,6 +61,11 @@
# define ulong unsigned long
# define inline /*Visual C++6.0 can't inline ".c" files*/
# define mode_t int
# define ENABLE_SQ
# define ENABLE_LZW
# define ENABLE_LZC
/*# define ENABLE_DEFLATE*/
/*# define ENABLE_BZIP2*/
# endif
# include <io.h>
@ -114,9 +119,10 @@
# endif
#endif
#ifdef MAC
# define HAS_RESOURCE_FORKS
#endif
/* resource forks on UFS filesystem under Mac OS X are a kluge */
/*#ifdef MAC*/
/*# define HAS_RESOURCE_FORKS*/
/*#endif*/
#ifdef __ORCAC__
# define HAS_RESOURCE_FORKS

View File

@ -1,4 +1,10 @@
dnl NuFX archive manipulation library
dnl Copyright (C) 2000 by Andy McFadden, All Rights Reserved.
dnl This is free software; you can redistribute it and/or modify it under the
dnl terms of the GNU Library General Public License, see the file COPYING.LIB.
dnl
dnl Process this file with autoconf to produce a configure script.
AC_INIT(NufxLibPriv.h)
AC_CONFIG_HEADER(config.h)

View File

@ -531,6 +531,60 @@ bail:
}
/*
* Can't count on having getopt on non-UNIX platforms, so just use this
* quick version instead. May not work exactly like getopt(), but it
* does everything we need here.
*/
int myoptind = 0;
char* myoptarg = nil;
const char* curchar = nil;
int skipnext = false;
int
mygetopt(int argc, char** argv, const char* optstr)
{
if (!myoptind) {
myoptind = 1;
if (argc <= 1)
return EOF;
curchar = argv[myoptind];
if (*curchar != '-')
return EOF;
}
curchar++;
if (*curchar == '\0') {
myoptind++;
if (skipnext)
myoptind++;
if (myoptind >= argc)
return EOF;
curchar = argv[myoptind];
if (*curchar != '-')
return EOF;
curchar++;
}
while (*optstr != '\0') {
if (*optstr == *curchar) {
/*printf("MATCHED '%c'\n", *optstr);*/
if (*(optstr+1) == ':') {
skipnext = true;
myoptarg = argv[myoptind+1];
/*printf("ATTACHED '%s'\n", myoptarg);*/
}
return *curchar;
}
optstr++;
}
fprintf(stderr, "Unrecognized option '%c'\n", *curchar);
return *curchar;
}
/*
* Print usage info.
*/
@ -555,8 +609,6 @@ Usage(const char* argv0)
int
main(int argc, char** argv)
{
extern char* optarg;
extern int optind;
NuValue compressMethod = kNuCompressLZW2;
long major, minor, bug;
const char* pBuildDate;
@ -570,7 +622,7 @@ main(int argc, char** argv)
major, minor, bug, pBuildDate);
errorFlag = false;
while ((ic = getopt(argc, argv, "crfatm:")) != EOF) {
while ((ic = mygetopt(argc, argv, "crfatm:")) != EOF) {
switch (ic) {
case 'c': flags |= kFlagCopyOnly; break;
case 'r': flags |= kFlagReverseThreads; break;
@ -592,7 +644,7 @@ main(int argc, char** argv)
{ "deflate", kNuCompressDeflate, kNuFeatureCompressDeflate},
{ "bzip2", kNuCompressBzip2, kNuFeatureCompressBzip2 },
};
char* methodStr = optarg;
char* methodStr = myoptarg;
int i;
for (i = 0; i < NELEM(methods); i++) {
@ -621,12 +673,12 @@ main(int argc, char** argv)
}
}
if (errorFlag || argc != optind+2) {
if (errorFlag || argc != myoptind+2) {
Usage(argv[0]);
exit(2);
}
cc = LaunderArchive(argv[optind], argv[optind+1], compressMethod, flags);
cc = LaunderArchive(argv[myoptind], argv[myoptind+1], compressMethod,flags);
if (cc == 0)
printf("Success!\n");

View File

@ -6,6 +6,11 @@
# in "..".
#
# To build without debugging info, use "nmake nodebug=1".
# To build with libz, use "nmake libz=1".
# To build with libbz2, use "nmake libbz2=1".
#
# For libz/libbz2, you need to have the appropriate library either
# in this directory or in a standard location that the linker can find.
#
# Windows magic
@ -26,6 +31,13 @@ LIB_FLAGS = /nodefaultlib:libc.lib /nologo libcd.lib setargv.obj
BUILD_FLAGS = /W3 /GX /D "WIN32" /D "_CONSOLE" /I "$(NUFXSRCDIR)"
!ifdef LIBZ
LIB_FLAGS = zlib.lib $(LIB_FLAGS)
!endif
!ifdef LIBBZ2
LIB_FLAGS = libbz2.lib $(LIB_FLAGS)
!endif
# how to compile sources
.c.obj:
@$(cc) $(cdebug) $(OPT) $(BUILD_FLAGS) $(cflags) $(cvars) -o $@ $<

View File

@ -136,6 +136,11 @@ bail:
* You could, of course, create a single record with a data thread and
* a disk image thread, but it's a fair bet ShrinkIt would ignore one
* or the other.
*
* NOTE: we don't currently work around the GSHK zero-length file bug.
* Such records, which have a filename thread but no data threads at all,
* will be categorized as "unknown". We could detect the situation and
* correct it, but we might as well flag it in a user-visible way.
*/
static NuError
AnalyzeRecord(const NuRecord* pRecord, enum RecordKind* pRecordKind,

View File

@ -6,6 +6,11 @@
# in "..\nufxlib-$(VERSION)".
#
# To build without debugging info, use "nmake nodebug=1".
# To link with libz, use "nmake libz=1".
# To build with libbz2, use "nmake libbz2=1".
#
# For libz/libbz2, you need to have the appropriate library either
# in this directory or in a standard location that the linker can find.
#
# Windows magic
@ -16,8 +21,8 @@ VERSION=0
NUFXSRCDIR = ..\nufxlib-$(VERSION)
# object files
OBJS1 = Add.obj ArcUtils.obj Delete.obj Extract.obj Filename.obj List.obj
OBJS2 = Main.obj MiscStuff.obj MiscUtils.obj State.obj SysUtils.obj
OBJS1 = Add.obj ArcUtils.obj Binary2.obj Delete.obj Extract.obj Filename.obj
OBJS2 = List.obj Main.obj MiscStuff.obj MiscUtils.obj State.obj SysUtils.obj
OBJS = $(OBJS1) $(OBJS2)
!ifdef NODEBUG
@ -31,6 +36,13 @@ LIB_FLAGS = /nodefaultlib:libc.lib /nologo libcd.lib setargv.obj
BUILD_FLAGS = /W3 /GX /D "WIN32" /D "_CONSOLE" /I "$(NUFXSRCDIR)"
!ifdef LIBZ
LIB_FLAGS = zlib.lib $(LIB_FLAGS)
!endif
!ifdef LIBBZ2
LIB_FLAGS = libbz2.lib $(LIB_FLAGS)
!endif
# how to compile sources
.c.obj:
@$(cc) $(cdebug) $(OPT) $(BUILD_FLAGS) $(cflags) $(cvars) -o $@ $<
@ -49,6 +61,7 @@ clean:
Add.obj: Add.c NuLib2.h $(NUFXSRCDIR)\NufxLib.h SysDefs.h State.h MiscStuff.h
ArcUtils.obj: ArcUtils.c NuLib2.h $(NUFXSRCDIR)\NufxLib.h SysDefs.h State.h MiscStuff.h
Binary2.obj: Binary2.c NuLib2.h $(NUFXSRCDIR)\NufxLib.h SysDefs.h State.h MiscStuff.h
Delete.obj: Delete.c NuLib2.h $(NUFXSRCDIR)\NufxLib.h SysDefs.h State.h MiscStuff.h
Extract.obj: Extract.c NuLib2.h $(NUFXSRCDIR)\NufxLib.h SysDefs.h State.h MiscStuff.h
Filename.obj: Filename.c NuLib2.h $(NUFXSRCDIR)\NufxLib.h SysDefs.h State.h MiscStuff.h

View File

@ -64,6 +64,7 @@
# endif
# include <io.h>
# include <direct.h>
# define FOPEN_WANTS_B
# define HAVE_CHSIZE
# define snprintf _snprintf

View File

@ -1,4 +1,10 @@
dnl Nulib2
dnl Copyright (C) 2000 by Andy McFadden, All Rights Reserved.
dnl This is free software; you can redistribute it and/or modify it under the
dnl terms of the GNU General Public License, see the file COPYING.
dnl
dnl Process this file with autoconf to produce a configure script.
AC_INIT(Main.c)
AC_CONFIG_HEADER(config.h)