|
|
|
@ -2,23 +2,39 @@ |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
#include <getopt.h> |
|
|
|
|
|
|
|
|
|
const char compare_string[] = "DOUBLEPLUS UNZIP, FACTOR="; |
|
|
|
|
|
|
|
|
|
int main (int argc, char **argv){ |
|
|
|
|
FILE *bob, *joe; |
|
|
|
|
int factor, thing, i; |
|
|
|
|
int modifier, factor, thing, i; |
|
|
|
|
int out = 0; |
|
|
|
|
char output[FILENAME_MAX]; |
|
|
|
|
if(argc < 2){ |
|
|
|
|
while((modifier=getopt(argc,argv,"c"))+1){ |
|
|
|
|
switch(modifier){ |
|
|
|
|
case 'c': |
|
|
|
|
joe=stdout; |
|
|
|
|
out = 1; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
fprintf(stderr,"modifier=%d\n",modifier); |
|
|
|
|
fputs("You're going to have to be clearer about what you want.\n",stderr); |
|
|
|
|
return EXIT_FAILURE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
argc-=optind; |
|
|
|
|
argv+=optind; |
|
|
|
|
if(argc < 1){ |
|
|
|
|
fputs("I pity the fool who don't have an input file!\n",stderr); |
|
|
|
|
return EXIT_FAILURE; |
|
|
|
|
} |
|
|
|
|
if(strlen(argv[1]) <= 4 || strcmp(argv[1] + strlen(argv[1]) - 4, ".dpu")) |
|
|
|
|
if(strlen(argv[0]) <= 4 || strcmp(argv[0] + strlen(argv[0]) - 4, ".dpu")) |
|
|
|
|
{ |
|
|
|
|
fputs("Where's the rest of the filename?\n", stderr); |
|
|
|
|
return EXIT_FAILURE; |
|
|
|
|
} |
|
|
|
|
if((bob = fopen(argv[1],"r"))==NULL){ |
|
|
|
|
if((bob = fopen(argv[0],"r"))==NULL){ |
|
|
|
|
fputs("That's no input file, THAT'S A SPACE STATION!\n",stderr); |
|
|
|
|
return EXIT_FAILURE; |
|
|
|
|
} |
|
|
|
@ -41,10 +57,12 @@ int main (int argc, char **argv){ |
|
|
|
|
return EXIT_FAILURE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
strlcpy(output,argv[1],strlen(argv[1])-4); |
|
|
|
|
if((joe = fopen(output,"w"))==NULL){ |
|
|
|
|
fputs("Ummm, the output file doesn't work.\n",stderr); |
|
|
|
|
return EXIT_FAILURE; |
|
|
|
|
if(!out){ |
|
|
|
|
strlcpy(output,argv[0],strlen(argv[0])-4); |
|
|
|
|
if((joe = fopen(output,"w"))==NULL){ |
|
|
|
|
fputs("Ummm, the output file doesn't work.\n",stderr); |
|
|
|
|
return EXIT_FAILURE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
while((thing=fgetc(bob))!=EOF){ |
|
|
|
|
fputc(thing,joe); |
|
|
|
|