Manual Pages for UNIX Darwin command on man err
MyWebUniversity

Manual Pages for UNIX Darwin command on man err

ERR(3) BSD Library Functions Manual ERR(3)

NAME

eerrrr, vveerrrr, eerrrrcc, vveerrrrcc, eerrrrxx, vveerrrrxx, wwaarrnn, vvwwaarrnn, wwaarrnncc, vvwwaarrnncc, wwaarrnnxx,

vvwwaarrnnxx, eerrrrsseetteexxiitt, eerrrrsseettffiillee - formatted error messages

LLIIBBRRAARRYY

Standard C Library (libc, -lc)

SYNOPSIS

##iinncclluuddee <>

void

eerrrr(int eval, const char *fmt, ...);

void

eerrrrsseetteexxiitt(void (*exitf)(int));

void

eerrrrsseettffiillee(void *vfp);

void

eerrrrcc(int eval, int code, const char *fmt, ...);

void

eerrrrxx(int eval, const char *fmt, ...);

void wwaarrnn(const char *fmt, ...); void wwaarrnncc(int code, const char *fmt, ...); void wwaarrnnxx(const char *fmt, ...);

##iinncclluuddee <>

void

vveerrrr(int eval, const char *fmt, valist args);

void

vveerrrrcc(int eval, int code, const char *fmt, valist args);

void

vveerrrrxx(int eval, const char *fmt, valist args);

void vvwwaarrnn(const char *fmt, valist args); void vvwwaarrnncc(int code, const char *fmt, valist args); void vvwwaarrnnxx(const char *fmt, valist args);

DESCRIPTION

The eerrrr() and wwaarrnn() family of functions display a formatted error mes-

sage on the standard error output, or on another file specified using the

eerrrrsseettffiillee() function. In all cases, the last component of the program

name, a colon character, and a space are output. If the fmt argument is

not NULL, the printf(3) -like formatted error message is output. The

output is terminated by a newline character.

The eerrrr(), eerrrrcc(), vveerrrr(), vveerrrrcc(), wwaarrnn(), wwaarrnncc(), vvwwaarrnn(), and

vvwwaarrnncc() functions append an error message obtained from strerror(3)

based on a code or the global variable errno, preceded by another colon

and space unless the fmt argument is NULL.

In the case of the eerrrrcc(), vveerrrrcc(), wwaarrnncc(), and vvwwaarrnncc() functions, the

code argument is used to look up the error message.

The eerrrr(), vveerrrr(), wwaarrnn(), and vvwwaarrnn() functions use the global variable

errno to look up the error message.

The eerrrrxx() and wwaarrnnxx() functions do not append an error message.

The eerrrr(), vveerrrr(), eerrrrcc(), vveerrrrcc(), eerrrrxx(), and vveerrrrxx() functions do not

return, but exit with the value of the argument eval. It is recommended that the standard values defined in sysexits(3) be used for the value of

eval. The eerrrrsseetteexxiitt() function can be used to specify a function

which is called before exit(3) to perform any necessary cleanup; passing a null function pointer for exitf resets the hook to do nothing. The

eerrrrsseettffiillee() function sets the output stream used by the other func-

tions. Its vfp argument must be either a pointer to an open stream (pos-

sibly already converted to void *) or a null pointer (in which case the

output stream is set to standard error).

EEXXAAMMPPLLEESS

Display the current errno information string and exit:

if ((p = malloc(size)) == NULL)

err(1, NULL);

if ((fd = open(filename, ORDONLY, 0)) == -1)

err(1, "%s", filename);

Display an error message and exit:

if (tm.tmhour < STARTTIME)

errx(1, "too early, wait until %s", starttimestring);

Warn of an error:

if ((fd = open(rawdevice, ORDONLY, 0)) == -1)

warnx("%s: %s: trying the block device",

rawdevice, strerror(errno));

if ((fd = open(blockdevice, ORDONLY, 0)) == -1)

err(1, "%s", blockdevice);

Warn of an error without using the global variable errno:

error = myfunction(); /* returns a value from */

if (error != 0)

warnc(error, "myfunction");

SEE ALSO

exit(3), fmtmsg(3), printf(3), strerror(3), sysexits(3)

HISTORY

The eerrrr() and wwaarrnn() functions first appeared in 4.4BSD. The

eerrrrsseetteexxiitt() and eerrrrsseettffiillee() functions first appeared in

FreeBSD 2.1. The eerrrrcc() and wwaarrnncc() functions first appeared in

FreeBSD 3.0. BSD March 6, 1999 BSD




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™