1 module squiz_box.c.lzma;
2 
3 import std.traits : isIntegral;
4 
5 private alias uint8_t = ubyte;
6 private alias uint32_t = uint;
7 private alias uint64_t = ulong;
8 
9 // lzma/version.h
10 
11 enum LZMA_VERSION_MAJOR = 5;
12 enum LZMA_VERSION_MINOR = 2;
13 enum LZMA_VERSION_PATCH = 5;
14 enum LZMA_VERSION_STABILITY = LZMA_VERSION_STABILITY_STABLE;
15 
16 /*
17  * Map symbolic stability levels to integers.
18  */
19 enum LZMA_VERSION_STABILITY_ALPHA = 0;
20 enum LZMA_VERSION_STABILITY_BETA = 1;
21 enum LZMA_VERSION_STABILITY_STABLE = 2;
22 
23 enum uint LZMA_VERSION = LZMA_VERSION_MAJOR * 10_000_000
24     + LZMA_VERSION_MINOR * 10_000
25     + LZMA_VERSION_PATCH * 10
26     + LZMA_VERSION_STABILITY;
27 
28 enum LZMA_VERSION_STRING = "5.2.5";
29 
30 extern (C) uint lzma_version_number() nothrow;
31 
32 extern (C) const(char)* lzma_version_string() nothrow;
33 
34 // lzma/base.h
35 
36 alias lzma_bool = bool;
37 
38 static assert(lzma_bool.sizeof == 1);
39 
40 enum lzma_reserved_enum
41 {
42     LZMA_RESERVED_ENUM = 0,
43 }
44 
45 enum lzma_ret
46 {
47     OK = 0,
48     STREAM_END = 1,
49     NO_CHECK = 2,
50     UNSUPPORTED_CHECK = 3,
51     GET_CHECK = 4,
52     MEM_ERROR = 5,
53     MEMLIMIT_ERROR = 6,
54     FORMAT_ERROR = 7,
55     OPTIONS_ERROR = 8,
56     DATA_ERROR = 9,
57     BUF_ERROR = 10,
58     PROG_ERROR = 11,
59 }
60 
61 enum lzma_action
62 {
63     RUN = 0,
64     SYNC_FLUSH = 1,
65     FULL_FLUSH = 2,
66     FULL_BARRIER = 4,
67     FINISH = 3
68 }
69 
70 struct lzma_allocator
71 {
72     extern (C) void* function(void* opaque, size_t nmemb, size_t size) alloc;
73     extern (C) void function(void* opaque, void* ptr) free;
74     void* opaque;
75 }
76 
77 struct lzma_internal;
78 
79 struct lzma_stream
80 {
81     const(uint8_t)* next_in;
82     size_t avail_in;
83     uint64_t total_in;
84 
85     uint8_t* next_out;
86     size_t avail_out;
87     uint64_t total_out;
88 
89     const(lzma_allocator)* allocator;
90 
91     lzma_internal* internal;
92 
93     void* reserved_ptr1;
94     void* reserved_ptr2;
95     void* reserved_ptr3;
96     void* reserved_ptr4;
97     uint64_t reserved_int1;
98     uint64_t reserved_int2;
99     size_t reserved_int3;
100     size_t reserved_int4;
101     lzma_reserved_enum reserved_enum1;
102     lzma_reserved_enum reserved_enum2;
103 }
104 
105 extern (C) lzma_ret lzma_code(lzma_stream* strm, lzma_action action) nothrow;
106 
107 extern (C) void lzma_end(lzma_stream* strm) nothrow;
108 
109 extern (C) void lzma_get_progress(lzma_stream* strm,
110     uint64_t* progress_in, uint64_t* progress_out) nothrow;
111 
112 extern (C) uint64_t lzma_memusage(const(lzma_stream)* strm)
113 nothrow pure;
114 
115 extern (C) uint64_t lzma_memlimit_get(const(lzma_stream)* strm)
116 nothrow pure;
117 
118 extern (C) lzma_ret lzma_memlimit_set(
119     lzma_stream* strm, uint64_t memlimit) nothrow;
120 
121 // lzma/vli.h
122 
123 enum LZMA_VLI_MAX = uint64_t.max / 2;
124 
125 enum LZMA_VLI_UNKNOWN = uint64_t.max;
126 
127 enum LZMA_VLI_BYTES_MAX = 9;
128 
129 lzma_vli LZMA_VLI_C(N)(N n) if (isIntegral!N)
130 {
131     return n;
132 }
133 
134 alias lzma_vli = uint64_t;
135 
136 bool lzma_vli_is_valid(lzma_vli vli)
137 {
138     return vli <= LZMA_VLI_MAX || vli == LZMA_VLI_UNKNOWN;
139 }
140 
141 extern (C) lzma_ret lzma_vli_encode(lzma_vli vli, size_t* vli_pos,
142     uint8_t* out_, size_t* out_pos, size_t out_size) nothrow;
143 
144 extern (C) lzma_ret lzma_vli_decode(lzma_vli* vli, size_t* vli_pos,
145     const uint8_t* in_, size_t* in_pos, size_t in_size)
146 nothrow;
147 
148 extern (C) uint32_t lzma_vli_size(lzma_vli vli)
149 nothrow pure;
150 
151 // lzma/check.h
152 
153 enum lzma_check
154 {
155     NONE = 0,
156     CRC32 = 1,
157     CRC64 = 4,
158     SHA256 = 10
159 }
160 
161 enum LZMA_CHECK_ID_MAX = 15;
162 
163 extern (C) lzma_bool lzma_check_is_supported(lzma_check check)
164 nothrow;
165 
166 extern (C) uint32_t lzma_check_size(lzma_check check)
167 nothrow;
168 
169 enum LZMA_CHECK_SIZE_MAX = 64;
170 
171 extern (C) uint32_t lzma_crc32(
172     const uint8_t* buf, size_t size, uint32_t crc)
173 nothrow pure;
174 
175 extern (C) uint64_t lzma_crc64(
176     const uint8_t* buf, size_t size, uint64_t crc)
177 nothrow pure;
178 
179 extern (C) lzma_check lzma_get_check(const lzma_stream* strm)
180 nothrow;
181 
182 // lzma/filter.h
183 enum LZMA_FILTERS_MAX = 4;
184 
185 struct lzma_filter
186 {
187     lzma_vli id;
188     void* options;
189 }
190 
191 extern (C) lzma_bool lzma_filter_encoder_is_supported(lzma_vli id)
192 nothrow;
193 
194 extern (C) lzma_bool lzma_filter_decoder_is_supported(lzma_vli id)
195 nothrow;
196 
197 extern (C) lzma_ret lzma_filters_copy(
198     const lzma_filter* src, lzma_filter* dest,
199     const lzma_allocator* allocator) nothrow;
200 
201 extern (C) uint64_t lzma_raw_encoder_memusage(const lzma_filter* filters)
202 nothrow pure;
203 
204 extern (C) uint64_t lzma_raw_decoder_memusage(const lzma_filter* filters)
205 nothrow pure;
206 
207 extern (C) lzma_ret lzma_raw_encoder(
208     lzma_stream* strm, const lzma_filter* filters)
209 nothrow;
210 
211 extern (C) lzma_ret lzma_raw_decoder(
212     lzma_stream* strm, const lzma_filter* filters)
213 nothrow;
214 
215 extern (C) lzma_ret lzma_filters_update(
216     lzma_stream* strm, const lzma_filter* filters) nothrow;
217 
218 extern (C) lzma_ret lzma_raw_buffer_encode(
219     const lzma_filter* filters, const lzma_allocator* allocator,
220     const uint8_t* in_, size_t in_size, uint8_t* out_,
221     size_t* out_pos, size_t out_size) nothrow;
222 
223 extern (C) lzma_ret lzma_raw_buffer_decode(
224     const lzma_filter* filters, const lzma_allocator* allocator,
225     const uint8_t* in_, size_t* in_pos, size_t in_size,
226     uint8_t* out_, size_t* out_pos, size_t out_size) nothrow;
227 
228 extern (C) lzma_ret lzma_properties_size(
229     uint32_t* size, const lzma_filter* filter) nothrow;
230 
231 extern (C) lzma_ret lzma_properties_encode(
232     const lzma_filter* filter, uint8_t* props) nothrow;
233 
234 extern (C) lzma_ret lzma_properties_decode(
235     lzma_filter* filter, const lzma_allocator* allocator,
236     const uint8_t* props, size_t props_size) nothrow;
237 
238 extern (C) lzma_ret lzma_filter_flags_size(
239     uint32_t* size, const lzma_filter* filter)
240 nothrow;
241 
242 extern (C) lzma_ret lzma_filter_flags_encode(const lzma_filter* filter,
243     uint8_t* out_, size_t* out_pos, size_t out_size)
244 nothrow;
245 
246 extern (C) lzma_ret lzma_filter_flags_decode(
247     lzma_filter* filter, const lzma_allocator* allocator,
248     const uint8_t* in_, size_t* in_pos, size_t in_size)
249 nothrow;
250 
251 // lzma/bcj.h
252 
253 enum LZMA_FILTER_X86 = LZMA_VLI_C(0x04);
254 
255 enum LZMA_FILTER_POWERPC = LZMA_VLI_C(0x05);
256 
257 enum LZMA_FILTER_IA64 = LZMA_VLI_C(0x06);
258 
259 enum LZMA_FILTER_ARM = LZMA_VLI_C(0x07);
260 
261 enum LZMA_FILTER_ARMTHUMB = LZMA_VLI_C(0x08);
262 
263 enum LZMA_FILTER_SPARC = LZMA_VLI_C(0x09);
264 
265 struct lzma_options_bcj
266 {
267     uint32_t start_offset;
268 }
269 
270 // lzma/delta.h
271 
272 enum LZMA_FILTER_DELTA = LZMA_VLI_C(0x03);
273 
274 enum lzma_delta_type
275 {
276     LZMA_DELTA_TYPE_BYTE
277 }
278 
279 enum LZMA_DELTA_DIST_MIN = 1;
280 enum LZMA_DELTA_DIST_MAX = 256;
281 
282 struct lzma_options_delta
283 {
284     lzma_delta_type type;
285 
286     uint32_t dist;
287     uint32_t reserved_int1;
288     uint32_t reserved_int2;
289     uint32_t reserved_int3;
290     uint32_t reserved_int4;
291     void* reserved_ptr1;
292     void* reserved_ptr2;
293 }
294 
295 // lzma/lzma12.h
296 
297 enum LZMA_FILTER_LZMA1 = LZMA_VLI_C(0x4000000000000001);
298 
299 enum LZMA_FILTER_LZMA2 = LZMA_VLI_C(0x21);
300 
301 enum lzma_match_finder
302 {
303     LZMA_MF_HC3 = 0x03,
304     LZMA_MF_HC4 = 0x04,
305 
306     LZMA_MF_BT2 = 0x12,
307 
308     LZMA_MF_BT3 = 0x13,
309 
310     LZMA_MF_BT4 = 0x14
311 }
312 
313 extern (C) lzma_bool lzma_mf_is_supported(lzma_match_finder match_finder)
314 nothrow;
315 
316 enum lzma_mode
317 {
318     LZMA_MODE_FAST = 1,
319     LZMA_MODE_NORMAL = 2
320 }
321 
322 extern (C) lzma_bool lzma_mode_is_supported(lzma_mode mode)
323 nothrow;
324 
325 enum LZMA_DICT_SIZE_MIN = 4096;
326 enum LZMA_DICT_SIZE_DEFAULT = 1 << 23;
327 enum LZMA_LCLP_MIN = 0;
328 enum LZMA_LCLP_MAX = 4;
329 enum LZMA_LC_DEFAULT = 3;
330 enum LZMA_LP_DEFAULT = 0;
331 enum LZMA_PB_MIN = 0;
332 enum LZMA_PB_MAX = 4;
333 enum LZMA_PB_DEFAULT = 2;
334 
335 struct lzma_options_lzma
336 {
337     uint32_t dict_size;
338 
339     const uint8_t* preset_dict;
340 
341     uint32_t preset_dict_size;
342 
343     uint32_t lc;
344 
345     uint32_t lp;
346 
347     uint32_t pb;
348     lzma_mode mode;
349 
350     uint32_t nice_len;
351 
352     lzma_match_finder mf;
353 
354     uint32_t depth;
355 
356     uint32_t reserved_int1;
357     uint32_t reserved_int2;
358     uint32_t reserved_int3;
359     uint32_t reserved_int4;
360     uint32_t reserved_int5;
361     uint32_t reserved_int6;
362     uint32_t reserved_int7;
363     uint32_t reserved_int8;
364     lzma_reserved_enum reserved_enum1;
365     lzma_reserved_enum reserved_enum2;
366     lzma_reserved_enum reserved_enum3;
367     lzma_reserved_enum reserved_enum4;
368     void* reserved_ptr1;
369     void* reserved_ptr2;
370 }
371 
372 extern (C) lzma_bool lzma_lzma_preset(
373     lzma_options_lzma* options, uint32_t preset) nothrow;
374 
375 // lzma/containers.h
376 /************
377  * Encoding *
378  ************/
379 
380 enum uint32_t LZMA_PRESET_DEFAULT = 6;
381 
382 enum uint32_t LZMA_PRESET_LEVEL_MASK = 0x1F;
383 
384 enum uint32_t LZMA_PRESET_EXTREME = 1 << 31;
385 
386 struct lzma_mt
387 {
388     uint32_t flags;
389 
390     uint32_t threads;
391 
392     uint64_t block_size;
393 
394     uint32_t timeout;
395 
396     uint32_t preset;
397 
398     const lzma_filter* filters;
399 
400     lzma_check check;
401 
402     lzma_reserved_enum reserved_enum1;
403     lzma_reserved_enum reserved_enum2;
404     lzma_reserved_enum reserved_enum3;
405     uint32_t reserved_int1;
406     uint32_t reserved_int2;
407     uint32_t reserved_int3;
408     uint32_t reserved_int4;
409     uint64_t reserved_int5;
410     uint64_t reserved_int6;
411     uint64_t reserved_int7;
412     uint64_t reserved_int8;
413     void* reserved_ptr1;
414     void* reserved_ptr2;
415     void* reserved_ptr3;
416     void* reserved_ptr4;
417 }
418 
419 extern (C) uint64_t lzma_easy_encoder_memusage(uint32_t preset)
420 nothrow pure;
421 
422 extern (C) uint64_t lzma_easy_decoder_memusage(uint32_t preset)
423 nothrow pure;
424 
425 extern (C) lzma_ret lzma_easy_encoder(
426     lzma_stream* strm, uint32_t preset, lzma_check check)
427 nothrow;
428 
429 extern (C) lzma_ret lzma_easy_buffer_encode(
430     uint32_t preset, lzma_check check,
431     const lzma_allocator* allocator,
432     const uint8_t* in_, size_t in_size,
433     uint8_t* out_, size_t* out_pos, size_t out_size) nothrow;
434 
435 extern (C) lzma_ret lzma_stream_encoder(lzma_stream* strm,
436     const lzma_filter* filters, lzma_check check)
437 nothrow;
438 
439 extern (C) uint64_t lzma_stream_encoder_mt_memusage(
440     const lzma_mt* options) nothrow pure;
441 
442 extern (C) lzma_ret lzma_stream_encoder_mt(
443     lzma_stream* strm, const lzma_mt* options)
444 nothrow;
445 
446 extern (C) lzma_ret lzma_alone_encoder(
447     lzma_stream* strm, const lzma_options_lzma* options)
448 nothrow;
449 
450 extern (C) size_t lzma_stream_buffer_bound(size_t uncompressed_size)
451 nothrow;
452 
453 extern (C) lzma_ret lzma_stream_buffer_encode(
454     lzma_filter* filters, lzma_check check,
455     const lzma_allocator* allocator,
456     const uint8_t* in_, size_t in_size,
457     uint8_t* out_, size_t* out_pos, size_t out_size)
458 nothrow;
459 
460 /************
461  * Decoding *
462  ************/
463 enum uint32_t LZMA_TELL_NO_CHECK = 0x01;
464 
465 enum uint32_t LZMA_TELL_UNSUPPORTED_CHECK = 0x02;
466 
467 enum uint32_t LZMA_TELL_ANY_CHECK = 0x04;
468 
469 enum uint32_t LZMA_IGNORE_CHECK = 0x10;
470 
471 enum uint32_t LZMA_CONCATENATED = 0x08;
472 
473 extern (C) lzma_ret lzma_stream_decoder(
474     lzma_stream* strm, uint64_t memlimit, uint32_t flags)
475 nothrow;
476 
477 extern (C) lzma_ret lzma_auto_decoder(
478     lzma_stream* strm, uint64_t memlimit, uint32_t flags)
479 nothrow;
480 
481 extern (C) lzma_ret lzma_alone_decoder(
482     lzma_stream* strm, uint64_t memlimit)
483 nothrow;
484 
485 extern (C) lzma_ret lzma_stream_buffer_decode(
486     uint64_t* memlimit, uint32_t flags,
487     const lzma_allocator* allocator,
488     const uint8_t* in_, size_t* in_pos, size_t in_size,
489     uint8_t* out_, size_t* out_pos, size_t out_size)
490 nothrow;
491 
492 // lzma/stream_flags.h
493 
494 enum LZMA_STREAM_HEADER_SIZE = 12;
495 
496 enum LZMA_BACKWARD_SIZE_MIN = 4;
497 enum LZMA_BACKWARD_SIZE_MAX = (LZMA_VLI_C(1) << 34);
498 
499 struct lzma_stream_flags
500 {
501     uint32_t version_;
502     lzma_vli backward_size;
503     lzma_check check;
504 
505     lzma_reserved_enum reserved_enum1;
506     lzma_reserved_enum reserved_enum2;
507     lzma_reserved_enum reserved_enum3;
508     lzma_reserved_enum reserved_enum4;
509     lzma_bool reserved_bool1;
510     lzma_bool reserved_bool2;
511     lzma_bool reserved_bool3;
512     lzma_bool reserved_bool4;
513     lzma_bool reserved_bool5;
514     lzma_bool reserved_bool6;
515     lzma_bool reserved_bool7;
516     lzma_bool reserved_bool8;
517     uint32_t reserved_int1;
518     uint32_t reserved_int2;
519 }
520 
521 extern (C) lzma_ret lzma_stream_header_encode(
522     const lzma_stream_flags* options, uint8_t* out_)
523 nothrow;
524 
525 extern (C) lzma_ret lzma_stream_footer_encode(
526     const lzma_stream_flags* options, uint8_t* out_)
527 nothrow;
528 
529 extern (C) lzma_ret lzma_stream_header_decode(
530     lzma_stream_flags* options, const uint8_t* in_)
531 nothrow;
532 
533 extern (C) lzma_ret lzma_stream_footer_decode(
534     lzma_stream_flags* options, const uint8_t* in_)
535 nothrow;
536 
537 extern (C) lzma_ret lzma_stream_flags_compare(
538     const lzma_stream_flags* a, const lzma_stream_flags* b)
539 nothrow pure;
540 
541 // lzma/block.h
542 
543 enum LZMA_BLOCK_HEADER_SIZE_MIN = 8;
544 enum LZMA_BLOCK_HEADER_SIZE_MAX = 1024;
545 
546 struct lzma_block
547 {
548     uint32_t version_;
549 
550     uint32_t header_size;
551 
552     lzma_check check;
553 
554     lzma_vli compressed_size;
555 
556     lzma_vli uncompressed_size;
557 
558     lzma_filter* filters;
559 
560     uint8_t[LZMA_CHECK_SIZE_MAX] raw_check;
561 
562     void* reserved_ptr1;
563     void* reserved_ptr2;
564     void* reserved_ptr3;
565     uint32_t reserved_int1;
566     uint32_t reserved_int2;
567     lzma_vli reserved_int3;
568     lzma_vli reserved_int4;
569     lzma_vli reserved_int5;
570     lzma_vli reserved_int6;
571     lzma_vli reserved_int7;
572     lzma_vli reserved_int8;
573     lzma_reserved_enum reserved_enum1;
574     lzma_reserved_enum reserved_enum2;
575     lzma_reserved_enum reserved_enum3;
576     lzma_reserved_enum reserved_enum4;
577 
578     lzma_bool ignore_check;
579 
580     lzma_bool reserved_bool2;
581     lzma_bool reserved_bool3;
582     lzma_bool reserved_bool4;
583     lzma_bool reserved_bool5;
584     lzma_bool reserved_bool6;
585     lzma_bool reserved_bool7;
586     lzma_bool reserved_bool8;
587 }
588 
589 uint32_t lzma_block_header_size_decode(B)(B b)
590 {
591     return (b + 1) * 4;
592 }
593 
594 extern (C) lzma_ret lzma_block_header_size(lzma_block* block)
595 nothrow;
596 
597 extern (C) lzma_ret lzma_block_header_encode(
598     const lzma_block* block, uint8_t* out_)
599 nothrow;
600 
601 extern (C) lzma_ret lzma_block_header_decode(lzma_block* block,
602     const lzma_allocator* allocator, const uint8_t* in_)
603 nothrow;
604 
605 extern (C) lzma_ret lzma_block_compressed_size(
606     lzma_block* block, lzma_vli unpadded_size)
607 nothrow;
608 
609 extern (C) lzma_vli lzma_block_unpadded_size(const lzma_block* block)
610 nothrow pure;
611 
612 extern (C) lzma_vli lzma_block_total_size(const lzma_block* block)
613 nothrow pure;
614 
615 extern (C) lzma_ret lzma_block_encoder(
616     lzma_stream* strm, lzma_block* block)
617 nothrow;
618 
619 extern (C) lzma_ret lzma_block_decoder(
620     lzma_stream* strm, lzma_block* block)
621 nothrow;
622 
623 extern (C) size_t lzma_block_buffer_bound(size_t uncompressed_size)
624 nothrow;
625 
626 extern (C) lzma_ret lzma_block_buffer_encode(
627     lzma_block* block, const lzma_allocator* allocator,
628     const uint8_t* in_, size_t in_size,
629     uint8_t* out_, size_t* out_pos, size_t out_size)
630 nothrow;
631 
632 extern (C) lzma_ret lzma_block_uncomp_encode(lzma_block* block,
633     const uint8_t* in_, size_t in_size,
634     uint8_t* out_, size_t* out_pos, size_t out_size)
635 nothrow;
636 
637 extern (C) lzma_ret lzma_block_buffer_decode(
638     lzma_block* block, const lzma_allocator* allocator,
639     const uint8_t* in_, size_t* in_pos, size_t in_size,
640     uint8_t* out_, size_t* out_pos, size_t out_size)
641 nothrow;
642 
643 // lzma/index.h
644 
645 struct lzma_index;
646 
647 struct lzma_index_iter_stream
648 {
649     const lzma_stream_flags* flags;
650 
651     const void* reserved_ptr1;
652     const void* reserved_ptr2;
653     const void* reserved_ptr3;
654 
655     lzma_vli number;
656 
657     lzma_vli block_count;
658 
659     lzma_vli compressed_offset;
660 
661     lzma_vli uncompressed_offset;
662 
663     lzma_vli compressed_size;
664 
665     lzma_vli uncompressed_size;
666 
667     lzma_vli padding;
668 
669     lzma_vli reserved_vli1;
670     lzma_vli reserved_vli2;
671     lzma_vli reserved_vli3;
672     lzma_vli reserved_vli4;
673 }
674 
675 struct lzma_index_iter_block
676 {
677     lzma_vli number_in_file;
678 
679     lzma_vli compressed_file_offset;
680 
681     lzma_vli uncompressed_file_offset;
682 
683     lzma_vli number_in_stream;
684 
685     lzma_vli compressed_stream_offset;
686 
687     lzma_vli uncompressed_stream_offset;
688 
689     lzma_vli uncompressed_size;
690 
691     lzma_vli unpadded_size;
692 
693     lzma_vli total_size;
694 
695     lzma_vli reserved_vli1;
696     lzma_vli reserved_vli2;
697     lzma_vli reserved_vli3;
698     lzma_vli reserved_vli4;
699 
700     const void* reserved_ptr1;
701     const void* reserved_ptr2;
702     const void* reserved_ptr3;
703     const void* reserved_ptr4;
704 }
705 
706 union lzma_index_iter_internal
707 {
708     const void* p;
709     size_t s;
710     lzma_vli v;
711 }
712 
713 struct lzma_index_iter
714 {
715     lzma_index_iter_stream stream;
716     lzma_index_iter_block block;
717     lzma_index_iter_internal[6] internal;
718 }
719 
720 enum lzma_index_iter_mode
721 {
722     LZMA_INDEX_ITER_ANY = 0,
723 
724     LZMA_INDEX_ITER_STREAM = 1,
725 
726     LZMA_INDEX_ITER_BLOCK = 2,
727 
728     LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3
729 }
730 
731 extern (C) uint64_t lzma_index_memusage(
732     lzma_vli streams, lzma_vli blocks) nothrow;
733 
734 extern (C) uint64_t lzma_index_memused(const lzma_index* i)
735 nothrow;
736 
737 extern (C) lzma_index* lzma_index_init(const lzma_allocator* allocator)
738 nothrow;
739 
740 extern (C) void lzma_index_end(
741     lzma_index* i, const lzma_allocator* allocator) nothrow;
742 
743 extern (C) lzma_ret lzma_index_append(
744     lzma_index* i, const lzma_allocator* allocator,
745     lzma_vli unpadded_size, lzma_vli uncompressed_size)
746 nothrow;
747 
748 extern (C) lzma_ret lzma_index_stream_flags(
749     lzma_index* i, const lzma_stream_flags* stream_flags)
750 nothrow;
751 
752 extern (C) uint32_t lzma_index_checks(const lzma_index* i)
753 nothrow pure;
754 
755 extern (C) lzma_ret lzma_index_stream_padding(
756     lzma_index* i, lzma_vli stream_padding)
757 nothrow;
758 
759 extern (C) lzma_vli lzma_index_stream_count(const lzma_index* i)
760 nothrow pure;
761 
762 extern (C) lzma_vli lzma_index_block_count(const lzma_index* i)
763 nothrow pure;
764 
765 extern (C) lzma_vli lzma_index_size(const lzma_index* i)
766 nothrow pure;
767 
768 extern (C) lzma_vli lzma_index_stream_size(const lzma_index* i)
769 nothrow pure;
770 
771 extern (C) lzma_vli lzma_index_total_size(const lzma_index* i)
772 nothrow pure;
773 
774 extern (C) lzma_vli lzma_index_file_size(const lzma_index* i)
775 nothrow pure;
776 
777 extern (C) lzma_vli lzma_index_uncompressed_size(const lzma_index* i)
778 nothrow pure;
779 
780 extern (C) void lzma_index_iter_init(
781     lzma_index_iter* iter, const lzma_index* i) nothrow;
782 
783 extern (C) void lzma_index_iter_rewind(lzma_index_iter* iter)
784 nothrow;
785 
786 extern (C) lzma_bool lzma_index_iter_next(
787     lzma_index_iter* iter, lzma_index_iter_mode mode)
788 nothrow;
789 
790 extern (C) lzma_bool lzma_index_iter_locate(
791     lzma_index_iter* iter, lzma_vli target) nothrow;
792 
793 extern (C) lzma_ret lzma_index_cat(lzma_index* dest, lzma_index* src,
794     const lzma_allocator* allocator)
795 nothrow;
796 
797 extern (C) lzma_index* lzma_index_dup(
798     const lzma_index* i, const lzma_allocator* allocator)
799 nothrow;
800 
801 extern (C) lzma_ret lzma_index_encoder(
802     lzma_stream* strm, const lzma_index* i)
803 nothrow;
804 
805 extern (C) lzma_ret lzma_index_decoder(
806     lzma_stream* strm, lzma_index** i, uint64_t memlimit)
807 nothrow;
808 
809 extern (C) lzma_ret lzma_index_buffer_encode(const lzma_index* i,
810     uint8_t* out_, size_t* out_pos, size_t out_size) nothrow;
811 
812 extern (C) lzma_ret lzma_index_buffer_decode(lzma_index** i,
813     uint64_t* memlimit, const lzma_allocator* allocator,
814     const uint8_t* in_, size_t* in_pos, size_t in_size)
815 nothrow;
816 
817 // lzma/index_hash.h
818 
819 struct lzma_index_hash;
820 
821 extern (C) lzma_index_hash* lzma_index_hash_init(
822     lzma_index_hash* index_hash, const lzma_allocator* allocator)
823 nothrow;
824 
825 extern (C) void lzma_index_hash_end(
826     lzma_index_hash* index_hash, const lzma_allocator* allocator)
827 nothrow;
828 
829 extern (C) lzma_ret lzma_index_hash_append(lzma_index_hash* index_hash,
830     lzma_vli unpadded_size, lzma_vli uncompressed_size)
831 nothrow;
832 
833 extern (C) lzma_ret lzma_index_hash_decode(lzma_index_hash* index_hash,
834     const uint8_t* in_, size_t* in_pos, size_t in_size)
835 nothrow;
836 
837 extern (C) lzma_vli lzma_index_hash_size(
838     const lzma_index_hash* index_hash)
839 nothrow pure;
840 
841 // lzma/hardware.h
842 
843 extern (C) uint64_t lzma_physmem() nothrow;
844 
845 extern (C) uint32_t lzma_cputhreads() nothrow;