elided cruft
authorJoey Hess <joey@kitenet.net>
Thu, 13 May 2010 05:26:33 +0000 (01:26 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 13 May 2010 05:26:33 +0000 (01:26 -0400)
zgz/bzip2-0.9.5d/bzip2.c

index 0e19733..78d5b2e 100644 (file)
@@ -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.
   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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #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 <sys/types.h>
-#   include <utime.h>
-#   include <unistd.h>
-#   include <sys/stat.h>
-#   include <sys/times.h>
-
-#   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 <io.h>
-#     include <fcntl.h>
-#     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 <io.h>
-#   include <fcntl.h>
-#   include <sys\stat.h>
-
-#   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 <sys/types.h>
+#include <utime.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/times.h>
 
 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;