blob: 4a1841ba2eee5dae73d40ff36b2380a80dd410d4 [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
Colin Cross64ceac32010-01-13 21:19:52 -080039#include <sys/cdefs.h>
Elliott Hughes414dd2d2024-10-16 14:48:30 +000040
41#include <stdarg.h>
Elliott Hughes9afe2882014-02-04 19:26:31 -080042#include <sys/types.h>
Colin Cross64ceac32010-01-13 21:19:52 -080043
44__BEGIN_DECLS
45
Elliott Hughes462e90c2018-08-21 16:10:48 -070046/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000047 * [err(3)](https://man7.org/linux/man-pages/man3/err.3.html) outputs the program name,
Elliott Hughes462e90c2018-08-21 16:10:48 -070048 * the printf()-like formatted message, and the result of strerror() if `errno` is non-zero.
49 *
50 * Calls exit() with `__status`.
51 *
52 * New code should consider error() in `<error.h>`.
53 */
zijunzhao377954f2023-02-16 23:29:54 +000054__noreturn void err(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3);
Elliott Hughes462e90c2018-08-21 16:10:48 -070055
56/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000057 * [verr(3)](https://man7.org/linux/man-pages/man3/verr.3.html) outputs the program name,
Elliott Hughes462e90c2018-08-21 16:10:48 -070058 * the vprintf()-like formatted message, and the result of strerror() if `errno` is non-zero.
59 *
60 * Calls exit() with `__status`.
61 *
62 * New code should consider error() in `<error.h>`.
63 */
zijunzhao377954f2023-02-16 23:29:54 +000064__noreturn void verr(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0);
Elliott Hughes462e90c2018-08-21 16:10:48 -070065
66/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000067 * [errx(3)](https://man7.org/linux/man-pages/man3/errx.3.html) outputs the program name, and
Elliott Hughes462e90c2018-08-21 16:10:48 -070068 * the printf()-like formatted message.
69 *
70 * Calls exit() with `__status`.
71 *
72 * New code should consider error() in `<error.h>`.
73 */
zijunzhao377954f2023-02-16 23:29:54 +000074__noreturn void errx(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3);
Elliott Hughes462e90c2018-08-21 16:10:48 -070075
76/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000077 * [verrx(3)](https://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, and
Elliott Hughes462e90c2018-08-21 16:10:48 -070078 * the vprintf()-like formatted message.
79 *
80 * Calls exit() with `__status`.
81 *
82 * New code should consider error() in `<error.h>`.
83 */
zijunzhao377954f2023-02-16 23:29:54 +000084__noreturn void verrx(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0);
Elliott Hughes462e90c2018-08-21 16:10:48 -070085
86/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000087 * [warn(3)](https://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name,
Elliott Hughes462e90c2018-08-21 16:10:48 -070088 * the printf()-like formatted message, and the result of strerror() if `errno` is non-zero.
89 *
90 * New code should consider error() in `<error.h>`.
91 */
zijunzhao377954f2023-02-16 23:29:54 +000092void warn(const char* _Nullable __fmt, ...) __printflike(1, 2);
Elliott Hughes462e90c2018-08-21 16:10:48 -070093
94/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +000095 * [vwarn(3)](https://man7.org/linux/man-pages/man3/vwarn.3.html) outputs the program name,
Elliott Hughes462e90c2018-08-21 16:10:48 -070096 * the vprintf()-like formatted message, and the result of strerror() if `errno` is non-zero.
97 *
98 * New code should consider error() in `<error.h>`.
99 */
zijunzhao377954f2023-02-16 23:29:54 +0000100void vwarn(const char* _Nullable __fmt, va_list __args) __printflike(1, 0);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700101
102/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +0000103 * [warnx(3)](https://man7.org/linux/man-pages/man3/warnx.3.html) outputs the program name, and
Elliott Hughes462e90c2018-08-21 16:10:48 -0700104 * the printf()-like formatted message.
105 *
106 * New code should consider error() in `<error.h>`.
107 */
zijunzhao377954f2023-02-16 23:29:54 +0000108void warnx(const char* _Nullable __fmt, ...) __printflike(1, 2);
Elliott Hughes462e90c2018-08-21 16:10:48 -0700109
110/**
Elliott Hughesbbd39aa2024-08-13 20:59:16 +0000111 * [vwarnx(3)](https://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, and
Elliott Hughes462e90c2018-08-21 16:10:48 -0700112 * the vprintf()-like formatted message.
113 *
114 * New code should consider error() in `<error.h>`.
115 */
zijunzhao377954f2023-02-16 23:29:54 +0000116void vwarnx(const char* _Nullable __fmt, va_list __args) __printflike(1, 0);
Colin Cross64ceac32010-01-13 21:19:52 -0800117
118__END_DECLS