/* existtest.c - say if corresponding file exists */ #include #include #include FILE * iop; char string[100]; char c; main(argc,argv) int argc; char ** argv; BEGIN IF (argc!=3) THEN fprintf(stderr,"usage: %s unambiguous-file-name prefix\n",argv[0]); fprintf(stderr,"will yield +mumble if corresponding file exists @ prefix\n"); fprintf(stderr,"yield -mumble if it does not\n"); error("\7"); FI strcpy(string,argv[2]); strcat(string,argv[1]); IF ( ! (iop=fopen(string,"r")) ) THEN IF (($$ferr&0xFF) == IE_NSF) THEN c = '-'; ELSE c = '+'; fprintf(stderr,"\7warning: \"%s\" returned %4o - assumed to exist\n",string,$$ferr&0xFF); FI ELSE c = '+'; FI printf("%c %s\n",c,string); END /* end: existtest.c */