OSDN Git Service

added add.c extract.c list.c
[lha/olha.git] / ar.h
diff --git a/ar.h b/ar.h
index 87d4cb5..f507a16 100644 (file)
--- a/ar.h
+++ b/ar.h
@@ -4,11 +4,25 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <limits.h>
+#include <sys/types.h>
+
 typedef unsigned char uchar;    /*  8 bits or more */
 typedef unsigned int uint;      /* 16 bits or more */
 typedef unsigned short ushort;  /* 16 bits or more */
 typedef unsigned long ulong;    /* 32 bits or more */
 
+struct lzh_header {
+    char filename[1024];
+    int  namelen;
+    char method[5];
+    int compsize;
+    int origsize;
+    time_t mtime;
+    int file_crc;
+    char os_id;
+    int level;
+};
+
 struct lha_method {
     char *id;
     int dicbit;
@@ -21,10 +35,28 @@ struct lha_opts {
     char *outdir;
     int quiet;
     int header_level;
+    int generic;
+    int verbose;
+    int force_extract;
+    int archive_to_stdio;
 
     /* compress parameter */
     struct lha_method *method;
 };
+#define INITIALIZE_OPTS(opts)                   \
+    do {                                        \
+        (opts).nocompress = 0;                  \
+        (opts).outdir = NULL;                   \
+        (opts).quiet = 0;                       \
+        (opts).header_level = 2;                \
+        (opts).generic = 0;                     \
+        (opts).verbose = 0;                     \
+        (opts).force_extract = 0;               \
+        (opts).archive_to_stdio = 0;            \
+                                                \
+        /* default is the -lh5- method */       \
+        (opts).method   = &methods[5];          \
+    } while (0)
 
 /* ar.c */
 extern struct lha_opts opts;
@@ -35,24 +67,13 @@ extern ulong origsize, compsize;
 
 #define INIT_CRC  0             /* CCITT: 0xFFFF */
 #define UPDATE_CRC(c) \
-       crc = crctable[(crc ^ (c)) & 0xFF] ^ (crc >> CHAR_BIT)
+    crc = crctable[(crc ^ (unsigned char)(c)) & 0xFF] ^ (crc >> CHAR_BIT)
 
 extern FILE *arcfile, *infile, *outfile;
 extern uint crc;
 extern ushort bitbuf;
 #define BITBUFSIZ (CHAR_BIT * sizeof bitbuf)
 
-void error(char *fmt, ...);
-void make_crctable(void);
-void fillbuf(int n);
-uint getbits(int n);
-/* void putbit(int bit); */
-void putbits(int n, uint x);
-int fread_crc(uchar * p, int n, FILE * f);
-void fwrite_crc(uchar * p, int n, FILE * f);
-void init_getbits(void);
-void init_putbits(void);
-
 /* encode.c and decode.c */
 
 #define MAXDICBIT    16            /* 12(-lh4-) or 13(-lh5-) */
@@ -60,11 +81,6 @@ void init_putbits(void);
 #define MATCHBIT   8            /* bits for MAXMATCH - THRESHOLD */
 #define MAXMATCH 256            /* formerly F (not more than UCHAR_MAX + 1) */
 #define THRESHOLD  3            /* choose optimal value */
-#define PERC_FLAG 0x8000U
-
-void encode(void);
-void decode_start(void);
-void decode(uint count, uchar text[]);
 
 /* huf.c */
 
@@ -75,18 +91,4 @@ void decode(uint count, uchar text[]);
 
 extern ushort left[], right[];
 
-void huf_encode_start(struct lha_method *m);
-void huf_decode_start(struct lha_method *m);
-uint decode_c(void);
-uint decode_p(void);
-void output(uint c, uint p);
-void huf_encode_end(void);
-
-/* maketbl.c */
-
-void make_table(int nchar, uchar bitlen[], int tablebits, ushort table[]);
-
-/* maketree.c */
-
-int make_tree(int nparm, ushort freqparm[],
-              uchar lenparm[], ushort codeparm[]);
+#include "prototypes.h"