err 2.0.0
Small error-printing library written in C
Loading...
Searching...
No Matches
err.h
Go to the documentation of this file.
1/*
2 * err - Small error-printing library for C
3 * Copyright (C) 2021-2022 Sebastian LaVine <mail@smlavine.com>
4 * SPDX-License-Identifier: MPL-2.0
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10
11/**
12 * @file err.h
13 * @version 2.0.0
14 * @brief Header file
15 * @details #include this to use err in your project.
16 */
17
18#include <stdarg.h>
19
20/**
21 * @brief Global value for the program's name.
22 * @details This must be set before any err functions are called.
23 */
24extern char *program_invocation_name;
25
26/**
27 * @brief Prints a formatted warning message to stderr.
28 * @pre program_invocation_name is set
29 * @param fmt format string
30 * @param ap va_list of arguments for the format string
31 */
32void vwarn(const char *, va_list);
33
34/**
35 * @brief Prints a formatted error message to stderr.
36 * @pre program_invocation_name is set
37 * @param fmt format string
38 * @param ap va_list of arguments for the format string
39 */
40void vewarn(const char *, va_list);
41
42/**
43 * @brief Prints a formatted error message to stderr and exits.
44 * @pre program_invocation_name is set
45 * @param fmt format string
46 * @param ap va_list of arguments for the format string
47 */
48void verr(const char *, va_list);
49
50/**
51 * @brief Prints a formatted error message to stderr and exits with the given
52 * exit code.
53 * @pre program_invocation_name is set
54 * @param code exit code
55 * @param fmt format string
56 * @param ap va_list of arguments for the format string
57 */
58void verrc(const int, const char *, va_list);
59
60/**
61 * @brief Prints a formatted warning message to stderr.
62 * @pre program_invocation_name is set
63 * @param fmt format string
64 * @param ... arguments for the format string
65 */
66void warn(const char *, ...);
67
68/**
69 * @brief Prints a formatted error message to stderr.
70 * @pre program_invocation_name is set
71 * @param fmt format string
72 * @param ... arguments for the format string
73 */
74void ewarn(const char *, ...);
75
76/**
77 * @brief Prints a formatted error message to stderr and exits.
78 * @pre program_invocation_name is set
79 * @param fmt format string
80 * @param ... arguments for the format string
81 */
82void err(const char *, ...);
83
84/**
85 * @brief Prints a formatted error message to stderr and exits with the given
86 * exit code.
87 * @pre program_invocation_name is set
88 * @param code exit code
89 * @param fmt format string
90 * @param ... arguments for the format string
91 */
92void errc(const int, const char *, ...);
void verrc(const int, const char *, va_list)
Prints a formatted error message to stderr and exits with the given exit code.
Definition: err.c:64
void warn(const char *,...)
Prints a formatted warning message to stderr.
Definition: err.c:84
void vwarn(const char *, va_list)
Prints a formatted warning message to stderr.
Definition: err.c:36
char * program_invocation_name
Global value for the program's name.
Definition: err.c:29
void err(const char *,...)
Prints a formatted error message to stderr and exits.
Definition: err.c:123
void verr(const char *, va_list)
Prints a formatted error message to stderr and exits.
Definition: err.c:75
void ewarn(const char *,...)
Prints a formatted error message to stderr.
Definition: err.c:97
void vewarn(const char *, va_list)
Prints a formatted error message to stderr.
Definition: err.c:46
void errc(const int, const char *,...)
Prints a formatted error message to stderr and exits with the given exit code.
Definition: err.c:110