Blob Blame Raw
#ifndef ARCH_H
#define ARCH_H


#include "buffer.h"


enum {
    RES_RETRY,
    RES_DONE,
    RES_FAIL
};


typedef unsigned short Code;


typedef struct Entry {
    struct Entry *parent, *prev, *next;
    Code children[256];
    Byte value;
} Entry;


typedef struct Arch {
    Buffer rb, wb;
    Entry root, *entries, *first, *last;
    Code nextcode;
    unsigned int codebits;
} Arch;


int arch_init(Arch *a);
void arch_deinit(Arch *a);
int arch_deflate(Arch *a, int final);
int arch_inflate(Arch *a, int final);


#endif