File longopt.diff of Package zstd-seekable_format

--- contrib/seekable_format/examples/seekable_compression.c.orig	2024-05-29 13:08:24.314324451 +0000
+++ contrib/seekable_format/examples/seekable_compression.c	2024-05-29 13:40:42.827030391 +0000
@@ -60,7 +60,7 @@ static size_t fclose_orDie(FILE* file)
     exit(6);
 }
 
-static void compressFile_orDie(const char* fname, const char* outName, int cLevel, unsigned frameSize)
+static void compressFile_orDie(const char* fname, const char* outName, int cLevel, unsigned frameSize, unsigned windowLog)
 {
     FILE* const fin  = fopen_orDie(fname, "rb");
     FILE* const fout = fopen_orDie(outName, "wb");
@@ -73,6 +73,10 @@ static void compressFile_orDie(const cha
     if (cstream==NULL) { fprintf(stderr, "ZSTD_seekable_createCStream() error \n"); exit(10); }
     size_t const initResult = ZSTD_seekable_initCStream(cstream, cLevel, 1, frameSize);
     if (ZSTD_isError(initResult)) { fprintf(stderr, "ZSTD_seekable_initCStream() error : %s \n", ZSTD_getErrorName(initResult)); exit(11); }
+    if (windowLog) {
+	size_t const initResult2 = ZSTD_seekable_setWindowLog(cstream, windowLog);
+	if (ZSTD_isError(initResult2)) { fprintf(stderr, "ZSTD_seekable_setWindowLog() error : %s \n", ZSTD_getErrorName(initResult2)); exit(11); }
+    }
 
     size_t read, toRead = buffInSize;
     while( (read = fread_orDie(buffIn, toRead, fin)) ) {
@@ -116,10 +120,16 @@ static char* createOutFilename_orDie(con
 int main(int argc, const char** argv)
 {
     const char* const exeName = argv[0];
+    unsigned windowLog = 0;
+    if (argc > 1 && !strcmp(argv[1], "--long")) {
+	windowLog = 27;
+	argc--;
+	argv++;
+    }
     if (argc<3 || argc>4) {
         printf("wrong arguments \n");
         printf("usage: \n");
-        printf("%s FILE FRAME_SIZE [LEVEL] \n", exeName);
+        printf("%s [--long] FILE FRAME_SIZE [LEVEL] \n", exeName);
         return 1;
     }
 
@@ -128,7 +138,7 @@ int main(int argc, const char** argv)
         int const cLevel = (argc==4) ? atoi(argv[3]) : CLEVEL_DEFAULT;
 
         char* const outFileName = createOutFilename_orDie(inFileName);
-        compressFile_orDie(inFileName, outFileName, cLevel, frameSize);
+        compressFile_orDie(inFileName, outFileName, cLevel, frameSize, windowLog);
         free(outFileName);
     }
 
--- contrib/seekable_format/zstd_seekable.h.orig	2024-05-29 13:21:34.561097509 +0000
+++ contrib/seekable_format/zstd_seekable.h	2024-05-29 13:23:26.544919264 +0000
@@ -90,6 +90,7 @@ ZSTDLIB_API size_t ZSTD_seekable_freeCSt
 
 /*===== Seekable compression functions =====*/
 ZSTDLIB_API size_t ZSTD_seekable_initCStream(ZSTD_seekable_CStream* zcs, int compressionLevel, int checksumFlag, unsigned maxFrameSize);
+ZSTDLIB_API size_t ZSTD_seekable_setWindowLog(ZSTD_seekable_CStream* zcs, unsigned windowLog);
 ZSTDLIB_API size_t ZSTD_seekable_compressStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
 ZSTDLIB_API size_t ZSTD_seekable_endFrame(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output);
 ZSTDLIB_API size_t ZSTD_seekable_endStream(ZSTD_seekable_CStream* zcs, ZSTD_outBuffer* output);
--- contrib/seekable_format/zstdseek_compress.c.orig	2024-05-29 13:17:19.661503235 +0000
+++ contrib/seekable_format/zstdseek_compress.c	2024-05-29 13:21:16.609126085 +0000
@@ -164,6 +164,10 @@ size_t ZSTD_seekable_initCStream(ZSTD_se
     return ZSTD_initCStream(zcs->cstream, compressionLevel);
 }
 
+size_t ZSTD_seekable_setWindowLog(ZSTD_seekable_CStream* zcs, unsigned windowLog) {
+    return ZSTD_CCtx_setParameter(zcs->cstream, ZSTD_c_windowLog, (int)windowLog);
+}
+
 size_t ZSTD_seekable_logFrame(ZSTD_frameLog* fl,
                               unsigned compressedSize,
                               unsigned decompressedSize,
openSUSE Build Service is sponsored by