]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Rename to ZSTD_d_forceIgnoreChecksum, add to DCtx, add function to set the advanced...
authorsenhuang42 <senhuang96@fb.com>
Fri, 21 Aug 2020 20:23:39 +0000 (16:23 -0400)
committersenhuang42 <senhuang96@fb.com>
Fri, 21 Aug 2020 20:23:39 +0000 (16:23 -0400)
lib/decompress/zstd_decompress.c
lib/decompress/zstd_decompress_internal.h
lib/zstd.h

index be5c7cfc3347da0291d839379b8ca15aab809e7c..82c24f32829bec37dafcdb28571060ca43c7f62c 100644 (file)
@@ -1397,6 +1397,11 @@ size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format)
     return ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, format);
 }
 
+size_t ZSTD_DCtx_setForceSkipChecksum(ZSTD_DCtx* dctx, ZSTD_format_e format)
+{
+    return ZSTD_DCtx_setParameter(dctx, ZSTD_d_forceSkipChecksum, format);
+}
+
 ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
 {
     ZSTD_bounds bounds = { 0, 0, 0 };
@@ -1414,6 +1419,9 @@ ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
             bounds.lowerBound = (int)ZSTD_obm_buffered;
             bounds.upperBound = (int)ZSTD_obm_stable;
             return bounds;
+        case ZSTD_d_forceIgnoreChecksum:
+            bounds.lowerBound = (int)ZSTD_d_validateChecksum;
+            bounds.upperBound = (int)ZSTD_d_ignoreChecksum;
         default:;
     }
     bounds.error = ERROR(parameter_unsupported);
@@ -1453,6 +1461,9 @@ size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter dParam, int value
             CHECK_DBOUNDS(ZSTD_d_stableOutBuffer, value);
             dctx->outBufferMode = (ZSTD_outBufferMode_e)value;
             return 0;
+        case ZSTD_d_forceIgnoreChecksum:
+            CHECK_DBOUNDS(ZSTD_d_forceIgnoreChecksum, value);
+            dctx->forceIgnoreChecksum = (ZSTD_ignoreChecksumMode_e)value;
         default:;
     }
     RETURN_ERROR(parameter_unsupported, "");
@@ -1524,7 +1535,7 @@ static void ZSTD_DCtx_updateOversizedDuration(ZSTD_DStream* zds, size_t const ne
 {
     if (ZSTD_DCtx_isOverflow(zds, neededInBuffSize, neededOutBuffSize))
         zds->oversizedDuration++;
-    else 
+    else
         zds->oversizedDuration = 0;
 }
 
@@ -1731,7 +1742,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
 
                 {   int const tooSmall = (zds->inBuffSize < neededInBuffSize) || (zds->outBuffSize < neededOutBuffSize);
                     int const tooLarge = ZSTD_DCtx_isOversizedTooLong(zds);
-                    
+
                     if (tooSmall || tooLarge) {
                         size_t const bufferSize = neededInBuffSize + neededOutBuffSize;
                         DEBUGLOG(4, "inBuff  : from %u to %u",
index 9ad96c554885c6d1c287d18e5e8588664cdf2d52..0481ce645a0a77c0ab9f6421a070c9923e5b62c7 100644 (file)
@@ -100,6 +100,11 @@ typedef enum {
     ZSTD_obm_stable = 1     /* ZSTD_outBuffer is stable */
 } ZSTD_outBufferMode_e;
 
+typedef enum {
+    ZSTD_d_validateChecksum = 0,
+    ZSTD_d_ignoreChecksum = 1
+} ZSTD_ignoreChecksumMode_e;
+
 struct ZSTD_DCtx_s
 {
     const ZSTD_seqSymbol* LLTptr;
@@ -122,6 +127,7 @@ struct ZSTD_DCtx_s
     XXH64_state_t xxhState;
     size_t headerSize;
     ZSTD_format_e format;
+    ZSTD_ignoreChecksumMode_e forceIgnoreChecksum;   /* if enabled, will ignore checksums in compressed frame */
     const BYTE* litPtr;
     ZSTD_customMem customMem;
     size_t litSize;
index 76afd183ea86535f26cf6f29580a4399b5ed0700..d37c59965da65a442802421ecaa934c74d3202fc 100644 (file)
@@ -528,7 +528,7 @@ typedef enum {
      * At the time of this writing, they include :
      * ZSTD_d_format
      * ZSTD_d_stableOutBuffer
-     * ZSTD_d_forceSkipChecksum
+     * ZSTD_d_forceIgnoreChecksum
      * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
      * note : never ever use experimentalParam? names directly
      */
@@ -1692,7 +1692,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowS
  */
 #define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2
 
-/* ZSTD_d_forceSkipChecksum
+/* ZSTD_d_forceIgnoreChecksum
  * Experimental parameter.
  * Default is 0 == disabled. Set to 1 to enable
  *
@@ -1700,7 +1700,7 @@ ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowS
  * of whether or not checksumming was specified during decompression. This offers some
  * slight performance benefits, and may be useful for debugging.
  */
-#define ZSTD_d_forceSkipChecksum ZSTD_d_experimentalParam3
+#define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3
 
 /*! ZSTD_DCtx_setFormat() :
  *  Instruct the decoder context about what kind of data to decode next.