--- bzip2-1.0.8.old/Makefile +++ bzip2-1.0.8/Makefile @@ -18,10 +18,9 @@ CC=gcc AR=ar RANLIB=ranlib -LDFLAGS= BIGFILES=-D_FILE_OFFSET_BITS=64 -CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) +CFLAGS+=-Wall -Winline -O2 $(BIGFILES) $(CPPFLAGS) # Where you want it installed when you do 'make install' PREFIX=/usr/local @@ -35,7 +34,7 @@ decompress.o \ bzlib.o -all: libbz2.a bzip2 bzip2recover test +all: libbz2.a bzip2 bzip2recover bzip2: libbz2.a bzip2.o $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2 --- bzip2-1.0.8.old/Makefile-libbz2_so +++ bzip2-1.0.8/Makefile-libbz2_so @@ -20,11 +20,10 @@ # in the file LICENSE. # ------------------------------------------------------------------ - SHELL=/bin/sh CC=gcc BIGFILES=-D_FILE_OFFSET_BITS=64 -CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES) +CFLAGS+=-fpic -fPIC -Wall -Winline -O2 $(BIGFILES) $(CPPFLAGS) OBJS= blocksort.o \ huffman.o \ @@ -35,13 +34,13 @@ bzlib.o all: $(OBJS) - $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.8 $(OBJS) + $(CC) -shared -Wl,-soname -Wl,libbz2.so.1 -o libbz2.so.1.0.8 $(OBJS) $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.8 - rm -f libbz2.so.1.0 - ln -s libbz2.so.1.0.8 libbz2.so.1.0 + rm -f libbz2.so.1 + ln -s libbz2.so.1.0.8 libbz2.so.1 clean: - rm -f $(OBJS) bzip2.o libbz2.so.1.0.8 libbz2.so.1.0 bzip2-shared + rm -f $(OBJS) bzip2.o libbz2.so.1.0.8 libbz2.so.1 bzip2-shared blocksort.o: blocksort.c $(CC) $(CFLAGS) -c blocksort.c @@ -57,3 +56,9 @@ $(CC) $(CFLAGS) -c decompress.c bzlib.o: bzlib.c $(CC) $(CFLAGS) -c bzlib.c + +bzip2: bzip2.o + $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2 + +bzip2recover: bzip2recover.o + $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o --- bzip2-1.0.8.old/bzip2.1 +++ bzip2-1.0.8/bzip2.1 @@ -235,6 +235,10 @@ Suppress non-essential warning messages. Messages pertaining to I/O errors and other critical events will not be suppressed. .TP +.B \-p --show-progress +Show percentage of input-file done and while compressing show the percentage +of the original file the new file is. +.TP .B \-v --verbose Verbose mode -- show the compression ratio for each file processed. Further \-v's increase the verbosity level, spewing out lots of --- bzip2-1.0.8.old/bzip2.c +++ bzip2-1.0.8/bzip2.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include "bzlib.h" @@ -209,6 +210,7 @@ Char progNameReally[FILE_NAME_LEN]; FILE *outputHandleJustInCase; Int32 workFactor; +Char showProgress; static void panic ( const Char* ) NORETURN; static void ioError ( void ) NORETURN; @@ -334,6 +336,12 @@ UInt32 nbytes_in_lo32, nbytes_in_hi32; UInt32 nbytes_out_lo32, nbytes_out_hi32; Int32 bzerr, bzerr_dummy, ret; + double fileSize = 0; /* initialized to make the compiler stop crying */ + /* double because big files might otherwhise give + * overflows. not long long since not all compilers + * support that one + */ + time_t startTime, currentTime; SET_BINARY_MODE(stream); SET_BINARY_MODE(zStream); @@ -341,12 +349,21 @@ if (ferror(stream)) goto errhandler_io; if (ferror(zStream)) goto errhandler_io; + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) { + (void)fseek(stream, 0, SEEK_END); + fileSize = (double)ftell(stream); + rewind(stream); + if (verbosity >= 1) + fprintf(stderr, "Input-file size: %ld\n", (long)fileSize); + } + bzf = BZ2_bzWriteOpen ( &bzerr, zStream, blockSize100k, verbosity, workFactor ); if (bzerr != BZ_OK) goto errhandler; if (verbosity >= 2) fprintf ( stderr, "\n" ); + time(&startTime); while (True) { if (myfeof(stream)) break; @@ -355,6 +372,25 @@ if (nIbuf > 0) BZ2_bzWrite ( &bzerr, bzf, (void*)ibuf, nIbuf ); if (bzerr != BZ_OK) goto errhandler; + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) + { + time(¤tTime); + + if ((currentTime - startTime) > 1) { /* show progress every 2 seconds */ + double curInPos = (double)ftell(stream); + double curOutPos = (double)ftell(zStream); + + startTime = currentTime; + + fprintf(stderr, "%.2f%% done", (curInPos * 100.0) / fileSize); + if (srcMode == SM_F2F) + { + fprintf(stderr, ", new size: %.2f%%", (curOutPos * 100.0) / curInPos); + } + + fprintf(stderr, " \r"); + } + } } BZ2_bzWriteClose64 ( &bzerr, bzf, 0, @@ -439,6 +475,8 @@ Int32 nUnused; void* unusedTmpV; UChar* unusedTmp; + double fileSize = 0; /* initialized to make the compiler stop crying */ + time_t startTime, currentTime; nUnused = 0; streamNo = 0; @@ -446,9 +484,19 @@ SET_BINARY_MODE(stream); SET_BINARY_MODE(zStream); + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) { + long dummy = ftell(zStream); + (void)fseek(zStream, 0, SEEK_END); + fileSize = (double)ftell(zStream); + (void)fseek(zStream, dummy, SEEK_SET); + if (verbosity >= 1) + fprintf(stderr, "Input-file size: %ld\n", (long)fileSize); + } + if (ferror(stream)) goto errhandler_io; if (ferror(zStream)) goto errhandler_io; + time(&startTime); while (True) { bzf = BZ2_bzReadOpen ( @@ -464,6 +512,17 @@ if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0) fwrite ( obuf, sizeof(UChar), nread, stream ); if (ferror(stream)) goto errhandler_io; + + if ((srcMode == SM_F2F || srcMode == SM_F2O) && showProgress == True) { + time(¤tTime); + if ((currentTime - startTime) >= 2) + { + double curInPos = (double)ftell(zStream); + startTime = currentTime; + + fprintf(stderr, "%.2f%% done\r", (curInPos * 100.0) / fileSize); + } + } } if (bzerr != BZ_STREAM_END) goto errhandler; @@ -1803,6 +1862,7 @@ deleteOutputOnInterrupt = False; exitValue = 0; i = j = 0; /* avoid bogus warning from egcs-1.1.X */ + showProgress = False; /*-- Set up signal handlers for mem access errors --*/ signal (SIGSEGV, mySIGSEGVorSIGBUScatcher); @@ -1880,6 +1940,7 @@ case 'k': keepInputFiles = True; break; case 's': smallMode = True; break; case 'q': noisy = False; break; + case 'p': showProgress = True; break; case '1': blockSize100k = 1; break; case '2': blockSize100k = 2; break; case '3': blockSize100k = 3; break; @@ -1916,6 +1977,7 @@ if (ISFLAG("--keep")) keepInputFiles = True; else if (ISFLAG("--small")) smallMode = True; else if (ISFLAG("--quiet")) noisy = False; else + if (ISFLAG("--show-progress")) showProgress = True; else if (ISFLAG("--version")) license(); else if (ISFLAG("--license")) license(); else if (ISFLAG("--exponential")) workFactor = 1; else