OSDN Git Service

Merge branch 'master' of github.com:jca02266/lha
[lha/lha.git] / src / lha_macro.h
index 2c168b8..f4f8f5a 100644 (file)
 # define kill(pid, sig)         0
 #endif
 
+#if defined __DJGPP__
+# define S_ISLNK(m)    0
+#endif
+
 /* ------------------------------------------------------------------------ */
 /* YOUR CUSTOMIZIES                                                         */
 /* ------------------------------------------------------------------------ */
@@ -44,6 +48,7 @@
 #define CODE_EUC 1
 #define CODE_SJIS 2
 #define CODE_UTF8 3
+#define CODE_CAP 4              /* Columbia AppleTalk Program */
 #define TO_LOWER 1
 #define TO_UPPER 2
 
@@ -68,6 +73,8 @@
 #define LARC5_METHOD            "-lz5-"
 #define LARC4_METHOD            "-lz4-"
 #define LZHDIRS_METHOD          "-lhd-"
+#define PMARC0_METHOD           "-pm0-"
+#define PMARC2_METHOD           "-pm2-"
 
 #define METHOD_TYPE_STORAGE     5
 
 #define LARC5_METHOD_NUM        9
 #define LARC4_METHOD_NUM        10
 #define LZHDIRS_METHOD_NUM      11
+#define PMARC0_METHOD_NUM       12
+#define PMARC2_METHOD_NUM       13
 /* Added N.Watazaki ..^ */
 
 #define LZHUFF0_DICBIT           0      /* no compress */
-#define LZHUFF1_DICBIT          12      /* 2^12 =  4k sliding dictionary */
-#define LZHUFF2_DICBIT          13      /* 2^13 =  8k sliding dictionary */
-#define LZHUFF3_DICBIT          13      /* 2^13 =  8k sliding dictionary */
-#define LZHUFF4_DICBIT          12      /* 2^12 =  4k sliding dictionary */
-#define LZHUFF5_DICBIT          13      /* 2^13 =  8k sliding dictionary */
-#define LZHUFF6_DICBIT          15      /* 2^15 = 32k sliding dictionary */
-#define LZHUFF7_DICBIT          16      /* 2^16 = 64k sliding dictionary */
-#define LARC_DICBIT             11      /* 2^11 =  2k sliding dictionary */
-#define LARC5_DICBIT            12      /* 2^12 =  4k sliding dictionary */
+#define LZHUFF1_DICBIT          12      /* 2^12 =  4KB sliding dictionary */
+#define LZHUFF2_DICBIT          13      /* 2^13 =  8KB sliding dictionary */
+#define LZHUFF3_DICBIT          13      /* 2^13 =  8KB sliding dictionary */
+#define LZHUFF4_DICBIT          12      /* 2^12 =  4KB sliding dictionary */
+#define LZHUFF5_DICBIT          13      /* 2^13 =  8KB sliding dictionary */
+#define LZHUFF6_DICBIT          15      /* 2^15 = 32KB sliding dictionary */
+#define LZHUFF7_DICBIT          16      /* 2^16 = 64KB sliding dictionary */
+#define LARC_DICBIT             11      /* 2^11 =  2KB sliding dictionary */
+#define LARC5_DICBIT            12      /* 2^12 =  4KB sliding dictionary */
 #define LARC4_DICBIT             0      /* no compress */
+#define PMARC0_DICBIT            0      /* no compress */
+#define PMARC2_DICBIT           13      /* 2^13 =  8KB sliding dictionary */
 
 #ifdef SUPPORT_LH7
 #define MAX_DICBIT          LZHUFF7_DICBIT      /* lh7 use 16bits */
 
 #define GENERIC_ATTRIBUTE               0x20
 #define GENERIC_DIRECTORY_ATTRIBUTE     0x10
-#define HEADER_LEVEL0                   0x00
-#define HEADER_LEVEL1                   0x01
-#define HEADER_LEVEL2                   0x02
 
 #define CURRENT_UNIX_MINOR_VERSION      0x00
 
 
 #define LZHEADER_STORAGE        4096
 
-#define MAX_INDICATOR_COUNT     64
-
 /* ------------------------------------------------------------------------ */
 /*  FILE Attribute                                                          */
 /* ------------------------------------------------------------------------ */
 #define is_symlink(statp)       (((statp)->st_mode & S_IFMT) == S_IFLNK)
 #define is_regularfile(statp)   (((statp)->st_mode & S_IFMT) == S_IFREG)
 
-#if 1 /* assume that fopen() will accepts "b" as binary mode on all system. */
+#if 1 /* assume that fopen() will accepts "b" as binary mode on all systems. */
 #define WRITE_BINARY    "wb"
 #define READ_BINARY     "rb"
 #else
 /* Individual macro define                                                  */
 /* ------------------------------------------------------------------------ */
 
-/* from crcio.c */
+#ifndef MIN
+#define MIN(a,b) ((a) <= (b) ? (a) : (b))
+#endif
+
+/* bitio.c */
+#define peekbits(n)     (bitbuf >> (sizeof(bitbuf)*8 - (n)))
+
+/* crcio.c */
 #define CRCPOLY         0xA001      /* CRC-16 (x^16+x^15+x^2+1) */
 #define INITIALIZE_CRC(crc) ((crc) = 0)
 #define UPDATE_CRC(crc, c) \
- (crctable[((crc) ^ (c)) & 0xFF] ^ ((crc) >> CHAR_BIT))
+ (crctable[((crc) ^ (unsigned char)(c)) & 0xFF] ^ ((crc) >> CHAR_BIT))
 
 /* dhuf.c */
 #define N_CHAR      (256 + 60 - THRESHOLD + 1)
 #define ROOT_P      TREESIZE_C
 
 /* huf.c */
+#define USHRT_BIT           16  /* (CHAR_BIT * sizeof(ushort)) */
 #define NP          (MAX_DICBIT + 1)
 #define NT          (USHRT_BIT + 3)
-#if 0
-#define PBIT        4       /* smallest integer such that (1 << PBIT) > * NP */
-#define TBIT        5       /* smallest integer such that (1 << TBIT) > * NT */
-#endif
+#define NC          (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
 
 #define PBIT        5       /* smallest integer such that (1 << PBIT) > * NP */
 #define TBIT        5       /* smallest integer such that (1 << TBIT) > * NT */
-
-#define NC          (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
+#define CBIT        9       /* smallest integer such that (1 << CBIT) > * NC */
 
 /*      #if NT > NP #define NPT NT #else #define NPT NP #endif  */
 #define NPT         0x80
 */
 
 /* slide.c */
-#define MATCHBIT            8   /* bits for MAXMATCH - THRESHOLD */
 #define MAXMATCH            256 /* formerly F (not more than UCHAR_MAX + 1) */
 #define THRESHOLD           3   /* choose optimal value */
-
-/* from huf.c */
-
-/* alphabet = {0, 1, 2, ..., NC - 1} */
-#define CBIT                9   /* $\lfloor \log_2 NC \rfloor + 1$ */
-#define USHRT_BIT           16  /* (CHAR_BIT * sizeof(ushort)) */