1 /*--- error.h ------------------------------------------------------------------
2 Copyright (C) 2004, 2005 Sylvain Fourmanoit <syfou@users.sourceforge.net>
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to
6 deal in the Software without restriction, including without limitation the
7 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 sell copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in
12 all copies of the Software and its documentation and acknowledgment shall be
13 given in the documentation and software packages that this Software was
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 ------------------------------------------------------------------------------*/
23 /* Wrapper around system error functions */
25 /*----------------------------------------------------------------------------*/
30 #error Autogenerated config.h should be used.
33 /*----------------------------------------------------------------------------*/
34 #include "config.h" /* Autoconf header */
37 #include <errno.h> /* C includes */
40 /*----------------------------------------------------------------------------*/
43 /*----------------------------------------------------------------------------*/
44 /* Error related management
50 if(errno) { errno_bis=errno; return 0;}\
53 /* Whenever TRY is going to be used in a function,
54 TRY_RESET should be invoked before. */
59 if(errno) errno_bis=errno;\
62 #define TRY_SUCCESS (errno_bis==0)
63 #define TRY_RESET errno_bis=0
65 /*----------------------------------------------------------------------------*/
67 I know, I know, variadic macros are ISO99 C, not ANSI...
79 #ifdef HAVE_SYS_TYPES_H
80 #include <sys/types.h>
85 void debug_init(void);
86 int debug(const char *, ...);
87 int vdebug(const char *, va_list);
88 int debug_on_stderr(void);
93 /* Now, make sure we have strerror() defined
99 #define strerror(errnum) sys_errlist[errnum]
101 #define strerror(errnum) NULL
105 /*----------------------------------------------------------------------------*/