/*
* decomp.c
*
- * Functions too long to declare as inline in decomp.h.
- *
+ * Functions used for decompression.
+ */
+
+/*
* Copyright (C) 2012 Eric Biggers
*
- * wimlib - Library for working with WIM files
+ * This file is part of wimlib, a library for working with WIM files.
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option) any
- * later version.
+ * wimlib is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
*
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
*
- * You should have received a copy of the GNU Lesser General Public License along
- * with this library; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wimlib; if not, see http://www.gnu.org/licenses/.
*/
#include "decomp.h"
/* Get the rest directly from the pointer to the data. Of course, it's
* necessary to check there are really n bytes available. */
if (n > stream->data_bytes_left) {
- ERROR("Unexpected end of input when "
- "reading %zu bytes from bitstream "
- "(only have %u bytes left)\n", n,
- stream->data_bytes_left);
+ ERROR("Unexpected end of input when reading %zu bytes from "
+ "bitstream (only have %u bytes left)",
+ n, stream->data_bytes_left);
return 1;
}
memcpy(p, stream->data, n);
ret = bitstream_ensure_bits(stream, 16);
if (ret != 0) {
ERROR("Unexpected end of input when "
- "aligning bitstream!\n");
+ "aligning bitstream");
return ret;
}
}
* tree. */
if (decode_table_pos >= table_num_entries) {
ERROR("Huffman decoding table overrun: "
- "pos = %u, num_entries = %u\n",
- decode_table_pos,
- table_num_entries);
+ "pos = %u, num_entries = %u",
+ decode_table_pos, table_num_entries);
return 1;
}
uint i = current_code >> (code_len - num_bits);
if (i >= (1 << num_bits)) {
- ERROR("Invalid canonical Huffman code!\n");
+ ERROR("Invalid canonical Huffman code");
return 1;
}
for (uint i = 0; i < num_syms; i++) {
if (lens[i] != 0) {
- ERROR("Lengths do not form a valid "
- "canonical Huffman tree "
- "(only filled %u of %u decode "
- "table slots)!\n", decode_table_pos,
- table_num_entries);
+ ERROR("Lengths do not form a valid canonical "
+ "Huffman tree (only filled %u of %u "
+ "decode table slots)",
+ decode_table_pos, table_num_entries);
return 1;
}
}
bitstream_remove_bits(istream, key_size);
do {
if (bitsleft == 0) {
- ERROR("Input stream exhausted!\n");
+ ERROR("Input stream exhausted");
return 1;
}
key_bits = sym + bitstream_peek_bits(istream, 1);