-
Notifications
You must be signed in to change notification settings - Fork 11
/
n_printf.c
66 lines (62 loc) · 1.94 KB
/
n_printf.c
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
/*!
* @file n_printf.c
*
* Written by Ray Ozzie and Blues Inc. team.
*
* Copyright (c) 2019 Blues Inc. MIT License. Use of this source code is
* governed by licenses granted by the copyright holder including that found in
* the
* <a href="https://github.com/blues/note-c/blob/master/LICENSE">LICENSE</a>
* file.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "n_lib.h"
// Externalized Hooks
//**************************************************************************/
/*!
@brief Hook for the calling platform's debug interface, if any.
*/
/**************************************************************************/
extern debugOutputFn hookDebugOutput;
//**************************************************************************/
/*!
@brief Write a formatted string to the debug output.
@param format A format string for output.
@param ... One or more values to interpolate into the format string.
*/
/**************************************************************************/
void NoteDebugf(const char *format, ...)
{
#ifndef NOTE_NODEBUG
if (hookDebugOutput != NULL) {
char line[256];
va_list args;
va_start(args, format);
vsnprintf(line, sizeof(line), format, args);
va_end(args);
hookDebugOutput(line);
}
#endif
}
//**************************************************************************/
/*!
@brief Write a formatted string to the debug output.
@param format A format string for output.
@param ... One or more values to interpolate into the format string.
@note. Do NOT use this in a memory-constrained environment (vsnprintf is large)
*/
/**************************************************************************/
#ifndef NOTE_LOMEM
bool NotePrintf(const char *format, ...)
{
char line[256];
va_list args;
va_start(args, format);
vsnprintf(line, sizeof(line), format, args);
va_end(args);
return NotePrint(line);
}
#endif