#include #include #include "dfc.h" FILE *Fopen(); main(argc,argv) int argc; char **argv; { short int style=LISTING; short int matches=1; short int errflag=0; short int status=CMD_ERR; while (--argc && **++argv=='-' && ! errflag) { switch(*++*argv) { case 'L': case 'l': style=LISTING; break; case 'S': case 's': style=SCRIPT; break; case 'M': case 'm': ++*argv; if(! (errflag+=(! isdigit(**argv)))) { matches=atoi(*argv); } break; default : errflag++; break; } } if (errflag || argc!=2) { fprintf(stderr,"usage: dfc [-{l|s|mINT}] Oldfile Newfile\n"); } else { DFC_PAR dp; if ((dp.fp_old=Fopen(*argv,R_PLUS_BIN))!=NULL) { if ((dp.fp_new=Fopen(*argv,R_PLUS_BIN))!=NULL) { dp.fp_out=stdout; dp.style=style; dp.matches=matches; switch((status=dodfc(&dp))) { case BAD_SEEK: fprintf(stderr,"dfc: can't seek\n"); break; case NO_MEMORY: fprintf(stderr,"dfc: not enough core\n"); break; case NO_DIFFERENCE: fprintf(stderr,"dfc: no difference\n"); break; case 1: fprintf(stderr,"dfc: one difference\n",PRG); break; default: fprintf(stderr,"dfc: %d differences\n", status); break; } fclose(dp.fp_old); } fclose(dp.fp_new); } } exit(status); } /* -- Fopen -------------------------------------------------------------------- Fopen oeffnet eine Datei fuer Standard-E/A. Im Fehlerfall wird eine Meldung ausgegeben. -------------------------------------------------------------------------- */ FILE *Fopen(name,type) char *name,*type; { FILE *fp; if ((fp=fopen(name,type))==NULL) { perror(name); return(NULL); } return(fp); } Bild 4. Das Programm-Listing