@@ -77,6 +77,30 @@ int zstd_min_clevel(void);
77
77
*/
78
78
int zstd_max_clevel (void );
79
79
80
+ /**
81
+ * zstd_default_clevel() - default compression level
82
+ *
83
+ * Return: Default compression level.
84
+ */
85
+ int zstd_default_clevel (void );
86
+
87
+ /**
88
+ * struct zstd_custom_mem - custom memory allocation
89
+ */
90
+ typedef ZSTD_customMem zstd_custom_mem ;
91
+
92
+ /**
93
+ * struct zstd_dict_load_method - Dictionary load method.
94
+ * See zstd_lib.h.
95
+ */
96
+ typedef ZSTD_dictLoadMethod_e zstd_dict_load_method ;
97
+
98
+ /**
99
+ * struct zstd_dict_content_type - Dictionary context type.
100
+ * See zstd_lib.h.
101
+ */
102
+ typedef ZSTD_dictContentType_e zstd_dict_content_type ;
103
+
80
104
/* ====== Parameter Selection ====== */
81
105
82
106
/**
@@ -136,6 +160,18 @@ typedef ZSTD_parameters zstd_parameters;
136
160
zstd_parameters zstd_get_params (int level ,
137
161
unsigned long long estimated_src_size );
138
162
163
+ /**
164
+ * zstd_get_cparams() - returns zstd_compression_parameters for selected level
165
+ * @level: The compression level
166
+ * @estimated_src_size: The estimated source size to compress or 0
167
+ * if unknown.
168
+ * @dict_size: Dictionary size.
169
+ *
170
+ * Return: The selected zstd_compression_parameters.
171
+ */
172
+ zstd_compression_parameters zstd_get_cparams (int level ,
173
+ unsigned long long estimated_src_size , size_t dict_size );
174
+
139
175
typedef ZSTD_CCtx zstd_cctx ;
140
176
typedef ZSTD_cParameter zstd_cparameter ;
141
177
@@ -205,6 +241,71 @@ zstd_cctx *zstd_init_cctx(void *workspace, size_t workspace_size);
205
241
size_t zstd_compress_cctx (zstd_cctx * cctx , void * dst , size_t dst_capacity ,
206
242
const void * src , size_t src_size , const zstd_parameters * parameters );
207
243
244
+ /**
245
+ * zstd_create_cctx_advanced() - Create compression context
246
+ * @custom_mem: Custom allocator.
247
+ *
248
+ * Return: NULL on error, pointer to compression context otherwise.
249
+ */
250
+ zstd_cctx * zstd_create_cctx_advanced (zstd_custom_mem custom_mem );
251
+
252
+ /**
253
+ * zstd_free_cctx() - Free compression context
254
+ * @cdict: Pointer to compression context.
255
+ *
256
+ * Return: Always 0.
257
+ */
258
+ size_t zstd_free_cctx (zstd_cctx * cctx );
259
+
260
+ /**
261
+ * struct zstd_cdict - Compression dictionary.
262
+ * See zstd_lib.h.
263
+ */
264
+ typedef ZSTD_CDict zstd_cdict ;
265
+
266
+ /**
267
+ * zstd_create_cdict_byreference() - Create compression dictionary
268
+ * @dict: Pointer to dictionary buffer.
269
+ * @dict_size: Size of the dictionary buffer.
270
+ * @dict_load_method: Dictionary load method.
271
+ * @dict_content_type: Dictionary content type.
272
+ * @custom_mem: Memory allocator.
273
+ *
274
+ * Note, this uses @dict by reference (ZSTD_dlm_byRef), so it should be
275
+ * free before zstd_cdict is destroyed.
276
+ *
277
+ * Return: NULL on error, pointer to compression dictionary
278
+ * otherwise.
279
+ */
280
+ zstd_cdict * zstd_create_cdict_byreference (const void * dict , size_t dict_size ,
281
+ zstd_compression_parameters cparams ,
282
+ zstd_custom_mem custom_mem );
283
+
284
+ /**
285
+ * zstd_free_cdict() - Free compression dictionary
286
+ * @cdict: Pointer to compression dictionary.
287
+ *
288
+ * Return: Always 0.
289
+ */
290
+ size_t zstd_free_cdict (zstd_cdict * cdict );
291
+
292
+ /**
293
+ * zstd_compress_using_cdict() - compress src into dst using a dictionary
294
+ * @cctx: The context. Must have been initialized with zstd_init_cctx().
295
+ * @dst: The buffer to compress src into.
296
+ * @dst_capacity: The size of the destination buffer. May be any size, but
297
+ * ZSTD_compressBound(srcSize) is guaranteed to be large enough.
298
+ * @src: The data to compress.
299
+ * @src_size: The size of the data to compress.
300
+ * @cdict: The dictionary to be used.
301
+ *
302
+ * Return: The compressed size or an error, which can be checked using
303
+ * zstd_is_error().
304
+ */
305
+ size_t zstd_compress_using_cdict (zstd_cctx * cctx , void * dst ,
306
+ size_t dst_capacity , const void * src , size_t src_size ,
307
+ const zstd_cdict * cdict );
308
+
208
309
/* ====== Single-pass Decompression ====== */
209
310
210
311
typedef ZSTD_DCtx zstd_dctx ;
@@ -245,6 +346,71 @@ zstd_dctx *zstd_init_dctx(void *workspace, size_t workspace_size);
245
346
size_t zstd_decompress_dctx (zstd_dctx * dctx , void * dst , size_t dst_capacity ,
246
347
const void * src , size_t src_size );
247
348
349
+ /**
350
+ * struct zstd_ddict - Decompression dictionary.
351
+ * See zstd_lib.h.
352
+ */
353
+ typedef ZSTD_DDict zstd_ddict ;
354
+
355
+ /**
356
+ * zstd_create_ddict_byreference() - Create decompression dictionary
357
+ * @dict: Pointer to dictionary buffer.
358
+ * @dict_size: Size of the dictionary buffer.
359
+ * @dict_load_method: Dictionary load method.
360
+ * @dict_content_type: Dictionary content type.
361
+ * @custom_mem: Memory allocator.
362
+ *
363
+ * Note, this uses @dict by reference (ZSTD_dlm_byRef), so it should be
364
+ * free before zstd_ddict is destroyed.
365
+ *
366
+ * Return: NULL on error, pointer to decompression dictionary
367
+ * otherwise.
368
+ */
369
+ zstd_ddict * zstd_create_ddict_byreference (const void * dict , size_t dict_size ,
370
+ zstd_custom_mem custom_mem );
371
+ /**
372
+ * zstd_free_ddict() - Free decompression dictionary
373
+ * @dict: Pointer to the dictionary.
374
+ *
375
+ * Return: Always 0.
376
+ */
377
+ size_t zstd_free_ddict (zstd_ddict * ddict );
378
+
379
+ /**
380
+ * zstd_create_dctx_advanced() - Create decompression context
381
+ * @custom_mem: Custom allocator.
382
+ *
383
+ * Return: NULL on error, pointer to decompression context otherwise.
384
+ */
385
+ zstd_dctx * zstd_create_dctx_advanced (zstd_custom_mem custom_mem );
386
+
387
+ /**
388
+ * zstd_free_dctx() -- Free decompression context
389
+ * @dctx: Pointer to decompression context.
390
+ * Return: Always 0.
391
+ */
392
+ size_t zstd_free_dctx (zstd_dctx * dctx );
393
+
394
+ /**
395
+ * zstd_decompress_using_ddict() - decompress src into dst using a dictionary
396
+ * @dctx: The decompression context.
397
+ * @dst: The buffer to decompress src into.
398
+ * @dst_capacity: The size of the destination buffer. Must be at least as large
399
+ * as the decompressed size. If the caller cannot upper bound the
400
+ * decompressed size, then it's better to use the streaming API.
401
+ * @src: The zstd compressed data to decompress. Multiple concatenated
402
+ * frames and skippable frames are allowed.
403
+ * @src_size: The exact size of the data to decompress.
404
+ * @ddict: The dictionary to be used.
405
+ *
406
+ * Return: The decompressed size or an error, which can be checked using
407
+ * zstd_is_error().
408
+ */
409
+ size_t zstd_decompress_using_ddict (zstd_dctx * dctx ,
410
+ void * dst , size_t dst_capacity , const void * src , size_t src_size ,
411
+ const zstd_ddict * ddict );
412
+
413
+
248
414
/* ====== Streaming Buffers ====== */
249
415
250
416
/**
0 commit comments