Add checks in "rd_add_field_to_tree()" for the length of the field.
[obnox/wireshark/wip.git] / epan / gdebug.h
1 /* gdebug.h
2  *
3  * Useful macro for use during development.
4  *
5  * $Id$
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@zing.org>
9  * Copyright 2001 Gerald Combs
10  *
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef GDEBUG_H
28 #define GDEBUG_H
29
30 #ifdef __GNUC__
31
32 /* The last "%s" in g_log() is for the empty-string arg that
33  * g_debug() always passes. */
34 #define _g_debug(format, args...) \
35         g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
36                         "%s():%s +%d: " format "%s", \
37                         G_GNUC_PRETTY_FUNCTION, __FILE__, __LINE__, ##args) ;
38
39 /* Always pass a empty-string argument to _g_debug() so that g_debug will always
40  * have at least 2 arguments. If user passes 1 arg to g_debug() (i.e., only
41  * a format string), _g_debug() will still work. */
42 #define g_debug(args...) \
43         _g_debug(args, "")
44
45
46 #else
47
48 #include <stdio.h>
49 #include <stdarg.h>
50
51 static void
52 g_debug(const char* format, ...)
53 {
54         va_list args;
55         va_start(args, format);
56         vfprintf(stderr, format, args);
57         va_end(args);
58 }
59
60 #endif /* __GNUC__ */
61
62 #endif /* GDEBUG_H */