efopen.c

Bernie Roehl broehl at watdcsu.UUCP
Fri Oct 11 00:19:42 AEST 1985


<bug line>

Here's efopen() and error().  They're short, and their use should be obvious
from the source.

--------- CUT HERE ------------
/* Open a file, aborting on failure */

/* Written by Bernie Roehl, June 1985 */

#include <stdio.h>
#include <sys.h>

efopen(fn, mode)
	char *fn, *mode;
	{
	FILE *unit;
	if ((unit = fopen(fn, mode)) == NULL)
		error("Cannot open file %s", fn);
	else
		return unit;
	}

extern char *progname;

error(s1, s2)
	char *s1, *s2;
	{
	fprintf(stderr, "%s: ", progname);
	fprintf(stderr, s1, s2);
	exit(1);
	}



More information about the Comp.sources.unix mailing list