Debian Codegraph @

Source/7zip/LZMADecode.h

raw
1 /*
2 * LZMADecode.c
3 *
4 * This file is a part of LZMA compression module for NSIS.
5 *
6 * Original LZMA SDK Copyright (C) 1999-2006 Igor Pavlov
7 * Modifications Copyright (C) 2003-2026 Amir Szekely <[email protected]>
8 *
9 * Licensed under the Common Public License version 1.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 *
12 * Licence details can be found in the file COPYING.
13 *
14 * This software is provided 'as-is', without any express or implied
15 * warranty.
16 *
17 * Reviewed for Unicode support by Jim Park -- 08/24/2007
18 */
19
20 #ifndef __LZMADECODE_H
21 #define __LZMADECODE_H
22
23 /***********************
24 * Configuration *
25 ***********************/
26
27 #include "../Platform.h"
28
29 /* #define _LZMA_PROB32 */
30 /* It can increase speed on some 32-bit CPUs,
31 but memory usage will be doubled in that case */
32
33 #ifdef _WIN32
34 # define lzmaalloc(bytes) GlobalAlloc(GPTR,bytes)
35 # define lzmafree GlobalFree
36 #endif
37
38 /***********************
39 * Configuration End *
40 ***********************/
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #ifndef lzmaalloc
47 #define lzmaalloc malloc
48 #endif
49
50 #ifndef lzmafree
51 #define lzmafree free
52 #endif
53
54 #ifndef LZMACALL
55 # define LZMACALL
56 #endif
57
58 #ifndef UInt32
59 #ifdef _LZMA_UINT32_IS_ULONG
60 #define UInt32 unsigned long
61 #else
62 #define UInt32 unsigned int
63 #endif
64 #endif
65
66 #ifdef _LZMA_PROB32
67 #define CProb UInt32
68 #else
69 #define CProb unsigned short
70 #endif
71
72 typedef unsigned char Byte;
73
74 #define LZMA_STREAM_END 1
75 #define LZMA_OK 0
76 #define LZMA_DATA_ERROR -1
77 /* we don't really care what the problem is... */
78 /* #define LZMA_RESULT_NOT_ENOUGH_MEM -2 */
79 #define LZMA_NOT_ENOUGH_MEM -1
80
81 typedef struct
82 {
83 /* mode control */
84 int mode;
85 int last;
86 int last2;
87 int last3;
88
89 /* properties */
90 UInt32 dynamicDataSize;
91 UInt32 dictionarySize;
92
93 /* io */
94 Byte *next_in; /* next input byte */
95 UInt32 avail_in; /* number of bytes available at next_in */
96
97 Byte *next_out; /* next output byte should be put there */
98 UInt32 avail_out; /* remaining free space at next_out */
99
100 UInt32 totalOut; /* total output - not always correct when lzmaDecode returns */
101
102 /* saved state */
103 Byte previousByte;
104 Byte matchByte;
105 CProb *probs;
106 CProb *prob;
107 int mi;
108 int posState;
109 int temp1;
110 int temp2;
111 int temp3;
112 int lc;
113 int state;
114 int isPreviousMatch;
115 int len;
116 UInt32 rep0;
117 UInt32 rep1;
118 UInt32 rep2;
119 UInt32 rep3;
120 UInt32 posStateMask;
121 UInt32 literalPosMask;
122 UInt32 dictionaryPos;
123
124 /* range coder */
125 UInt32 range;
126 UInt32 code;
127
128 /* allocated buffers */
129 Byte *dictionary;
130 Byte *dynamicData;
131 } lzma_stream;
132
133 void LZMACALL lzmaInit(lzma_stream *);
134 int LZMACALL lzmaDecode(lzma_stream *);
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif