blob: eca7473a234442cd4a653c357aab06b41c1b7040 (
plain)
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
|
/****************************************************************************
* This file is part of PPMd project *
* Written and distributed to public domain by Dmitry Shkarin 1997, *
* 1999-2001 *
* Contents: compilation parameters and miscelaneous definitions *
* Comments: system & compiler dependent file *
****************************************************************************/
#if !defined(_PPMDTYPE_H_)
#define _PPMDTYPE_H_
#include <stdio.h>
//#define _WIN32_ENVIRONMENT_
//#define _DOS32_ENVIRONMENT_
#define _POSIX_ENVIRONMENT_
//#define _UNKNOWN_ENVIRONMENT_
#if defined(_WIN32_ENVIRONMENT_)+defined(_DOS32_ENVIRONMENT_)+defined(_POSIX_ENVIRONMENT_)+defined(_UNKNOWN_ENVIRONMENT_) != 1
#error Only one environment must be defined
#endif /* defined(_WIN32_ENVIRONMENT_)+defined(_DOS32_ENVIRONMENT_)+defined(_POSIX_ENVIRONMENT_)+defined(_UNKNOWN_ENVIRONMENT_) != 1 */
#if defined(_WIN32_ENVIRONMENT_)
#include <windows.h>
#else /* _DOS32_ENVIRONMENT_ || _POSIX_ENVIRONMENT_ || _UNKNOWN_ENVIRONMENT_ */
typedef int BOOL;
#define FALSE 0
#define TRUE 1
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned int UINT;
#endif /* defined(_WIN32_ENVIRONMENT_) */
const DWORD PPMdSignature=0x84ACAF8F, Variant='I';
const int MAX_O=16; /* maximum allowed model order */
#define _USE_PREFETCHING /* for puzzling mainly */
#if !defined(_UNKNOWN_ENVIRONMENT_) && !defined(__GNUC__)
#define _FASTCALL __fastcall
#define _STDCALL __stdcall
#else
#define _FASTCALL
#define _STDCALL
#endif /* !defined(_UNKNOWN_ENVIRONMENT_) && !defined(__GNUC__) */
#if defined(__GNUC__)
#define _PACK_ATTR __attribute__ ((packed))
#else /* "#pragma pack" is used for other compilers */
#define _PACK_ATTR
#endif /* defined(__GNUC__) */
/* PPMd module works with file streams via ...GETC/...PUTC macros only */
typedef FILE _PPMD_FILE;
#define _PPMD_E_GETC(pps) (pps)->get()
#define _PPMD_E_PUTC(c,pps) (pps)->put(c)
#define _PPMD_D_GETC(pps) (pps)->get()
#define _PPMD_D_PUTC(c,pps) (pps)->put(c)
/****************** Example of C++ buffered stream ************************
class PRIME_STREAM {
public:
enum { BUF_SIZE=64*1024 };
PRIME_STREAM(): Error(0), StrPos(0), Count(0), p(Buf) {}
int get( ) { return (--Count >= 0)?(*p++ ):( fill( )); }
int put(int c) { return (--Count >= 0)?(*p++ = c):(flush(c)); }
int getErr() const { return Error; }
int tell() const { return StrPos+(p-Buf); }
BOOL atEOS() const { return (Count < 0); }
protected:
int Error, StrPos, Count;
BYTE* p, Buf[BUF_SIZE];
virtual int fill( ) = 0; // it must fill Buf[]
virtual int flush(int c) = 0; // it must remove (p-Buf) bytes
};
typedef PRIME_STREAM _PPMD_FILE;
#define _PPMD_E_GETC(pps) (pps)->get()
#define _PPMD_E_PUTC(c,pps) (pps)->put(c)
#define _PPMD_D_GETC(pps) (pps)->get()
#define _PPMD_D_PUTC(c,pps) (pps)->put(c)
************************** End of example *********************************/
#endif /* !defined(_PPMDTYPE_H_) */
|