home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char rcsid[] = "$Header: efopen.c,v 1.3 86/05/11 09:50:48 root Exp $";
- #endif
-
- #include <stdio.h>
-
- FILE *
- efopen(file, mode) /* fopen file, die if cannot */
- char *file, *mode; /* from K & P with addition of perror() and handling
- of "-" as stdin */
- {
- FILE *fp;
- extern char *progname;
-
- if (strcmp(file, "-") == 0)
- return(stdin);
-
- if ((fp = fopen(file, mode)) != NULL)
- return (fp);
-
- if (progname)
- fprintf(stderr, "%s ", progname);
- fprintf(stderr, "can't open file %s mode %s: ", file, mode);
- perror("");
- exit(1);
- /* NOTREACHED */
- }
-