46 #if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
56 static int prints(
char **out,
const char *
string,
int width,
int pad)
58 register int pc = 0, padchar =
' ';
62 register const char *ptr;
63 for (ptr =
string; *ptr; ++ptr)
73 for (; width > 0; --width) {
78 for (; *string; ++string) {
82 for (; width > 0; --width) {
91 #define PRINT_BUF_LEN 12
93 static int printi(
char **out,
int i,
int b,
int sg,
int width,
int pad,
int letbase)
97 register int t, neg = 0, pc = 0;
98 register unsigned int u =
i;
103 return prints(out, print_buf, width, pad);
106 if (sg && b == 10 && i < 0) {
117 t += letbase -
'0' - 10;
132 return pc +
prints(out, s, width, pad);
135 static int print(
char **out,
const char *format, va_list
args)
137 register int width,
pad;
141 for (; *format != 0; ++format) {
142 if (*format ==
'%') {
149 if (*format ==
'-') {
153 while (*format ==
'0') {
157 for (; *format >=
'0' && *format <=
'9'; ++format) {
159 width += *format -
'0';
161 if (*format ==
's') {
162 register char *s = (
char *)va_arg(args,
int);
163 pc +=
prints(out, s ? s :
"(null)", width, pad);
166 if (*format ==
'd') {
167 pc +=
printi(out, va_arg(args,
int), 10, 1, width, pad,
'a');
170 if (*format ==
'x') {
171 pc +=
printi(out, va_arg(args,
int), 16, 0, width, pad,
'a');
174 if (*format ==
'X') {
175 pc +=
printi(out, va_arg(args,
int), 16, 0, width, pad,
'A');
178 if (*format ==
'u') {
179 pc +=
printi(out, va_arg(args,
int), 10, 0, width, pad,
'a');
182 if (*format ==
'c') {
184 scr[0] = (char)va_arg(args,
int);
186 pc +=
prints(out, scr, width, pad);
205 va_start(args, format);
206 return print(0, format, args);
212 return print(0, format, args);
215 int sprintf(
char *out,
const char *format, ...)
219 va_start(args, format);
220 return print(&out, format, args);
228 return print(&_out, format, args);
237 va_start(args, format);
238 return print(&buf, format, args);
static int prints(char **out, const char *string, int width, int pad)
Main PiOS header to include all the compiled in PiOS options.
int vprintf(const char *format, va_list args)
int sprintf(char *out, const char *format,...)
static int print(char **out, const char *format, va_list args)
int32_t PIOS_COM_SendChar(uintptr_t com_id, char c)
static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)
static void printchar(char **str, int c)
int vsprintf(char *out, const char *format, va_list args)
int printf(const char *format,...)
int snprintf(char *buf, size_t count, const char *format,...)