this repo has no description
1#ifndef __COMPRESSION_H__
2#define __COMPRESSION_H__
3
4#include <stdint.h>
5#include <os/base.h>
6#include <sys/types.h>
7#include <Availability.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#if __has_feature(assume_nonnull)
14 _Pragma("clang assume_nonnull begin")
15#else
16# define __nullable
17#endif
18
19typedef enum {
20
21 COMPRESSION_LZ4 = 0x100,
22 COMPRESSION_ZLIB = 0x205,
23 COMPRESSION_LZMA = 0x306,
24 COMPRESSION_LZ4_RAW = 0x101,
25 COMPRESSION_LZFSE = 0x801,
26
27} compression_algorithm;
28
29extern size_t
30compression_encode_scratch_buffer_size(compression_algorithm algorithm)
31__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
32
33extern size_t
34compression_encode_buffer(uint8_t * __restrict dst_buffer, size_t dst_size,
35 const uint8_t * __restrict src_buffer, size_t src_size,
36 void * __restrict __nullable scratch_buffer,
37 compression_algorithm algorithm)
38__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
39
40extern size_t
41compression_decode_scratch_buffer_size(compression_algorithm algorithm)
42__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
43
44extern size_t
45compression_decode_buffer(uint8_t * __restrict dst_buffer, size_t dst_size,
46 const uint8_t * __restrict src_buffer, size_t src_size,
47 void * __restrict __nullable scratch_buffer,
48 compression_algorithm algorithm)
49__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
50
51typedef struct {
52 uint8_t * dst_ptr;
53 size_t dst_size;
54 const uint8_t * src_ptr;
55 size_t src_size;
56 void * __nullable state;
57
58} compression_stream;
59
60typedef enum {
61 COMPRESSION_STREAM_ENCODE = 0,
62 COMPRESSION_STREAM_DECODE = 1,
63
64} compression_stream_operation;
65
66typedef enum {
67 COMPRESSION_STREAM_FINALIZE = 0x0001,
68} compression_stream_flags;
69
70typedef enum {
71
72 COMPRESSION_STATUS_OK = 0,
73 COMPRESSION_STATUS_ERROR = -1,
74 COMPRESSION_STATUS_END = 1,
75
76} compression_status;
77
78
79extern compression_status
80compression_stream_init(compression_stream * stream,
81 compression_stream_operation operation,
82 compression_algorithm algorithm)
83__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
84
85extern compression_status
86compression_stream_process(compression_stream * stream,
87 int flags)
88__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
89
90extern compression_status
91compression_stream_destroy(compression_stream * stream)
92__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0);
93
94#if __has_feature(assume_nonnull)
95 _Pragma("clang assume_nonnull end")
96#endif
97#ifdef __cplusplus
98}
99#endif
100
101#endif
102