home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum7.lzh
/
RICO
/
MAN
/
man.lose
< prev
next >
Wrap
Text File
|
1988-09-26
|
2KB
|
71 lines
lose, warn, lose_title - easy routines for printing error messages
SYNOPSIS
extern char *ErrStr, *ProgTitle;
lose_title(title)
char *title;
lose(format [ , pointer ] . . . )
char *format;
warn(format [ , pointer ] . . . )
char *format;
#include <lose.h> /* for values of errMode */
PrintErr(errMode, format [ , pointer ] . . . )
int errMode; /* ERR_FATAL, ERR_WARN, or ERR_NOTE */
char *format;
DESCRIPTION
These routines provide an easy to use error printing system.
lose_title is called at the beginning of the user's main
with argv[0] as title. This sets ProgTitle with the name of
the program. Errors of various severity levels can now be
processed with calls to lose, warn or PrintErr.
lose prints an error message (described below) and exits the
program with value 1.
warn prints an error message, sets errno to 0, and returns.
PrintErr performs one of the above depending on the value of
errMode; ERR_FATAL selects lose, ERR_WARN selects warn, and
ERR_NOTE just places the error message in ErrStr.
ERROR MESSAGE CONSTRUCTION
The error message is built by calling vsprintf with the given
parameters; it is then prefixed with the program name.
Then, if errno (see man errno) is non-zero, the appropriate
error message (see sys_nerr in perror(3)) is appended. Once
the error message has been constructed, errno is reset to 0.
EXAMPLE
lose_title(argv[0]);
if (argc != 2)
Epitaph("Usage: %s filename", argv[0]);
...
if ((fp=fopen(argv[1], "r")) == NULL)
lose("Can't open source file %s", argv[1]);
...
if (line is bad)
Epitaph("Badly formatted line %s at line %d of file %s",
line, lineNumber, argv[1]);
SEE ALSO
perror, argproc, vsprintf, varargs
LIBRARY
Use argproc.l