+ HUFF_STATE *fshuff = (HUFF_STATE*)malloc(sizeof(HUFF_STATE));
+ int i;
+
+ /* Inicializo la estructura para trabajar con Huff Static by File */
+ fshuff->tmpfp = NULL;
+ fshuff->sourcefile = (char*)malloc(sizeof(char)*(strlen(inputfile)+1));
+ fshuff->targetfile = (char*)malloc(sizeof(char)*(strlen(outputfile)+1));
+ strcpy(fshuff->sourcefile,inputfile);
+ strcpy(fshuff->targetfile,outputfile);
+ fshuff->preloadfreq = 0;
+ fshuff->volsize = volsize;
+ fshuff->sumfreq = 0;
+ fshuff->freqtable = (t_freq*)malloc(sizeof(t_freq)*256);
+ for (i = 0; i < 256; ++i) fshuff->freqtable[i] = 0;
+
+ return fshuff;
+}
+
+HUFF_STATE *shuff_init_static_bychunk(char *outputfile, long volsize)
+{
+ /* Locals */
+ HUFF_STATE *cshuff = (HUFF_STATE*)malloc(sizeof(HUFF_STATE));
+ FILE *fp;
+ int i;
+
+ /* Inicializo la estructura para trabajar con Huff Static by Chunks */
+ cshuff->sourcefile = (char*)malloc(sizeof(char)*(strlen(outputfile)+2));
+ cshuff->targetfile = (char*)malloc(sizeof(char)*(strlen(outputfile)+1));
+ strcpy(cshuff->targetfile,outputfile);
+ strcpy(cshuff->sourcefile,outputfile);
+ strcat(cshuff->sourcefile,"~");
+ cshuff->volsize = volsize;
+ cshuff->preloadfreq = 1;
+ cshuff->sumfreq = 0;
+ cshuff->freqtable = (t_freq*)malloc(sizeof(t_freq)*256);
+ for (i = 0; i < 256; ++i) cshuff->freqtable[i] = 0;
+
+ /* Abrimos un archivo temporal para ir tirando los chunks */
+ if ((cshuff->tmpfp = fopen(cshuff->sourcefile,"w")) == NULL) return NULL;
+
+ return cshuff;
+}
+
+void shuff_deinit_static_byfile(HUFF_STATE *fshuff)
+{
+ /* Libero mallocs y cierro archivos */
+ free(fshuff->freqtable);
+ free(fshuff->sourcefile);
+ free(fshuff->targetfile);
+}
+
+void shuff_deinit_static_bychunk(HUFF_STATE *cshuff)
+{
+ /* Libero mallocs y cierro archivos */
+ free(cshuff->freqtable);
+ free(cshuff->sourcefile);
+ free(cshuff->targetfile);
+ fclose(cshuff->tmpfp);
+}
+
+int shuff_encode_file(HUFF_STATE *shuff)
+{
+ /* Locals */