OSDN Git Service

pass the lha-test4
[lha/olha.git] / ar.h
1 /***********************************************************
2         ar.h
3 ***********************************************************/
4 #include <stdio.h>
5 #include <stdint.h>
6 #include <limits.h>
7
8 typedef unsigned char uchar;    /*  8 bits or more */
9 typedef unsigned int uint;      /* 16 bits or more */
10 typedef unsigned short ushort;  /* 16 bits or more */
11 typedef unsigned long ulong;    /* 32 bits or more */
12
13 struct lzh_header {
14     char filename[1024];
15     int  namelen;
16     char method[5];
17     int compsize;
18     int origsize;
19     int ftime;
20     int file_crc;
21     char os_id;
22     int level;
23 };
24
25 struct lha_method {
26     char *id;
27     int dicbit;
28     int pbit;
29     int maxmatch;
30 };
31
32 struct lha_opts {
33     int nocompress;
34     char *outdir;
35     int quiet;
36     int header_level;
37     int generic;
38     int verbose;
39
40     /* compress parameter */
41     struct lha_method *method;
42 };
43
44 /* ar.c */
45 extern struct lha_opts opts;
46 extern int unpackable;
47 extern ulong origsize, compsize;
48
49 /* io.c */
50
51 #define INIT_CRC  0             /* CCITT: 0xFFFF */
52 #define UPDATE_CRC(c) \
53         crc = crctable[(crc ^ (c)) & 0xFF] ^ (crc >> CHAR_BIT)
54
55 extern FILE *arcfile, *infile, *outfile;
56 extern uint crc;
57 extern ushort bitbuf;
58 #define BITBUFSIZ (CHAR_BIT * sizeof bitbuf)
59
60 /* encode.c and decode.c */
61
62 #define MAXDICBIT    16            /* 12(-lh4-) or 13(-lh5-) */
63 #define MAXDICSIZ (1U << MAXDICBIT)
64 #define MATCHBIT   8            /* bits for MAXMATCH - THRESHOLD */
65 #define MAXMATCH 256            /* formerly F (not more than UCHAR_MAX + 1) */
66 #define THRESHOLD  3            /* choose optimal value */
67
68 /* huf.c */
69
70 #define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
71         /* alphabet = {0, 1, 2, ..., NC - 1} */
72 #define CBIT 9                  /* $\lfloor \log_2 NC \rfloor + 1$ */
73 #define CODE_BIT  16            /* codeword length */
74
75 extern ushort left[], right[];
76
77 #include "prototypes.h"