2 #include "statichuff/statichuff.h"
3 #include "blocksorting/bs.h"
9 int main(int argc, char* argv[])
15 long int volumesize = 0;
16 size_t pagesize = 32768; /* 32KB */
20 while ((ch = getopt(argc, argv, "cdt:p:")) != -1) {
30 volumesize = atol(optarg);
34 pagesize = atoi(optarg);
37 default: fprintf(stderr, "Usage: %s [-cdpt] sourcefile targetfile\n", argv[0]);
42 if ( (argc == 1) || (cflag & dflag) || !(cflag | dflag) || ((argc - optind) < 2) ) {
43 fprintf(stderr, "Usage: %s [-cdt] sourcefile targetfile\n", argv[0]);
46 if ((tflag) && (volumesize <= 0l)) {
47 fprintf(stderr,"Error: The volume size must be a non-zero value\n");
50 if ((pflag) && (pagesize <= 1u)) {
51 fprintf(stderr,"Error: El tamaño de página debe ser mayor a 1 byte.\n");
57 /* No me gusta el tmpfile ... es para probar como anda todo junto */
59 unsigned long int i, j, total, k;
61 char *salida, *data, c;
62 data = malloc(sizeof(char)*pagesize);
63 salida = malloc(sizeof(char)*(pagesize));
64 bs = bs_create(pagesize);
65 fp = fopen(argv[optind], "rb");
66 fp_out = fopen("tmp.comp", "wb");
71 while ((!feof(fp)) && (i < pagesize)) {
77 bs_solve(data, salida, bs, &k, i);
78 /* Le aplico el MTF */
79 mtf = jacu_mtf(salida, i);
81 fputc(mtf[j], fp_out);
86 i = shuff_encode_file("tmp.comp",argv[optind+1],volumesize);
87 /* borro el temporal */
94 return shuff_decode_file(argv[optind],argv[optind+1]);