| 1 | /* |
| 2 | This Software is distributed with the following X11 License, |
| 3 | sometimes also known as MIT license. |
| 4 | |
| 5 | Copyright (c) 2010 Miguel A. Ballicora |
| 6 | |
| 7 | Permission is hereby granted, free of charge, to any person |
| 8 | obtaining a copy of this software and associated documentation |
| 9 | files (the "Software"), to deal in the Software without |
| 10 | restriction, including without limitation the rights to use, |
| 11 | copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | copies of the Software, and to permit persons to whom the |
| 13 | Software is furnished to do so, subject to the following |
| 14 | conditions: |
| 15 | |
| 16 | The above copyright notice and this permission notice shall be |
| 17 | included in all copies or substantial portions of the Software. |
| 18 | |
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 21 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 25 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 26 | OTHER DEALINGS IN THE SOFTWARE. |
| 27 | */ |
| 28 | |
| 29 | /*--------------------------------------------------------------------------*\ |
| 30 | | |
| 31 | | Compressing wrapper functions |
| 32 | | |
| 33 | *---------------------------------------------------------------------------*/ |
| 34 | #define MAXBLOCKcxx . . $ `gtb-dec.c:34:9`! (1 << 16) |
| 35 | |
| 36 | #include <stdlib.h> |
| 37 | #include "gtb-dec.h"cxx . . $ `<file>/gtb-dec.h`/ |
| 38 | #include "hzip.h"cxx . . $ `<file>/compression/huffman/hzip.h`/ |
| 39 | #include "wrap.h"cxx . . $ `<file>/compression/wrap.h`/ |
| 40 | |
| 41 | typedef int bool_tcxx . . $ bool_t#; |
| 42 | |
| 43 | #ifndef TRUE |
| 44 | #define TRUEcxx . . $ `gtb-dec.c:44:9`! 1 |
| 45 | #endif |
| 46 | #ifndef FALSE |
| 47 | #define FALSEcxx . . $ `gtb-dec.c:47:9`! 0; |
| 48 | #endif |
| 49 | |
| 50 | /*static unsigned char intermediate_block[MAXBLOCK] ;*/ |
| 51 | |
| 52 | static int DECODE_SCHEMEcxx . . $ DECODE_SCHEME. = CP4cxx . . $ CP4.; |
| 53 | static int CP_SCHEMEcxx . . $ CP_SCHEME. = CP4cxx . . $ CP4.; |
| 54 | |
| 55 | static int f_decodecxx . . $ f_decode(91b8b4e864c7541e). (size_t z, unsigned char *bz, size_t n, unsigned char *bp); |
| 56 | |
| 57 | extern void |
| 58 | set_decoding_schemecxx . . $ set_decoding_scheme(d4f767463ce0a6b3).(int x) |
| 59 | { |
| 60 | DECODE_SCHEMEcxx . . $ DECODE_SCHEME. = x; |
| 61 | CP_SCHEMEcxx . . $ CP_SCHEME. = x; |
| 62 | } |
| 63 | |
| 64 | extern int decoding_schemecxx . . $ decoding_scheme(b126dc7c1de90089).(void) |
| 65 | { |
| 66 | return DECODE_SCHEMEcxx . . $ DECODE_SCHEME.; |
| 67 | } |
| 68 | |
| 69 | extern int |
| 70 | decodecxx . . $ decode(91b8b4e864c7541e). (size_t z, unsigned char *bz, size_t n, unsigned char *bp) |
| 71 | { |
| 72 | return f_decodecxx . . $ f_decode(91b8b4e864c7541e). (z, bz, n, bp); |
| 73 | } |
| 74 | |
| 75 | /*======================== WRAPPERS ========================*/ |
| 76 | |
| 77 | static int |
| 78 | f_decodecxx . . $ f_decode(91b8b4e864c7541e). (size_t z, unsigned char *bz, size_t n, unsigned char *bp) |
| 79 | { |
| 80 | /* bp buffer provided |
| 81 | | bz buffer "zipped", compressed |
| 82 | | n len of buffer provided |
| 83 | | z len of buffer zipped |
| 84 | \*---------------------------------------------------------------*/ |
| 85 | |
| 86 | /* |
| 87 | unsigned char *ib = intermediate_block; |
| 88 | unsigned int m; |
| 89 | return huff_decode (bz, z, ib, &m, MAXBLOCK) && rle_decode (ib, m, bp, &n, MAXBLOCK); |
| 90 | */ |
| 91 | |
| 92 | if (CP_SCHEMEcxx . . $ CP_SCHEME. == CP1cxx . . $ CP1.) { |
| 93 | |
| 94 | /* HUFFMAN */ |
| 95 | return huff_decodecxx . . $ huff_decode(8df7f9bf94206c40). (bz, z, bp, &n, MAXBLOCKcxx . . $ `gtb-dec.c:34:9`!); |
| 96 | |
| 97 | } else if (CP_SCHEMEcxx . . $ CP_SCHEME. == CP2cxx . . $ CP2.) { |
| 98 | |
| 99 | /* LZF */ |
| 100 | return lzf_decodecxx . . $ lzf_decode(8df7f9bf94206c40). (bz, z, bp, &n, MAXBLOCKcxx . . $ `gtb-dec.c:34:9`!); |
| 101 | |
| 102 | } else if (CP_SCHEMEcxx . . $ CP_SCHEME. == CP3cxx . . $ CP3.) { |
| 103 | |
| 104 | /* ZLIB */ |
| 105 | return zlib_decodecxx . . $ zlib_decode(8df7f9bf94206c40). (bz, z, bp, &n, MAXBLOCKcxx . . $ `gtb-dec.c:34:9`!); |
| 106 | |
| 107 | } else if (CP_SCHEMEcxx . . $ CP_SCHEME. == CP4cxx . . $ CP4.) { |
| 108 | |
| 109 | /* LZMA86 */ |
| 110 | return lzma_decodecxx . . $ lzma_decode(8df7f9bf94206c40). (bz, z, bp, &n, n); /* maximum needs to be the exact number that it will produce */ |
| 111 | |
| 112 | } else if (CP_SCHEMEcxx . . $ CP_SCHEME. == CP7cxx . . $ CP7.) { |
| 113 | |
| 114 | /* RLE */ |
| 115 | return rle_decodecxx . . $ rle_decode(8df7f9bf94206c40). (bz, z, bp, &n, MAXBLOCKcxx . . $ `gtb-dec.c:34:9`!); |
| 116 | |
| 117 | #if defined (LIBBZIP2) |
| 118 | } else if (CP_SCHEME == CP8) { |
| 119 | |
| 120 | /* BZIP2 */ |
| 121 | return bzip2_decode (bz, z, bp, &n, MAXBLOCK); |
| 122 | #endif |
| 123 | |
| 124 | } else if (CP_SCHEMEcxx . . $ CP_SCHEME. == CP9cxx . . $ CP9.) { |
| 125 | |
| 126 | return justcopy_decodecxx . . $ justcopy_decode(8df7f9bf94206c40). (bz, z, bp, &n, MAXBLOCKcxx . . $ `gtb-dec.c:34:9`!); |
| 127 | |
| 128 | } else { |
| 129 | |
| 130 | return FALSEcxx . . $ `gtb-dec.c:47:9`!; |
| 131 | } |
| 132 | } |
| 133 |