1 #ifndef LZMA_STUB_H
2 #define LZMA_STUB_H
3 
4 /* Some platforms, notably macOS, ship a usable liblzma shared library but
5    do not ship any LZMA header files. The <lzma.h> and <lzma/{*}.h> header
6    files that come with the library contain the following statement:
7 
8      *
9      * Author: Lasse Collin
10      *
11      * This file has been put into the public domain.
12      * You can do whatever you want with this file.
13      *
14 
15    Accordingly the following declarations have been copied and distilled
16    from <lzma/base.h> and <lzma/container.h> (primarily) and are sufficient
17    to compile cram/cram_io.c in the absence of proper LZMA headers.
18 
19    This file, lzma_stub.h, remains in the public domain.  */
20 
21 #include <stdint.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef enum { LZMA_OK = 0, LZMA_STREAM_END = 1 } lzma_ret;
28 typedef enum { LZMA_RUN = 0, LZMA_FINISH = 3 } lzma_action;
29 typedef enum { LZMA_CHECK_CRC32 = 1 } lzma_check;
30 typedef enum { LZMA_RESERVED_ENUM = 0 } lzma_reserved_enum;
31 
32 struct lzma_allocator;
33 struct lzma_internal;
34 
35 typedef struct {
36     const uint8_t *next_in;
37     size_t avail_in;
38     uint64_t total_in;
39 
40     uint8_t *next_out;
41     size_t avail_out;
42     uint64_t total_out;
43 
44     const struct lzma_allocator *allocator;
45     struct lzma_internal *internal;
46 
47     void *reserved_ptr1;
48     void *reserved_ptr2;
49     void *reserved_ptr3;
50     void *reserved_ptr4;
51     uint64_t reserved_int1;
52     uint64_t reserved_int2;
53     size_t reserved_int3;
54     size_t reserved_int4;
55     lzma_reserved_enum reserved_enum1;
56     lzma_reserved_enum reserved_enum2;
57 } lzma_stream;
58 
59 #define LZMA_STREAM_INIT \
60     { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \
61     NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
62     LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
63 
64 extern size_t lzma_stream_buffer_bound(size_t uncompressed_size);
65 
66 extern lzma_ret lzma_easy_buffer_encode(
67         uint32_t preset, lzma_check check,
68         const struct lzma_allocator *allocator,
69         const uint8_t *in, size_t in_size,
70         uint8_t *out, size_t *out_pos, size_t out_size);
71 
72 extern lzma_ret lzma_stream_decoder(
73         lzma_stream *strm, uint64_t memlimit, uint32_t flags);
74 
75 extern uint64_t lzma_easy_decoder_memusage(uint32_t preset);
76 
77 extern lzma_ret lzma_code(lzma_stream *strm, lzma_action action);
78 
79 extern void lzma_end(lzma_stream *strm);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
86