Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cwjcc!hal!nic.MR.NET!umn-d-ub!rutgers!bellcore!texbell!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.unix.wizards Subject: Re: friendly messages Message-ID: <3314@ficc.uu.net> Date: 6 Mar 89 14:05:50 GMT References: <435@laic.UUCP> <955@auspex.UUCP> <9218@bloom-beacon.MIT.EDU> <9780@smoke.BRL.MIL> Organization: Xenix Support Lines: 69 In article <9780@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: > In article <3283@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: > >Have you looked at the new "perror()" docs? They describe a 4-component > >error message format for all programs to use... > perror() CANNOT do this, as its interface is standardized and has no > room for the additional information (severity and object; the program > name can and probably should be automated). I realise this. The document describes what programs should do for error messages, but makes no recommendation as to how this should be done. > Presumably there is an > analogous function that accepts the additional information. Unfortunately it's like Open Look... they just specced what it should look like without providing a programmer interface. The documentation has been out in the bookstores for some time: it's a red book with a plastic spiral binding. > What is supposed to be done when there is no particular object? > prog: fatal: ???: Insufficient memory available What does perror do when there is no particular object? if(!(buffer = malloc(BUFSIZ*NUMBUFS))) { perror(.....?.....); ... } Same problem. Perhaps we (the usenet community) should spec a better interface: extern char *progname; extern char *errformat; extern char default_errformat[]; char *errmsg(); main(argc, argv) int argc; char **argv; { progname = argv[0]; errformat = getenv("ERRORFORMAT"); if(errformat == NULL) errformat = default_errformat; ... } ... fprintf(stderr, "%s\n", errmsg(object, severity)); errformat would be printf/sccs-like: %p program name %P program name, tail only (no path). %o object %e error message %E short error message %s severity %S severity, 1 char %E %p: %s: %o: %e %Q %o: %e -- Peter da Silva, Xenix Support, Ferranti International Controls Corporation. Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180. `-_-' Home: ...!texbell!sugar!peter, peter@sugar.hackercorp.com. 'U` People have opinions. Companies have policy. And typos are my own business.