libkdenetwork Library API Documentation

debug.h

00001 /* debug.h - interface to debugging functions
00002  *      Copyright (C) 2002 g10 Code GmbH
00003  *
00004  * This file is part of GPGME.
00005  *
00006  * GPGME is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * GPGME is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00019  */
00020 
00021 #ifndef DEBUG_H
00022 #define DEBUG_H
00023 
00024 /* Log the formatted string FORMAT at debug level LEVEL or higher.  */
00025 void _gpgme_debug (int level, const char *format, ...);
00026 
00027 /* Start a new debug line in *LINE, logged at level LEVEL or higher,
00028    and starting with the formatted string FORMAT.  */
00029 void _gpgme_debug_begin (void **helper, int level, const char *format, ...);
00030 
00031 /* Add the formatted string FORMAT to the debug line *LINE.  */
00032 void _gpgme_debug_add (void **helper, const char *format, ...);
00033 
00034 /* Finish construction of *LINE and send it to the debug output
00035    stream.  */
00036 void _gpgme_debug_end (void **helper);
00037 
00038 /* Indirect stringification, requires __STDC__ to work.  */
00039 #define STRINGIFY(v) #v
00040 #define XSTRINGIFY(v) STRINGIFY(v)
00041 
00042 #if 0
00043 /* Only works in GNU.  */
00044 #define DEBUG(fmt, arg...) \
00045   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__) , ##arg)
00046 #define DEBUG_BEGIN(hlp, lvl, fmt, arg...) \
00047   _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \
00048               XSTRINGIFY (__LINE__) , ##arg)
00049 #define DEBUG_ADD(hlp, fmt, arg...) \
00050   _gpgme_debug_add (&(hlp), fmt , ##arg)
00051 #define DEBUG_END(hlp, fmt, arg...) \
00052   _gpgme_debug_add (&(hlp), fmt , ##arg); \
00053   _gpgme_debug_end (&(hlp))
00054 #elif 0
00055 /* Only works in C99.  */
00056 #define DEBUG0(fmt) \
00057   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__))
00058 #define DEBUG(fmt, ...) \
00059   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), __VA_ARGS__)
00060 #define DEBUG_BEGIN(hlp, lvl, fmt) \
00061   _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \
00062               XSTRINGIFY (__LINE__))
00063 #define DEBUG_BEGINX(hlp, lvl, fmt, ...) \
00064   _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \
00065               XSTRINGIFY (__LINE__), __VA_ARGS__)
00066 #define DEBUG_ADD0(hlp, fmt) \
00067   _gpgme_debug_add (&(hlp), fmt)
00068 #define DEBUG_ADD(hlp, fmt, ...) \
00069   _gpgme_debug_add (&(hlp), fmt, __VA_ARGS__)
00070 #define DEBUG_END(hlp, fmt) \
00071   _gpgme_debug_add (&(hlp), fmt); \
00072   _gpgme_debug_end (&(hlp))
00073 #define DEBUG_ENDX(hlp, fmt, ...) \
00074   _gpgme_debug_add (&(hlp), fmt, __VA_ARGS__); \
00075   _gpgme_debug_end (&(hlp))
00076 #else
00077 /* This finally works everywhere, horror.  */
00078 #define DEBUG0(fmt) \
00079   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__))
00080 #define DEBUG1(fmt,a) \
00081   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a))
00082 #define DEBUG2(fmt,a,b) \
00083   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b))
00084 #define DEBUG3(fmt,a,b,c) \
00085   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \
00086         (c))
00087 #define DEBUG4(fmt,a,b,c,d) \
00088   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \
00089         (c), (d))
00090 #define DEBUG5(fmt,a,b,c,d,e) \
00091   _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \
00092         (c), (d), (e))
00093 #define DEBUG_BEGIN(hlp,lvl,fmt) \
00094   _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__))
00095 #define DEBUG_ADD0(hlp,fmt) \
00096   _gpgme_debug_add (&(hlp), fmt)
00097 #define DEBUG_ADD1(hlp,fmt,a) \
00098   _gpgme_debug_add (&(hlp), fmt, (a))
00099 #define DEBUG_ADD2(hlp,fmt,a,b) \
00100   _gpgme_debug_add (&(hlp), fmt, (a), (b))
00101 #define DEBUG_ADD3(hlp,fmt,a,b,c) \
00102   _gpgme_debug_add (&(hlp), fmt, (a), (b), (c))
00103 #define DEBUG_END(hlp,fmt) \
00104   _gpgme_debug_add (&(hlp), fmt); \
00105   _gpgme_debug_end (&(hlp))
00106 #endif
00107 
00108 #define DEBUG_ENABLED(hlp) (!!(hlp))
00109 
00110 #endif  /* DEBUG_H */
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Apr 4 04:44:05 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003