archivelib-sys 0.2.0

An implementaton(in C++) of the Greenleaf ArchiveLib compression/decompression algorithm
Documentation
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/*
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
*/

#ifndef _ALDEFS_H
#define _ALDEFS_H

/*
 *  The next long set of definitions and tests are all here simply to
 *  determine which compiler we are using, and what sort of target
 *  configuration we are trying to build/use.
 */
#if defined(__BORLANDC__) || defined(__TURBOC__)
#  if defined( __WIN32__ )
#    define AL_FLAT_MODEL

#    define AL_WINDOWS_MEMORY

#  endif
#  if !defined( __BORLANDC__ )
#      define AL_BORLAND __TURBOC__

#  else
#      define AL_BORLAND __BORLANDC__

#  endif
#  if sizeof( void * ) == 4
#    define AL_LARGE_DATA

#  endif
#  if defined( _Windows )
#    define AL_WINDOWS_MEMORY

#    ifdef __DLL__
#      define AL_BUILDING_DLL

#    endif
#    if !defined( __DPMI16__ ) && !defined( __CONSOLE__ )
#      define AL_WINDOWS_GUI

#    endif
#  endif
#elif defined( __SC__ )
#  define AL_SYMANTEC _MSC_VER

#  if defined( __NT__ )
#    define AL_FLAT_MODEL

#    define AL_WINDOWS_MEMORY

#    define AL_WINDOWS_GUI

#  endif
#  if defined( _M_I86HM ) || defined( _M_I86CM ) || defined( _M_I86LM )
#    define AL_LARGE_DATA

#  endif
/*
 * The _WINDOWS and _WINDLL macros are only documented in LIBRARY.TXT
 */
#  ifdef _WINDOWS
#    define AL_WINDOWS_MEMORY

#    define AL_WINDOWS_GUI

#    ifdef _WINDLL
#      define AL_BUILDING_DLL

#      ifndef M_I86LM
         #error All DLLs must be built using Large Model!
#      endif
#    endif
#  endif
#elif defined( _MSC_VER ) && defined( _MSDOS )
#  define AL_MICROSOFT _MSC_VER

#  if defined( _M_I86HM ) || defined( _M_I86CM ) || defined( _M_I86LM )
#    define AL_LARGE_DATA

#  endif
#  if ( AL_MICROSOFT >= 800 )
/*
 * I really don't want MSC to tell me when it is using a precompiled
 * header file.  What is really dumb is that I probably do want it
 * to tell me when it is creating one, but they generate the same
 * warning!
 */
#    pragma warning( disable : 4699 )
/*
 * This error occurs if you have inline functions in a header file and
 * they don't get used in a particular file.  Bogus.
 */
#    pragma warning( disable : 4505 )
/*
 * This warning occurs if you are using assert() macros with NDEBUG and /Ox
 * it is bogus
 */
#    pragma warning( disable : 4705 )
/*
 * This gives a warning for cout << setw( x )
 */
#    pragma warning( disable : 4270 )
/*
 * This is informational, it tells me when a function has been
 * chosen for inlining.
 */
#    pragma warning( disable : 4711 )
/*
 * This is informational, it tells me when a function has been
 * rejected for inlining.  The funny part is that it gives
 * me this message even if I don't select inlining for that
 * particular function???
 */
#    pragma warning( disable : 4710 )
#  else  /*#if ( AL_MICROSOFT >= 800 ) */
/*
 * Microsoft C 7.0 has a major linker problems if a symbol exceeds
 * 64 characters.  Unfortunately, with full decoration, we have
 * a couple of functions that hit that wall.  So I have to redefine
 * a couple of innocuous class names. I am trying to use similar
 * names so that if you hit them in the debugger you will be able
 * to understand what they mean.
 *
 *  #if defined( _WINDLL )
 *     #define ALWindowsMessage ALWinMsg_
 *      #define ALCompressionEngine ALEngine_
 *  #endif  NOTE: Fixing problem with /H64 in BUILD.INI! */
#  endif /*#if ( AL_MICROSOFT >= 800 ) ... #else */
#  ifdef _WINDOWS
#    define AL_WINDOWS_MEMORY

#    define AL_WINDOWS_GUI

#    ifdef _WINDLL
#      define AL_BUILDING_DLL

#      ifndef M_I86LM
         #error All DLLs must be built using Large Model!
#      endif
#    endif
#  endif
#elif defined( _MSC_VER ) && !defined( _MSDOS ) /* Looks like NT */
#  define AL_MICROSOFT _MSC_VER

#  define AL_FLAT_MODEL

#  define AL_LARGE_DATA

#  define AL_WIN32S

#  define AL_WINDOWS_MEMORY

/*
 * See the previous MSC standard section for the meanings of these pragmas.
 */
#  pragma warning( disable : 4699 )
#  pragma warning( disable : 4505 )
#  pragma warning( disable : 4705 )
#  pragma warning( disable : 4270 )
#  pragma warning( disable : 4711 )
#  pragma warning( disable : 4710 )
/*
 * We get this error in Microsoft's header files!
 */
# pragma warning( disable : 4201 )
#  ifdef _WINDOWS
#    define AL_WINDOWS_MEMORY

#    define AL_WINDOWS_GUI

#    ifdef _WINDLL
#      define AL_BUILDING_DLL

#    endif
#  endif
#elif defined( __WATCOMC__ ) && defined( __386__ )
#  define AL_FLAT_MODEL

#  ifdef __WINDOWS__
#    define AL_WINDOWS_MEMORY

#    define AL_WINDOWS_GUI

#  endif
#  if __WATCOMC__ > 950
#    pragma warning 690 9 /*  Warning for AL_ASSERT() at /w3 */
#    pragma warning 549 9 /*  Warning for sizeof() on class */
#  endif
#elif defined( __WATCOMC__ ) && !defined( __386__ )
#  define AL_WATCOM

#  ifdef __WINDOWS__
#    define AL_WINDOWS_MEMORY

#    define AL_WINDOWS_GUI

#    ifdef __SW_ZU
#      define AL_BUILDING_DLL

#      ifndef M_I86LM
         #error All DLLs must be built using Large Model!
#      endif
#    endif
#  endif
#  if defined( _M_I86HM ) || defined( _M_I86CM ) || defined( _M_I86LM )
#    define AL_LARGE_DATA

#  endif
#  pragma warning 549 9 /*  Warning for sizeof() on class */
#elif defined( __IBMC__ ) || defined( __IBMCPP__ )
#  define AL_IBM

#  define AL_OS2

#  define AL_FLAT_MODEL

#elif defined( AL_SUN4 )
#  if !defined( AL_UNIX )
#    define AL_UNIX

#  endif
#  if !defined( AL_GCC ) && !defined( __cplusplus )
#    define AL_KR

#  endif
#else
#endif

#if defined( AL_WINDOWS_MEMORY ) || defined( AL_WINDOWS_GUI ) || defined( AL_WIN32S )
#  define STRICT

#  include <windows.h>
#  ifdef AL_FLAT_MODEL
#    define AL_HUGE

#  else
#    define AL_HUGE _huge

#  endif
#else
#  define WORD unsigned int

#  define DWORD unsigned long

#endif

/*
 * I modified some assumptions here.  I now assume that all 32 bit DOS
 * Extenders are going to use the Win32 memory API.
 */
#if ( defined( AL_WINDOWS_GUI ) || defined( AL_WINDOWS_MEMORY ) ) && defined( AL_FLAT_MODEL )
#  define AL_WIN32S

#endif

#if defined( AL_WINDOWS_GUI ) && defined( AL_WINDOWS_MEMORY ) && \

    !defined( AL_FLAT_MODEL ) && defined( AL_BUILDING_DLL )
#  define AL_VB

#endif

#if defined( AL_BUILDING_DLL )
#if defined( AL_FLAT_MODEL ) && defined( AL_MICROSOFT )
/*
 * This doesn't work in Release 1.01A.  Sorry, no 32 bit DLLs using
 * Microsoft.  The problem is that functions need to be declare with
 * this _declspec() guy, but the declaration goes in a different
 * place in the function signature than the old _export routine
 * went.  I can either modify *every* function, or I can create a
 * DEF file.  I will modify the functions in ArcLib 2.0.
 */
#    define AL_CLASS_TYPE     __declspec( dllexport )

#    define AL_PROTO

#    define AL_DLL_FAR

#    define AL_FUNCTION

#    define AL_CFUNCTION

#  elif defined( AL_FLAT_MODEL )
#    define AL_CLASS_TYPE     _export

#    define AL_PROTO          _export

#    define AL_DLL_FAR

#    define AL_FUNCTION       _export pascal

#    define AL_CFUNCTION      _export cdecl

#  elif defined( AL_WATCOM )
#    define AL_CLASS_TYPE

#    define AL_PROTO          _export

#    define AL_DLL_FAR

#    define AL_FUNCTION       _export _far pascal

#    define AL_CFUNCTION      _export _far cdecl

#  else
#    define AL_CLASS_TYPE     _export

#    define AL_PROTO          _far

#    define AL_DLL_FAR        _far

#    define AL_FUNCTION       _export _far pascal

#    define AL_CFUNCTION      _export _far cdecl

#  endif
#elif defined( AL_USING_DLL )
#  if defined( AL_FLAT_MODEL ) && defined( AL_BORLAND )
#    define AL_CLASS_TYPE     _import

#    define AL_PROTO          _import

#    define AL_DLL_FAR

#    define AL_FUNCTION       _import pascal

#    define AL_CFUNCTION      _import cdecl

#  elif defined( AL_FLAT_MODEL ) && defined( AL_MICROSOFT )
#    define AL_CLASS_TYPE

#    define AL_PROTO

#    define AL_DLL_FAR

#    define AL_FUNCTION

#    define AL_CFUNCTION

#  elif defined( AL_FLAT_MODEL ) && defined( AL_SYMANTEC )
#    define AL_CLASS_TYPE     _export

#    define AL_PROTO          _export

#    define AL_DLL_FAR

#    define AL_FUNCTION       _export pascal

#    define AL_CFUNCTION      _export cdecl

#  elif defined( AL_WATCOM )
#    define AL_PROTO

#    define AL_DLL_FAR

#    define AL_CLASS_TYPE

#    define AL_FUNCTION       _far _pascal

#    define AL_CFUNCTION      _far cdecl

#  else
#    define AL_PROTO          _far

#    define AL_DLL_FAR        _far

#    ifdef AL_BORLAND
#      if ( AL_BORLAND >= 0x450 )
#        define AL_CLASS_TYPE _import

#      else
#        define AL_CLASS_TYPE   _huge

#      endif
#    else
#      define AL_CLASS_TYPE   _export

#    endif
#    define AL_FUNCTION       _export _far _pascal

#    define AL_CFUNCTION      _export _far cdecl

#  endif
#else
#  define AL_PROTO

#  define AL_CLASS_TYPE

#  define AL_DLL_FAR

#  define AL_FUNCTION

#  define AL_CFUNCTION

#endif

#if defined( AL_WIN32S )
#define AL_EXPORT

#else
#define AL_EXPORT _export

#endif

#if defined( AL_MICROSOFT )
# define AL_UNUSED_PARAMETER( a ) ( a = a )

#else
# define AL_UNUSED_PARAMETER( a ) (void) a

#endif

/*
 * All objects of type ALMonitor are set up to monitor jobs or objects.
 * This enum is passed to the constructor to select which one is desired.
 */
enum ALMonitorType {
    AL_MONITOR_OBJECTS,
    AL_MONITOR_JOB
};

/*
 * An ALMonitor object can either send out byte counts or percentage
 * complete ratios.  When constructing the object, this enum indicates
 * which strategy is going to be used.
 */
enum ALWindowsMessageType {
    AL_SEND_BYTE_COUNT,
    AL_SEND_RATIO,
};

/*
 * Global enumerated error codes
 */
enum ALErrors {
        AL_CANT_OPEN_BUFFER = -1200,
        AL_CANT_ALLOCATE_MEMORY,
        AL_CANT_CREATE_ENGINE,
        AL_CANT_CREATE_STORAGE_OBJECT,
        AL_RENAME_ERROR,
        AL_CANT_OPEN_FILE,
        AL_SEEK_ERROR,
        AL_READ_ERROR,
        AL_WRITE_ERROR,
        AL_DELETE_ERROR,
        AL_ILLEGAL_PARAMETER,
        AL_INTERNAL_ERROR,
        AL_USER_ABORT,
        AL_SERVER_NOT_PRESENT,
        AL_COMPRESSION_TYPE_MISMATCH,
        AL_NEED_LENGTH,
        AL_CRC_ERROR,
        AL_COMPARE_ERROR,
        AL_UNKNOWN_COMPRESSION_TYPE,
        AL_UNKNOWN_STORAGE_OBJECT,
        AL_INVALID_ARCHIVE,
        AL_LOGIC_ERROR,
        AL_BACKUP_FAILURE,
        AL_GETSEL_ERROR,
        AL_DUPLICATE_ENTRY,
        AL_END_OF_FILE = -1,
        AL_SUCCESS = 0
};

/*
 * Enum used by ALName guys.  Names can either be forced to upper
 * or lower case, or support normal mixed case representations.  Objects
 * like MS-DOS file names should be forced to upper or lower, since the
 * O/S keeps the names as case insensitive.
 */

enum ALCase {
    AL_UPPER,
    AL_LOWER,
    AL_MIXED
};

/*
 * Compressing levels used by the Greenleaf Engine.  In the archive, this
 * ratio is stored in the engine private data.
 */
enum ALGreenleafCompressionLevels {
    AL_GREENLEAF_COPY    = -1,
    AL_GREENLEAF_LEVEL_0 = 0,
    AL_GREENLEAF_LEVEL_1,
    AL_GREENLEAF_LEVEL_2,
    AL_GREENLEAF_LEVEL_3,
    AL_GREENLEAF_LEVEL_4,
};

/*
 * Used when constructing ALWildCardExpander objects.  It decides whether
 * the expander will traverse the entire subdirectory tree, or just stay
 * on the current level.
 */

enum ALTraverseSetting {
    AL_TRAVERSE = 1,
    AL_DONT_TRAVERSE = 0,
};

/*
 * The type of storage object.  This is stored in the base class, ALStorage,
 * and is initialized in the constructor.
 */
enum ALStorageType {
    AL_UNDEFINED     = -1,
    AL_MEMORY_OBJECT = 0,
    AL_FILE_OBJECT   = 1 };

/*
 * The type of compression engine.  This is stored in the base class,
 * ALEngine, and is initialized in the constructor.
 */
enum ALCompressionType {
    AL_COMPRESSION_COPY = 0,
    AL_COMPRESSION_GREENLEAF = 1
};

#endif