Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
lzo.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
17*/
18
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : WWLib *
24 * *
25 * $Archive:: /Commando/Code/wwlib/lzo.cpp $*
26 * *
27 * Author:: Greg Hjelstrom *
28 * *
29 * $Modtime:: 8/24/01 5:07p $*
30 * *
31 * $Revision:: 7 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * LZOCompressor::Compress -- compress a buffer using LZO *
36 * LZOCompressor::Decompress -- decompress a buffer using LZO *
37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
38
39#include "lzo.h"
40#include "mutex.h"
41#include "wwdebug.h"
42#include <stdlib.h>
43
44/*
45** Work Buffer for the LZOCompressor...
46*/
47lzo_byte LZOCompressor::WorkBuffer[LZO1X_MEM_COMPRESS + 1];
48lzo_byte * LZOCompressor::EOWorkBuffer = &(LZOCompressor::WorkBuffer[LZO1X_MEM_COMPRESS + 1]);
49
50static CriticalSectionClass mutex;
51
52#define BUFFER_OVERRUN_TEST_VALUE ((char)0x7d)
53
54
55/***********************************************************************************************
56 * LZOCompressor::Compress -- compress a buffer using LZO *
57 * *
58 * INPUT: *
59 * *
60 * OUTPUT: *
61 * *
62 * WARNINGS: *
63 * *
64 * HISTORY: *
65 * 7/19/99 GTH : Created. *
66 *=============================================================================================*/
68(
69 const lzo_byte * in,
70 lzo_uint in_len,
71 lzo_byte * out,
72 lzo_uint * out_len
73)
74{
76
77#ifdef WWDEBUG
78 // Debugging code to verify that the work buffer is not overrun...
79 *EOWorkBuffer = BUFFER_OVERRUN_TEST_VALUE;
80#endif
81
82 int result = lzo1x_1_compress(in,in_len,out,out_len,WorkBuffer);
83
84#ifdef WWDEBUG
85 WWASSERT(*EOWorkBuffer == BUFFER_OVERRUN_TEST_VALUE);
86#endif
87
88 return result;
89}
90
91
92/***********************************************************************************************
93 * LZOCompressor::Decompress -- decompress a buffer using LZO *
94 * *
95 * INPUT: *
96 * *
97 * OUTPUT: *
98 * *
99 * WARNINGS: *
100 * *
101 * HISTORY: *
102 * 7/19/99 GTH : Created. *
103 *=============================================================================================*/
105(
106 const lzo_byte * in,
107 lzo_uint in_len,
108 lzo_byte * out,
109 lzo_uint * out_len
110)
111{
113
114 return lzo1x_decompress(in,in_len,out,out_len,NULL);
115}
#define NULL
Definition BaseType.h:92
#define WWASSERT
static int Decompress(const lzo_byte *in, lzo_uint in_len, lzo_byte *out, lzo_uint *out_len)
Definition lzo.cpp:105
static int Compress(const lzo_byte *in, lzo_uint in_len, lzo_byte *out, lzo_uint *out_len)
Definition lzo.cpp:68
#define LZO1X_MEM_COMPRESS
Definition lzo1x.h:81
#define BUFFER_OVERRUN_TEST_VALUE
Definition lzo.cpp:52
int lzo1x_1_compress(const lzo_byte *in, lzo_uint in_len, lzo_byte *out, lzo_uint *out_len, lzo_voidp wrkmem)
Definition lzo1x_c.cpp:335
int lzo1x_decompress(const lzo_byte *in, lzo_uint in_len, lzo_byte *out, lzo_uint *out_len, lzo_voidp)
Definition lzo1x_d.cpp:82
#define lzo_byte
Definition lzoconf.h:127
unsigned int lzo_uint
Definition lzoconf.h:99