]> wimlib.net Git - wimlib/blobdiff - include/wimlib/decompress.h
Refactor headers
[wimlib] / include / wimlib / decompress.h
similarity index 87%
rename from src/decompress.h
rename to include/wimlib/decompress.h
index a2466456f90019ea1189252cb46cfbdd245246b6..c020cbadeb64ea35394fc04bedd3af00b89170b9 100644 (file)
@@ -4,11 +4,13 @@
  * Functions useful for decompression, mainly bitstreams.
  */
 
-#ifndef _WIMLIB_DECOMP_H
-#define _WIMLIB_DECOMP_H
+#ifndef _WIMLIB_DECOMPRESS_H
+#define _WIMLIB_DECOMPRESS_H
 
-#include "util.h"
-#include "endianness.h"
+#include "wimlib/assert.h"
+#include "wimlib/endianness.h"
+#include "wimlib/error.h"
+#include "wimlib/types.h"
 
 /* Must be at least 32 bits. */
 typedef unsigned long input_bitbuf_t;
@@ -36,8 +38,9 @@ struct input_bitstream {
 };
 
 /* Initializes a bitstream to receive its input from @data. */
-static inline void init_input_bitstream(struct input_bitstream *istream,
-                                       const void *data, unsigned num_data_bytes)
+static inline void
+init_input_bitstream(struct input_bitstream *istream,
+                    const void *data, unsigned num_data_bytes)
 {
        istream->bitbuf          = 0;
        istream->bitsleft        = 0;
@@ -50,8 +53,8 @@ static inline void init_input_bitstream(struct input_bitstream *istream,
  *
  * If there are at least @num_bits bits remaining in the bitstream, 0 is
  * returned.  Otherwise, -1 is returned.  */
-static inline int bitstream_ensure_bits(struct input_bitstream *istream,
-                                       unsigned num_bits)
+static inline int
+bitstream_ensure_bits(struct input_bitstream *istream, unsigned num_bits)
 {
        wimlib_assert2(num_bits <= 16);
 
@@ -101,8 +104,8 @@ bitstream_peek_bits(const struct input_bitstream *istream, unsigned num_bits)
 
 /* Removes @num_bits bits from the buffer variable, which must contain at least
  * @num_bits bits, for the bitstream. */
-static inline void bitstream_remove_bits(struct input_bitstream *istream,
-                                        unsigned num_bits)
+static inline void
+bitstream_remove_bits(struct input_bitstream *istream, unsigned num_bits)
 {
        wimlib_assert2(istream->bitsleft >= num_bits);
        istream->bitbuf <<= num_bits;
@@ -112,8 +115,9 @@ static inline void bitstream_remove_bits(struct input_bitstream *istream,
 /* Reads @num_bits bits from the input bitstream.  @num_bits must be 16 or fewer.
  * On success, returns 0 and returns the requested bits in @n.  If there are
  * fewer than @num_bits remaining in the bitstream, -1 is returned. */
-static inline int bitstream_read_bits(struct input_bitstream *istream,
-                                     unsigned num_bits, unsigned *n)
+static inline int
+bitstream_read_bits(struct input_bitstream *istream,
+                   unsigned num_bits, unsigned *n)
 {
        wimlib_assert2(num_bits <= 16);
        int ret = bitstream_ensure_bits(istream, num_bits);
@@ -133,7 +137,8 @@ static inline int bitstream_read_bits(struct input_bitstream *istream,
  *
  * This function returns the next such literal byte, or -1 if there are no more.
  */
-static inline int bitstream_read_byte(struct input_bitstream *istream)
+static inline int
+bitstream_read_byte(struct input_bitstream *istream)
 {
        wimlib_assert2(istream->bitsleft < 32);
        int ret;
@@ -158,12 +163,13 @@ bitstream_read_bits_nocheck(struct input_bitstream *istream, unsigned num_bits)
        return n;
 }
 
-extern int read_huffsym_near_end_of_input(struct input_bitstream *istream,
-                                         const u16 decode_table[],
-                                         const u8 lens[],
-                                         unsigned num_syms,
-                                         unsigned table_bits,
-                                         unsigned *n);
+extern int
+read_huffsym_near_end_of_input(struct input_bitstream *istream,
+                              const u16 decode_table[],
+                              const u8 lens[],
+                              unsigned num_syms,
+                              unsigned table_bits,
+                              unsigned *n);
 
 /*
  * Reads a Huffman-encoded symbol from a bitstream.
@@ -183,13 +189,14 @@ extern int read_huffsym_near_end_of_input(struct input_bitstream *istream,
  *                             directory in the decode_table, as the
  *                             decode_table contains 2**table_bits entries.
  */
-static inline int read_huffsym(struct input_bitstream *istream,
-                              const u16 decode_table[],
-                              const u8 lens[],
-                              unsigned num_syms,
-                              unsigned table_bits,
-                              unsigned *n,
-                              unsigned max_codeword_len)
+static inline int
+read_huffsym(struct input_bitstream *istream,
+            const u16 decode_table[],
+            const u8 lens[],
+            unsigned num_syms,
+            unsigned table_bits,
+            unsigned *n,
+            unsigned max_codeword_len)
 {
        int ret;
 
@@ -234,4 +241,4 @@ extern int make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
                                     unsigned num_bits, const u8 lengths[],
                                     unsigned max_codeword_len);
 
-#endif /* _WIMLIB_DECOMP_H */
+#endif /* _WIMLIB_DECOMPRESS_H */