X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/2167870f7379daba93d3d93902da3f80c61d294c..cb53166758c12a09e9911769ce89c94cee4cc0f0:/src/statichuff/statichuff.h?ds=inline diff --git a/src/statichuff/statichuff.h b/src/statichuff/statichuff.h index eac6505..97e8f4c 100644 --- a/src/statichuff/statichuff.h +++ b/src/statichuff/statichuff.h @@ -1,5 +1,10 @@ +#ifndef _STATICHUFF_H_ +#define _STATICHUFF_H_ + #include +#include +#include "../vfile/vfile.h" typedef unsigned long int t_freq; @@ -14,3 +19,34 @@ typedef struct t_code { unsigned long int code; unsigned char codelength; } SHUFFCODE; + +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_ */