home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8712 / mkmf / 2 / src / mustfopen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-13  |  570 b   |  31 lines

  1. /* $Header: mustfopen.c,v 1.2 85/03/17 12:51:04 nicklin Exp $ */
  2.  
  3. /*
  4.  * Author: Peter J. Nicklin
  5.  */
  6.  
  7. /*
  8.  * mustfopen() opens a file in the manner of fopen(3). However, if the file
  9.  * cannot be accessed, exit(1) is called.
  10.  */
  11. #include <stdio.h>
  12.  
  13. extern char *PGN;        /* program name */
  14.  
  15. FILE *
  16. mustfopen(filename,mode)
  17.     char *filename;
  18.     char *mode;
  19. {
  20.     FILE *stream;            /* file stream */
  21.  
  22.     if ((stream = fopen(filename,mode)) == NULL)
  23.         {
  24.         if (*PGN != '\0')
  25.             fprintf(stderr, "%s: ", PGN);
  26.         fprintf(stderr, "can't open %s\n",filename);
  27.         exit(1);
  28.         }
  29.     return(stream);
  30. }
  31.