xref: /dflybsd-src/contrib/grep/lib/error.h (revision 91b9ed38d3db6a8a8ac5b66da1d43e6e331e259a)
195b7b453SJohn Marino /* Declaration for error-reporting function
2*09d4459fSDaniel Fojt    Copyright (C) 1995-1997, 2003, 2006, 2008-2020 Free Software Foundation,
3200fbe8dSJohn Marino    Inc.
495b7b453SJohn Marino    This file is part of the GNU C Library.
595b7b453SJohn Marino 
695b7b453SJohn Marino    This program is free software: you can redistribute it and/or modify
795b7b453SJohn Marino    it under the terms of the GNU General Public License as published by
895b7b453SJohn Marino    the Free Software Foundation; either version 3 of the License, or
995b7b453SJohn Marino    (at your option) any later version.
1095b7b453SJohn Marino 
1195b7b453SJohn Marino    This program is distributed in the hope that it will be useful,
1295b7b453SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
1395b7b453SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1495b7b453SJohn Marino    GNU General Public License for more details.
1595b7b453SJohn Marino 
1695b7b453SJohn Marino    You should have received a copy of the GNU General Public License
17*09d4459fSDaniel Fojt    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
1895b7b453SJohn Marino 
1995b7b453SJohn Marino #ifndef _ERROR_H
2095b7b453SJohn Marino #define _ERROR_H 1
2195b7b453SJohn Marino 
2295b7b453SJohn Marino /* The __attribute__ feature is available in gcc versions 2.5 and later.
2395b7b453SJohn Marino    The __-protected variants of the attributes 'format' and 'printf' are
2495b7b453SJohn Marino    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
25200fbe8dSJohn Marino    We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
2695b7b453SJohn Marino    gnulib and libintl do '#define printf __printf__' when they override
2795b7b453SJohn Marino    the 'printf' function.  */
28200fbe8dSJohn Marino #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
29200fbe8dSJohn Marino # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
30200fbe8dSJohn Marino #else
31200fbe8dSJohn Marino # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
3295b7b453SJohn Marino #endif
3395b7b453SJohn Marino 
34dc7c36e4SJohn Marino /* On mingw, the flavor of printf depends on whether the extensions module
35dc7c36e4SJohn Marino  * is in use; the check for <stdio.h> determines the witness macro.  */
36dc7c36e4SJohn Marino #ifndef _GL_ATTRIBUTE_SPEC_PRINTF
37dc7c36e4SJohn Marino # if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
38dc7c36e4SJohn Marino #  define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__
39dc7c36e4SJohn Marino # else
40dc7c36e4SJohn Marino #  define _GL_ATTRIBUTE_SPEC_PRINTF __printf__
41dc7c36e4SJohn Marino # endif
42dc7c36e4SJohn Marino #endif
43dc7c36e4SJohn Marino 
4495b7b453SJohn Marino #ifdef __cplusplus
4595b7b453SJohn Marino extern "C" {
4695b7b453SJohn Marino #endif
4795b7b453SJohn Marino 
48cf28ed85SJohn Marino /* Print a message with 'fprintf (stderr, FORMAT, ...)';
4995b7b453SJohn Marino    if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
50cf28ed85SJohn Marino    If STATUS is nonzero, terminate the program with 'exit (STATUS)'.  */
5195b7b453SJohn Marino 
5295b7b453SJohn Marino extern void error (int __status, int __errnum, const char *__format, ...)
53dc7c36e4SJohn Marino      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4));
5495b7b453SJohn Marino 
5595b7b453SJohn Marino extern void error_at_line (int __status, int __errnum, const char *__fname,
5695b7b453SJohn Marino                            unsigned int __lineno, const char *__format, ...)
57dc7c36e4SJohn Marino      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6));
5895b7b453SJohn Marino 
5995b7b453SJohn Marino /* If NULL, error will flush stdout, then print on stderr the program
6095b7b453SJohn Marino    name, a colon and a space.  Otherwise, error will call this
6195b7b453SJohn Marino    function without parameters instead.  */
6295b7b453SJohn Marino extern void (*error_print_progname) (void);
6395b7b453SJohn Marino 
64cf28ed85SJohn Marino /* This variable is incremented each time 'error' is called.  */
6595b7b453SJohn Marino extern unsigned int error_message_count;
6695b7b453SJohn Marino 
6795b7b453SJohn Marino /* Sometimes we want to have at most one error per line.  This
6895b7b453SJohn Marino    variable controls whether this mode is selected or not.  */
6995b7b453SJohn Marino extern int error_one_per_line;
7095b7b453SJohn Marino 
7195b7b453SJohn Marino #ifdef __cplusplus
7295b7b453SJohn Marino }
7395b7b453SJohn Marino #endif
7495b7b453SJohn Marino 
7595b7b453SJohn Marino #endif /* error.h */
76