9 #define required_argument 1
14 { return fgetc(input_stream);
16 int get_cell(int col,int row,int value)
17 { return table[epp_get(infile,col,row)];
19 int main(int argc,char **argv)
20 { char outname[256]="reclass.out.epp";
23 struct option long_options[]={
27 {"file",required_argument,0,'f'},
28 {"output-file",required_argument,0,'o'},
35 while ((c=getopt_long(argc,argv,"%f:o:",long_options,&index))!=-1)
37 { case 2:/* version */show_version("reclass","$Revision: 1.1 $");
38 case '%':verbose=1;break;
39 case 'o':strcpy(outname,default_ext(optarg,".epp"));
40 case 'f':if((input_stream=fopen(optarg,"r"))==NULL)
41 {fprintf(stderr,"Cannot open reclass file %s\n",optarg);
47 printf("Usage %s [--help] [--version] [-v] [-f reclass_file]\n"
48 "[-o output_file] file_to_reclass\n",argv[0]);
53 { fprintf(stderr,"No input files specified\n");
57 { fprintf(stderr,"Too many input files\n");
61 infile=open_epp(default_ext(argv[optind],".epp"));
62 if (!infile) { fprintf(stderr,"Cannot open input file\n");
66 outfile=creat_epp_as(outname,infile);
67 if (!outfile){ fprintf(stderr,"Cannot create output file\n");
70 if (input_stream==stdin&&isatty(0))
72 printf("Enter reclass statements. Press ^D to end.\n");
75 /* init reclass table */
76 if (!(table=make_reclass_table(infile,reclass_getc)))
77 { unlink(outname);return 1;}
78 if (table[infile->offsite]!=infile->offsite)
79 outfile->offsite=table[infile->offsite];
80 install_progress_indicator(verbose?show_percent:check_int);
81 for_each_cell(outfile,get_cell);
84 if (outfile->max<255){
85 fast_convert_to_8bit(outfile,strcat(strcpy(filename,outname),".8bit"));
87 rename(filename,outname);