#include <stdio.h>
#include <unistd.h>
+#include "../vfile/vfile.h"
typedef unsigned long int t_freq;
} SHUFFCODE;
typedef struct t_huff {
- FILE *tmpfp; /* filepointer al temporal para un shuff_bychunk */
+ 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 */
- long volsize; /* Tamanio de volumen para multivol */
- char preloadfreq; /* 1 freqtable preloaded (bychunk|canonico) - 0 byfile */
-
+ 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_static_byfile(char *inputfile, char *outputfile, long volsize);
-HUFF_STATE *shuff_init_static_bychunk(char *outputfile, long volsize);
-void shuff_deinit_static_byfile(HUFF_STATE *fshuff);
-void shuff_deinit_static_bychunk(HUFF_STATE *cshuff);
-int shuff_decode_file(HUFF_STATE *shuff);
+
+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_ */