00001 /**************************************************************************** 00002 * This file is part of PPMd project * 00003 * Written and distributed to public domain by Dmitry Shkarin 1997, * 00004 * 1999-2001 * 00005 * Contents: compilation parameters and miscelaneous definitions * 00006 * Comments: system & compiler dependent file * 00007 ****************************************************************************/ 00008 #if !defined(_PPMDTYPE_H_) 00009 #define _PPMDTYPE_H_ 00010 00011 #include <stdio.h> 00012 00013 //#define _WIN32_ENVIRONMENT_ 00014 //#define _DOS32_ENVIRONMENT_ 00015 #define _POSIX_ENVIRONMENT_ 00016 //#define _UNKNOWN_ENVIRONMENT_ 00017 #if defined(_WIN32_ENVIRONMENT_)+defined(_DOS32_ENVIRONMENT_)+defined(_POSIX_ENVIRONMENT_)+defined(_UNKNOWN_ENVIRONMENT_) != 1 00018 #error Only one environment must be defined 00019 #endif /* defined(_WIN32_ENVIRONMENT_)+defined(_DOS32_ENVIRONMENT_)+defined(_POSIX_ENVIRONMENT_)+defined(_UNKNOWN_ENVIRONMENT_) != 1 */ 00020 00021 #if defined(_WIN32_ENVIRONMENT_) 00022 #include <windows.h> 00023 #else /* _DOS32_ENVIRONMENT_ || _POSIX_ENVIRONMENT_ || _UNKNOWN_ENVIRONMENT_ */ 00024 typedef int BOOL; 00025 #define FALSE 0 00026 #define TRUE 1 00027 typedef unsigned char BYTE; 00028 typedef unsigned short WORD; 00029 typedef unsigned long DWORD; 00030 typedef unsigned int UINT; 00031 #endif /* defined(_WIN32_ENVIRONMENT_) */ 00032 00033 const DWORD PPMdSignature=0x84ACAF8F, Variant='I'; 00034 const int MAX_O=16; /* maximum allowed model order */ 00035 00036 #define _USE_PREFETCHING /* for puzzling mainly */ 00037 00038 #if !defined(_UNKNOWN_ENVIRONMENT_) && !defined(__GNUC__) 00039 #define _FASTCALL __fastcall 00040 #define _STDCALL __stdcall 00041 #else 00042 #define _FASTCALL 00043 #define _STDCALL 00044 #endif /* !defined(_UNKNOWN_ENVIRONMENT_) && !defined(__GNUC__) */ 00045 00046 #if defined(__GNUC__) 00047 #define _PACK_ATTR __attribute__ ((packed)) 00048 #else /* "#pragma pack" is used for other compilers */ 00049 #define _PACK_ATTR 00050 #endif /* defined(__GNUC__) */ 00051 00052 /* PPMd module works with file streams via ...GETC/...PUTC macros only */ 00053 typedef FILE _PPMD_FILE; 00054 #define _PPMD_E_GETC(pps) (pps)->get() 00055 #define _PPMD_E_PUTC(c,pps) (pps)->put(c) 00056 #define _PPMD_D_GETC(pps) (pps)->get() 00057 #define _PPMD_D_PUTC(c,pps) (pps)->put(c) 00058 /****************** Example of C++ buffered stream ************************ 00059 class PRIME_STREAM { 00060 public: 00061 enum { BUF_SIZE=64*1024 }; 00062 PRIME_STREAM(): Error(0), StrPos(0), Count(0), p(Buf) {} 00063 int get( ) { return (--Count >= 0)?(*p++ ):( fill( )); } 00064 int put(int c) { return (--Count >= 0)?(*p++ = c):(flush(c)); } 00065 int getErr() const { return Error; } 00066 int tell() const { return StrPos+(p-Buf); } 00067 BOOL atEOS() const { return (Count < 0); } 00068 protected: 00069 int Error, StrPos, Count; 00070 BYTE* p, Buf[BUF_SIZE]; 00071 virtual int fill( ) = 0; // it must fill Buf[] 00072 virtual int flush(int c) = 0; // it must remove (p-Buf) bytes 00073 }; 00074 typedef PRIME_STREAM _PPMD_FILE; 00075 #define _PPMD_E_GETC(pps) (pps)->get() 00076 #define _PPMD_E_PUTC(c,pps) (pps)->put(c) 00077 #define _PPMD_D_GETC(pps) (pps)->get() 00078 #define _PPMD_D_PUTC(c,pps) (pps)->put(c) 00079 ************************** End of example *********************************/ 00080 00081 #endif /* !defined(_PPMDTYPE_H_) */
1.4.2