xref: /csrg-svn/lib/libc/gen/err.3 (revision 58450)
1*58450Sbostic.\" Copyright (c) 1993 The Regents of the University of California.
2*58450Sbostic.\" All rights reserved.
3*58450Sbostic.\"
4*58450Sbostic.\" %sccs.include.redist.roff%
5*58450Sbostic.\"
6*58450Sbostic.\"	@(#)err.3	5.1 (Berkeley) 03/04/93
7*58450Sbostic.\"
8*58450Sbostic.Dd ""
9*58450Sbostic.Dt ERR 3
10*58450Sbostic.Os BSD 4
11*58450Sbostic.Sh NAME
12*58450Sbostic.Nm err ,
13*58450Sbostic.Nm verr ,
14*58450Sbostic.Nm errx ,
15*58450Sbostic.Nm verrx ,
16*58450Sbostic.Nm warn ,
17*58450Sbostic.Nm vwarn ,
18*58450Sbostic.Nm warnx ,
19*58450Sbostic.Nm vwarnx
20*58450Sbostic.Nd formatted error messages
21*58450Sbostic.Sh SYNOPSIS
22*58450Sbostic.Fd #include <err.h>
23*58450Sbostic.Ft void
24*58450Sbostic.Fn err "int eval" "const char *fmt" "..."
25*58450Sbostic.Ft void
26*58450Sbostic.Fn verr "int eval" "const char *fmt" "va_list args"
27*58450Sbostic.Ft void
28*58450Sbostic.Fn errx "int eval" "const char *fmt" "..."
29*58450Sbostic.Ft void
30*58450Sbostic.Fn verrx "int eval" "const char *fmt" "va_list args"
31*58450Sbostic.Ft void
32*58450Sbostic.Fn warn "const char *fmt" "..."
33*58450Sbostic.Ft void
34*58450Sbostic.Fn vwarn "const char *fmt" "va_list args"
35*58450Sbostic.Ft void
36*58450Sbostic.Fn warnx "const char *fmt" "..."
37*58450Sbostic.Ft void
38*58450Sbostic.Fn vwarnx "const char *fmt" "va_list args"
39*58450Sbostic.Sh DESCRIPTION
40*58450SbosticThe
41*58450Sbostic.Fn err
42*58450Sbosticand
43*58450Sbostic.Fn warn
44*58450Sbosticfamily of functions display a formatted error message on the standard
45*58450Sbosticerror output.
46*58450SbosticIn all cases, the error message is preceded by the last component
47*58450Sbosticof the program name, a colon character, and a space.
48*58450SbosticIn the case of the
49*58450Sbostic.Fn err ,
50*58450Sbostic.Fn verr ,
51*58450Sbostic.Fn warn ,
52*58450Sbosticand
53*58450Sbostic.Fn vwarn
54*58450Sbosticfunctions, a colon character, a space and the error message string
55*58450Sbosticaffiliated with the current value of the global variable
56*58450Sbostic.Va errno
57*58450Sbosticare displayed after the formatted error message.
58*58450SbosticIn all cases, the message is followed by a newline character.
59*58450Sbostic.Pp
60*58450SbosticThe
61*58450Sbostic.Fn err ,
62*58450Sbostic.Fn verr ,
63*58450Sbostic.Fn errx ,
64*58450Sbosticand
65*58450Sbostic.Fn verrx
66*58450Sbosticfunctions do not return, but exit with the value of the argument
67*58450Sbostic.Fa eval .
68*58450Sbostic.Sh EXAMPLES
69*58450SbosticDisplay the current errno information string and exit:
70*58450Sbostic.Bd -literal -offset indent
71*58450Sbosticif ((fd = open(file_name, O_RDONLY, 0)) == -1)
72*58450Sbostic	err(1, "%s", file_name);
73*58450Sbostic.Ed
74*58450Sbostic.Pp
75*58450SbosticDisplay an error message and exit:
76*58450Sbostic.Bd -literal -offset indent
77*58450Sbosticif (tm.tm_hour < START_TIME)
78*58450Sbostic	errx(1, "too early, wait until %s", start_time_string);
79*58450Sbostic.Ed
80*58450Sbostic.Pp
81*58450SbosticWarn of an error:
82*58450Sbostic.Bd -literal -offset indent
83*58450Sbosticif ((fd = open(raw_device, O_RDONLY, 0)) == -1)
84*58450Sbostic	warnx("%s: %s: trying the block device",
85*58450Sbostic	    raw_device, strerror(errno));
86*58450Sbosticif ((fd = open(block_device, O_RDONLY, 0)) == -1)
87*58450Sbostic	err(1, "%s", block_device);
88*58450Sbostic.Ed
89*58450Sbostic.Sh SEE ALSO
90*58450Sbostic.Xr strerror 3
91*58450Sbostic.Sh HISTORY
92*58450SbosticThe
93*58450Sbostic.Fn err
94*58450Sbosticand
95*58450Sbostic.Fn warn
96*58450Sbosticfunctions are
97*58450Sbostic.Ud .
98