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