File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / sudo / include / error.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:26:49 2012 UTC (12 years, 1 month ago) by misho
Branches: sudo, MAIN
CVS tags: v1_8_5p1, HEAD
sudo 1.8.5p1

    1: /*
    2:  * Copyright (c) 2004, 2010 Todd C. Miller <Todd.Miller@courtesan.com>
    3:  *
    4:  * Permission to use, copy, modify, and distribute this software for any
    5:  * purpose with or without fee is hereby granted, provided that the above
    6:  * copyright notice and this permission notice appear in all copies.
    7:  *
    8:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    9:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   10:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   11:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   12:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   13:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   14:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   15:  */
   16: 
   17: #ifndef _SUDO_ERROR_H_
   18: #define	_SUDO_ERROR_H_
   19: 
   20: #include <stdarg.h>
   21: 
   22: /*
   23:  * We wrap error/errorx and warn/warnx so that the same output can
   24:  * go to the debug file, if there is one.
   25:  */
   26: #if defined(SUDO_ERROR_WRAP) && SUDO_ERROR_WRAP == 0
   27: # if defined(__GNUC__) && __GNUC__ == 2
   28: #  define error(rval, fmt...) error2((rval), (fmt))
   29: #  define errorx(rval, fmt...) errorx2((rval), (fmt))
   30: #  define warning(fmt...) warning2((fmt))
   31: #  define warningx(fmt...) warningx2((fmt))
   32: # else
   33: #  define error(rval, ...) error2((rval), __VA_ARGS__)
   34: #  define errorx(rval, ...) errorx2((rval), __VA_ARGS__)
   35: #  define warning(...) warning2(__VA_ARGS__)
   36: #  define warningx(...) warningx2(__VA_ARGS__)
   37: # endif /* __GNUC__ == 2 */
   38: #else /* SUDO_ERROR_WRAP */
   39: # if defined(__GNUC__) && __GNUC__ == 2
   40: #  define error(rval, fmt...) do {					       \
   41:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   42: 	SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
   43: 	(fmt));								       \
   44:     error2((rval), (fmt));						       \
   45: } while (0)
   46: #  define errorx(rval, fmt...) do {					       \
   47:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   48: 	SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, (fmt));	       \
   49:     errorx2((rval), (fmt));						       \
   50: } while (0)
   51: #  define warning(fmt...) do {						       \
   52:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   53: 	SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
   54: 	(fmt));								       \
   55:     warning2((fmt));							       \
   56: } while (0)
   57: #  define warningx(fmt...) do {						       \
   58:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   59: 	SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, (fmt));	       \
   60:     warningx2((fmt));							       \
   61: } while (0)
   62: # else
   63: #  define error(rval, ...) do {						       \
   64:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   65: 	SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
   66: 	__VA_ARGS__);							       \
   67:     error2((rval), __VA_ARGS__);					       \
   68: } while (0)
   69: #  define errorx(rval, ...) do {					       \
   70:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   71: 	SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, __VA_ARGS__);    \
   72:     errorx2((rval), __VA_ARGS__);					       \
   73: } while (0)
   74: #  define warning(...) do {						       \
   75:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   76: 	SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys,  \
   77: 	__VA_ARGS__);							       \
   78:     warning2(__VA_ARGS__);						       \
   79: } while (0)
   80: #  define warningx(...) do {						       \
   81:     sudo_debug_printf2(__func__, __FILE__, __LINE__,			       \
   82: 	SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|sudo_debug_subsys, __VA_ARGS__);     \
   83:     warningx2(__VA_ARGS__);						       \
   84: } while (0)
   85: # endif /* __GNUC__ == 2 */
   86: #endif /* SUDO_ERROR_WRAP */
   87: 
   88: void	error2(int, const char *, ...)  __printflike(2, 3) __attribute__((__noreturn__));
   89: void	errorx2(int, const char *, ...)  __printflike(2, 3) __attribute__((__noreturn__));
   90: void	warning2(const char *, ...) __printflike(1, 2);
   91: void	warningx2(const char *, ...) __printflike(1, 2);
   92: 
   93: #endif /* _SUDO_ERROR_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>