check more carefully that the input file is valid dpu formst

master
Jonathan Lamothe 11 years ago
parent ec835973b7
commit ce867fb996
  1. 12
      undpu.c

@ -3,18 +3,20 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
const char compare_string[] = "DOUBLEPLUS UNZIP, FACTOR=";
int main (int argc, char **argv){ int main (int argc, char **argv){
FILE *bob, *joe; FILE *bob, *joe;
int factor, thing; int factor, thing, i;
char output[FILENAME_MAX]; char output[FILENAME_MAX];
if((bob = fopen(argv[1],"r"))==NULL){ if((bob = fopen(argv[1],"r"))==NULL){
fputs("That's no input file, THAT'S A SPACE STATION!\n",stderr); fputs("That's no input file, THAT'S A SPACE STATION!\n",stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
while(thing != '='){ for(i = 0; compare_string[i]; i++) {
thing=fgetc(bob); thing = fgetc(bob);
if(thing==EOF){ if(thing != compare_string[i]) {
fputs("You suck! That's not a DPU file!\n",stderr); fputs("You suck! That's not a DPU file!\n", stderr);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} }

Loading…
Cancel
Save