1 /*- 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 32 #pragma once 33 34 /** 35 * @file err.h 36 * @brief BSD error reporting functions. See `<error.h>` for the GNU equivalent. 37 */ 38 39 #include <sys/cdefs.h> 40 41 #include <stdarg.h> 42 #include <sys/types.h> 43 44 __BEGIN_DECLS 45 46 /** 47 * [err(3)](https://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, 48 * 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 */ 54 __noreturn void err(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3); 55 56 /** 57 * [verr(3)](https://man7.org/linux/man-pages/man3/verr.3.html) outputs the program name, 58 * 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 */ 64 __noreturn void verr(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0); 65 66 /** 67 * [errx(3)](https://man7.org/linux/man-pages/man3/errx.3.html) outputs the program name, and 68 * the printf()-like formatted message. 69 * 70 * Calls exit() with `__status`. 71 * 72 * New code should consider error() in `<error.h>`. 73 */ 74 __noreturn void errx(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3); 75 76 /** 77 * [verrx(3)](https://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, and 78 * the vprintf()-like formatted message. 79 * 80 * Calls exit() with `__status`. 81 * 82 * New code should consider error() in `<error.h>`. 83 */ 84 __noreturn void verrx(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0); 85 86 /** 87 * [warn(3)](https://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, 88 * 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 */ 92 void warn(const char* _Nullable __fmt, ...) __printflike(1, 2); 93 94 /** 95 * [vwarn(3)](https://man7.org/linux/man-pages/man3/vwarn.3.html) outputs the program name, 96 * 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 */ 100 void vwarn(const char* _Nullable __fmt, va_list __args) __printflike(1, 0); 101 102 /** 103 * [warnx(3)](https://man7.org/linux/man-pages/man3/warnx.3.html) outputs the program name, and 104 * the printf()-like formatted message. 105 * 106 * New code should consider error() in `<error.h>`. 107 */ 108 void warnx(const char* _Nullable __fmt, ...) __printflike(1, 2); 109 110 /** 111 * [vwarnx(3)](https://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, and 112 * the vprintf()-like formatted message. 113 * 114 * New code should consider error() in `<error.h>`. 115 */ 116 void vwarnx(const char* _Nullable __fmt, va_list __args) __printflike(1, 0); 117 118 __END_DECLS 119