1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/* NetworkManager -- Network link manager
*
* Ray Strode <rstrode@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
*/
#ifndef NM_UTILS_H
#define NM_UTILS_H
#include <glib.h>
#include <execinfo.h>
#define nm_print_backtrace() \
G_STMT_START \
{ \
void *_call_stack[512]; \
int _call_stack_size; \
char **_symbols; \
_call_stack_size = backtrace (_call_stack, \
G_N_ELEMENTS (_call_stack)); \
_symbols = backtrace_symbols (_call_stack, _call_stack_size); \
if (_symbols != NULL) \
{ \
int _i; \
_i = 0; \
g_critical ("traceback:\n"); \
while (_i < _call_stack_size) \
{ \
g_critical ("\t%s\n", _symbols[_i]); \
_i++; \
} \
free (_symbols); \
} \
} \
G_STMT_END
#define nm_get_timestamp(timestamp) \
G_STMT_START \
{ \
GTimeVal _tv; \
g_get_current_time (&_tv); \
*timestamp = (_tv.tv_sec * (1.0 * G_USEC_PER_SEC) + \
_tv.tv_usec) / G_USEC_PER_SEC; \
} \
G_STMT_END
#define nm_info(fmt, args...) \
G_STMT_START \
{ \
g_message ("<information>\t" fmt "\n", ##args); \
} G_STMT_END
#define nm_debug(fmt, args...) \
G_STMT_START \
{ \
gdouble _timestamp; \
nm_get_timestamp (&_timestamp); \
g_debug ("<debug info>\t[%f] %s (): " fmt "\n", _timestamp, \
G_GNUC_PRETTY_FUNCTION, ##args); \
} G_STMT_END
#define nm_warning(fmt, args...) \
G_STMT_START \
{ \
g_warning ("<WARNING>\t %s (): " fmt "\n", \
G_GNUC_PRETTY_FUNCTION, ##args); \
} G_STMT_END
#define nm_error(fmt, args...) \
G_STMT_START \
{ \
gdouble _timestamp; \
nm_get_timestamp (&_timestamp); \
g_critical ("<ERROR>\t[%f] %s (): " fmt "\n", _timestamp, \
G_GNUC_PRETTY_FUNCTION, ##args); \
nm_print_backtrace (); \
G_BREAKPOINT (); \
} G_STMT_END
gchar *nm_dbus_escape_object_path (const gchar *utf8_string);
gchar *nm_dbus_unescape_object_path (const gchar *object_path);
#endif /* NM_UTILS_H */
|