#include <stdlib.h>
#include <string.h>
-static inline void flush_bits(struct output_bitstream *ostream)
+static inline void
+flush_bits(struct output_bitstream *ostream)
{
*(u16*)ostream->bit_output = cpu_to_le16(ostream->bitbuf);
ostream->bit_output = ostream->next_bit_output;
/* Writes @num_bits bits, given by the @num_bits least significant bits of
* @bits, to the output @ostream. */
-int bitstream_put_bits(struct output_bitstream *ostream, output_bitbuf_t bits,
- unsigned num_bits)
+int
+bitstream_put_bits(struct output_bitstream *ostream, output_bitbuf_t bits,
+ unsigned num_bits)
{
unsigned rem_bits;
}
/* Flushes any remaining bits in the output buffer to the output byte stream. */
-int flush_output_bitstream(struct output_bitstream *ostream)
+int
+flush_output_bitstream(struct output_bitstream *ostream)
{
if (ostream->num_bytes_remaining + (ostream->output -
ostream->bit_output) < 2)
/* Initializes an output bit buffer to write its output to the memory location
* pointer to by @data. */
-void init_output_bitstream(struct output_bitstream *ostream, void *data,
- unsigned num_bytes)
+void
+init_output_bitstream(struct output_bitstream *ostream, void *data,
+ unsigned num_bytes)
{
wimlib_assert(num_bytes >= 4);
/* Comparator function for HuffmanLeafNodes. Sorts primarily by symbol
* frequency and secondarily by symbol value. */
-static int cmp_leaves_by_freq(const void *__leaf1, const void *__leaf2)
+static int
+cmp_leaves_by_freq(const void *__leaf1, const void *__leaf2)
{
const HuffmanLeafNode *leaf1 = __leaf1;
const HuffmanLeafNode *leaf2 = __leaf2;
/* Comparator function for HuffmanLeafNodes. Sorts primarily by code length and
* secondarily by symbol value. */
-static int cmp_leaves_by_code_len(const void *__leaf1, const void *__leaf2)
+static int
+cmp_leaves_by_code_len(const void *__leaf1, const void *__leaf2)
{
const HuffmanLeafNode *leaf1 = __leaf1;
const HuffmanLeafNode *leaf2 = __leaf2;
/* Recursive function to calculate the depth of the leaves in a Huffman tree.
* */
-static void huffman_tree_compute_path_lengths(HuffmanNode *node, u16 cur_len)
+static void
+huffman_tree_compute_path_lengths(HuffmanNode *node, u16 cur_len)
{
if (node->sym == (u16)(-1)) {
/* Intermediate node. */
* lens[i] bits of codewords[i] will contain the codeword
* for symbol i.
*/
-void make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len,
- const freq_t freq_tab[], u8 lens[],
- u16 codewords[])
+void
+make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len,
+ const freq_t freq_tab[], u8 lens[],
+ u16 codewords[])
{
/* We require at least 2 possible symbols in the alphabet to produce a
* valid Huffman decoding table. It is allowed that fewer than 2 symbols
* indices into the decoding table, and symbol entries are distinguished from
* pointers by the fact that values less than @num_syms must be symbol values.
*/
-int make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
- unsigned table_bits, const u8 lens[],
- unsigned max_codeword_len)
+int
+make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
+ unsigned table_bits, const u8 lens[],
+ unsigned max_codeword_len)
{
unsigned len_counts[max_codeword_len + 1];
u16 sorted_syms[num_syms];
/* Reads a Huffman-encoded symbol from the bistream when the number of remaining
* bits is less than the maximum codeword length. */
-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)
+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)
{
unsigned bitsleft = istream->bitsleft;
unsigned key_size;
}
/* Frees an inode. */
-void free_inode(struct wim_inode *inode)
+void
+free_inode(struct wim_inode *inode)
{
if (inode) {
if (inode->i_ads_entries) {
/* Decrements link count on an inode and frees it if the link count reaches 0.
* */
-static void put_inode(struct wim_inode *inode)
+static void
+put_inode(struct wim_inode *inode)
{
wimlib_assert(inode->i_nlink != 0);
if (--inode->i_nlink == 0) {
* The corresponding inode (if any) is freed only if its link count is
* decremented to 0.
*/
-void free_dentry(struct wim_dentry *dentry)
+void
+free_dentry(struct wim_dentry *dentry)
{
FREE(dentry->file_name);
FREE(dentry->short_name);
FREE(dentry);
}
-void put_dentry(struct wim_dentry *dentry)
+void
+put_dentry(struct wim_dentry *dentry)
{
wimlib_assert(dentry->refcnt != 0);
if (--dentry->refcnt == 0)
/* This function is passed as an argument to for_dentry_in_tree_depth() in order
* to free a directory tree. */
-static int do_free_dentry(struct wim_dentry *dentry, void *__lookup_table)
+static int
+do_free_dentry(struct wim_dentry *dentry, void *__lookup_table)
{
struct wim_lookup_table *lookup_table = __lookup_table;
unsigned i;
* table entries corresponding to the dentries will be
* decremented.
*/
-void free_dentry_tree(struct wim_dentry *root, struct wim_lookup_table *lookup_table)
+void
+free_dentry_tree(struct wim_dentry *root, struct wim_lookup_table *lookup_table)
{
if (root)
for_dentry_in_tree_depth(root, do_free_dentry, lookup_table);
}
-int increment_dentry_refcnt(struct wim_dentry *dentry, void *ignore)
+int
+increment_dentry_refcnt(struct wim_dentry *dentry, void *ignore)
{
dentry->refcnt++;
return 0;
/* Watch out for conflicts with ntfs-3g headers... */
#ifndef bswap16
-static inline uint16_t bswap16(uint16_t n)
+static inline uint16_t
+bswap16(uint16_t n)
{
return (n << 8) | (n >> 8);
}
#endif /* ifndef bswap16 */
#ifndef bswap32
-static inline uint32_t bswap32(uint32_t n)
+static inline uint32_t
+bswap32(uint32_t n)
{
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
return __builtin_bswap32(n);
#endif /* ifndef bswap32 */
#ifndef bswap64
-static inline uint64_t bswap64(uint64_t n)
+static inline uint64_t
+bswap64(uint64_t n)
{
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
return __builtin_bswap64(n);
# endif
#endif
-static inline void array_cpu_to_le32(uint32_t *p, size_t n)
+static inline void
+array_cpu_to_le32(uint32_t *p, size_t n)
{
for (size_t i = 0; i < n; i++)
p[i] = cpu_to_le32(p[i]);
}
-static inline void array_le32_to_cpu(uint32_t *p, size_t n)
+static inline void
+array_le32_to_cpu(uint32_t *p, size_t n)
{
for (size_t i = 0; i < n; i++)
p[i] = le32_to_cpu(p[i]);
}
-static inline void array_cpu_to_le64(uint64_t *p, size_t n)
+static inline void
+array_cpu_to_le64(uint64_t *p, size_t n)
{
for (size_t i = 0; i < n; i++)
p[i] = cpu_to_le64(p[i]);
}
-static inline void array_le64_to_cpu(uint64_t *p, size_t n)
+static inline void
+array_le64_to_cpu(uint64_t *p, size_t n)
{
for (size_t i = 0; i < n; i++)
p[i] = le64_to_cpu(p[i]);
* numbers in the lzx_position_base array to calculate the slot directly from
* the formatted offset without actually looking at the array.
*/
-static inline unsigned lzx_get_position_slot(unsigned formatted_offset)
+static inline unsigned
+lzx_get_position_slot(unsigned formatted_offset)
{
#if 0
/*
}
}
-static u32 lzx_record_literal(u8 literal, void *__main_freq_tab)
+static u32
+lzx_record_literal(u8 literal, void *__main_freq_tab)
{
freq_t *main_freq_tab = __main_freq_tab;
main_freq_tab[literal]++;
* the frequency of symbols in the main, length, and aligned offset alphabets.
* The return value is a 32-bit number that provides the match in an
* intermediate representation documented below. */
-static u32 lzx_record_match(unsigned match_offset, unsigned match_len,
- void *__freq_tabs, void *__queue)
+static u32
+lzx_record_match(unsigned match_offset, unsigned match_len,
+ void *__freq_tabs, void *__queue)
{
struct lzx_freq_tables *freq_tabs = __freq_tabs;
struct lru_queue *queue = __queue;
* @codes: Pointer to a structure that contains the codewords for the
* main, length, and aligned offset Huffman codes.
*/
-static int lzx_write_match(struct output_bitstream *out, int block_type,
- u32 match, const struct lzx_codes *codes)
+static int
+lzx_write_match(struct output_bitstream *out, int block_type,
+ u32 match, const struct lzx_codes *codes)
{
/* low 8 bits are the match length minus 2 */
unsigned match_len_minus_2 = match & 0xff;
* @codes: Pointer to a structure that contains the codewords for the
* main, length, and aligned offset Huffman codes.
*/
-static int lzx_write_compressed_literals(struct output_bitstream *ostream,
- int block_type,
- const u32 match_tab[],
- unsigned num_compressed_literals,
- const struct lzx_codes *codes)
+static int
+lzx_write_compressed_literals(struct output_bitstream *ostream,
+ int block_type,
+ const u32 match_tab[],
+ unsigned num_compressed_literals,
+ const struct lzx_codes *codes)
{
unsigned i;
u32 match;
* @lens: The code lengths for the Huffman tree, indexed by symbol.
* @num_symbols: The number of symbols in the code.
*/
-static int lzx_write_compressed_tree(struct output_bitstream *out,
- const u8 lens[], unsigned num_symbols)
+static int
+lzx_write_compressed_tree(struct output_bitstream *out,
+ const u8 lens[], unsigned num_symbols)
{
/* Frequencies of the length symbols, including the RLE symbols (NOT the
* actual lengths themselves). */
/* Builds the canonical Huffman code for the main tree, the length tree, and the
* aligned offset tree. */
-static void lzx_make_huffman_codes(const struct lzx_freq_tables *freq_tabs,
- struct lzx_codes *codes)
+static void
+lzx_make_huffman_codes(const struct lzx_freq_tables *freq_tabs,
+ struct lzx_codes *codes)
{
make_canonical_huffman_code(LZX_MAINTREE_NUM_SYMBOLS,
LZX_MAX_CODEWORD_LEN,
codes->aligned_codewords);
}
-static void do_call_insn_translation(u32 *call_insn_target, int input_pos,
- int32_t file_size)
+static void
+do_call_insn_translation(u32 *call_insn_target, int input_pos,
+ int32_t file_size)
{
int32_t abs_offset;
int32_t rel_offset;
/* This is the reverse of undo_call_insn_preprocessing() in lzx-decompress.c.
* See the comment above that function for more information. */
-static void do_call_insn_preprocessing(u8 uncompressed_data[],
- int uncompressed_data_len)
+static void
+do_call_insn_preprocessing(u8 uncompressed_data[], int uncompressed_data_len)
{
for (int i = 0; i < uncompressed_data_len - 10; i++) {
if (uncompressed_data[i] == 0xe8) {
* not reduce its size, and @compressed_data will not contain the full
* compressed data.
*/
-int lzx_compress(const void *__uncompressed_data, unsigned uncompressed_len,
- void *compressed_data, unsigned *compressed_len_ret)
+int
+lzx_compress(const void *__uncompressed_data, unsigned uncompressed_len,
+ void *compressed_data, unsigned *compressed_len_ret)
{
struct output_bitstream ostream;
u8 uncompressed_data[uncompressed_len + 8];
/*
* Reads a Huffman-encoded symbol using the pre-tree.
*/
-static inline int read_huffsym_using_pretree(struct input_bitstream *istream,
- const u16 pretree_decode_table[],
- const u8 pretree_lens[], unsigned *n)
+static inline int
+read_huffsym_using_pretree(struct input_bitstream *istream,
+ const u16 pretree_decode_table[],
+ const u8 pretree_lens[], unsigned *n)
{
return read_huffsym(istream, pretree_decode_table, pretree_lens,
LZX_PRETREE_NUM_SYMBOLS, LZX_PRETREE_TABLEBITS, n,
}
/* Reads a Huffman-encoded symbol using the main tree. */
-static inline int read_huffsym_using_maintree(struct input_bitstream *istream,
- const struct lzx_tables *tables,
- unsigned *n)
+static inline int
+read_huffsym_using_maintree(struct input_bitstream *istream,
+ const struct lzx_tables *tables,
+ unsigned *n)
{
return read_huffsym(istream, tables->maintree_decode_table,
tables->maintree_lens, LZX_MAINTREE_NUM_SYMBOLS,
}
/* Reads a Huffman-encoded symbol using the length tree. */
-static inline int read_huffsym_using_lentree(struct input_bitstream *istream,
- const struct lzx_tables *tables,
- unsigned *n)
+static inline int
+read_huffsym_using_lentree(struct input_bitstream *istream,
+ const struct lzx_tables *tables,
+ unsigned *n)
{
return read_huffsym(istream, tables->lentree_decode_table,
tables->lentree_lens, LZX_LENTREE_NUM_SYMBOLS,
}
/* Reads a Huffman-encoded symbol using the aligned offset tree. */
-static inline int read_huffsym_using_alignedtree(struct input_bitstream *istream,
- const struct lzx_tables *tables,
- unsigned *n)
+static inline int
+read_huffsym_using_alignedtree(struct input_bitstream *istream,
+ const struct lzx_tables *tables,
+ unsigned *n)
{
return read_huffsym(istream, tables->alignedtree_decode_table,
tables->alignedtree_lens,
* @num_lens: Number of length values to decode and return.
*
*/
-static int lzx_read_code_lens(struct input_bitstream *istream, u8 lens[],
- unsigned num_lens)
+static int
+lzx_read_code_lens(struct input_bitstream *istream, u8 lens[],
+ unsigned num_lens)
{
/* Declare the decoding table and length table for the pretree. */
u16 pretree_decode_table[(1 << LZX_PRETREE_TABLEBITS) +
* R0, R1, and R2 will be written (only for uncompressed
* blocks, which contain this information in the header)
*/
-static int lzx_read_block_header(struct input_bitstream *istream,
- unsigned *block_size_ret,
- unsigned *block_type_ret,
- struct lzx_tables *tables,
- struct lru_queue *queue)
+static int
+lzx_read_block_header(struct input_bitstream *istream,
+ unsigned *block_size_ret,
+ unsigned *block_type_ret,
+ struct lzx_tables *tables,
+ struct lru_queue *queue)
{
int ret;
unsigned block_type;
* - Match refers to data before the window.
* - The input bitstream ended unexpectedly.
*/
-static int lzx_decode_match(unsigned main_element, int block_type,
- unsigned bytes_remaining, u8 *window,
- unsigned window_pos,
- const struct lzx_tables *tables,
- struct lru_queue *queue,
- struct input_bitstream *istream)
+static int
+lzx_decode_match(unsigned main_element, int block_type,
+ unsigned bytes_remaining, u8 *window,
+ unsigned window_pos,
+ const struct lzx_tables *tables,
+ struct lru_queue *queue,
+ struct input_bitstream *istream)
{
unsigned length_header;
unsigned position_slot;
return match_len;
}
-static void undo_call_insn_translation(u32 *call_insn_target, int input_pos,
- int32_t file_size)
+static void
+undo_call_insn_translation(u32 *call_insn_target, int input_pos,
+ int32_t file_size)
{
int32_t abs_offset;
int32_t rel_offset;
* Call instruction processing is supposed to take the file size as a parameter,
* as it is used in calculating the translated jump targets. But in WIM files,
* this file size is always the same (LZX_WIM_MAGIC_FILESIZE == 12000000).*/
-static void undo_call_insn_preprocessing(u8 uncompressed_data[],
- int uncompressed_data_len)
+static void
+undo_call_insn_preprocessing(u8 uncompressed_data[], int uncompressed_data_len)
{
for (int i = 0; i < uncompressed_data_len - 10; i++) {
if (uncompressed_data[i] == 0xe8) {
* @queue: The least-recently-used queue for match offsets.
* @istream: The input bitstream for the compressed literals.
*/
-static int lzx_decompress_block(int block_type, unsigned block_size,
- u8 *window,
- unsigned window_pos,
- const struct lzx_tables *tables,
- struct lru_queue *queue,
- struct input_bitstream *istream)
+static int
+lzx_decompress_block(int block_type, unsigned block_size,
+ u8 *window,
+ unsigned window_pos,
+ const struct lzx_tables *tables,
+ struct lru_queue *queue,
+ struct input_bitstream *istream)
{
unsigned main_element;
unsigned end;
*
* Return 0 on success; non-zero on failure.
*/
-int lzx_decompress(const void *compressed_data, unsigned compressed_len,
- void *uncompressed_data, unsigned uncompressed_len)
+int
+lzx_decompress(const void *compressed_data, unsigned compressed_len,
+ void *uncompressed_data, unsigned uncompressed_len)
{
struct lzx_tables tables;
struct input_bitstream istream;
#include <string.h>
#include <locale.h>
-static int extract_wim_chunk_to_ntfs_attr(const void *buf, size_t len,
- u64 offset, void *arg)
+static int
+extract_wim_chunk_to_ntfs_attr(const void *buf, size_t len,
+ u64 offset, void *arg)
{
ntfs_attr *na = arg;
if (ntfs_attr_pwrite(na, offset, len, buf) == len) {
*
* Returns 0 on success, nonzero on failure.
*/
-static int write_ntfs_data_streams(ntfs_inode *ni, const struct wim_dentry *dentry,
- union wimlib_progress_info *progress_info)
+static int
+write_ntfs_data_streams(ntfs_inode *ni, const struct wim_dentry *dentry,
+ union wimlib_progress_info *progress_info)
{
int ret = 0;
unsigned stream_idx = 0;
* Transfers the reparse data from a WIM inode (which must represent a reparse
* point) to a NTFS inode.
*/
-static int apply_reparse_data(ntfs_inode *ni, const struct wim_dentry *dentry,
- union wimlib_progress_info *progress_info)
+static int
+apply_reparse_data(ntfs_inode *ni, const struct wim_dentry *dentry,
+ union wimlib_progress_info *progress_info)
{
struct wim_lookup_table_entry *lte;
int ret = 0;
*
* @codewords and @lens provide the Huffman code that is being used.
*/
-static int xpress_write_match(struct output_bitstream *ostream, u32 match,
- const u16 codewords[], const u8 lens[])
+static int
+xpress_write_match(struct output_bitstream *ostream, u32 match,
+ const u16 codewords[], const u8 lens[])
{
u32 adjusted_match_len = match & 0xffff;
u32 match_offset = match >> 16;
match_offset ^ (1 << offset_bsr), offset_bsr);
}
-static int xpress_write_compressed_literals(struct output_bitstream *ostream,
- const u32 match_tab[],
- unsigned num_matches,
- const u16 codewords[],
- const u8 lens[])
+static int
+xpress_write_compressed_literals(struct output_bitstream *ostream,
+ const u32 match_tab[],
+ unsigned num_matches,
+ const u16 codewords[],
+ const u8 lens[])
{
for (unsigned i = 0; i < num_matches; i++) {
int ret;
lens[XPRESS_END_OF_DATA]);
}
-static u32 xpress_record_literal(u8 literal, void *__freq_tab)
+static u32
+xpress_record_literal(u8 literal, void *__freq_tab)
{
freq_t *freq_tab = __freq_tab;
freq_tab[literal]++;
return literal;
}
-static u32 xpress_record_match(unsigned match_offset, unsigned match_len,
- void *freq_tab, void *ignore)
+static u32
+xpress_record_match(unsigned match_offset, unsigned match_len,
+ void *freq_tab, void *ignore)
{
wimlib_assert(match_len >= XPRESS_MIN_MATCH &&
match_len <= XPRESS_MAX_MATCH);
* not reduce its size, and @compressed_data will not contain the full
* compressed data.
*/
-int xpress_compress(const void *__uncompressed_data, unsigned uncompressed_len,
- void *__compressed_data, unsigned *compressed_len_ret)
+int
+xpress_compress(const void *__uncompressed_data, unsigned uncompressed_len,
+ void *__compressed_data, unsigned *compressed_len_ret)
{
const u8 *uncompressed_data = __uncompressed_data;
u8 *compressed_data = __compressed_data;
*
* Returns the match length, or -1 on error.
*/
-static int xpress_decode_match(unsigned huffsym, unsigned window_pos,
- unsigned window_len, u8 window[],
- struct input_bitstream *istream)
+static int
+xpress_decode_match(unsigned huffsym, unsigned window_pos,
+ unsigned window_len, u8 window[],
+ struct input_bitstream *istream)
{
unsigned match_len;
unsigned match_offset;
/* Decodes the Huffman-encoded matches and literal bytes in a block of
* XPRESS-encoded data. */
-static int xpress_decompress_block(struct input_bitstream *istream,
- u8 uncompressed_data[],
- unsigned uncompressed_len,
- const u8 lens[],
- const u16 decode_table[])
+static int
+xpress_decompress_block(struct input_bitstream *istream,
+ u8 uncompressed_data[],
+ unsigned uncompressed_len,
+ const u8 lens[],
+ const u16 decode_table[])
{
unsigned curpos;
unsigned huffsym;
}
-int xpress_decompress(const void *__compressed_data, unsigned compressed_len,
- void *uncompressed_data, unsigned uncompressed_len)
+int
+xpress_decompress(const void *__compressed_data, unsigned compressed_len,
+ void *uncompressed_data, unsigned uncompressed_len)
{
u8 lens[XPRESS_NUM_SYMBOLS];
u16 decode_table[(1 << XPRESS_TABLEBITS) + 2 * XPRESS_NUM_SYMBOLS];