home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / AR002.LZH / AR.H < prev    next >
C/C++ Source or Header  |  1990-08-15  |  2KB  |  72 lines

  1. /***********************************************************
  2.     ar.h
  3. ***********************************************************/
  4. #include <stdio.h>
  5. #include <limits.h>
  6. typedef unsigned char  uchar;   /*  8 bits or more */
  7. typedef unsigned int   uint;    /* 16 bits or more */
  8. typedef unsigned short ushort;  /* 16 bits or more */
  9. typedef unsigned long  ulong;   /* 32 bits or more */
  10.  
  11. /* ar.c */
  12.  
  13. extern int unpackable;
  14. extern ulong origsize, compsize;
  15.  
  16. /* io.c */
  17.  
  18. #define INIT_CRC  0  /* CCITT: 0xFFFF */
  19. extern FILE *arcfile, *infile, *outfile;
  20. extern uint crc, bitbuf;
  21. #define BITBUFSIZ (CHAR_BIT * sizeof bitbuf)
  22.  
  23. void error(char *fmt, ...);
  24. void make_crctable(void);
  25. void fillbuf(int n);
  26. uint getbits(int n);
  27. /* void putbit(int bit); */
  28. void putbits(int n, uint x);
  29. int fread_crc(uchar *p, int n, FILE *f);
  30. void fwrite_crc(uchar *p, int n, FILE *f);
  31. void init_getbits(void);
  32. void init_putbits(void);
  33.  
  34. /* encode.c and decode.c */
  35.  
  36. #define DICBIT    13    /* 12(-lh4-) or 13(-lh5-) */
  37. #define DICSIZ (1U << DICBIT)
  38. #define MATCHBIT   8    /* bits for MAXMATCH - THRESHOLD */
  39. #define MAXMATCH 256    /* formerly F (not more than UCHAR_MAX + 1) */
  40. #define THRESHOLD  3    /* choose optimal value */
  41. #define PERC_FLAG 0x8000U
  42.  
  43. void encode(void);
  44. void decode_start(void);
  45. void decode(uint count, uchar text[]);
  46.  
  47. /* huf.c */
  48.  
  49. #define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
  50.     /* alphabet = {0, 1, 2, ..., NC - 1} */
  51. #define CBIT 9  /* $\lfloor \log_2 NC \rfloor + 1$ */
  52. #define CODE_BIT  16  /* codeword length */
  53.  
  54. extern ushort left[], right[];
  55.  
  56. void huf_encode_start(void);
  57. void huf_decode_start(void);
  58. uint decode_c(void);
  59. uint decode_p(void);
  60. void output(uint c, uint p);
  61. void huf_encode_end(void);
  62.  
  63. /* maketbl.c */
  64.  
  65. void make_table(int nchar, uchar bitlen[],
  66.                 int tablebits, ushort table[]);
  67.  
  68. /* maketree.c */
  69.  
  70. int make_tree(int nparm, ushort freqparm[],
  71.                 uchar lenparm[], ushort codeparm[]);
  72.