2 #include "statichuff/statichuff.h"
3 #include "blocksorting/bs.h"
5 #include "vfile/vfile.h"
10 int main(int argc, char* argv[])
16 long int volumesize = 0;
17 size_t pagesize = 32768; /* 32KB */
21 while ((ch = getopt(argc, argv, "cdt:p:")) != -1) {
31 volumesize = atol(optarg);
35 pagesize = atoi(optarg);
38 default: fprintf(stderr, "Usage: %s [-cdpt] sourcefile targetfile\n", argv[0]);
43 if ( (argc == 1) || (cflag & dflag) || !(cflag | dflag) || ((argc - optind) < 2) ) {
44 fprintf(stderr, "Usage: %s [-cdt] sourcefile targetfile\n", argv[0]);
47 if ((tflag) && (volumesize <= 0l)) {
48 fprintf(stderr,"Error: The volume size must be a non-zero value\n");
51 if ((pflag) && (pagesize <= 1u)) {
52 fprintf(stderr,"Error: El tamaño de página debe ser mayor a 1 byte.\n");
58 /* No me gusta el tmpfile ... es para probar como anda todo junto */
60 unsigned long int i, j, total, k;
62 char *salida, *data, c;
63 data = malloc(sizeof(char)*pagesize);
64 /* Reservo lugar tambien para guardar el k */
65 salida = malloc(sizeof(char)*(pagesize)+sizeof(unsigned long int)*2);
66 bs = bs_create(pagesize);
67 fp = fopen(argv[optind], "rb");
68 fp_out = fopen("tmp.comp", "wb");
73 while ((!feof(fp)) && (i < pagesize)) {
79 bs_solve(data, salida, bs, &k, i);
80 /* Le aplico el MTF */
81 mtf = jacu_mtf(salida, i+sizeof(unsigned long int)*2);
83 fputc(mtf[j], fp_out);
88 i = shuff_encode_file("tmp.comp",argv[optind+1], volumesize);
89 /* borro el temporal */
96 return shuff_decode_file(argv[optind],argv[optind+1]);