OSDN Git Service

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