1 |
zoff99 |
2 |
/**
|
2 |
zoff99 |
28 |
* ZANavi, Zoff Android Navigation system.
|
3 |
zoff99 |
40 |
* Copyright (C) 2012 - 2015 Zoff <zoff@zoff.cc>
|
4 |
zoff99 |
28 |
*
|
5 |
|
|
* This program is free software; you can redistribute it and/or
|
6 |
|
|
* modify it under the terms of the GNU General Public License
|
7 |
|
|
* version 2 as published by the Free Software Foundation.
|
8 |
|
|
*
|
9 |
|
|
* This program is distributed in the hope that it will be useful,
|
10 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
* GNU General Public License for more details.
|
13 |
|
|
*
|
14 |
|
|
* You should have received a copy of the GNU General Public License
|
15 |
|
|
* along with this program; if not, write to the
|
16 |
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17 |
|
|
* Boston, MA 02110-1301, USA.
|
18 |
|
|
*/
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
zoff99 |
2 |
* Navit, a modular navigation system.
|
22 |
|
|
* Copyright (C) 2005-2008 Navit Team
|
23 |
|
|
*
|
24 |
|
|
* This program is free software; you can redistribute it and/or
|
25 |
|
|
* modify it under the terms of the GNU Library General Public License
|
26 |
|
|
* version 2 as published by the Free Software Foundation.
|
27 |
|
|
*
|
28 |
|
|
* This program is distributed in the hope that it will be useful,
|
29 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
30 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
31 |
|
|
* GNU Library General Public License for more details.
|
32 |
|
|
*
|
33 |
|
|
* You should have received a copy of the GNU Library General Public
|
34 |
|
|
* License along with this program; if not, write to the
|
35 |
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
36 |
|
|
* Boston, MA 02110-1301, USA.
|
37 |
|
|
*/
|
38 |
|
|
|
39 |
|
|
#ifndef NAVIT_DEBUG_H
|
40 |
|
|
#define NAVIT_DEBUG_H
|
41 |
|
|
|
42 |
zoff99 |
28 |
/*
|
43 |
zoff99 |
31 |
*
|
44 |
|
|
*
|
45 |
|
|
*
|
46 |
zoff99 |
28 |
* define some debug stuff here
|
47 |
zoff99 |
31 |
*
|
48 |
|
|
*
|
49 |
|
|
*
|
50 |
zoff99 |
28 |
*/
|
51 |
zoff99 |
40 |
#define NAVIT_ATTR_SAFETY_CHECK 1 // leave this always ON !!
|
52 |
zoff99 |
28 |
// #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1
|
53 |
|
|
// #define NAVIT_SAY_DEBUG_PRINT 1
|
54 |
|
|
// #define NAVIT_MEASURE_TIME_DEBUG 1
|
55 |
zoff99 |
30 |
// #define NAVIT_CALLBACK_DEBUG_PRINT 1
|
56 |
zoff99 |
40 |
// #define NAVIT_ROUTING_DEBUG_PRINT 1
|
57 |
|
|
// #define NAVIT_GPS_DIRECTION_DAMPING 1
|
58 |
|
|
// #define NAVIT_FREE_TEXT_DEBUG_PRINT 1
|
59 |
|
|
// #define NAVIT_ANGLE_LIST_DEBUG_PRINT_DRAW 1
|
60 |
|
|
// #define NAVIT_ANGLE_LIST_DEBUG_PRINT_2 1
|
61 |
|
|
// #define NAVIT_ANGLE_LIST_DEBUG_PRINT_1 1
|
62 |
|
|
// #define NAVIT_DEBUG_BAREMETAL 1
|
63 |
zoff99 |
41 |
// #define NAVIT_DEBUG_COORD_LIST 1
|
64 |
zoff99 |
46 |
//
|
65 |
zoff99 |
40 |
#define NAVIT_DEBUG_SPEECH_POSITION 1
|
66 |
zoff99 |
31 |
//
|
67 |
zoff99 |
46 |
#define NAVIT_TRACKING_SHOW_REAL_GPS_POS 1
|
68 |
zoff99 |
41 |
#define NAVIT_NAVIGATION_REMOVE_DUPL_WAYS 1
|
69 |
zoff99 |
40 |
#define NAVIT_SHOW_ROUTE_ARROWS 1
|
70 |
|
|
#define NAVIT_CALC_ALLOWED_NEXT_WAYS 1
|
71 |
|
|
#define NAVIT_CALC_LANES 1
|
72 |
|
|
#define NAVIT_TRACKING_STICK_TO_ROUTE 1
|
73 |
|
|
//
|
74 |
zoff99 |
41 |
// #define NAVIT_ROUTE_DIJKSTRA_REVERSE 1
|
75 |
|
|
//
|
76 |
zoff99 |
31 |
// #define DEBUG_GLIB_MALLOC 1 // <-- does not work yet!
|
77 |
|
|
// #define DEBUG_GLIB_FREE 1
|
78 |
|
|
// #define DEBUG_GLIB_REALLY_FREE 1
|
79 |
|
|
// #define DEBUG_GLIB_MEM_FUNCTIONS 1
|
80 |
zoff99 |
40 |
|
81 |
|
|
extern int global_func_indent_counter;
|
82 |
|
|
extern const char* global_func_indent_spaces;
|
83 |
|
|
|
84 |
zoff99 |
31 |
/*
|
85 |
|
|
*
|
86 |
|
|
*
|
87 |
|
|
*
|
88 |
|
|
*
|
89 |
|
|
*
|
90 |
|
|
*
|
91 |
|
|
*
|
92 |
|
|
*/
|
93 |
zoff99 |
28 |
|
94 |
zoff99 |
2 |
#ifdef __cplusplus
|
95 |
zoff99 |
28 |
extern "C"
|
96 |
|
|
{
|
97 |
zoff99 |
2 |
#endif
|
98 |
|
|
|
99 |
|
|
#include <stdarg.h>
|
100 |
|
|
#include <string.h>
|
101 |
|
|
|
102 |
|
|
#ifdef _MSC_VER
|
103 |
|
|
#define __PRETTY_FUNCTION__ __FUNCTION__
|
104 |
|
|
#endif
|
105 |
|
|
|
106 |
zoff99 |
31 |
#ifndef HAVE_API_ANDROID
|
107 |
|
|
#define g_free_func g_free
|
108 |
|
|
#endif
|
109 |
|
|
|
110 |
zoff99 |
40 |
/** Possible debug levels (inspired by SLF4J). */
|
111 |
|
|
typedef enum {
|
112 |
|
|
/** Internal use only, do not use for logging. */
|
113 |
|
|
lvl_unset=-1,
|
114 |
zoff99 |
41 |
|
115 |
zoff99 |
40 |
/** Informational message. Should make sense to non-programmers. */
|
116 |
|
|
lvl_info, // = 0
|
117 |
zoff99 |
41 |
|
118 |
zoff99 |
40 |
/** Error: something did not work. */
|
119 |
|
|
lvl_error, // = 1
|
120 |
zoff99 |
41 |
|
121 |
zoff99 |
40 |
/** Warning: something may not have worked. */
|
122 |
|
|
lvl_warning, // = 2
|
123 |
zoff99 |
41 |
|
124 |
zoff99 |
40 |
/** Debug output: (almost) anything goes. */
|
125 |
|
|
lvl_debug // = 3
|
126 |
zoff99 |
41 |
|
127 |
zoff99 |
40 |
} dbg_level;
|
128 |
|
|
|
129 |
zoff99 |
41 |
|
130 |
zoff99 |
2 |
extern int debug_level;
|
131 |
zoff99 |
41 |
|
132 |
|
|
|
133 |
|
|
#ifdef _DEBUG_BUILD_
|
134 |
|
|
|
135 |
zoff99 |
2 |
#define dbg_str2(x) #x
|
136 |
|
|
#define dbg_str1(x) dbg_str2(x)
|
137 |
|
|
#define dbg_module dbg_str1(MODULE)
|
138 |
|
|
#define dbg(level,...) { if (debug_level >= level) debug_printf(level,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,__VA_ARGS__); }
|
139 |
zoff99 |
40 |
#define dbg_func(level,indent,...) { if (debug_level >= level) debug_printf_func(level,indent,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,__VA_ARGS__); }
|
140 |
zoff99 |
2 |
#define dbg_assert(expr) ((expr) ? (void) 0 : debug_assert_fail(dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),__FILE__,__LINE__,dbg_str1(expr)))
|
141 |
|
|
|
142 |
zoff99 |
41 |
#else
|
143 |
|
|
|
144 |
|
|
#define dbg_str2(x) #x
|
145 |
|
|
#define dbg_str1(x) #x
|
146 |
|
|
#define dbg_module dbg_str1(MODULE)
|
147 |
|
|
#define dbg(level,...) #level
|
148 |
|
|
#define dbg_func(level,indent,...) #level
|
149 |
|
|
#define dbg_assert(expr) ((expr) ? (void) 0 : (void) 0)
|
150 |
|
|
|
151 |
|
|
#endif
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
zoff99 |
31 |
//#ifdef DEBUG_MALLOC
|
156 |
|
|
// ----------------
|
157 |
|
|
//#undef g_new
|
158 |
|
|
//#undef g_new0
|
159 |
|
|
//#define g_new(type, size) (type *)debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
|
160 |
|
|
//#define g_new0(type, size) (type *)debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
|
161 |
|
|
//#define g_malloc(size) debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
|
162 |
|
|
//#define g_malloc0(size) debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
|
163 |
|
|
//#define g_realloc(ptr,size) debug_realloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr,(size))
|
164 |
|
|
//#define g_free(ptr) debug_free(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
|
165 |
|
|
//#define g_strdup(ptr) debug_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
|
166 |
|
|
//#define g_strdup_printf(fmt...) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,g_strdup_printf(fmt))
|
167 |
|
|
//#define graphics_icon_path(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,graphics_icon_path(x))
|
168 |
|
|
//#define dbg_guard(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
|
169 |
|
|
//#define g_free_func debug_free_func
|
170 |
|
|
// ----------------
|
171 |
|
|
//#else
|
172 |
|
|
// ----------------
|
173 |
|
|
//#define g_free_func g_free
|
174 |
zoff99 |
2 |
#define dbg_guard(x) x
|
175 |
zoff99 |
31 |
// ----------------
|
176 |
|
|
//#endif
|
177 |
zoff99 |
2 |
|
178 |
|
|
/* prototypes */
|
179 |
|
|
struct attr;
|
180 |
|
|
struct debug;
|
181 |
|
|
void debug_init(const char *program_name);
|
182 |
|
|
void debug_level_set(const char *name, int level);
|
183 |
|
|
struct debug *debug_new(struct attr *parent, struct attr **attrs);
|
184 |
|
|
int debug_level_get(const char *name);
|
185 |
|
|
void debug_vprintf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap);
|
186 |
zoff99 |
40 |
void debug_vprintf_func(int level, int indent, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap);
|
187 |
zoff99 |
2 |
void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
|
188 |
zoff99 |
40 |
void debug_printf_func(int level, int indent, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
|
189 |
zoff99 |
2 |
void debug_assert_fail(const char *module, const int mlen, const char *function, const int flen, const char *file, int line, const char *expr);
|
190 |
|
|
void debug_destroy(void);
|
191 |
|
|
void debug_set_logfile(const char *path);
|
192 |
|
|
void debug_dump_mallocs(void);
|
193 |
|
|
void *debug_malloc(const char *where, int line, const char *func, int size);
|
194 |
|
|
void *debug_malloc0(const char *where, int line, const char *func, int size);
|
195 |
|
|
char *debug_strdup(const char *where, int line, const char *func, const char *ptr);
|
196 |
|
|
char *debug_guard(const char *where, int line, const char *func, char *str);
|
197 |
|
|
void debug_free(const char *where, int line, const char *func, void *ptr);
|
198 |
|
|
void debug_free_func(void *ptr);
|
199 |
|
|
void debug_finished(void);
|
200 |
|
|
void *debug_realloc(const char *where, int line, const char *func, void *ptr, int size);
|
201 |
zoff99 |
40 |
void debug_get_timestamp_millis(long *ts_millis);
|
202 |
zoff99 |
2 |
/* end of prototypes */
|
203 |
|
|
|
204 |
zoff99 |
40 |
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
// printf -----------
|
213 |
|
|
|
214 |
|
|
#if 0
|
215 |
|
|
#include <stdarg.h>
|
216 |
|
|
|
217 |
|
|
#define NEED_ASPRINTF
|
218 |
|
|
#define NEED_ASNPRINTF
|
219 |
|
|
#define NEED_VASPRINTF
|
220 |
|
|
#define NEED_VASNPRINTF
|
221 |
|
|
|
222 |
|
|
/* #define PREFER_PORTABLE_SNPRINTF */
|
223 |
|
|
|
224 |
|
|
#include "snprintf.h"
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
#undef g_strdup_printf
|
228 |
|
|
#define g_strdup_printf(format, ...) g_strdup_printf_custom(format, __VA_ARGS__)
|
229 |
|
|
|
230 |
|
|
#undef g_strdup_vprintf
|
231 |
|
|
#define g_strdup_vprintf(format, args) g_strdup_vprintf_custom(format, args)
|
232 |
|
|
|
233 |
|
|
#undef g_vasprintf
|
234 |
|
|
#define g_vasprintf(str, format, args) g_vasprintf_custom(str, format, args)
|
235 |
|
|
|
236 |
|
|
// ---- BAD !!!! ----
|
237 |
|
|
typedef char gchar;
|
238 |
|
|
typedef short gshort;
|
239 |
|
|
typedef long glong;
|
240 |
|
|
typedef int gint;
|
241 |
|
|
typedef gint gboolean;
|
242 |
|
|
// ---- BAD !!!! ----
|
243 |
|
|
|
244 |
|
|
gchar* g_strdup_printf_custom(const gchar *format, ...);
|
245 |
|
|
gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
|
246 |
|
|
gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
|
247 |
|
|
#endif
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
#define HAVE_STDARG_H 1
|
251 |
|
|
//#define HAVE_STDDEF_H 1
|
252 |
|
|
//#define HAVE_STDINT_H 1
|
253 |
|
|
//#define HAVE_STDLIB_H 1
|
254 |
|
|
//#define HAVE_INTTYPES_H 1
|
255 |
|
|
//#define HAVE_LOCALE_H 1
|
256 |
|
|
//#define HAVE_LOCALECONV 1
|
257 |
|
|
//#define HAVE_LCONV_DECIMAL_POINT
|
258 |
|
|
//#define HAVE_LCONV_THOUSANDS_SEP
|
259 |
|
|
#define HAVE_LONG_DOUBLE 1
|
260 |
|
|
#define HAVE_LONG_LONG_INT 1
|
261 |
|
|
#define HAVE_UNSIGNED_LONG_LONG_INT 1
|
262 |
|
|
//#define HAVE_INTMAX_T
|
263 |
|
|
//#define HAVE_UINTMAX_T
|
264 |
|
|
//#define HAVE_UINTPTR_T
|
265 |
|
|
//#define HAVE_PTRDIFF_T
|
266 |
|
|
//#define HAVE_VA_COPY 1
|
267 |
|
|
//#define HAVE___VA_COPY 1
|
268 |
|
|
|
269 |
|
|
#ifndef NO_GTYPES_
|
270 |
|
|
|
271 |
|
|
#include <stdarg.h>
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
#undef g_strdup_printf
|
276 |
|
|
#define g_strdup_printf(format, ...) g_strdup_printf_custom(format, __VA_ARGS__)
|
277 |
|
|
|
278 |
|
|
#undef g_strdup_vprintf
|
279 |
|
|
#define g_strdup_vprintf(format, args) g_strdup_vprintf_custom(format, args)
|
280 |
|
|
|
281 |
|
|
#undef g_vasprintf
|
282 |
|
|
#define g_vasprintf(str, format, args) g_vasprintf_custom(str, format, args)
|
283 |
|
|
|
284 |
|
|
// ---- BAD !!!! ----
|
285 |
|
|
typedef char gchar;
|
286 |
|
|
typedef short gshort;
|
287 |
|
|
typedef long glong;
|
288 |
|
|
typedef int gint;
|
289 |
|
|
typedef gint gboolean;
|
290 |
|
|
// ---- BAD !!!! ----
|
291 |
|
|
|
292 |
|
|
gchar* g_strdup_printf_custom(const gchar *format, ...);
|
293 |
|
|
gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
|
294 |
|
|
gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
|
295 |
|
|
|
296 |
|
|
|
297 |
|
|
//#if !HAVE_VSNPRINTF
|
298 |
|
|
int rpl_vsnprintf(char *, size_t, const char *, va_list);
|
299 |
|
|
//#endif
|
300 |
|
|
//#if !HAVE_SNPRINTF
|
301 |
|
|
int rpl_snprintf(char *, size_t, const char *, ...);
|
302 |
|
|
//#endif
|
303 |
|
|
//#if !HAVE_VASPRINTF
|
304 |
|
|
int rpl_vasprintf(char **, const char *, va_list);
|
305 |
|
|
//#endif
|
306 |
|
|
//#if !HAVE_ASPRINTF
|
307 |
|
|
int rpl_asprintf(char **, const char *, ...);
|
308 |
|
|
|
309 |
|
|
#define vsnprintf rpl_vsnprintf
|
310 |
|
|
#define snprintf rpl_snprintf
|
311 |
|
|
#define vasprintf rpl_vasprintf
|
312 |
|
|
#define asprintf rpl_asprintf
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
#else
|
316 |
|
|
|
317 |
zoff99 |
46 |
#ifndef XXMAPTOOL
|
318 |
zoff99 |
40 |
#include <glib.h>
|
319 |
|
|
gchar* g_strdup_printf_custom(const gchar *format, ...);
|
320 |
|
|
gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
|
321 |
|
|
gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
|
322 |
zoff99 |
46 |
#else
|
323 |
|
|
#define g_strdup_printf_custom g_strdup_printf
|
324 |
|
|
#define g_strdup_vprintf_custom g_strdup_vprintf
|
325 |
|
|
#define g_vasprintf_custom g_vasprintf
|
326 |
|
|
#endif
|
327 |
zoff99 |
40 |
|
328 |
zoff99 |
46 |
|
329 |
zoff99 |
40 |
#endif
|
330 |
|
|
|
331 |
|
|
// printf -----------
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
zoff99 |
2 |
#ifdef __cplusplus
|
342 |
|
|
}
|
343 |
|
|
#endif
|
344 |
|
|
|
345 |
|
|
#endif
|
346 |
|
|
|