blob: e91dac90be0dc9562f6d96736502502318acce2d [file] [log] [blame]
Colin Cross64ceac32010-01-13 21:19:52 -08001/*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)err.h 8.1 (Berkeley) 6/2/93
30 */
31
Elliott Hughes462e90c2018-08-21 16:10:48 -070032#pragma once
33
34/**
35 * @file err.h
36 * @brief BSD error reporting functions. See `<error.h>` for the GNU equivalent.
37 */
Colin Cross64ceac32010-01-13 21:19:52 -080038
Elliott Hughes4a8de0d2017-08-01 10:48:08 -070039#include <stdarg.h>
Colin Cross64ceac32010-01-13 21:19:52 -080040#include <sys/cdefs.h>
Elliott Hughes9afe2882014-02-04 19:26:31 -080041#include <sys/types.h>
Colin Cross64ceac32010-01-13 21:19:52 -080042
43__BEGIN_DECLS
44
Elliott Hughes462e90c2018-08-21 16:10:48 -070045/**
46 * [err(3)](http://man7.org/linux/man-pages/man3/err.3.html) outputs the program name,
47 * the printf()-like formatted message, and the result of strerror() if `errno` is non-zero.
48 *
49 * Calls exit() with `__status`.
50 *
51 * New code should consider error() in `<error.h>`.
52 */
Elliott Hughesff26a162017-08-17 22:34:21 +000053__noreturn void err(int __status, const char* __fmt, ...) __printflike(2, 3);
Elliott Hughes462e90c2018-08-21 16:10:48 -070054
55/**
56 * [verr(3)](http://man7.org/linux/man-pages/man3/verr.3.html) outputs the program name,
57 * the vprintf()-like formatted message, and the result of strerror() if `errno` is non-zero.
58 *
59 * Calls exit() with `__status`.
60 *
61 * New code should consider error() in `<error.h>`.
62 */
Elliott Hughesff26a162017-08-17 22:34:21 +000063__noreturn void verr(int __status, const char* __fmt, va_list __args) __printflike(2, 0);
Elliott Hughes462e90c2018-08-21 16:10:48 -070064
65/**
66 * [errx(3)](http://man7.org/linux/man-pages/man3/errx.3.html) outputs the program name, and
67 * the printf()-like formatted message.
68 *
69 * Calls exit() with `__status`.
70 *
71 * New code should consider error() in `<error.h>`.
72 */
Elliott Hughesff26a162017-08-17 22:34:21 +000073__noreturn void errx(int __status, const char* __fmt, ...) __printflike(2, 3);
Elliott Hughes462e90c2018-08-21 16:10:48 -070074
75/**
76 * [verrx(3)](http://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, and
77 * the vprintf()-like formatted message.
78 *
79 * Calls exit() with `__status`.
80 *
81 * New code should consider error() in `<error.h>`.
82 */
Elliott Hughesff26a162017-08-17 22:34:21 +000083__noreturn void verrx(int __status, const char* __fmt, va_list __args) __printflike(2, 0);
Elliott Hughes462e90c2018-08-21 16:10:48 -070084
85/**
86 * [warn(3)](http://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name,
87 * the printf()-like formatted message, and the result of strerror() if `errno` is non-zero.
88 *
89 * New code should consider error() in `<error.h>`.
90 */
Elliott Hughesff26a162017-08-17 22:34:21 +000091void warn(const char* __fmt, ...) __printflike(1, 2);
Elliott Hughes462e90c2018-08-21 16:10:48 -070092
93/**
94 * [vwarn(3)](http://man7.org/linux/man-pages/man3/vwarn.3.html) outputs the program name,
95 * the vprintf()-like formatted message, and the result of strerror() if `errno` is non-zero.
96 *
97 * New code should consider error() in `<error.h>`.
98 */
Elliott Hughesff26a162017-08-17 22:34:21 +000099void vwarn(const char* __fmt, va_list __args) __printflike(1, 0);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700100
101/**
102 * [warnx(3)](http://man7.org/linux/man-pages/man3/warnx.3.html) outputs the program name, and
103 * the printf()-like formatted message.
104 *
105 * New code should consider error() in `<error.h>`.
106 */
Elliott Hughesff26a162017-08-17 22:34:21 +0000107void warnx(const char* __fmt, ...) __printflike(1, 2);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700108
109/**
110 * [vwarnx(3)](http://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, and
111 * the vprintf()-like formatted message.
112 *
113 * New code should consider error() in `<error.h>`.
114 */
Elliott Hughesff26a162017-08-17 22:34:21 +0000115void vwarnx(const char* __fmt, va_list __args) __printflike(1, 0);
Colin Cross64ceac32010-01-13 21:19:52 -0800116
117__END_DECLS