]> git.llucax.com Git - z.facultad/75.06/jacu.git/blob - src/statichuff/main.c
* Agrego al MTF 2 parametros para recuperar el Z y Z_len a fin de meterlos en el...
[z.facultad/75.06/jacu.git] / src / statichuff / main.c
1
2 #include "statichuff.h"
3 #include <stdlib.h>
4
5 int main(int argc, char* argv[])
6 {       
7         int cflag = 0;
8         int dflag = 0;
9         int tflag = 0;
10         long int volumesize = 0;
11         int ch;
12                         
13         while ((ch = getopt(argc, argv, "cdt:")) != -1) { 
14                  
15                 switch (ch) { 
16                         case 'c': cflag = 1; 
17                                           break;
18                         
19                         case 'd': dflag = 1; 
20                                           break; 
21                         
22                         case 't': tflag = 1; 
23                                           volumesize = atoi(optarg);                                      
24                                           break; 
25                         
26                         default: fprintf(stderr, "Usage: %s [-cdt] sourcefile targetfile\n", argv[0]); 
27                                          return(2);
28                 }
29         }
30                 
31         if ( (argc == 1) || (cflag & dflag) || !(cflag | dflag) || ((argc - optind) < 2) ) {
32                 fprintf(stderr, "Usage: %s [-cdt] sourcefile targetfile\n", argv[0]); 
33                 if ((tflag == 1) && (volumesize < 0)) fprintf(stderr,"Error: The volume size must be a non-zero value\n");
34                 return (2);             
35         }
36                 
37         if (cflag == 1) {
38                 /* Comprimo */
39             return shuff_encode_file(argv[optind],argv[optind+1],volumesize*1024);
40         }
41         
42         if (dflag == 1) { 
43                 /* Descomprimo */
44                 return shuff_decode_file(argv[optind],argv[optind+1]);
45         }
46                 
47         return 0;
48 }