1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
/*
Copyright 1990-2008 Light Infocon Tecnologia S/A
Este arquivo é parte do programa LightBase - Banco de Dados Textual Documental
O LightBase é um software livre; você pode redistribui-lo e/ou modifica-lo dentro
dos termos da Licença Pública Geral GNU como publicada pela Fundação do Software
Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO
EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU versao 2, sob o
título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do
Software Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// void * ALCompressedObject::operator new( size_t size )
//
// ARGUMENTS:
//
// size : The number of bytes needed to create a new ALCompressedObject
// object.
//
// RETURNS
//
// A pointer to the newly allocated storage area, or 0 if no storage
// was available.
//
// DESCRIPTION
//
// When using a DLL, it is easy to get into a dangerous situation when
// creating objects whose ctor and dtor are both in the DLL. The problem
// arises because when you create an object using new, the memory for
// the object will be allocated from the EXE. However, when you destroy
// the object using delete, the memory is freed inside the DLL. Since
// the DLL doesn't really own that memory, bad things can happen.
//
// But, you say, won't the space just go back to the Windows heap regardless
// of who tries to free it? Maybe, but maybe not. If the DLL is using
// a subsegment allocation scheme, it might do some sort of local free
// before returning the space to the windows heap. That is the point where
// you could conceivably cook your heap.
//
// By providing our own version of operator new inside this class, we
// ensure that all memory allocation for the class will be done from
// inside the DLL, not the EXE calling the DLL.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
void AL_DLL_FAR * AL_PROTO ALCompressedObject::operator new
//
// ALCompressedObject::
// ALCompressedObject( ALStorage AL_DLL_FAR & storage_object,
// ALCompressionEngine AL_DLL_FAR & compression_engine )
//
// ARGUMENTS:
//
// storage_object : A reference to the storage object that is going
// to get the compressed data.
//
// compression_engine : A reference to the compression engine that will
// be used to insert an object or extract an object.
//
// RETURNS
//
// A constructor, you don't get a return.
//
// DESCRIPTION
//
// A compressed object is a storage object that gets a single compressed
// object packed into it. You get to call Insert() or Extract(), to
// put the object in or take it out. Compressed objects don't get all
// the fancy options that Archives do. For example, you have to know in
// advance what sort of compression engine and storage object you are
// going to use to put things in and take things out. You don't get to
// store comments or time date stamps, or anything like that.
//
// The one piece of flexibility you do get the ALCompressedObject is
// the ability to derive a new class from this base, then use the
// new class to write some custom data out to the object.
//
// This constructor stores references to the object being used to hold the
// compressed data, and the engine being used to pack and unpack it.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
AL_PROTO
//
// ALCompressedObject::~ALCompressedObject()
//
// ARGUMENTS:
//
// None, destructor.
//
// RETURNS
//
// None, destructor.
//
// DESCRIPTION
//
// This destructor has nothing important to do. The debug version
// checks the object type for validity, but that's it.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
AL_PROTO ALCompressedObject::~
//
// int ALCompressedObject::Insert( ALStorage &input_object )
//
// ARGUMENTS:
//
// input_object : A storage object that is going to be inserted into
// the compressed object.
//
// RETURNS
//
// AL_SUCCESS if everything worked properly, or < AL_SUCCESS if an
// error was encountered.
//
// DESCRIPTION
//
// The compressed object has this format:
//
// long uncompressed_size
// long compressed_size
// DWORD crc_32
// Any data from derived classes
// unsigned char data[]
//
// Writing all this out is pretty straightforward, although you might
// note that it is going to require at least one seek() back to the
// start of the compressed object after the compression is done.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
// August 10, 1994 1.0B : Modified the call to WriteHeaderData so that
// passes a pointer to the input storage object.
// This would allow me, for example, to figure
// out that that input file was DATA.TXT, and
// store that file name so it can be recovered
// upon extraction.
int AL_PROTO
//
// int ALCompressedObject::Extract( ALStorage &output_object )
//
// ARGUMENTS:
//
// output_object : The storage object that is going to receive the
// extracted data from the compressed object.
//
// RETURNS
//
// AL_SUCCESS, or < AL_SUCCESS if an error occurs.
//
// DESCRIPTION
//
// Extracting the data to a new storage object is easy. We read in
// all the data so that we can do a little error checking along the
// way, but that's all.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
// July 13, 1994 1.0B : Rearranged things so that the output file didn't
// get opened until *after* ReadHeaderData was called.
// Also added a pointer to the output storage object
// in the call to ReadHeaderData. That way, if I
// stored the original file name in the header data,
// I could use it to restore the original name in
// the output object.
//
int AL_PROTO
//
// int ALCompressedObject::WriteHeaderData( ALStorage * storage = 0 )
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// AL_SUCCESS, always.
//
// DESCRIPTION
//
// Derived classes can override this function and use it to add
// additional data bytes to the header of a compressed object. Note
// that this data does not have to be written out in any particular
// format, we have no portability concerns here. It is up to the
// derived class to insure that the data is written in an internally
// consistent format so that ReadHeaderData() can always position the
// file pointer to the correct start of data.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
// July 13, 1994 1.0B : Added the pointer to the storage object that
// is in the process of being compressed. This
// helps if you want to store information about the
// file being compressed.
//
int AL_PROTO
//
// int ALCompressedObject::ReadHeaderData( ALStorage AL_DLL_FAR * = 0 )
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// AL_SUCCESS, always.
//
// DESCRIPTION
//
// Derived classes can override this function and use it to read
// additional data bytes from the header of a compressed object. Note
// that this data does not have to be written out in any particular
// format, we have no portability concerns here. It is up to the
// derived class to insure that the data is written in an internally
// consistent format so that ReadHeaderData() can always position the
// file pointer to the correct start of data.
//
// REVISION HISTORY
//
// May 23, 1994 1.0A : First release
//
// July 13, 1994 1.0B : Added the pointer to the storage object that
// is in the process of being decompressed. This
// helps if you want to read information about the
// file before starting the expansion.
//
int AL_PROTO