update for HEAD-2003091401
[reactos.git] / ntoskrnl / rtl / compress.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2002 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$
20  *
21  * COPYRIGHT:         See COPYING in the top level directory
22  * PROJECT:           ReactOS kernel
23  * PURPOSE:           Compression and decompression functions
24  * FILE:              ntoskrnl/rtl/compress.c
25  * PROGRAMER:         Eric Kohl (ekohl@zr-online.de)
26  */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <ddk/ntddk.h>
31
32
33 /* MACROS *******************************************************************/
34
35 #define COMPRESSION_FORMAT_MASK  0x00FF
36 #define COMPRESSION_ENGINE_MASK  0xFF00
37
38
39 /* FUNCTIONS ****************************************************************/
40
41
42 static NTSTATUS
43 RtlpCompressBufferLZNT1(USHORT Engine,
44                         PUCHAR UncompressedBuffer,
45                         ULONG UncompressedBufferSize,
46                         PUCHAR CompressedBuffer,
47                         ULONG CompressedBufferSize,
48                         ULONG UncompressedChunkSize,
49                         PULONG FinalCompressedSize,
50                         PVOID WorkSpace)
51 {
52   return(STATUS_NOT_IMPLEMENTED);
53 }
54
55
56 static NTSTATUS
57 RtlpWorkSpaceSizeLZNT1(USHORT Engine,
58                        PULONG BufferAndWorkSpaceSize,
59                        PULONG FragmentWorkSpaceSize)
60 {
61   if (Engine == COMPRESSION_ENGINE_STANDARD)
62     {
63       *BufferAndWorkSpaceSize = 0x8010;
64       *FragmentWorkSpaceSize = 0x1000;
65       return(STATUS_SUCCESS);
66     }
67   else if (Engine == COMPRESSION_ENGINE_MAXIMUM)
68     {
69       *BufferAndWorkSpaceSize = 0x10;
70       *FragmentWorkSpaceSize = 0x1000;
71       return(STATUS_SUCCESS);
72     }
73
74   return(STATUS_NOT_SUPPORTED);
75 }
76
77
78
79
80 /*
81  * @unimplemented
82  */
83 NTSTATUS STDCALL
84 RtlCompressBuffer(IN USHORT CompressionFormatAndEngine,
85                   IN PUCHAR UncompressedBuffer,
86                   IN ULONG UncompressedBufferSize,
87                   OUT PUCHAR CompressedBuffer,
88                   IN ULONG CompressedBufferSize,
89                   IN ULONG UncompressedChunkSize,
90                   OUT PULONG FinalCompressedSize,
91                   IN PVOID WorkSpace)
92 {
93   USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
94   USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
95
96   if ((Format == COMPRESSION_FORMAT_NONE) ||
97       (Format == COMPRESSION_FORMAT_DEFAULT))
98     return(STATUS_INVALID_PARAMETER);
99
100   if (Format == COMPRESSION_FORMAT_LZNT1)
101     return(RtlpCompressBufferLZNT1(Engine,
102                                    UncompressedBuffer,
103                                    UncompressedBufferSize,
104                                    CompressedBuffer,
105                                    CompressedBufferSize,
106                                    UncompressedChunkSize,
107                                    FinalCompressedSize,
108                                    WorkSpace));
109
110   return(STATUS_UNSUPPORTED_COMPRESSION);
111 }
112
113
114 /*
115  * @unimplemented
116  */
117 NTSTATUS STDCALL
118 RtlCompressChunks(IN PUCHAR UncompressedBuffer,
119                   IN ULONG UncompressedBufferSize,
120                   OUT PUCHAR CompressedBuffer,
121                   IN ULONG CompressedBufferSize,
122                   IN OUT PCOMPRESSED_DATA_INFO CompressedDataInfo,
123                   IN ULONG CompressedDataInfoLength,
124                   IN PVOID WorkSpace)
125 {
126   return(STATUS_NOT_IMPLEMENTED);
127 }
128
129
130 /*
131  * @unimplemented
132  */
133 NTSTATUS STDCALL
134 RtlDecompressBuffer(IN USHORT CompressionFormat,
135                     OUT PUCHAR UncompressedBuffer,
136                     IN ULONG UncompressedBufferSize,
137                     IN PUCHAR CompressedBuffer,
138                     IN ULONG CompressedBufferSize,
139                     OUT PULONG FinalUncompressedSize)
140 {
141   return(STATUS_NOT_IMPLEMENTED);
142 }
143
144
145 /*
146  * @unimplemented
147  */
148 NTSTATUS STDCALL
149 RtlDecompressChunks(OUT PUCHAR UncompressedBuffer,
150                     IN ULONG UncompressedBufferSize,
151                     IN PUCHAR CompressedBuffer,
152                     IN ULONG CompressedBufferSize,
153                     IN PUCHAR CompressedTail,
154                     IN ULONG CompressedTailSize,
155                     IN PCOMPRESSED_DATA_INFO CompressedDataInfo)
156 {
157   return(STATUS_NOT_IMPLEMENTED);
158 }
159
160
161 /*
162  * @unimplemented
163  */
164 NTSTATUS STDCALL
165 RtlDecompressFragment(IN USHORT CompressionFormat,
166                       OUT PUCHAR UncompressedFragment,
167                       IN ULONG UncompressedFragmentSize,
168                       IN PUCHAR CompressedBuffer,
169                       IN ULONG CompressedBufferSize,
170                       IN ULONG FragmentOffset,
171                       OUT PULONG FinalUncompressedSize,
172                       IN PVOID WorkSpace)
173 {
174   return(STATUS_NOT_IMPLEMENTED);
175 }
176
177
178 /*
179  * @unimplemented
180  */
181 NTSTATUS STDCALL
182 RtlDescribeChunk(IN USHORT CompressionFormat,
183                  IN OUT PUCHAR *CompressedBuffer,
184                  IN PUCHAR EndOfCompressedBufferPlus1,
185                  OUT PUCHAR *ChunkBuffer,
186                  OUT PULONG ChunkSize)
187 {
188   return(STATUS_NOT_IMPLEMENTED);
189 }
190
191
192 /*
193  * @unimplemented
194  */
195 NTSTATUS STDCALL
196 RtlGetCompressionWorkSpaceSize(IN USHORT CompressionFormatAndEngine,
197                                OUT PULONG CompressBufferAndWorkSpaceSize,
198                                OUT PULONG CompressFragmentWorkSpaceSize)
199 {
200   USHORT Format = CompressionFormatAndEngine & COMPRESSION_FORMAT_MASK;
201   USHORT Engine = CompressionFormatAndEngine & COMPRESSION_ENGINE_MASK;
202
203   if ((Format == COMPRESSION_FORMAT_NONE) ||
204       (Format == COMPRESSION_FORMAT_DEFAULT))
205     return(STATUS_INVALID_PARAMETER);
206
207   if (Format == COMPRESSION_FORMAT_LZNT1)
208     return(RtlpWorkSpaceSizeLZNT1(Engine,
209                                   CompressBufferAndWorkSpaceSize,
210                                   CompressFragmentWorkSpaceSize));
211
212   return(STATUS_UNSUPPORTED_COMPRESSION);
213 }
214
215
216 /*
217  * @unimplemented
218  */
219 NTSTATUS STDCALL
220 RtlReserveChunk(IN USHORT CompressionFormat,
221                 IN OUT PUCHAR *CompressedBuffer,
222                 IN PUCHAR EndOfCompressedBufferPlus1,
223                 OUT PUCHAR *ChunkBuffer,
224                 IN ULONG ChunkSize)
225 {
226   return(STATUS_NOT_IMPLEMENTED);
227 }
228
229 /* EOF */