/* Define FIXFNAME to activate the fixfname() function that converts
filename syntax to be acceptable to the host system */
/* #define FIXFNAME */

/*
OPEN(x)     open file x for read
CREATE(x)   create file x for read/write

Files opened by OPEN() and CREATE() must be opened in
binary mode (not involving any newline translation).
*/

#define NEED_B

/* Conventional stdio, using "b" suffix for binary open */
#ifdef NEED_B
#define  CREATE(x)      fopen(x, "wb")
#define  OPEN(x)        fopen(x, "rb")

#else
/* some systems (e.g. Ultrix) don't like a trailinb "b" */
#define  CREATE(x)      fopen(x, "w")
#define  OPEN(x)        fopen(x, "r")
#endif

/* don't change the rest of this file */
#define MEM_BLOCK_SIZE  8192

/* Functions defined by Booz */

int addbfcrc();
void message();
int fixfname ();

/* Standard functions */

char *malloc();

#include <stdio.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 */

uint decode_c();
uint decode_p();
uint getbits();
#define DICBIT    13    /* 12(-lh4-) or 13(-lh5-) */
#define DICSIZ ((unsigned) 1 << DICBIT)

/* Define some things if they aren't defined in header files */
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif

#ifndef UCHAR_MAX
# define UCHAR_MAX 255
#endif

/* io.c */

extern FILE *arcfile;
extern ulong bitbuf;
#define BITBUFSIZ (CHAR_BIT * sizeof bitbuf)

/* encode.c and decode.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 */
#define PERC_FLAG ((unsigned) 0x8000)

/* huf.c */

#define NC (UCHAR_MAX + MAXMATCH + 2 - THRESHOLD)
        /* alphabet = {0, 1, 2, ..., NC - 1} */
#define CBIT 9  /* $\lfloor \log_2 NC \rfloor + 1$ */
#define CODE_BIT  16  /* codeword length */

extern ushort left[], right[];

