{
zds->stage = zdss_loadHeader;
zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0;
- if ((dict != zds->dictSource) || (dictSize != zds->dictSize)) { /* new dictionary */
+ if ((dict != zds->dictSource) | (dictSize != zds->dictSize)) { /* new dictionary */
if (dictSize > zds->dictSize) {
if (zds->dictContent) zds->customMem.customFree(zds->customMem.opaque, zds->dictContent);
zds->dictContent = zds->customMem.customAlloc(zds->customMem.opaque, dictSize);
#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
if (zds->legacyVersion)
- return ZSTD_decompressLegacyStream(&zds->legacyContext, zds->legacyVersion, output, input);
+ return ZSTD_decompressLegacyStream(zds->legacyContext, zds->legacyVersion, output, input);
#endif
while (someMoreWork) {
case ZBUFFds_loadHeader :
{ size_t const hSize = ZSTDv07_getFrameParams(&(zbd->fParams), zbd->headerBuffer, zbd->lhSize);
+ if (ZSTDv07_isError(hSize)) return hSize;
if (hSize != 0) {
size_t const toLoad = hSize - zbd->lhSize; /* if hSize!=0, hSize > zbd->lhSize */
- if (ZSTDv07_isError(hSize)) return hSize;
if (toLoad > (size_t)(iend-ip)) { /* not enough input to load full header */
memcpy(zbd->headerBuffer + zbd->lhSize, ip, iend-ip);
zbd->lhSize += iend-ip;
if (zbd->outBuff == NULL) return ERROR(memory_allocation);
} } }
zbd->stage = ZBUFFds_read;
+ /* pass-through */
case ZBUFFds_read:
{ size_t const neededInSize = ZSTDv07_nextSrcSizeToDecompress(zbd->zd);
*/
+/* *************************************
+ * Tuning options
+ ***************************************/
+#ifndef ZSTD_LEGACY_SUPPORT
+/* LEGACY_SUPPORT :
+ * decompressor can decode older formats (starting from Zstd 0.1+) */
+# define ZSTD_LEGACY_SUPPORT 1
+#endif
+
+
/* *************************************
* Compiler Options
***************************************/
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_magicNumber, ZSTD_frameHeaderSize_max */
#include "zstd.h"
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT==1)
+# include "zstd_legacy.h" /* ZSTD_isLegacy */
+#endif
+
/*-*************************************
* OS-specific Includes
readSomething = 1;
if (sizeCheck != toRead) { DISPLAY("zstd: %s: unknown header \n", srcFileName); fclose(srcFile); return 1; } /* srcFileName is empty */
{ U32 const magic = MEM_readLE32(ress.srcBuffer);
- if (((magic & 0xFFFFFFF0U) != ZSTD_MAGIC_SKIPPABLE_START) & (magic != ZSTD_MAGICNUMBER)) {
+ if (((magic & 0xFFFFFFF0U) != ZSTD_MAGIC_SKIPPABLE_START) & (magic != ZSTD_MAGICNUMBER)
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ & (!ZSTD_isLegacy(ress.srcBuffer, toRead))
+#endif
+ ) {
if ((g_overwrite) && !strcmp (srcFileName, stdinmark)) { /* pass-through mode */
unsigned const result = FIO_passThrough(dstFile, srcFile, ress.srcBuffer, ress.srcBufferSize);
if (fclose(srcFile)) EXM_THROW(32, "zstd: %s close error", srcFileName); /* error should never happen */
+
/*
zstdcli - Command Line Interface (cli) for zstd
Copyright (C) Yann Collet 2014-2016