/**
 * Wolfenstein: Enemy Territory GPL Source Code
 * Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
 * This file is part of the Wolfenstein: Enemy Territory GPL Source Code
 * If you have questions concerning this license or the applicable additional terms, you may contact
 * in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
 */

#ifndef HUFFENSTEIN_HUFFENSTEIN_H
#define HUFFENSTEIN_HUFFENSTEIN_H

#include <string.h>
#include <stdbool.h>

#define INTERNAL_NODE (HMAX + 1)
#define NYT HMAX
#define HMAX 256

typedef struct nodetype {
	struct nodetype *left, *right, *parent;
	struct nodetype *next, *prev;
	struct nodetype **head;
	int weight;
	int symbol;
} node_t;

typedef struct {
	int blocNode;
	int blocPtrs;
	node_t *tree;
	node_t *lhead;
	node_t *ltail;
	node_t *loc[HMAX + 1];
	node_t **freelist;
	node_t nodeList[768];
	node_t *nodePtrs[768];
} huff_t;

typedef struct {
	huff_t decompressor;
} huffman_t;

void Huff_Init();
void Huff_OffsetReceive(int *ch, unsigned char *fin, int *offset, int *bloc);
int Huff_GetBit(unsigned char *fin, int *offset, int *bloc);

#endif