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) (side-by-side diff)
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 @@
+/****************************************************************************
+ * 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_) */