mbgtools-lx  4.2.8
mbgddmsg.h
Go to the documentation of this file.
1 
2 /**************************************************************************
3  *
4  * $Id: mbgddmsg.h 1.15 2018/11/22 14:17:15 martin TRASH $
5  *
6  * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
7  *
8  * Description:
9  * Definitions and function prototypes to deal with messages
10  * generated by kernel mode drivers. Some type of messages are
11  * always generated, others are only generated ibn DEBUG builds
12  * and are defined void in release builds.
13  *
14  * -----------------------------------------------------------------------
15  * $Log: mbgddmsg.h $
16  * Revision 1.15 2018/11/22 14:17:15 martin
17  * Support QNX target.
18  * Make sure DEBUG_MSG_SLEEP is always defined but evaluates
19  * to 'true' or 'false'.
20  * Debug logging functions now expect a flag that controls if
21  * a log message is to be generated, and a severity code
22  * (error, warning, info, ...).
23  * Revision 1.14 2018/09/21 14:55:14 martin
24  * Updated mbg_kdd_vsnprintf() for some targets.
25  * Removed obsolete debug symbols.
26  * Revision 1.13 2018/06/25 12:13:49 martin
27  * Unified implementation of kernel driver messages.
28  * Support MBG_TGT_NO_TGT.
29  * Conditionally support DEBUG_MSG_SLEEP.
30  * Improved support for most target systems.
31  * Added inline function mbg_kdd_vsnprintf() for Linux and Windows.
32  * New Meinberg-specific debug messages.
33  * mbg_kdd_msg() now also takes a log level.
34  * Moved some debug message macros here.
35  * Added _mbgddmsg_8().
36  * Revision 1.12 2017/08/10 13:52:39 martin
37  * Distinguish targets in more detail.
38  * Revision 1.11 2017/07/05 14:31:23 martin
39  * Added _mbg_kdd_msg...() macros.
40  * Code cleanup.
41  * Updated function prototypes.
42  * Revision 1.10 2012/10/02 18:33:21Z martin
43  * Support for *BSD.
44  * Also enable debug msgs if MBG_DEBUG is defined.
45  * Revision 1.8 2009/04/22 09:54:55 martin
46  * Include mbg_tgt.h also if building without DEBUG.
47  * Revision 1.7 2009/03/19 15:22:54 martin
48  * Cleaned up debug levels.
49  * Revision 1.6 2008/12/05 13:31:47 martin
50  * Use do {} while (0) syntax to avoid potential syntax problems.
51  * Added _mbgddmsg_7().
52  * Revision 1.5 2006/06/19 15:26:19 martin
53  * Fixed compiler warnings if DEBUG or DBG not defined.
54  * Revision 1.4 2002/06/12 12:25:54 martin
55  * Bug fix: check for target MBG_TGT_WIN32 instead of MBG_TGT_W32.
56  * Revision 1.3 2002/02/19 14:50:48Z MARTIN
57  * Added support for Win32.
58  * Revision 1.2 2002/02/19 09:28:00 MARTIN
59  * Use new header mbg_tgt.h to check the target environment.
60  * Revision 1.1 2001/03/02 13:51:23 MARTIN
61  * Initial revision
62  *
63  **************************************************************************/
64 
65 #ifndef _MBGDDMSG_H
66 #define _MBGDDMSG_H
67 
68 
69 /* Other headers to be included */
70 
71 #include <mbg_tgt.h>
72 
73 #if defined( MBG_TGT_NETWARE )
74  #include <conio.h>
75 #elif defined( MBG_TGT_OS2 )
76  #include <iprintf.h>
77 #elif defined( MBG_TGT_WIN32 )
78  #include <ntddk.h>
79  #include <stdio.h>
80  #include <stdarg.h>
81 #elif defined( MBG_TGT_LINUX )
82  #include <linux/module.h>
83  #include <linux/version.h>
84 #elif defined( MBG_TGT_FREEBSD )
85  #include <sys/types.h>
86  #include <sys/systm.h>
87  #include <machine/stdarg.h>
88 #elif defined( MBG_TGT_NETBSD )
89  #include <sys/param.h> // for __NetBSD_Version__, __NetBSD_Prereq__
90  #if __NetBSD_Prereq__(7,0,0) // NetBSD >= 7.0
91  #include <sys/stdarg.h> // works at least for NetBSD 7.1
92  #else
93  #include <machine/stdarg.h> // works at least for NetBSD 5.1
94  #endif
95 #elif defined( MBG_TGT_QNX )
96  #include <stdio.h>
97 #elif defined( MBG_TGT_DOS )
98  #include <stdio.h>
99  #include <stdarg.h>
100 #endif
101 
102 #include <str_util.h>
103 
104 
105 #ifdef _MBGDDMSG
106  #define _ext
107  #define _DO_INIT
108 #else
109  #define _ext extern
110 #endif
111 
112 
113 /* Start of header body */
114 
115 #if defined( _USE_PACK )
116  #pragma pack( 1 ) // set byte alignment
117  #define _USING_BYTE_ALIGNMENT
118 #endif
119 
120 #ifdef __cplusplus
121 extern "C" {
122 #endif
123 
124 #if !defined( DEBUG_MSG_SLEEP )
125  #define DEBUG_MSG_SLEEP 0
126 #endif
127 
128 #if DEBUG_MSG_SLEEP
129  _ext int debug_msg_sleep
130  #ifdef _DO_INIT
132  #endif
133  ;
134 #endif
135 
136 
137 #if defined( MBG_TGT_WIN32 )
138 
139  #define USE_MBG_KDD_MSG 1
140 
141 #elif defined( MBG_TGT_LINUX )
142 
143  #define USE_MBG_KDD_MSG 1
144 
145 #elif defined( MBG_TGT_FREEBSD )
146 
147  #if defined( _VA_LIST_DECLARED ) // at least since FreeBSD 8.2
148 
149  #define USE_MBG_KDD_MSG 1
150 
151  #else
152 
153  #define _printf printf
154  #define _hd
155  #define _tl "\n"
156 
157  #endif
158 
159 #elif defined( MBG_TGT_NETBSD )
160 
161  #if defined( __VA_LIST_DECLARED ) // at least NetBSD 7.1
162 
163  #define USE_MBG_KDD_MSG 1
164  #define va_list __va_list
165 
166  #elif defined( _BSD_VA_LIST_ )
167 
168  #define USE_MBG_KDD_MSG 1
169 
170  #else
171 
172  #define _printf printf
173  #define _hd
174  #define _tl "\n"
175 
176  #endif
177 
178 #elif defined( MBG_TGT_NETWARE )
179 
180  #define _printf ConsolePrintf
181  #define _hd
182  #define _tl "\n"
183 
184 #elif defined( MBG_TGT_OS2 )
185 
186  #define _printf iprintf
187  #define _hd
188  #define _tl "\n"
189 
190 #elif defined( MBG_TGT_QNX ) // at least QNX 6.x (Neutrino)
191 
192  #define USE_MBG_KDD_MSG 1
193 
194 #elif defined( MBG_TGT_DOS )
195 
196  #define USE_MBG_KDD_MSG 1
197 
198 #else // other targets ...
199 
200  #if !defined( _printf )
201  #define _printf printf
202  #endif
203 
204  #if !defined( _hd )
205  #define _hd
206  #endif
207 
208  #if !defined( _tl )
209  #define _tl "\n"
210  #endif
211 
212 #endif
213 
214 
215 #if !defined( USE_MBG_KDD_MSG )
216  #define USE_MBG_KDD_MSG 0
217 #endif
218 
219 
221 {
228 };
229 
230 
231 #if USE_MBG_KDD_MSG
232 
233  #define _mbg_kdd_msg_0( _lvl, _fmt ) \
234  mbg_kdd_msg( _lvl, _fmt )
235 
236  #define _mbg_kdd_msg_1( _lvl, _fmt, _p1 ) \
237  mbg_kdd_msg( _lvl, _fmt, (_p1) )
238 
239  #define _mbg_kdd_msg_2( _lvl, _fmt, _p1, _p2 ) \
240  mbg_kdd_msg( _lvl, _fmt, (_p1), (_p2) )
241 
242  #define _mbg_kdd_msg_3( _lvl, _fmt, _p1, _p2, _p3 ) \
243  mbg_kdd_msg( _lvl, _fmt, (_p1), (_p2), (_p3) )
244 
245  #define _mbg_kdd_msg_4( _lvl, _fmt, _p1, _p2, _p3, _p4 ) \
246  mbg_kdd_msg( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4) )
247 
248  #define _mbg_kdd_msg_5( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5 ) \
249  mbg_kdd_msg( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5) )
250 
251  #define _mbg_kdd_msg_6( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6 ) \
252  mbg_kdd_msg( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6) )
253 
254  #define _mbg_kdd_msg_7( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) \
255  mbg_kdd_msg( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6), (_p7) )
256 
257  #define _mbg_kdd_msg_8( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) \
258  mbg_kdd_msg( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6), (_p7), (_p8) )
259 
260 #else
261 
262  #define _mbg_kdd_msg_0( _lvl, _fmt ) \
263  do { \
264  _printf( _hd _fmt _tl ); \
265  } while ( 0 )
266 
267  #define _mbg_kdd_msg_1( _lvl, _fmt, _p1 ) \
268  do { \
269  _printf( _hd _fmt _tl, (_p1) ); \
270  } while ( 0 )
271 
272  #define _mbg_kdd_msg_2( _lvl, _fmt, _p1, _p2 ) \
273  do { \
274  _printf( _hd _fmt _tl, (_p1), (_p2) ); \
275  } while ( 0 )
276 
277  #define _mbg_kdd_msg_3( _lvl, _fmt, _p1, _p2, _p3 ) \
278  do { \
279  _printf( _hd _fmt _tl, (_p1), (_p2), (_p3) ); \
280  } while ( 0 )
281 
282  #define _mbg_kdd_msg_4( _lvl, _fmt, _p1, _p2, _p3, _p4 ) \
283  do { \
284  _printf( _hd _fmt _tl, (_p1), (_p2), (_p3), (_p4) ); \
285  } while ( 0 )
286 
287  #define _mbg_kdd_msg_5( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5 ) \
288  do { \
289  _printf( _hd _fmt _tl, (_p1), (_p2), (_p3), (_p4), (_p5) ); \
290  } while ( 0 )
291 
292  #define _mbg_kdd_msg_6( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6 ) \
293  do { \
294  _printf( _hd _fmt _tl, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6) ); \
295  } while ( 0 )
296 
297  #define _mbg_kdd_msg_7( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) \
298  do { \
299  _printf( _hd _fmt _tl, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6), (_p7) ); \
300  } while ( 0 )
301 
302  #define _mbg_kdd_msg_8( _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) \
303  do { \
304  _printf( _hd _fmt _tl, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6), (_p7), (_p8) ); \
305  } while ( 0 )
306 
307 #endif
308 
309 
310 #if defined( DEBUG ) || defined( MBG_DEBUG ) || ( defined( DBG ) && DBG )
311 
312 #define _mbgddmsg_0( _f, _lvl, _fmt ) \
313 do { \
314  if ( (_f) ) \
315  { _mbg_kdd_msg_0( _lvl, _fmt ); } \
316 } while ( 0 )
317 
318 #define _mbgddmsg_1( _f, _lvl, _fmt, _p1 ) \
319 do { \
320  if ( (_f) ) \
321  { _mbg_kdd_msg_1( _lvl, _fmt, (_p1) ); } \
322 } while ( 0 )
323 
324 #define _mbgddmsg_2( _f, _lvl, _fmt, _p1, _p2 ) \
325 do { \
326  if ( (_f) ) \
327  { _mbg_kdd_msg_2( _lvl, _fmt, (_p1), (_p2) ); } \
328 } while ( 0 )
329 
330 #define _mbgddmsg_3( _f, _lvl, _fmt, _p1, _p2, _p3 ) \
331 do { \
332  if ( (_f) ) \
333  { _mbg_kdd_msg_3( _lvl, _fmt, (_p1), (_p2), (_p3) ); } \
334 } while ( 0 )
335 
336 #define _mbgddmsg_4( _f, _lvl, _fmt, _p1, _p2, _p3, _p4 ) \
337 do { \
338  if ( (_f) ) \
339  { _mbg_kdd_msg_4( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4) ); } \
340 } while ( 0 )
341 
342 #define _mbgddmsg_5( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5 ) \
343 do { \
344  if ( (_f) ) \
345  { _mbg_kdd_msg_5( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5) ); } \
346 } while ( 0 )
347 
348 #define _mbgddmsg_6( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6 ) \
349 do { \
350  if ( (_f) ) \
351  { _mbg_kdd_msg_6( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6) ); } \
352 } while ( 0 )
353 
354 #define _mbgddmsg_7( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) \
355 do { \
356  if ( (_f) ) \
357  { _mbg_kdd_msg_7( _f, _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6), (_p7) ); } \
358 } while ( 0 )
359 
360 #define _mbgddmsg_8( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) \
361 do { \
362  if ( (_f) ) \
363  { _mbg_kdd_msg_8( _lvl, _fmt, (_p1), (_p2), (_p3), (_p4), (_p5), (_p6), (_p7), (_p8) ); } \
364 } while ( 0 )
365 
366 
367 
368 #else
369 
370  #define _mbgddmsg_0( _f, _lvl, _fmt ) _nop_macro_fnc()
371  #define _mbgddmsg_1( _f, _lvl, _fmt, _p1 ) _nop_macro_fnc()
372  #define _mbgddmsg_2( _f, _lvl, _fmt, _p1, _p2 ) _nop_macro_fnc()
373  #define _mbgddmsg_3( _f, _lvl, _fmt, _p1, _p2, _p3 ) _nop_macro_fnc()
374  #define _mbgddmsg_4( _f, _lvl, _fmt, _p1, _p2, _p3, _p4 ) _nop_macro_fnc()
375  #define _mbgddmsg_5( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5 ) _nop_macro_fnc()
376  #define _mbgddmsg_6( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6 ) _nop_macro_fnc()
377  #define _mbgddmsg_7( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7 ) _nop_macro_fnc()
378  #define _mbgddmsg_8( _f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8 ) _nop_macro_fnc()
379 
380 #endif
381 
382 
383 
384 #define MBG_LOG_FMT_ENTERING "Entering \"%s\""
385 #define MBG_LOG_FMT_ENTERING_STR MBG_LOG_FMT_ENTERING " %s"
386 
387 #define MBG_LOG_FMT_LEAVING "Leaving \"%s\""
388 #define MBG_LOG_FMT_LEAVING_STR MBG_LOG_FMT_LEAVING " %s"
389 #define MBG_LOG_FMT_LEAVING_SUCCESS MBG_LOG_FMT_LEAVING " success"
390 #define MBG_LOG_FMT_LEAVING_ERR MBG_LOG_FMT_LEAVING " err"
391 #define MBG_LOG_FMT_LEAVING_ERR_MBG MBG_LOG_FMT_LEAVING " err %i: %s"
392 #define MBG_LOG_FMT_LEAVING_ERR_DEC MBG_LOG_FMT_LEAVING " err %li"
393 #define MBG_LOG_FMT_LEAVING_ERR_HEX MBG_LOG_FMT_LEAVING " err 0x%08lX"
394 
395 
396 
397 #if USE_MBG_KDD_MSG && defined( DEBUG ) && DEBUG
398 
399  #define _mbgddmsg_fnc_entry() \
400  mbg_kdd_msg( MBG_LOG_DEBUG, MBG_LOG_FMT_ENTERING, \
401  __func__ )
402 
403  #define _mbgddmsg_fnc_entry_str( _s ) \
404  mbg_kdd_msg( MBG_LOG_DEBUG, MBG_LOG_FMT_ENTERING_STR, \
405  __func__, (_s) )
406 
407  #define _mbgddmsg_fnc_exit() \
408  mbg_kdd_msg( MBG_LOG_DEBUG, MBG_LOG_FMT_LEAVING, \
409  __func__ )
410 
411  #define _mbgddmsg_fnc_exit_str( _s ) \
412  mbg_kdd_msg( MBG_LOG_DEBUG, MBG_LOG_FMT_LEAVING_STR, \
413  __func__, (_s) )
414 
415  #define _mbgddmsg_fnc_exit_success() \
416  mbg_kdd_msg( MBG_LOG_DEBUG, MBG_LOG_FMT_LEAVING_SUCCESS, \
417  __func__ )
418 
419  #define _mbgddmsg_fnc_exit_err() \
420  mbg_kdd_msg( MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR, \
421  __func__ )
422 
423 
424  #define _mbgddmsg_fnc_exit_err_mbg( _mbg_errno ) \
425  mbg_kdd_msg( MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR_MBG, \
426  __func__, _mbg_errno, mbg_strerror( _mbg_errno ) )
427 
428  #define _mbgddmsg_fnc_exit_err_dec( _errnum ) \
429  mbg_kdd_msg( MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR_DEC, \
430  __func__, (long) (_errnum) )
431 
432  #define _mbgddmsg_fnc_exit_err_hex( _errnum ) \
433  mbg_kdd_msg( MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR_HEX, \
434  __func__, (ulong) (_errnum) )
435 
436 
437  #define _mbgddmsg_fnc_exit_chk_mbg_rc( _rc ) \
438  do \
439  { \
440  if ( mbg_rc_is_success( _rc ) ) \
441  _mbgddmsg_fnc_exit_success(); \
442  else \
443  _mbgddmsg_fnc_exit_err_mbg( _rc ); \
444  } while ( 0 )
445 
446  #define _mbgddmsg_fnc_exit_chk_rc( _rc ) \
447  do \
448  { \
449  if ( mbg_rc_is_success( _rc ) ) \
450  _mbgddmsg_fnc_exit_success(); \
451  else \
452  _mbgddmsg_fnc_exit_err_dec( _rc ); \
453  } while ( 0 )
454 
455  #if defined( MBG_TGT_WIN32 )
456 
457  #define _mbgddmsg_fnc_exit_chk_st( _st ) \
458  do \
459  { \
460  if ( NT_SUCCESS( (_st) ) ) \
461  _mbgddmsg_fnc_exit_success(); \
462  else \
463  _mbgddmsg_fnc_exit_err_hex( _st ); \
464  } while ( 0 )
465 
466  #endif
467 
468 #else
469 
470  // Building with or without debug is handled
471  // via the definition of the _mbgddmsg_* macros.
472 
473  #define _mbgddmsg_fnc_entry() \
474  _mbgddmsg_1( DEBUG, MBG_LOG_DEBUG, MBG_LOG_FMT_ENTERING, \
475  __func__ )
476 
477  #define _mbgddmsg_fnc_entry_str( _s ) \
478  _mbgddmsg_2( DEBUG, MBG_LOG_DEBUG, MBG_LOG_FMT_ENTERING_STR, \
479  __func__, (_s) )
480 
481  #define _mbgddmsg_fnc_exit() \
482  _mbgddmsg_1( DEBUG, MBG_LOG_DEBUG, MBG_LOG_FMT_LEAVING, \
483  __func__ )
484 
485  #define _mbgddmsg_fnc_exit_str( _s ) \
486  _mbgddmsg_2( DEBUG, MBG_LOG_DEBUG, MBG_LOG_FMT_LEAVING_STR, \
487  __func__, (_s) )
488 
489  #define _mbgddmsg_fnc_exit_success() \
490  _mbgddmsg_1( DEBUG, MBG_LOG_DEBUG, MBG_LOG_FMT_LEAVING_SUCCESS, \
491  __func__ )
492 
493  #define _mbgddmsg_fnc_exit_err() \
494  _mbgddmsg_1( DEBUG, MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR_DEC, \
495  __func__ )
496 
497  #define _mbgddmsg_fnc_exit_err_mbg( _mbg_errno ) \
498  _mbgddmsg_3( DEBUG, MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR_MBG, \
499  __func__, _mbg_errno, mbg_strerror( _mbg_errno ) )
500 
501  #define _mbgddmsg_fnc_exit_err_dec( _errnum ) \
502  _mbgddmsg_2( DEBUG, MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR_DEC, \
503  __func__, (long) (_errnum) )
504 
505  #define _mbgddmsg_fnc_exit_err_hex( _errnum ) \
506  _mbgddmsg_2( DEBUG, MBG_LOG_ERR, MBG_LOG_FMT_LEAVING_ERR_HEX, \
507  __func__, (ulong) (_errnum) )
508 
509  #define _mbgddmsg_fnc_exit_chk_mbg_rc( _rc ) \
510  _nop_macro_fnc() // TODO
511 
512  #define _mbgddmsg_fnc_exit_chk_rc( _rc ) \
513  _nop_macro_fnc() // TODO
514 
515  #define _mbgddmsg_fnc_exit_chk_st( _st ) \
516  _nop_macro_fnc() // TODO
517 
518 #endif
519 
520 
521 
522 #if USE_MBG_KDD_MSG
523 
524 static __mbg_inline /*HDR*/
525 __attribute__( ( format( printf, 3, 0 ) ) )
526 int mbg_kdd_vsnprintf( char *s, size_t max_len, const char *fmt, va_list args )
527 {
528  size_t n;
529 
530  if ( !mbg_buffer_specs_valid( s, max_len ) )
531  return 0; // nothing to do anyway
532 
533  #if defined( MBG_TGT_WIN32 )
534 
535  n = _vsnprintf( s, max_len, fmt, args );
536 
537  #elif defined( MBG_TGT_LINUX )
538 
539  n = vscnprintf( s, max_len, fmt, args );
540 
541  #elif defined( MBG_TGT_BSD )
542 
543  n = vsnprintf( s, max_len, fmt, args );
544 
545  #elif defined( MBG_TGT_QNX )
546 
547  n = vsnprintf_safe( s, max_len, fmt, args );
548 
549  #elif defined( MBG_TGT_DOS )
550 
551  n = vsnprintf_safe( s, max_len, fmt, args );
552 
553  #elif defined( MBG_TGT_NO_TGT )
554 
555  n = vsnprintf_no_tgt( s, max_len, fmt, args );
556 
557  #else
558 
559  #error mbg_kdd_vsnprintf() needs to be implemented for this target.
560 
561  #endif
562 
563  // Do some common checks to avoid subsequent buffer overflows, etc.
564  return mbg_chk_snprint_results( n, s, max_len );
565 
566 } // mbg_kdd_vsnprintf
567 
568 #endif // USE_MBG_KDD_MSG
569 
570 
571 
572 /* ----- function prototypes begin ----- */
573 
574 /* This section was generated automatically */
575 /* by MAKEHDR, do not remove the comments. */
576 
577  __attribute__( ( format( printf, 3, 4 ) ) ) int mbg_kdd_snprintf( char *buf, size_t size, const char *fmt, ... ) ;
578  __attribute__( ( format( printf, 2, 3 ) ) ) void mbg_kdd_msg( int lvl, const char *fmt, ... ) ;
579 
580 /* ----- function prototypes end ----- */
581 
582 #ifdef __cplusplus
583 }
584 #endif
585 
586 
587 #if defined( _USING_BYTE_ALIGNMENT )
588  #pragma pack() // set default alignment
589  #undef _USING_BYTE_ALIGNMENT
590 #endif
591 
592 /* End of header body */
593 
594 
595 #undef _ext
596 #undef _DO_INIT
597 
598 #endif /* _MBGDDMSG_H */
#define _ext
Definition: mbgddmsg.h:109
int mbg_kdd_snprintf(char *buf, size_t size, const char *fmt,...)
void mbg_kdd_msg(int lvl, const char *fmt,...)
int vsnprintf_safe(char *s, size_t max_len, const char *fmt, va_list args)
A portable, safe implementation of vsnprintf()
Definition: str_util.c:121
MBG_LOG_LEVELS
Definition: mbgddmsg.h:220
static __mbg_inline bool mbg_buffer_specs_valid(char *s, size_t max_len)
Check if the buffer plus size parameters passed to a function are valid.
Definition: str_util.h:88
static __mbg_inline int mbg_chk_snprint_results(size_t n, char *s, size_t max_len)
Check the results of an snprintf()-like function.
Definition: str_util.h:123
static __mbg_inline int mbg_kdd_vsnprintf(char *s, size_t max_len, const char *fmt, va_list args)
Definition: mbgddmsg.h:526
#define DEBUG_MSG_SLEEP
Definition: mbgddmsg.h:125