From 673b754fbcf364c65fe68afb5897913b7e33927a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 13 May 2010 01:26:33 -0400 Subject: [PATCH] elided cruft --- zgz/bzip2-0.9.5d/bzip2.c | 218 +++-------------------------------------------- 1 file changed, 11 insertions(+), 207 deletions(-) diff --git a/zgz/bzip2-0.9.5d/bzip2.c b/zgz/bzip2-0.9.5d/bzip2.c index 0e19733..78d5b2e 100644 --- a/zgz/bzip2-0.9.5d/bzip2.c +++ b/zgz/bzip2-0.9.5d/bzip2.c @@ -1,8 +1,3 @@ - -/*-----------------------------------------------------------*/ -/*--- A block-sorting, lossless compressor bzip2.c ---*/ -/*-----------------------------------------------------------*/ - /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. @@ -57,42 +52,6 @@ For more information on these sources, see the manual. --*/ - -/*----------------------------------------------------*/ -/*--- and now for something much more pleasant :-) ---*/ -/*----------------------------------------------------*/ - -/*---------------------------------------------*/ -/*-- - Place a 1 beside your platform, and 0 elsewhere. ---*/ - -/*-- - Generic 32-bit Unix. - Also works on 64-bit Unix boxes. ---*/ -#define BZ_UNIX 1 - -/*-- - Win32, as seen by Jacob Navia's excellent - port of (Chris Fraser & David Hanson)'s excellent - lcc compiler. ---*/ -#define BZ_LCCWIN32 0 - -#if defined(_WIN32) && !defined(__CYGWIN32__) -#undef BZ_LCCWIN32 -#define BZ_LCCWIN32 1 -#undef BZ_UNIX -#define BZ_UNIX 0 -#endif - - -/*---------------------------------------------*/ -/*-- - Some stuff for all platforms. ---*/ - #include #include #include @@ -106,109 +65,11 @@ #define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); } #define ERROR_IF_MINUS_ONE(i) { if ((i) == (-1)) ioError(); } - -/*---------------------------------------------*/ -/*-- - Platform-specific stuff. ---*/ - -#if BZ_UNIX -# include -# include -# include -# include -# include - -# define PATH_SEP '/' -# define MY_LSTAT lstat -# define MY_S_IFREG S_ISREG -# define MY_STAT stat - -# define APPEND_FILESPEC(root, name) \ - root=snocString((root), (name)) - -# define APPEND_FLAG(root, name) \ - root=snocString((root), (name)) - -# define SET_BINARY_MODE(fd) /**/ - -# ifdef __GNUC__ -# define NORETURN __attribute__ ((noreturn)) -# else -# define NORETURN /**/ -# endif -# ifdef __DJGPP__ -# include -# include -# undef MY_LSTAT -# define MY_LSTAT stat -# undef SET_BINARY_MODE -# define SET_BINARY_MODE(fd) \ - do { \ - int retVal = setmode ( fileno ( fd ), \ - O_BINARY ); \ - ERROR_IF_MINUS_ONE ( retVal ); \ - } while ( 0 ) -# endif -#endif - - - -#if BZ_LCCWIN32 -# include -# include -# include - -# define NORETURN /**/ -# define PATH_SEP '\\' -# define MY_LSTAT _stat -# define MY_STAT _stat -# define MY_S_IFREG(x) ((x) & _S_IFREG) - -# define APPEND_FLAG(root, name) \ - root=snocString((root), (name)) - -# if 0 - /*-- lcc-win32 seems to expand wildcards itself --*/ -# define APPEND_FILESPEC(root, spec) \ - do { \ - if ((spec)[0] == '-') { \ - root = snocString((root), (spec)); \ - } else { \ - struct _finddata_t c_file; \ - long hFile; \ - hFile = _findfirst((spec), &c_file); \ - if ( hFile == -1L ) { \ - root = snocString ((root), (spec)); \ - } else { \ - int anInt = 0; \ - while ( anInt == 0 ) { \ - root = snocString((root), \ - &c_file.name[0]); \ - anInt = _findnext(hFile, &c_file); \ - } \ - } \ - } \ - } while ( 0 ) -# else -# define APPEND_FILESPEC(root, name) \ - root = snocString ((root), (name)) -# endif - -# define SET_BINARY_MODE(fd) \ - do { \ - int retVal = setmode ( fileno ( fd ), \ - O_BINARY ); \ - ERROR_IF_MINUS_ONE ( retVal ); \ - } while ( 0 ) - -#endif - - -/*---------------------------------------------*/ -/*-- - Some more stuff for all platforms :-) ---*/ +#include +#include +#include +#include +#include typedef char Char; typedef unsigned char Bool; @@ -227,62 +88,10 @@ typedef unsigned short UInt16; --*/ typedef int IntNative; - -/*---------------------------------------------------*/ -/*--- Misc (file handling) data decls ---*/ -/*---------------------------------------------------*/ - Int32 verbosity; -Bool keepInputFiles, smallMode; -Bool forceOverwrite, testFailsExist, noisy; -Int32 numFileNames, numFilesProcessed, blockSize100k; - - -/*-- source modes; F==file, I==stdin, O==stdout --*/ -#define SM_I2O 1 -#define SM_F2O 2 -#define SM_F2F 3 - -/*-- operation modes --*/ -#define OM_Z 1 -#define OM_UNZ 2 -#define OM_TEST 3 - -Int32 opMode; -Int32 srcMode; - -#define FILE_NAME_LEN 1034 - -Int32 longestFileName; -Char inName [FILE_NAME_LEN]; -Char outName[FILE_NAME_LEN]; -Char tmpName[FILE_NAME_LEN]; -Char *progName; -Char progNameReally[FILE_NAME_LEN]; -FILE *outputHandleJustInCase; +Int32 blockSize100k; Int32 workFactor; -void panic ( Char* ) NORETURN; -void ioError ( void ) NORETURN; -void outOfMemory ( void ) NORETURN; -void blockOverrun ( void ) NORETURN; -void badBlockHeader ( void ) NORETURN; -void badBGLengths ( void ) NORETURN; -void crcError ( void ) NORETURN; -void bitStreamEOF ( void ) NORETURN; -void cleanUpAndFail ( Int32 ) NORETURN; -void compressedStreamEOF ( void ) NORETURN; - -void copyFileName ( Char*, Char* ); -void* myMalloc ( Int32 ); - - - -/*---------------------------------------------------*/ -/*--- Processing of complete files and streams ---*/ -/*---------------------------------------------------*/ - -/*---------------------------------------------*/ Bool myfeof ( FILE* f ) { Int32 c = fgetc ( f ); @@ -291,8 +100,12 @@ Bool myfeof ( FILE* f ) return False; } +void panic (char *msg) { + perror("oops"); + fprintf(stderr, "%s\n", msg); + exit(1); +} -/*---------------------------------------------*/ void compressStream ( FILE *stream, FILE *zStream ) { BZFILE* bzf = NULL; @@ -301,9 +114,6 @@ void compressStream ( FILE *stream, FILE *zStream ) UInt32 nbytes_in, nbytes_out; Int32 bzerr, bzerr_dummy, ret; - SET_BINARY_MODE(stream); - SET_BINARY_MODE(zStream); - if (ferror(stream)) goto errhandler_io; if (ferror(zStream)) goto errhandler_io; @@ -357,12 +167,6 @@ void compressStream ( FILE *stream, FILE *zStream ) /*notreached*/ } -void panic (char *msg) { - perror("oops"); - fprintf(stderr, "%s\n", msg); - exit(1); -} - int main () { /* tunables */ workFactor = 30; -- 2.7.4