xref: /netbsd-src/external/gpl2/diffutils/dist/lib/error.h (revision 75f6d617e282811cb173c2ccfbf5df0dd71f7045)
1*75f6d617Schristos /*	$NetBSD: error.h,v 1.1.1.1 2016/01/13 03:15:30 christos Exp $	*/
2*75f6d617Schristos 
3*75f6d617Schristos /* Declaration for error-reporting function
4*75f6d617Schristos    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
5*75f6d617Schristos 
6*75f6d617Schristos 
7*75f6d617Schristos    NOTE: The canonical source of this file is maintained with the GNU C Library.
8*75f6d617Schristos    Bugs can be reported to bug-glibc@prep.ai.mit.edu.
9*75f6d617Schristos 
10*75f6d617Schristos    This program is free software; you can redistribute it and/or modify it
11*75f6d617Schristos    under the terms of the GNU General Public License as published by the
12*75f6d617Schristos    Free Software Foundation; either version 2, or (at your option) any
13*75f6d617Schristos    later version.
14*75f6d617Schristos 
15*75f6d617Schristos    This program is distributed in the hope that it will be useful,
16*75f6d617Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
17*75f6d617Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*75f6d617Schristos    GNU General Public License for more details.
19*75f6d617Schristos 
20*75f6d617Schristos    You should have received a copy of the GNU General Public License
21*75f6d617Schristos    along with this program; if not, write to the Free Software
22*75f6d617Schristos    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
23*75f6d617Schristos    USA.  */
24*75f6d617Schristos 
25*75f6d617Schristos #ifndef _ERROR_H
26*75f6d617Schristos #define _ERROR_H 1
27*75f6d617Schristos 
28*75f6d617Schristos #ifndef __attribute__
29*75f6d617Schristos /* This feature is available in gcc versions 2.5 and later.  */
30*75f6d617Schristos # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
31*75f6d617Schristos #  define __attribute__(Spec) /* empty */
32*75f6d617Schristos # endif
33*75f6d617Schristos /* The __-protected variants of `format' and `printf' attributes
34*75f6d617Schristos    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
35*75f6d617Schristos # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
36*75f6d617Schristos #  define __format__ format
37*75f6d617Schristos #  define __printf__ printf
38*75f6d617Schristos # endif
39*75f6d617Schristos #endif
40*75f6d617Schristos 
41*75f6d617Schristos #ifdef	__cplusplus
42*75f6d617Schristos extern "C" {
43*75f6d617Schristos #endif
44*75f6d617Schristos 
45*75f6d617Schristos #if defined (__STDC__) && __STDC__
46*75f6d617Schristos 
47*75f6d617Schristos /* Print a message with `fprintf (stderr, FORMAT, ...)';
48*75f6d617Schristos    if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
49*75f6d617Schristos    If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
50*75f6d617Schristos 
51*75f6d617Schristos extern void error (int status, int errnum, const char *format, ...)
52*75f6d617Schristos      __attribute__ ((__format__ (__printf__, 3, 4)));
53*75f6d617Schristos 
54*75f6d617Schristos extern void error_at_line (int status, int errnum, const char *fname,
55*75f6d617Schristos 			   unsigned int lineno, const char *format, ...)
56*75f6d617Schristos      __attribute__ ((__format__ (__printf__, 5, 6)));
57*75f6d617Schristos 
58*75f6d617Schristos /* If NULL, error will flush stdout, then print on stderr the program
59*75f6d617Schristos    name, a colon and a space.  Otherwise, error will call this
60*75f6d617Schristos    function without parameters instead.  */
61*75f6d617Schristos extern void (*error_print_progname) (void);
62*75f6d617Schristos 
63*75f6d617Schristos #else
64*75f6d617Schristos void error ();
65*75f6d617Schristos void error_at_line ();
66*75f6d617Schristos extern void (*error_print_progname) ();
67*75f6d617Schristos #endif
68*75f6d617Schristos 
69*75f6d617Schristos /* This variable is incremented each time `error' is called.  */
70*75f6d617Schristos extern unsigned int error_message_count;
71*75f6d617Schristos 
72*75f6d617Schristos /* Sometimes we want to have at most one error per line.  This
73*75f6d617Schristos    variable controls whether this mode is selected or not.  */
74*75f6d617Schristos extern int error_one_per_line;
75*75f6d617Schristos 
76*75f6d617Schristos #ifdef	__cplusplus
77*75f6d617Schristos }
78*75f6d617Schristos #endif
79*75f6d617Schristos 
80*75f6d617Schristos #endif /* error.h */
81