]> git.llucax.com Git - z.facultad/75.06/jacu.git/commitdiff
Modifico el main del Jacu para que compile con la nueva API de Huffman por lo que...
authorAlan Kennedy <kennedya@3dgames.com.ar>
Wed, 23 Jun 2004 08:55:15 +0000 (08:55 +0000)
committerAlan Kennedy <kennedya@3dgames.com.ar>
Wed, 23 Jun 2004 08:55:15 +0000 (08:55 +0000)
src/jacu.c
src/statichuff/statichuff.c
src/statichuff/statichuff.h

index 9971abf8e61ea979bcf3a5d033b067297fac8384..c91f0e07cdb35187d00c0f1e29950ca67d1290cd 100644 (file)
@@ -22,6 +22,7 @@ int main(int argc, char* argv[])
        size_t pagesize = 32768; /* 32KB */
        int ch;
        t_BlockSort *bs;
+       HUFF_STATE *shuff;
                        
        while ((ch = getopt(argc, argv, "cdzt:q:")) != -1) { 
                 
@@ -175,14 +176,17 @@ int main(int argc, char* argv[])
                bs_destroy(bs);
 
                /* Comprimo con huffman */
-               i = shuff_encode_file("tmp.comp", argv[optind+1], volumesize);
+               if ((shuff = shuff_init_encoder_byfile("tmp.comp", argv[optind+1], volumesize)) == NULL) return 1;
+               shuff_encode_file(shuff);
+               shuff_deinit_encoder(shuff);
+               free(shuff);
 
                /* borro el temporal */
                remove("tmp.comp");
 
                /* Muestro bpb */
                printf("Comprimido a %.04f bpb.\n", get_file_size(argv[optind+1])*8.0/get_file_size(argv[optind]));
-               return i;
+               return 0;
        }
        
        if (dflag == 1) { 
@@ -194,7 +198,11 @@ int main(int argc, char* argv[])
                char *z;
                int z_len;
 
-               shuff_decode_file(argv[optind], "tmp.comp"); /*argv[optind+1]);*/
+               if ((shuff = shuff_init_decoder(argv[optind],"tmp.comp")) == NULL) return 1;
+               shuff_decode_file(shuff);
+               shuff_deinit_decoder(shuff);
+               free(shuff);
+               
                fp_in = fopen("tmp.comp", "rb");
                fp_out = fopen(argv[optind+1], "wb");
 
@@ -267,4 +275,3 @@ long get_file_size(const char* filename)
        fclose(file);
        return file_size;
 }
-
index 908729be341efc986cff022f2c6aa42f018543b9..55346bd4bb04dcb32eeec11478f284630f5d8a1b 100644 (file)
@@ -1,6 +1,7 @@
 
 #include "statichuff.h"
 #include <stdlib.h>
+#include <string.h>
 
 void putbit(char bit, char restart, char flush, VFILE *fp)
 {
@@ -393,7 +394,7 @@ HUFF_STATE *shuff_init_decoder(char *inputfile, char *outputfile)
        }       
        
        /* Levanto cuantos bytes decodeo y la freq table */
-       if ((shuff->decoderfp = vfopen(shuff->sourcefile,"r",0)) == NULL) return 0;     
+       if ((shuff->decoderfp = vfopen(shuff->sourcefile,"r",0)) == NULL) return NULL;  
        vfread(&(shuff->bytesleft),sizeof(unsigned long int),1,shuff->decoderfp);
        vfread(shuff->freqtable,sizeof(unsigned long int),256,shuff->decoderfp);                
        shuff->codetree = shuff_buildtree(shuff->freqtable);
index 35a550c5d31c1728662bbcb47ab5453e480136b4..3d80401ec32f07cfde3711f7f3a70b1649452a01 100644 (file)
@@ -40,6 +40,7 @@ HUFF_STATE *shuff_init_encoder_byfile(char *inputfile, char *outputfile, long vo
 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);