[net.sources] efopen.c

broehl@watdcsu.UUCP (Bernie Roehl) (10/10/85)

<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);
	}

mikel@codas.UUCP (Mikel Manitius) (10/18/85)

I was just looking at the code for efopen.c, and again I found myself
barfing at the fact of how many people don't know of the existance of
perror(3), apparently the people who wrote sh(1) and cat(1) didn't know
of it either, all the damn things tell you is "cannot open ...". Please
people, read your manual about perror(3), or use errno yourself, it is
so easy to program in perror so it will tell you why it cannot open a
file, execute a system call, exec a file, etc...
-- 
	Mikel Manitius  - ...{ihnp4|akguc|attmail|indra!koura}!codas!mikel