X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/69bddb46f46871d27bcf797cd6fae14430802380..2ee6f95a8db79ede018e0f15124dd486451c4170:/src/statichuff/statichuff.h diff --git a/src/statichuff/statichuff.h b/src/statichuff/statichuff.h index 8c3502d..97e8f4c 100644 --- a/src/statichuff/statichuff.h +++ b/src/statichuff/statichuff.h @@ -4,6 +4,7 @@ #include #include +#include "../vfile/vfile.h" typedef unsigned long int t_freq; @@ -19,7 +20,33 @@ typedef struct t_code { unsigned char codelength; } SHUFFCODE; -int shuff_decode_file(char *inputfile, char *outputfile); -int shuff_encode_file(char *inputfile, char *outputfile); +typedef struct t_huff { + FILE *coderfp; /* fpointer usado en el coder de bychunk para el temp */ + VFILE *decoderfp; /* fpointer al archivo a descomrimir */ + char *sourcefile; /* Nombre del archivo a comprimir */ + char *targetfile; /* Nombre del archivo comprimido */ + long volsize; /* Tamanio de volumen para multivol */ + char bychunk; /* 0 works byfile, 1 works bychunk */ + char canonic; /* 1 Huffman Canonico con preloaded freqtable */ + t_freq *freqtable; /* Tabla de frecuencias */ + t_freq sumfreq; /* Frecuencia total acumulada */ + SHUFFNODE *codetree; /* Puntero al arbol de codigos prefijos */ + unsigned long int bytesleft; /* Cuanto falta descomprimir en un bychunk */ + unsigned long int codebuffer; /* Buffer de descompresion para bychunk */ + int bitsleft; /* Posicion en el buffer de descompresion para bychunk */ +} HUFF_STATE; + + +HUFF_STATE *shuff_init_encoder_byfile(char *inputfile, char *outputfile, long volsize); +HUFF_STATE *shuff_init_encoder_bychunk(char *outputfile, long volsize); +HUFF_STATE *shuff_init_decoder(char *inputfile, char *outputfile); +void shuff_deinit_encoder(HUFF_STATE *shuff); +void shuff_deinit_decoder(HUFF_STATE *shuff); +int shuff_encode_file(HUFF_STATE *shuff); +int shuff_decode_file(HUFF_STATE *shuff); +int shuff_scanfreq_chunk(HUFF_STATE *chunkshuff, char* chunk, int chunksize); +int shuff_decode_chunk(HUFF_STATE *shuff, char *chunk, int chunksize, int *decodedbytes); +int shuff_savemodel(HUFF_STATE *shuff); +int shuff_loadmodel(HUFF_STATE *shuff, char *modelfile); #endif /* _STATICHUFF_H_ */