summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/PPMdType.h
authorpohly <pohly>2004-08-24 20:52:45 (UTC)
committer pohly <pohly>2004-08-24 20:52:45 (UTC)
commit73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (unidiff)
tree1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/PPMdType.h
parente90847c784c48bd21bf8768cb38edb853b832697 (diff)
downloadopie-73253e93327cf4ef0932de1b4afb56af22a0f37e.zip
opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.gz
opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.bz2
updated source to opie-reader 0.7g
Diffstat (limited to 'noncore/apps/opie-reader/PPMdType.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/PPMdType.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/PPMdType.h b/noncore/apps/opie-reader/PPMdType.h
new file mode 100644
index 0000000..eca7473
--- a/dev/null
+++ b/noncore/apps/opie-reader/PPMdType.h
@@ -0,0 +1,81 @@
1/****************************************************************************
2 * This file is part of PPMd project *
3 * Written and distributed to public domain by Dmitry Shkarin 1997, *
4 * 1999-2001 *
5 * Contents: compilation parameters and miscelaneous definitions *
6 * Comments: system & compiler dependent file *
7 ****************************************************************************/
8#if !defined(_PPMDTYPE_H_)
9#define _PPMDTYPE_H_
10
11#include <stdio.h>
12
13//#define _WIN32_ENVIRONMENT_
14//#define _DOS32_ENVIRONMENT_
15#define _POSIX_ENVIRONMENT_
16//#define _UNKNOWN_ENVIRONMENT_
17#if defined(_WIN32_ENVIRONMENT_)+defined(_DOS32_ENVIRONMENT_)+defined(_POSIX_ENVIRONMENT_)+defined(_UNKNOWN_ENVIRONMENT_) != 1
18#error Only one environment must be defined
19#endif /* defined(_WIN32_ENVIRONMENT_)+defined(_DOS32_ENVIRONMENT_)+defined(_POSIX_ENVIRONMENT_)+defined(_UNKNOWN_ENVIRONMENT_) != 1 */
20
21#if defined(_WIN32_ENVIRONMENT_)
22#include <windows.h>
23#else /* _DOS32_ENVIRONMENT_ || _POSIX_ENVIRONMENT_ || _UNKNOWN_ENVIRONMENT_ */
24typedef int BOOL;
25#define FALSE 0
26#define TRUE 1
27typedef unsigned char BYTE;
28typedef unsigned short WORD;
29typedef unsigned long DWORD;
30typedef unsigned int UINT;
31#endif /* defined(_WIN32_ENVIRONMENT_) */
32
33const DWORD PPMdSignature=0x84ACAF8F, Variant='I';
34const int MAX_O=16; /* maximum allowed model order */
35
36#define _USE_PREFETCHING /* for puzzling mainly */
37
38#if !defined(_UNKNOWN_ENVIRONMENT_) && !defined(__GNUC__)
39#define _FASTCALL __fastcall
40#define _STDCALL __stdcall
41#else
42#define _FASTCALL
43#define _STDCALL
44#endif /* !defined(_UNKNOWN_ENVIRONMENT_) && !defined(__GNUC__) */
45
46#if defined(__GNUC__)
47#define _PACK_ATTR __attribute__ ((packed))
48#else /* "#pragma pack" is used for other compilers */
49#define _PACK_ATTR
50#endif /* defined(__GNUC__) */
51
52/* PPMd module works with file streams via ...GETC/...PUTC macros only */
53typedef FILE _PPMD_FILE;
54#define _PPMD_E_GETC(pps) (pps)->get()
55#define _PPMD_E_PUTC(c,pps) (pps)->put(c)
56#define _PPMD_D_GETC(pps) (pps)->get()
57#define _PPMD_D_PUTC(c,pps) (pps)->put(c)
58/****************** Example of C++ buffered stream ************************
59class PRIME_STREAM {
60public:
61enum { BUF_SIZE=64*1024 };
62 PRIME_STREAM(): Error(0), StrPos(0), Count(0), p(Buf) {}
63 int get( ) { return (--Count >= 0)?(*p++ ):( fill( )); }
64 int put(int c) { return (--Count >= 0)?(*p++ = c):(flush(c)); }
65 int getErr() const { return Error; }
66 int tell() const { return StrPos+(p-Buf); }
67 BOOL atEOS() const { return (Count < 0); }
68protected:
69 int Error, StrPos, Count;
70 BYTE* p, Buf[BUF_SIZE];
71 virtual int fill( ) = 0; // it must fill Buf[]
72 virtual int flush(int c) = 0; // it must remove (p-Buf) bytes
73};
74typedef PRIME_STREAM _PPMD_FILE;
75#define _PPMD_E_GETC(pps) (pps)->get()
76#define _PPMD_E_PUTC(c,pps) (pps)->put(c)
77#define _PPMD_D_GETC(pps) (pps)->get()
78#define _PPMD_D_PUTC(c,pps) (pps)->put(c)
79************************** End of example *********************************/
80
81#endif /* !defined(_PPMDTYPE_H_) */