RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 05-Jun-2017 01:09:45 Branch: rpm-5_4 Handle: 2017060423094500 Modified files: (Branch: rpm-5_4) rpm/rpmio rpmzstd.c Log: - rpmzstd: replace with Stat/Lstat. Summary: Revision Changes Path 1.1.2.4 +225 -160 rpm/rpmio/rpmzstd.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/rpmzstd.c ============================================================================ $ cvs diff -u -r1.1.2.3 -r1.1.2.4 rpmzstd.c --- rpm/rpmio/rpmzstd.c 4 Jun 2017 04:45:52 -0000 1.1.2.3 +++ rpm/rpmio/rpmzstd.c 4 Jun 2017 23:09:45 -0000 1.1.2.4 @@ -12,12 +12,28 @@ #define ZSTD_NODICT #undef POPTIO_OPTIONS /* XXX NOTYET: <poptIO.h> option/arg processing. */ +#define USE_RPMIO +#define _FPIO "" #include "system.h" -#include <rpmdefs.h> +#if defined(USE_RPMIO) +#include <rpmio_internal.h> +#else +typedef FILE * FD_t; +#define Fopen fopen +#define Fread fread +#define Fwrite fwrite +#define Fseek fseek +#define Fclose fclose +#define Ferror ferror +#define Stat stat +#define Lstat lstat +#endif + #include <rpmmacro.h> #include <argv.h> + #if defined(POPTIO_OPTION_PROCESSING) # include <poptIO.h> #endif /* POPTIO_OPTION_PROCESSING */ @@ -995,7 +1011,7 @@ #elif defined(__MINGW32__) && defined(__MSVCRT__) && !defined(__STRICT_ANSI__) && !defined(__NO_MINGW_LFS) # define UTIL_fseek fseeko64 #else -# define UTIL_fseek fseek +# define UTIL_fseek Fseek #endif @@ -1146,7 +1162,7 @@ r = _stat64(ifn, st); if (r || !(st->st_mode & S_IFREG)) return 0; /* No good... */ #else - r = stat(ifn, st); + r = Stat(ifn, st); if (r || !S_ISREG(st->st_mode)) return 0; /* No good... */ #endif return 1; @@ -1168,7 +1184,7 @@ r = _stat64(ifn, &sb); if (!r && (sb.st_mode & _S_IFDIR)) return 1; #else - r = stat(ifn, &sb); + r = Stat(ifn, &sb); if (!r && S_ISDIR(sb.st_mode)) return 1; #endif return 0; @@ -1182,7 +1198,7 @@ #else int r; stat_t sb; - r = lstat(ifn, &sb); + r = Lstat(ifn, &sb); if (!r && S_ISLNK(sb.st_mode)) return 1; #endif return 0; @@ -1202,7 +1218,7 @@ if (r || !(sb.st_mode & S_IFREG)) return 0; /* No good... */ #else struct stat sb; - r = stat(ifn, &sb); + r = Stat(ifn, &sb); if (r || !S_ISREG(sb.st_mode)) return 0; /* No good... */ #endif return (U64)sb.st_size; @@ -1560,7 +1576,8 @@ } /* try to determine if there's hyperthreading */ - { FILE * const cpuinfo = fopen("/proc/cpuinfo", "r"); + { + FILE * const cpuinfo = fopen("/proc/cpuinfo", "r"); #define BUF_SIZE 80 char buff[BUF_SIZE]; @@ -2621,14 +2638,15 @@ unsigned long long const fs64 = UTIL_getFileSize(fn); size_t const fileSize = (size_t) MIN(fs64, SAMPLESIZE_MAX); if (fileSize > *bufferSizePtr-pos) break; - { FILE * const f = fopen(fn, "rb"); - if (f == NULL) EXM_THROW(10, "zstd: dictBuilder: %s %s ", fn, strerror(errno)); + { + FILE * const fp = fopen(fn, "rb"); + if (fp == NULL) EXM_THROW(10, "zstd: dictBuilder: %s %s ", fn, strerror(errno)); DISPLAYUPDATE(2, "Loading %s... \r", fn); - { size_t const readSize = fread(buff+pos, 1, fileSize, f); + { size_t const readSize = fread(buff+pos, 1, fileSize, fp); if (readSize != fileSize) EXM_THROW(11, "Pb reading %s", fn); pos += readSize; } fileSizes[n] = fileSize; - fclose(f); + fclose(fp); } } DISPLAYLEVEL(2, "\r%79s\r", ""); *bufferSizePtr = pos; @@ -2707,13 +2725,13 @@ const void * buff, size_t buffSize) { SPEW("-->\t%s()\n", __FUNCTION__); - FILE * const f = fopen(dfn, "wb"); - if (f == NULL) EXM_THROW(3, "cannot open %s ", dfn); + FILE * const fp = fopen(dfn, "wb"); + if (fp == NULL) EXM_THROW(3, "cannot open %s ", dfn); - { size_t const n = fwrite(buff, 1, buffSize, f); + { size_t const n = fwrite(buff, 1, buffSize, fp); if (n!=buffSize) EXM_THROW(4, "%s : write error", dfn) } - { size_t const n = (size_t)fclose(f); + { size_t const n = (size_t)fclose(fp); if (n!=0) EXM_THROW(5, "%s : flush error", dfn) } } @@ -2937,7 +2955,7 @@ return -1; } #else -# define LONG_SEEK fseek +# define LONG_SEEK Fseek #endif @@ -3023,42 +3041,50 @@ } /** FIO_openSrcFile() : - * condition : `dstfn` must be non-NULL. - * @result : FILE * to `dstfn`, or NULL if it fails */ -static FILE * FIO_openSrcFile(const char * srcfn) + * condition : `srcfn` must be non-NULL. + * @result : FD_t of `srcfn`, or NULL if Fopen fails */ +static FD_t FIO_openSrcFile(const char * srcfn) { SPEW("-->\t%s(%s)\n", __FUNCTION__, srcfn); - FILE * fp; + FD_t fd; if (!strcmp (srcfn, stdinmark)) { DISPLAYLEVEL(4,"Using stdin for input\n"); - fp = stdin; +#if defined(USE_RPMIO) + fd = Fopen("-", "rb"_FPIO); +#else + fd = stdin; SET_BINARY_MODE(stdin); +#endif } else { if (!UTIL_isRegFile(srcfn)) { DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", srcfn); return NULL; } - fp = fopen(srcfn, "rb"); - if (fp == NULL) DISPLAYLEVEL(1, "zstd: %s: %s \n", srcfn, strerror(errno)); + fd = Fopen(srcfn, "rbm"_FPIO); } + if (fd == NULL) DISPLAYLEVEL(1, "zstd: %s: %s \n", srcfn, strerror(errno)); -SPEW("<--\t%s(%s) fp %p\n", __FUNCTION__, srcfn, fp); - return fp; +SPEW("<--\t%s(%s) fd %p\n", __FUNCTION__, srcfn, fd); + return fd; } /** FIO_openDstFile() : * condition : `dstfn` must be non-NULL. - * @result : FILE * to `dstfn`, or NULL if it fails */ -static FILE * FIO_openDstFile(const char * dstfn) + * @result : FD_t of `dstfn`, or NULL if Fopen fails */ +static FD_t FIO_openDstFile(const char * dstfn) { SPEW("-->\t%s(%s)\n", __FUNCTION__, dstfn); - FILE * fp; + FD_t fd; if (!strcmp (dstfn, stdoutmark)) { DISPLAYLEVEL(4,"Using stdout for output\n"); - fp = stdout; +#if defined(USE_RPMIO) + fd = Fopen("-", "wb"_FPIO); +#else + fd = stdout; SET_BINARY_MODE(stdout); +#endif if (g_sparseFileSupport == 1) { g_sparseFileSupport = 0; DISPLAYLEVEL(4, "Sparse File Support is automatically disabled on stdout ; try --sparse \n"); @@ -3068,9 +3094,9 @@ g_sparseFileSupport = ZSTD_SPARSE_DEFAULT; } if (strcmp (dstfn, nulmark)) { /* Check if destination file already exists */ - fp = fopen( dstfn, "rb" ); - if (fp != NULL) { /* dest file exists, prompt for overwrite authorization */ - fclose(fp); + fd = Fopen( dstfn, "rbm"_FPIO); + if (fd != NULL) { /* dest file exists, prompt for overwrite authorization */ + Fclose(fd); if (!g_overwrite) { if (g_FIO_displayLevel <= 1) { /* No interaction possible */ @@ -3090,12 +3116,12 @@ /* need to unlink */ FIO_remove(dstfn); } } - fp = fopen(dstfn, "wb"); - if (fp == NULL) DISPLAYLEVEL(1, "zstd: %s: %s\n", dstfn, strerror(errno)); + fd = Fopen(dstfn, "wb"_FPIO); + if (fd == NULL) DISPLAYLEVEL(1, "zstd: %s: %s\n", dstfn, strerror(errno)); } -SPEW("<--\t%s() fp %p\n", __FUNCTION__, fp); - return fp; +SPEW("<--\t%s() fd %p\n", __FUNCTION__, fd); + return fd; } @@ -3103,28 +3129,28 @@ * creates a buffer, pointed by `*bufferPtr`, * loads `filename` content into it, up to DICTSIZE_MAX bytes. * @return : loaded size - * if fileName == NULL, returns 0 and a NULL pointer + * if fn == NULL, returns 0 and a NULL pointer */ -static size_t FIO_createDictBuffer(void ** bufferPtr, const char * fileName) +static size_t FIO_createDictBuffer(void ** bufferPtr, const char * fn) { -SPEW("-->\t%s(%p, %s)\n", __FUNCTION__, bufferPtr, fileName); - FILE * fp; +SPEW("-->\t%s(%p, %s)\n", __FUNCTION__, bufferPtr, fn); + FD_t fd; U64 fileSize; *bufferPtr = NULL; - if (fileName == NULL) return 0; + if (fn == NULL) return 0; - DISPLAYLEVEL(4,"Loading %s as dictionary \n", fileName); - fp = fopen(fileName, "rb"); - if (fp == NULL) EXM_THROW(31, "zstd: %s: %s", fileName, strerror(errno)); - fileSize = UTIL_getFileSize(fileName); - if (fileSize > DICTSIZE_MAX) EXM_THROW(32, "Dictionary file %s is too large (> %u MB)", fileName, DICTSIZE_MAX >> 20); /* avoid extreme cases */ + DISPLAYLEVEL(4,"Loading %s as dictionary \n", fn); + fd = Fopen(fn, "rbm"_FPIO); + if (fd == NULL) EXM_THROW(31, "zstd: %s: %s", fn, strerror(errno)); + fileSize = UTIL_getFileSize(fn); + if (fileSize > DICTSIZE_MAX) EXM_THROW(32, "Dictionary file %s is too large (> %u MB)", fn, DICTSIZE_MAX >> 20); /* avoid extreme cases */ *bufferPtr = malloc((size_t)fileSize); if (*bufferPtr == NULL) EXM_THROW(34, "zstd: %s", strerror(errno)); - { size_t const readSize = fread(*bufferPtr, 1, (size_t)fileSize, fp); - if (readSize!=fileSize) EXM_THROW(35, "Error reading dictionary file %s", fileName); } - fclose(fp); -SPEW("<--\t%s(%p, %s) rc %zd\n", __FUNCTION__, bufferPtr, fileName, (size_t)fileSize); + { size_t const readSize = Fread(*bufferPtr, 1, (size_t)fileSize, fd); + if (readSize!=fileSize) EXM_THROW(35, "Error reading dictionary file %s", fn); } + Fclose(fd); +SPEW("<--\t%s(%p, %s) rc %zd\n", __FUNCTION__, bufferPtr, fn, (size_t)fileSize); return (size_t)fileSize; } @@ -3134,11 +3160,13 @@ * Compression ************************************************************************/ typedef struct { - FILE * srcfp; - FILE * dstfp; - void * srcBuffer; + FD_t srcfd; + FD_t dstfd; + void * srcIOBuffer; + void * srcBuffer; size_t srcBufferSize; - void * dstBuffer; + void * dstIOBuffer; + void * dstBuffer; size_t dstBufferSize; #ifdef ZSTD_MULTITHREAD ZSTDMT_CCtx* cctx; @@ -3171,8 +3199,10 @@ #endif ress.srcBufferSize = ZSTD_CStreamInSize(); ress.srcBuffer = malloc(ress.srcBufferSize); + ress.srcIOBuffer = malloc(ress.srcBufferSize); ress.dstBufferSize = ZSTD_CStreamOutSize(); ress.dstBuffer = malloc(ress.dstBufferSize); + ress.dstIOBuffer = malloc(ress.dstBufferSize); if (!ress.srcBuffer || !ress.dstBuffer) EXM_THROW(31, "zstd: allocation error : not enough memory"); @@ -3212,7 +3242,9 @@ { SPEW("-->\t%s(%p)\n", __FUNCTION__, &ress); free(ress.srcBuffer); + if (ress.srcIOBuffer) free(ress.srcIOBuffer); free(ress.dstBuffer); + if (ress.dstIOBuffer) free(ress.dstIOBuffer); #ifdef ZSTD_MULTITHREAD ZSTDMT_freeCCtx(ress.cctx); #else @@ -3251,7 +3283,7 @@ while (1) { if (strm.avail_in == 0) { - size_t const inSize = fread(ress->srcBuffer, 1, ress->srcBufferSize, ress->srcfp); + size_t const inSize = Fread(ress->srcBuffer, 1, ress->srcBufferSize, ress->srcfd); if (inSize == 0) break; inFileSize += inSize; strm.next_in = (z_const unsigned char *)ress->srcBuffer; @@ -3262,7 +3294,7 @@ EXM_THROW(72, "zstd: %s: deflate error %d \n", srcfn, ret); { size_t const decompBytes = ress->dstBufferSize - strm.avail_out; if (decompBytes) { - if (fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfp) != decompBytes) + if (fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfd) != decompBytes) EXM_THROW(73, "Write error : cannot write to output file"); outFileSize += decompBytes; strm.next_out = (Bytef*)ress->dstBuffer; @@ -3283,7 +3315,7 @@ ret = deflate(&strm, Z_FINISH); { size_t const decompBytes = ress->dstBufferSize - strm.avail_out; if (decompBytes) { - if (fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfp) != decompBytes) + if (Fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfd) != decompBytes) EXM_THROW(75, "Write error : cannot write to output file"); outFileSize += decompBytes; strm.next_out = (Bytef*)ress->dstBuffer; @@ -3339,7 +3371,7 @@ while (1) { if (strm.avail_in == 0) { - size_t const inSize = fread(ress->srcBuffer, 1, ress->srcBufferSize, ress->srcfp); + size_t const inSize = Fread(ress->srcBuffer, 1, ress->srcBufferSize, ress->srcfd); if (inSize == 0) action = LZMA_FINISH; inFileSize += inSize; strm.next_in = ress->srcBuffer; @@ -3352,7 +3384,7 @@ EXM_THROW(72, "zstd: %s: lzma_code encoding error %d", srcfn, ret); { size_t const compBytes = ress->dstBufferSize - strm.avail_out; if (compBytes) { - if (fwrite(ress->dstBuffer, 1, compBytes, ress->dstfp) != compBytes) + if (Fwrite(ress->dstBuffer, 1, compBytes, ress->dstfd) != compBytes) EXM_THROW(73, "Write error : cannot write to output file"); outFileSize += compBytes; strm.next_out = ress->dstBuffer; @@ -3417,12 +3449,12 @@ if (LZ4F_isError(headerSize)) EXM_THROW(33, "File header generation failed : %s", LZ4F_getErrorName(headerSize)); - { size_t const sizeCheck = fwrite(ress->dstBuffer, 1, headerSize, ress->dstfp); + { size_t const sizeCheck = Fwrite(ress->dstBuffer, 1, headerSize, ress->dstfd); if (sizeCheck!=headerSize) EXM_THROW(34, "Write error : cannot write header"); } outFileSize += headerSize; /* Read first block */ - readSize = fread(ress->srcBuffer, (size_t)1, (size_t)blockSize, ress->srcfp); + readSize = Fread(ress->srcBuffer, (size_t)1, (size_t)blockSize, ress->srcfd); inFileSize += readSize; /* Main Loop */ @@ -3445,14 +3477,14 @@ (double)outFileSize/inFileSize*100); /* Write Block */ - { size_t const sizeCheck = fwrite(ress->dstBuffer, 1, outSize, ress->dstfp); + { size_t const sizeCheck = Fwrite(ress->dstBuffer, 1, outSize, ress->dstfd); if (sizeCheck!=outSize) EXM_THROW(36, "Write error : cannot write compressed block"); } /* Read next block */ - readSize = fread(ress->srcBuffer, (size_t)1, (size_t)blockSize, ress->srcfp); + readSize = Fread(ress->srcBuffer, (size_t)1, (size_t)blockSize, ress->srcfd); inFileSize += readSize; } - if (ferror(ress->srcfp)) EXM_THROW(37, "Error reading %s ", srcfn); + if (Ferror(ress->srcfd)) EXM_THROW(37, "Error reading %s ", srcfn); /* End of Stream mark */ headerSize = LZ4F_compressEnd(ctx, ress->dstBuffer, ress->dstBufferSize, NULL); @@ -3460,7 +3492,7 @@ EXM_THROW(38, "zstd: %s: lz4 end of file generation failed : %s", srcfn, LZ4F_getErrorName(headerSize)); - { size_t const sizeCheck = fwrite(ress->dstBuffer, 1, headerSize, ress->dstfp); + { size_t const sizeCheck = Fwrite(ress->dstBuffer, 1, headerSize, ress->dstfd); if (sizeCheck!=headerSize) EXM_THROW(39, "Write error : cannot write end of stream"); } outFileSize += headerSize; } @@ -3483,8 +3515,8 @@ const char * dstfn, const char * srcfn, int compressionLevel) { SPEW("-->\t%s(%p, %s, %s)\n", __FUNCTION__, &ress, dstfn, srcfn); - FILE * const srcfp = ress.srcfp; - FILE * const dstfp = ress.dstfp; + FD_t srcfd = ress.srcfd; + FD_t dstfd = ress.dstfd; U64 readsize = 0; U64 compressedfilesize = 0; U64 const fileSize = UTIL_getFileSize(srcfn); @@ -3539,7 +3571,7 @@ /* Main compression loop */ while (1) { /* Fill input Buffer */ - size_t const inSize = fread(ress.srcBuffer, (size_t)1, ress.srcBufferSize, srcfp); + size_t const inSize = Fread(ress.srcBuffer, (size_t)1, ress.srcBufferSize, srcfd); if (inSize == 0) break; readsize += inSize; @@ -3556,7 +3588,7 @@ /* Write compressed stream */ if (outBuff.pos) { - size_t const sizeCheck = fwrite(ress.dstBuffer, 1, outBuff.pos, dstfp); + size_t const sizeCheck = Fwrite(ress.dstBuffer, 1, outBuff.pos, dstfd); if (sizeCheck!=outBuff.pos) EXM_THROW(25, "Write error : cannot write compressed block into %s", dstfn); compressedfilesize += outBuff.pos; @@ -3589,7 +3621,7 @@ result = ZSTD_endStream(ress.cctx, &outBuff); #endif if (ZSTD_isError(result)) EXM_THROW(26, "Compression error during frame end : %s", ZSTD_getErrorName(result)); - { size_t const sizeCheck = fwrite(ress.dstBuffer, 1, outBuff.pos, dstfp); + { size_t const sizeCheck = Fwrite(ress.dstBuffer, 1, outBuff.pos, dstfd); if (sizeCheck!=outBuff.pos) EXM_THROW(27, "Write error : cannot write frame end into %s", dstfn); } compressedfilesize += outBuff.pos; } @@ -3626,16 +3658,35 @@ return 1; } - ress.srcfp = FIO_openSrcFile(srcfn); - if (!ress.srcfp) return 1; /* srcfp could not be opened */ + ress.srcfd = FIO_openSrcFile(srcfn); + if (!ress.srcfd) return 1; /* srcfd could not be opened */ + + + int xx; +#if defined(USE_RPMIO) + if (fdGetIo(ress.srcfd) == fpio) { + if (ress.srcIOBuffer) + xx = setvbuf(fdGetFILE(ress.srcfd), ress.srcIOBuffer, _IOFBF, ress.srcBufferSize); + if (ress.dstIOBuffer) + xx = setvbuf(fdGetFILE(ress.dstfd), ress.dstIOBuffer, _IOFBF, ress.dstBufferSize); + } +#else + if (ress.srcIOBuffer) + xx = setvbuf(ress.srcfd, ress.srcIOBuffer, _IOFBF, ress.srcBufferSize); + if (ress.dstIOBuffer) + xx = setvbuf(ress.dstfd, ress.dstIOBuffer, _IOFBF, ress.dstBufferSize); +#endif + (void)xx; + result = FIO_compressFilename_internal(ress, dstfn, srcfn, compressionLevel); - fclose(ress.srcfp); + Fclose(ress.srcfd); if (g_removeSrcFile /* --rm */ && !result && strcmp(srcfn, stdinmark)) { if (remove(srcfn)) EXM_THROW(1, "zstd: %s: %s", srcfn, strerror(errno)); } + SPEW("<--\t%s(%p, %s, %s, %d) rc %d\n", __FUNCTION__, &ress, dstfn, srcfn, compressionLevel, result); return result; } @@ -3655,14 +3706,14 @@ stat_t sb; int stat_result = 0; - ress.dstfp = FIO_openDstFile(dstfn); - if (ress.dstfp == NULL) return 1; /* could not open dstfn */ + ress.dstfd = FIO_openDstFile(dstfn); + if (ress.dstfd == NULL) return 1; /* could not open dstfn */ if (strcmp (srcfn, stdinmark) && UTIL_getFileStat(srcfn, &sb)) stat_result = 1; result = FIO_compressFilename_srcFile(ress, dstfn, srcfn, compressionLevel); - if (fclose(ress.dstfp)) { /* error closing dstfp */ + if (Fclose(ress.dstfd)) { /* error closing dstfd */ DISPLAYLEVEL(1, "zstd: %s: %s \n", dstfn, strerror(errno)); result=1; } @@ -3719,11 +3770,15 @@ /* loop on each file */ if (!strcmp(suffix, stdoutmark)) { - ress.dstfp = stdout; +#if defined(USE_RPMIO) + ress.dstfd = Fopen("-", "wb"_FPIO); +#else + ress.dstfd = stdout; SET_BINARY_MODE(stdout); +#endif for (int i = 0; i < ac; i++) missed_files += FIO_compressFilename_srcFile(ress, stdoutmark, av[i], compressionLevel); - if (fclose(ress.dstfp)) + if (Fclose(ress.dstfd)) EXM_THROW(29, "Write error : cannot properly close stdout"); } else { for (int i = 0; i < ac; i++) { @@ -3758,13 +3813,15 @@ * Decompression ****************************************************************************/ typedef struct { - void * srcBuffer; + void * srcIOBuffer; + void * srcBuffer; size_t srcBufferLoaded; size_t srcBufferSize; - void * dstBuffer; + void * dstIOBuffer; + void * dstBuffer; size_t dstBufferSize; ZSTD_DStream* dctx; - FILE * dstfp; + FD_t dstfd; } dRess_t; static dRess_t FIO_createDResources(const char * dfn) @@ -3779,8 +3836,10 @@ ZSTD_setDStreamParameter(ress.dctx, DStream_p_maxWindowSize, g_memLimit); ress.srcBufferSize = ZSTD_DStreamInSize(); ress.srcBuffer = malloc(ress.srcBufferSize); + ress.srcIOBuffer = malloc(ress.srcBufferSize); ress.dstBufferSize = ZSTD_DStreamOutSize(); ress.dstBuffer = malloc(ress.dstBufferSize); + ress.dstIOBuffer = malloc(ress.dstBufferSize); if (!ress.srcBuffer || !ress.dstBuffer) EXM_THROW(61, "Allocation error : not enough memory"); @@ -3805,15 +3864,19 @@ EXM_THROW(69, "Error : can't free ZSTD_DStream context resource : %s", ZSTD_getErrorName(errorCode)); free(ress.srcBuffer); + if (ress.srcIOBuffer) + free(ress.srcIOBuffer); free(ress.dstBuffer); + if (ress.dstIOBuffer) + free(ress.dstIOBuffer); } /** FIO_fwriteSparse() : * @return : storedSkips, to be provided to next call to FIO_fwriteSparse() of LZ4IO_fwriteSparseEnd() */ -static unsigned FIO_fwriteSparse(FILE * fp, const void * buffer, size_t bufferSize, unsigned storedSkips) +static unsigned FIO_fwriteSparse(FD_t fd, const void * buffer, size_t bufferSize, unsigned storedSkips) { -SPEW("-->\t%s(%p, %p[%zd], %u)\n", __FUNCTION__, fp, buffer, bufferSize, storedSkips); +SPEW("-->\t%s(%p, %p[%zd], %u)\n", __FUNCTION__, fd, buffer, bufferSize, storedSkips); const size_t* const bufferT = (const size_t*)buffer; /* Buffer is supposed malloc'ed, hence aligned on size_t */ size_t bufferSizeT = bufferSize / sizeof(size_t); const size_t* const bufferTEnd = bufferT + bufferSizeT; @@ -3821,14 +3884,14 @@ static const size_t segmentSizeT = (32 KB) / sizeof(size_t); /* 0-test re-attempted every 32 KB */ if (!g_sparseFileSupport) { /* normal write */ - size_t const sizeCheck = fwrite(buffer, 1, bufferSize, fp); + size_t const sizeCheck = Fwrite(buffer, 1, bufferSize, fd); if (sizeCheck != bufferSize) EXM_THROW(70, "Write error : cannot write decoded block"); return 0; } /* avoid int overflow */ if (storedSkips > 1 GB) { - int const seekResult = LONG_SEEK(fp, 1 GB, SEEK_CUR); + int const seekResult = LONG_SEEK(fd, 1 GB, SEEK_CUR); if (seekResult != 0) EXM_THROW(71, "1 GB skip error (sparse file support)"); storedSkips -= 1 GB; } @@ -3844,12 +3907,12 @@ storedSkips += (unsigned)(nb0T * sizeof(size_t)); if (nb0T != seg0SizeT) { /* not all 0s */ - int const seekResult = LONG_SEEK(fp, storedSkips, SEEK_CUR); + int const seekResult = LONG_SEEK(fd, storedSkips, SEEK_CUR); if (seekResult) EXM_THROW(72, "Sparse skip error ; try --no-sparse"); storedSkips = 0; seg0SizeT -= nb0T; ptrT += nb0T; - { size_t const sizeCheck = fwrite(ptrT, sizeof(size_t), seg0SizeT, fp); + { size_t const sizeCheck = Fwrite(ptrT, sizeof(size_t), seg0SizeT, fd); if (sizeCheck != seg0SizeT) EXM_THROW(73, "Write error : cannot write decoded block"); } } @@ -3866,27 +3929,27 @@ for (; (restPtr < restEnd) && (*restPtr == 0); restPtr++) ; storedSkips += (unsigned) (restPtr - restStart); if (restPtr != restEnd) { - int seekResult = LONG_SEEK(fp, storedSkips, SEEK_CUR); + int seekResult = LONG_SEEK(fd, storedSkips, SEEK_CUR); if (seekResult) EXM_THROW(74, "Sparse skip error ; try --no-sparse"); storedSkips = 0; - { size_t const sizeCheck = fwrite(restPtr, 1, restEnd - restPtr, fp); + { size_t const sizeCheck = Fwrite(restPtr, 1, restEnd - restPtr, fd); if (sizeCheck != (size_t)(restEnd - restPtr)) EXM_THROW(75, "Write error : cannot write decoded end of block"); } } } } -SPEW("<--\t%s(%p, %p[%zd], %u) storedSkips %u\n", __FUNCTION__, fp, buffer, bufferSize, storedSkips, storedSkips); +SPEW("<--\t%s(%p, %p[%zd], %u) storedSkips %u\n", __FUNCTION__, fd, buffer, bufferSize, storedSkips, storedSkips); return storedSkips; } -static void FIO_fwriteSparseEnd(FILE * fp, unsigned storedSkips) +static void FIO_fwriteSparseEnd(FD_t fd, unsigned storedSkips) { -SPEW("-->\t%s(%p, %u)\n", __FUNCTION__, fp, storedSkips); +SPEW("-->\t%s(%p, %u)\n", __FUNCTION__, fd, storedSkips); if (storedSkips-->0) { /* implies g_sparseFileSupport>0 */ - int const seekResult = LONG_SEEK(fp, storedSkips, SEEK_CUR); + int const seekResult = LONG_SEEK(fd, storedSkips, SEEK_CUR); if (seekResult != 0) EXM_THROW(69, "Final skip error (sparse file)"); { const char lastZeroByte[1] = { 0 }; - size_t const sizeCheck = fwrite(lastZeroByte, 1, 1, fp); + size_t const sizeCheck = Fwrite(lastZeroByte, 1, 1, fd); if (sizeCheck != 1) EXM_THROW(69, "Write error : cannot write last zero"); } } @@ -3895,7 +3958,7 @@ /** FIO_passThrough() : just copy input into output, for compatibility with gzip -df mode @return : 0 (no error) */ -static unsigned FIO_passThrough(FILE * ofp, FILE * ifp, void * buffer, size_t bufferSize, size_t alreadyLoaded) +static unsigned FIO_passThrough(FD_t ofd, FD_t ifd, void * buffer, size_t bufferSize, size_t alreadyLoaded) { SPEW("-->\t%s()\n", __FUNCTION__); size_t const blockSize = MIN(64 KB, bufferSize); @@ -3903,15 +3966,15 @@ unsigned storedSkips = 0; /* assumption : ress->srcBufferLoaded bytes already loaded and stored within buffer */ - { size_t const sizeCheck = fwrite(buffer, 1, alreadyLoaded, ofp); + { size_t const sizeCheck = Fwrite(buffer, 1, alreadyLoaded, ofd); if (sizeCheck != alreadyLoaded) EXM_THROW(50, "Pass-through write error"); } while (readFromInput) { - readFromInput = fread(buffer, 1, blockSize, ifp); - storedSkips = FIO_fwriteSparse(ofp, buffer, readFromInput, storedSkips); + readFromInput = Fread(buffer, 1, blockSize, ifd); + storedSkips = FIO_fwriteSparse(ofd, buffer, readFromInput, storedSkips); } - FIO_fwriteSparseEnd(ofp, storedSkips); + FIO_fwriteSparseEnd(ofd, storedSkips); SPEW("<--\t%s() rc %d\n", __FUNCTION__, 0); return 0; } @@ -3922,11 +3985,11 @@ */ #define FIO_ERROR_ZSTD_DECODING ((unsigned long long)(-2)) unsigned long long FIO_decompressFrame(dRess_t* ress, - FILE * ifp, + FD_t ifd, const char * srcfn, U64 alreadyDecoded) { -SPEW("-->\t%s(%p, %p, %s, %llu)\n", __FUNCTION__, ress, ifp, srcfn, (unsigned long long)alreadyDecoded); +SPEW("-->\t%s(%p, %p, %s, %llu)\n", __FUNCTION__, ress, ifd, srcfn, (unsigned long long)alreadyDecoded); U64 frameSize = 0; U32 storedSkips = 0; @@ -3936,7 +3999,7 @@ /* Header loading (optional, saves one loop) */ { size_t const toRead = 9; if (ress->srcBufferLoaded < toRead) - ress->srcBufferLoaded += fread(((char *)ress->srcBuffer) + ress->srcBufferLoaded, 1, toRead - ress->srcBufferLoaded, ifp); + ress->srcBufferLoaded += Fread(((char *)ress->srcBuffer) + ress->srcBufferLoaded, 1, toRead - ress->srcBufferLoaded, ifd); } /* Main decompression Loop */ @@ -3951,7 +4014,7 @@ } /* Write block */ - storedSkips = FIO_fwriteSparse(ress->dstfp, ress->dstBuffer, outBuff.pos, storedSkips); + storedSkips = FIO_fwriteSparse(ress->dstfd, ress->dstBuffer, outBuff.pos, storedSkips); frameSize += outBuff.pos; DISPLAYUPDATE(2, "\r%-20.20s : %u MB... ", srcfn, (U32)((alreadyDecoded+frameSize)>>20) ); @@ -3971,24 +4034,24 @@ /* Fill input buffer */ { size_t const toRead = MIN(readSizeHint, ress->srcBufferSize); /* support large skippable frames */ if (ress->srcBufferLoaded < toRead) - ress->srcBufferLoaded += fread((char *)ress->srcBuffer + ress->srcBufferLoaded, - 1, toRead - ress->srcBufferLoaded, ifp); + ress->srcBufferLoaded += Fread((char *)ress->srcBuffer + ress->srcBufferLoaded, + 1, toRead - ress->srcBufferLoaded, ifd); if (ress->srcBufferLoaded < toRead) { DISPLAYLEVEL(1, "%s : Read error (39) : premature end \n", srcfn); return FIO_ERROR_ZSTD_DECODING; } } } - FIO_fwriteSparseEnd(ress->dstfp, storedSkips); + FIO_fwriteSparseEnd(ress->dstfd, storedSkips); -SPEW("<--\t%s(%p, %p, %s, %llu) rc %llu\n", __FUNCTION__, ress, ifp, srcfn, (unsigned long long)alreadyDecoded, (unsigned long long)frameSize); +SPEW("<--\t%s(%p, %p, %s, %llu) rc %llu\n", __FUNCTION__, ress, ifd, srcfn, (unsigned long long)alreadyDecoded, (unsigned long long)frameSize); return frameSize; } #ifdef ZSTD_GZDECOMPRESS static unsigned long long FIO_decompressGzFrame(dRess_t* ress, - FILE * srcfp, const char * srcfn) + FD_t srcfd, const char * srcfn) { SPEW("-->\t%s()\n", __FUNCTION__); unsigned long long outFileSize = 0; @@ -4012,7 +4075,7 @@ for (;;) { if (strm.avail_in == 0) { - ress->srcBufferLoaded = fread(ress->srcBuffer, 1, ress->srcBufferSize, srcfp); + ress->srcBufferLoaded = Fread(ress->srcBuffer, 1, ress->srcBufferSize, srcfd); if (ress->srcBufferLoaded == 0) flush = Z_FINISH; strm.next_in = (z_const unsigned char *)ress->srcBuffer; strm.avail_in = (uInt)ress->srcBufferLoaded; @@ -4025,7 +4088,7 @@ } { size_t const decompBytes = ress->dstBufferSize - strm.avail_out; if (decompBytes) { - if (fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfp) != decompBytes) + if (Fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfd) != decompBytes) EXM_THROW(31, "Write error : cannot write to output file"); outFileSize += decompBytes; strm.next_out = (Bytef*)ress->dstBuffer; @@ -4046,7 +4109,7 @@ #ifdef ZSTD_LZMADECOMPRESS -static unsigned long long FIO_decompressLzmaFrame(dRess_t* ress, FILE * srcfp, const char * srcfn, int plain_lzma) +static unsigned long long FIO_decompressLzmaFrame(dRess_t* ress, FD_t srcfd, const char * srcfn, int plain_lzma) { SPEW("-->\t%s()\n", __FUNCTION__); unsigned long long outFileSize = 0; @@ -4073,7 +4136,7 @@ for (;;) { if (strm.avail_in == 0) { - ress->srcBufferLoaded = fread(ress->srcBuffer, 1, ress->srcBufferSize, srcfp); + ress->srcBufferLoaded = Fread(ress->srcBuffer, 1, ress->srcBufferSize, srcfd); if (ress->srcBufferLoaded == 0) action = LZMA_FINISH; strm.next_in = ress->srcBuffer; strm.avail_in = ress->srcBufferLoaded; @@ -4088,7 +4151,7 @@ } { size_t const decompBytes = ress->dstBufferSize - strm.avail_out; if (decompBytes) { - if (fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfp) != decompBytes) + if (Fwrite(ress->dstBuffer, 1, decompBytes, ress->dstfd) != decompBytes) EXM_THROW(31, "Write error : cannot write to output file"); outFileSize += decompBytes; strm.next_out = ress->dstBuffer; @@ -4107,7 +4170,7 @@ #ifdef ZSTD_LZ4DECOMPRESS static unsigned long long FIO_decompressLz4Frame(dRess_t* ress, - FILE * srcfp, const char * srcfn) + FD_t srcfd, const char * srcfn) { SPEW("-->\t%s()\n", __FUNCTION__); unsigned long long filesize = 0; @@ -4136,7 +4199,7 @@ /* Read input */ if (nextToLoad > ress->srcBufferSize) nextToLoad = ress->srcBufferSize; - readSize = fread(ress->srcBuffer, 1, nextToLoad, srcfp); + readSize = Fread(ress->srcBuffer, 1, nextToLoad, srcfd); if (!readSize) break; /* reached end of file or stream */ while ((pos < readSize) || (decodedBytes == ress->dstBufferSize)) { /* still to read, or still to flush */ @@ -4151,7 +4214,7 @@ /* Write Block */ if (decodedBytes) { - if (fwrite(ress->dstBuffer, 1, decodedBytes, ress->dstfp) != decodedBytes) + if (Fwrite(ress->dstBuffer, 1, decodedBytes, ress->dstfd) != decodedBytes) EXM_THROW(63, "Write error : cannot write to output file"); filesize += decodedBytes; DISPLAYUPDATE(2, "\rDecompressed : %u MB ", (unsigned)(filesize>>20)); @@ -4161,7 +4224,7 @@ } } /* can be out because readSize == 0, which could be an fread() error */ - if (ferror(srcfp)) EXM_THROW(67, "zstd: %s: read error", srcfn); + if (Ferror(srcfd)) EXM_THROW(67, "zstd: %s: read error", srcfn); if (nextToLoad!=0) EXM_THROW(68, "zstd: %s: unfinished stream", srcfn); @@ -4176,14 +4239,14 @@ /** FIO_decompressSrcFile() : - Decompression `srcfn` into `ress.dstfp` + Decompression `srcfn` into `ress.dstfd` @return : 0 : OK 1 : operation not started */ static int FIO_decompressSrcFile(dRess_t ress, const char * dstfn, const char * srcfn) { SPEW("-->\t%s(%p, %s, %s)\n", __FUNCTION__, &ress, dstfn, srcfn); - FILE * srcfp; + FD_t srcfd; unsigned readSomething = 0; unsigned long long filesize = 0; @@ -4192,8 +4255,24 @@ return 1; } - srcfp = FIO_openSrcFile(srcfn); - if (srcfp == NULL) return 1; + srcfd = FIO_openSrcFile(srcfn); + if (srcfd == NULL) return 1; + + int xx; +#if defined(USE_RPMIO) + if (fdGetIo(srcfd) == fpio) { + if (ress.srcIOBuffer) + xx = setvbuf(fdGetFILE(srcfd), ress.srcIOBuffer, _IOFBF, ress.srcBufferSize); + if (ress.dstIOBuffer) + xx = setvbuf(fdGetFILE(ress.dstfd), ress.dstIOBuffer, _IOFBF, ress.dstBufferSize); + } +#else + if (ress.srcIOBuffer) + xx = setvbuf(srcfd, ress.srcIOBuffer, _IOFBF, ress.srcBufferSize); + if (ress.dstIOBuffer) + xx = setvbuf(ress.dstfd, ress.dstIOBuffer, _IOFBF, ress.dstBufferSize); +#endif + (void)xx; /* for each frame */ for (;;) { @@ -4201,25 +4280,25 @@ size_t const toRead = 4; const BYTE* buf = (const BYTE*)ress.srcBuffer; if (ress.srcBufferLoaded < toRead) - ress.srcBufferLoaded += fread((char *)ress.srcBuffer + ress.srcBufferLoaded, - (size_t)1, toRead - ress.srcBufferLoaded, srcfp); + ress.srcBufferLoaded += Fread((char *)ress.srcBuffer + ress.srcBufferLoaded, + (size_t)1, toRead - ress.srcBufferLoaded, srcfd); if (ress.srcBufferLoaded == 0) { if (readSomething == 0) { DISPLAY("zstd: %s: unexpected end of file \n", srcfn); - fclose(srcfp); + Fclose(srcfd); return 1; } /* srcfn is empty */ break; /* no more input */ } - readSomething = 1; /* there is at least >= 4 bytes in srcfp */ + readSomething = 1; /* there is at least >= 4 bytes in srcfd */ if (ress.srcBufferLoaded < toRead) { DISPLAY("zstd: %s: unknown header \n", srcfn); - fclose(srcfp); + Fclose(srcfd); return 1; } if (buf[0] == 31 && buf[1] == 139) { /* gz magic number */ #ifdef ZSTD_GZDECOMPRESS - unsigned long long const result = FIO_decompressGzFrame(&ress, srcfp, srcfn); + unsigned long long const result = FIO_decompressGzFrame(&ress, srcfd, srcfn); if (result == 0) return 1; filesize += result; #else @@ -4229,7 +4308,7 @@ } else if ((buf[0] == 0xFD && buf[1] == 0x37) /* xz magic number */ || (buf[0] == 0x5D && buf[1] == 0x00)) { /* lzma header (no magic number) */ #ifdef ZSTD_LZMADECOMPRESS - unsigned long long const result = FIO_decompressLzmaFrame(&ress, srcfp, srcfn, buf[0] != 0xFD); + unsigned long long const result = FIO_decompressLzmaFrame(&ress, srcfd, srcfn, buf[0] != 0xFD); if (result == 0) return 1; filesize += result; #else @@ -4238,7 +4317,7 @@ #endif } else if (MEM_readLE32(buf) == LZ4_MAGICNUMBER) { #ifdef ZSTD_LZ4DECOMPRESS - unsigned long long const result = FIO_decompressLz4Frame(&ress, srcfp, srcfn); + unsigned long long const result = FIO_decompressLz4Frame(&ress, srcfd, srcfn); if (result == 0) return 1; filesize += result; #else @@ -4248,18 +4327,18 @@ } else { if (!ZSTD_isFrame(ress.srcBuffer, toRead)) { if ((g_overwrite) && !strcmp (dstfn, stdoutmark)) { /* pass-through mode */ - unsigned const result = FIO_passThrough(ress.dstfp, srcfp, + unsigned const result = FIO_passThrough(ress.dstfd, srcfd, ress.srcBuffer, ress.srcBufferSize, ress.srcBufferLoaded); - if (fclose(srcfp)) EXM_THROW(32, "zstd: %s close error", srcfn); /* error should never happen */ + if (Fclose(srcfd)) EXM_THROW(32, "zstd: %s close error", srcfn); /* error should never happen */ return result; } else { DISPLAYLEVEL(1, "zstd: %s: not in zstd format \n", srcfn); - fclose(srcfp); + Fclose(srcfd); return 1; } } - { unsigned long long const frameSize = FIO_decompressFrame(&ress, srcfp, srcfn, filesize); + { unsigned long long const frameSize = FIO_decompressFrame(&ress, srcfd, srcfn, filesize); if (frameSize == FIO_ERROR_ZSTD_DECODING) { - fclose(srcfp); + Fclose(srcfd); return 1; } filesize += frameSize; @@ -4271,7 +4350,7 @@ DISPLAYLEVEL(2, "%-20s: %llu bytes \n", srcfn, filesize); /* Close file */ - if (fclose(srcfp)) EXM_THROW(33, "zstd: %s close error", srcfn); /* error should never happen */ + if (Fclose(srcfd)) EXM_THROW(33, "zstd: %s close error", srcfn); /* error should never happen */ if (g_removeSrcFile /* --rm */ && strcmp(srcfn, stdinmark)) { if (remove(srcfn)) EXM_THROW(34, "zstd: %s: %s", srcfn, strerror(errno)); @@ -4294,14 +4373,14 @@ stat_t sb; int stat_result = 0; - ress.dstfp = FIO_openDstFile(dstfn); - if (ress.dstfp == NULL) return 1; + ress.dstfd = FIO_openDstFile(dstfn); + if (ress.dstfd == NULL) return 1; if (strcmp (srcfn, stdinmark) && UTIL_getFileStat(srcfn, &sb)) stat_result = 1; result = FIO_decompressSrcFile(ress, dstfn, srcfn); - if (fclose(ress.dstfp)) + if (Fclose(ress.dstfd)) EXM_THROW(38, "Write error : cannot properly close %s", dstfn); if ( (result != 0) @@ -4344,11 +4423,11 @@ EXM_THROW(70, "zstd: decompression: unknown dst"); /* should never happen */ if (!strcmp(suffix, stdoutmark) || !strcmp(suffix, nulmark)) { /* special cases : -c or -t */ - ress.dstfp = FIO_openDstFile(suffix); - if (ress.dstfp == 0) EXM_THROW(71, "cannot open %s", suffix); + ress.dstfd = FIO_openDstFile(suffix); + if (ress.dstfd == NULL) EXM_THROW(71, "cannot open %s", suffix); for (int i = 0; i < ac; i++) missingFiles += FIO_decompressSrcFile(ress, suffix, av[i]); - if (fclose(ress.dstfp)) + if (Fclose(ress.dstfd)) EXM_THROW(72, "Write error : cannot properly close stdout"); } else { size_t suffixSize; @@ -4567,11 +4646,9 @@ static const char * lastNameFromPath(const char * path) { -SPEW("-->\t%s()\n", __FUNCTION__); const char * name = path; if (strrchr(name, '/')) name = strrchr(name, '/') + 1; if (strrchr(name, '\\')) name = strrchr(name, '\\') + 1; /* windows */ -SPEW("<--\t%s(%s) name %s\n", __FUNCTION__, path, name); return name; } @@ -4580,10 +4657,8 @@ */ static int exeNameMatch(const char * exeName, const char * test) { -SPEW("-->\t%s()\n", __FUNCTION__); int rc = !strncmp(exeName, test, strlen(test)) && (exeName[strlen(test)] == '\0' || exeName[strlen(test)] == '.'); -SPEW("<--\t%s(%s, %s) rc %d\n", __FUNCTION__, exeName, test, rc); return rc; } @@ -4752,7 +4827,7 @@ int cover = 1; #endif -#if 0 +#if defined(POPTIO_OPTION_PROCESSING) struct poptOption rpmzstdOptionsTable[] = { { "debug", 'd', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_debug, 1, NULL, NULL }, @@ -4769,6 +4844,10 @@ }; optContext con = rpmioInit(argc, argv, rpmzstdOptionsTable); +#endif /* POPTIO_OPTION_PROCESSING */ + +#if defined(USE_RPMIO) +_rpmio_debug = -1; #endif (void) recursive; (void)cLevelLast; /* not used when ZSTD_NOBENCH set */ @@ -5038,7 +5117,6 @@ av[ac++] = arg; } av[ac] = NULL; -argvPrint(__FUNCTION__, av, NULL); if (lastCommand) { DISPLAY("error : command must be followed by arg \n"); CLEAN_RETURN(1); } /* forgotten arg */ @@ -5054,7 +5132,6 @@ DISPLAYLEVEL(4, "PLATFORM_POSIX_VERSION defined: %ldL\n", (long) PLATFORM_POSIX_VERSION); #endif -SPEW("*** %s:%u nbThreads %d\n", __FUNCTION__, __LINE__, nbThreads); if (nbThreads == 0) { /* try to guess */ nbThreads = UTIL_countPhysicalCores(); @@ -5062,7 +5139,6 @@ } g_utilDisplayLevel = g_displayLevel; -SPEW("*** %s:%u followLinks %d\n", __FUNCTION__, __LINE__, followLinks); if (!followLinks) { nac = 0; for (unsigned u = 0; u < ac; u++) { @@ -5075,7 +5151,6 @@ ac = nac; } #ifdef UTIL_HAS_CREATEFILELIST -SPEW("*** %s:%u recursive %d\n", __FUNCTION__, __LINE__, recursive); if (recursive) { /* at this stage, av is a list of paths, which can contain both files and directories */ nav = UTIL_createFileList(av, ac, &navbuf, &nac, followLinks); if (nav) { @@ -5089,7 +5164,6 @@ #endif /* Check if benchmark is selected */ -SPEW("*** %s:%u op %d zom_bench %d\n", __FUNCTION__, __LINE__, operation, zom_bench); if (operation == zom_bench) { #ifndef ZSTD_NOBENCH BMK_setNotificationLevel(g_displayLevel); @@ -5104,7 +5178,6 @@ } /* Check if dictionary builder is selected */ -SPEW("*** %s:%u op %d zom_train %d\n", __FUNCTION__, __LINE__, operation, zom_train); if (operation == zom_train) { #ifndef ZSTD_NODICT if (cover) { @@ -5128,7 +5201,6 @@ } /* No input filename ==> use stdin and stdout */ -SPEW("*** %s:%u op %d\n", __FUNCTION__, __LINE__, operation); ac += (ac == 0); /* av[0] is stdin by default */ if (!strcmp(av[0], stdinmark) && !ofn) ofn = stdoutmark; /* when input is stdin, default output is stdout */ @@ -5138,7 +5210,6 @@ CLEAN_RETURN(badusage(programName)); /* user-selected output filename, only possible with a single file */ -SPEW("*** %s:%u ofn %s stdoutmark %s nulmark %s\n", __FUNCTION__, __LINE__, ofn, stdoutmark, nulmark); if (ofn && strcmp(ofn, stdoutmark) && strcmp(ofn, nulmark) && (ac > 1)) { DISPLAY("Too many files (%u) on the command line. \n", ac); CLEAN_RETURN(ac); @@ -5147,7 +5218,6 @@ #ifndef ZSTD_NOCOMPRESS /* check compression level limits */ int const maxCLevel = ultra ? ZSTD_maxCLevel() : ZSTDCLI_CLEVEL_MAX; -SPEW("*** %s:%u cLevel %d maxCLevel %d\n", __FUNCTION__, __LINE__, cLevel, maxCLevel); if (cLevel > maxCLevel) { DISPLAYLEVEL(2, "Warning : compression level higher than max, reduced to %i \n", maxCLevel); cLevel = maxCLevel; @@ -5155,16 +5225,13 @@ #endif /* No status message in pipe mode (stdin - stdout) or multi-files mode */ -SPEW("*** %s:%u op %d\n", __FUNCTION__, __LINE__, operation); if (!strcmp(av[0], stdinmark) && ofn && !strcmp(ofn, stdoutmark) && (g_displayLevel == 2)) g_displayLevel=1; if ((ac >1 ) & (g_displayLevel == 2)) g_displayLevel = 1; /* IO Stream/File */ -SPEW("*** %s:%u op %d\n", __FUNCTION__, __LINE__, operation); FIO_setNotificationLevel(g_displayLevel); if (operation == zom_compress) { #ifndef ZSTD_NOCOMPRESS -SPEW("*** %s:%u op %d zom_compress %d\n", __FUNCTION__, __LINE__, operation, zom_compress); FIO_setNbThreads(nbThreads); FIO_setBlockSize((U32)blockSize); if (g_overlapLog!=OVERLAP_LOG_DEFAULT) FIO_setOverlapLog(g_overlapLog); @@ -5176,7 +5243,6 @@ DISPLAY("Compression not supported\n"); #endif } else { /* decompression or test */ -SPEW("*** %s:%u op %d\n", __FUNCTION__, __LINE__, operation); #ifndef ZSTD_NODECOMPRESS if (operation == zom_test) { ofn = nulmark; FIO_setRemoveSrcFile(0); } /* test mode */ FIO_setMemLimit(memLimit); @@ -5190,7 +5256,6 @@ } _end: -SPEW("*** %s:%u op %d\n", __FUNCTION__, __LINE__, operation); if (main_pause) waitEnter(); #ifdef UTIL_HAS_CREATEFILELIST if (nav) @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org