Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site umcp-cs.UUCP
Path: utzoo!watmath!clyde!floyd!harpo!seismo!rlgvax!cvl!umcp-cs!chris
From: chris@umcp-cs.UUCP
Newsgroups: net.unix,net.lang.c
Subject: Re: 'exit(1);' considered useless; perror; stdio; etc.
Message-ID: <4998@umcp-cs.UUCP>
Date: Mon, 6-Feb-84 01:05:23 EST
Article-I.D.: umcp-cs.4998
Posted: Mon Feb  6 01:05:23 1984
Date-Received: Thu, 9-Feb-84 07:06:41 EST
References: <957@proper.UUCP>, <232@hou3c.UUCP>, <968@proper.UUCP>
Organization: Univ. of Maryland, Computer Science Dept.
Lines: 26

Speaking of "perror"... one thing I'd like to see is a ``%'' format
for printf that interprets an error number, so that I could say
(for example)

#include 

/*
 * Log an error message, and print it to stderr too.  'err' is a Unix(tm)
 * system error number (one of the beasts from ).
 */
LogError (err) int err; {
    static FILE *logfile;

    /* Replace '#' with appropriate char.  Can't use 'E', sigh. */
    fprintf (stderr, "%#\n", err);
    if (logfile || (logfile = fopen ("/foo/bar/errors", "a")))
	fprintf (logfile, "%#\n", err);
}

Many times I've wanted to print the error message associated with
"errno" -- but not the way perror(3) prints it.  I've had to fall
back on "extern char *sys_errlist[]; extern int sys_nerr;" hacks.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris.umcp-cs@CSNet-Relay