xref: /dragonfly/contrib/diffutils/lib/error.h (revision 6ea1f93e)
1855caec6SPeter Avalos /* Declaration for error-reporting function
2*6ea1f93eSDaniel Fojt    Copyright (C) 1995-1997, 2003, 2006, 2008-2018 Free Software Foundation,
3008e37b6SJohn Marino    Inc.
4855caec6SPeter Avalos    This file is part of the GNU C Library.
5855caec6SPeter Avalos 
644b87433SJohn Marino    This program is free software: you can redistribute it and/or modify
7855caec6SPeter Avalos    it under the terms of the GNU General Public License as published by
844b87433SJohn Marino    the Free Software Foundation; either version 3 of the License, or
944b87433SJohn Marino    (at your option) any later version.
10855caec6SPeter Avalos 
11855caec6SPeter Avalos    This program is distributed in the hope that it will be useful,
12855caec6SPeter Avalos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13855caec6SPeter Avalos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14855caec6SPeter Avalos    GNU General Public License for more details.
15855caec6SPeter Avalos 
1644b87433SJohn Marino    You should have received a copy of the GNU General Public License
17*6ea1f93eSDaniel Fojt    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
18855caec6SPeter Avalos 
19855caec6SPeter Avalos #ifndef _ERROR_H
20855caec6SPeter Avalos #define _ERROR_H 1
21855caec6SPeter Avalos 
2244b87433SJohn Marino /* The __attribute__ feature is available in gcc versions 2.5 and later.
2344b87433SJohn Marino    The __-protected variants of the attributes 'format' and 'printf' are
2444b87433SJohn Marino    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
25008e37b6SJohn Marino    We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
2644b87433SJohn Marino    gnulib and libintl do '#define printf __printf__' when they override
2744b87433SJohn Marino    the 'printf' function.  */
28008e37b6SJohn Marino #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
29008e37b6SJohn Marino # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
30008e37b6SJohn Marino #else
31008e37b6SJohn Marino # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
32855caec6SPeter Avalos #endif
33855caec6SPeter Avalos 
34*6ea1f93eSDaniel Fojt /* On mingw, the flavor of printf depends on whether the extensions module
35*6ea1f93eSDaniel Fojt  * is in use; the check for <stdio.h> determines the witness macro.  */
36*6ea1f93eSDaniel Fojt #ifndef _GL_ATTRIBUTE_SPEC_PRINTF
37*6ea1f93eSDaniel Fojt # if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
38*6ea1f93eSDaniel Fojt #  define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__
39*6ea1f93eSDaniel Fojt # else
40*6ea1f93eSDaniel Fojt #  define _GL_ATTRIBUTE_SPEC_PRINTF __printf__
41*6ea1f93eSDaniel Fojt # endif
42*6ea1f93eSDaniel Fojt #endif
43*6ea1f93eSDaniel Fojt 
44855caec6SPeter Avalos #ifdef __cplusplus
45855caec6SPeter Avalos extern "C" {
46855caec6SPeter Avalos #endif
47855caec6SPeter Avalos 
484536c563SJohn Marino /* Print a message with 'fprintf (stderr, FORMAT, ...)';
49855caec6SPeter Avalos    if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
504536c563SJohn Marino    If STATUS is nonzero, terminate the program with 'exit (STATUS)'.  */
51855caec6SPeter Avalos 
52855caec6SPeter Avalos extern void error (int __status, int __errnum, const char *__format, ...)
53*6ea1f93eSDaniel Fojt      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4));
54855caec6SPeter Avalos 
55855caec6SPeter Avalos extern void error_at_line (int __status, int __errnum, const char *__fname,
56855caec6SPeter Avalos                            unsigned int __lineno, const char *__format, ...)
57*6ea1f93eSDaniel Fojt      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6));
58855caec6SPeter Avalos 
59855caec6SPeter Avalos /* If NULL, error will flush stdout, then print on stderr the program
60855caec6SPeter Avalos    name, a colon and a space.  Otherwise, error will call this
61855caec6SPeter Avalos    function without parameters instead.  */
62855caec6SPeter Avalos extern void (*error_print_progname) (void);
63855caec6SPeter Avalos 
644536c563SJohn Marino /* This variable is incremented each time 'error' is called.  */
65855caec6SPeter Avalos extern unsigned int error_message_count;
66855caec6SPeter Avalos 
67855caec6SPeter Avalos /* Sometimes we want to have at most one error per line.  This
68855caec6SPeter Avalos    variable controls whether this mode is selected or not.  */
69855caec6SPeter Avalos extern int error_one_per_line;
70855caec6SPeter Avalos 
71855caec6SPeter Avalos #ifdef __cplusplus
72855caec6SPeter Avalos }
73855caec6SPeter Avalos #endif
74855caec6SPeter Avalos 
75855caec6SPeter Avalos #endif /* error.h */
76