Pip
Architecture-dependent parts of Pip: MAL, IAL and boot
Macros | Functions
printf.h File Reference
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define _putchar   putchar
 

Functions

int printf (const char *format,...)
 
int sprintf (char *buffer, const char *format,...)
 
int snprintf (char *buffer, size_t count, const char *format,...)
 
int vsnprintf (char *buffer, size_t count, const char *format, va_list va)
 
int fctprintf (void(*out)(char character, void *arg), void *arg, const char *format,...)
 

Macro Definition Documentation

◆ _putchar

#define _putchar   putchar

Output a character to a custom device like UART, used by the printf() function This function is declared here only. You have to write your custom implementation somewhere

Parameters
characterCharacter to output

Function Documentation

◆ fctprintf()

int fctprintf ( void(*)(char character, void *arg)  out,
void *  arg,
const char *  format,
  ... 
)

printf with output function You may use this as dynamic alternative to printf() with its fixed _putchar() output

Parameters
outAn output function which takes one character and an argument pointer
argAn argument pointer for user data passed to output function
formatA string that specifies the format of the output
Returns
The number of characters that are sent to the output function, not counting the terminating null character

◆ printf()

int printf ( const char *  format,
  ... 
)

Tiny printf implementation You have to implement _putchar if you use printf()

Parameters
formatA string that specifies the format of the output
Returns
The number of characters that are written into the array, not counting the terminating null character

◆ snprintf()

int snprintf ( char *  buffer,
size_t  count,
const char *  format,
  ... 
)

Tiny snprintf/vsnprintf implementation

Parameters
bufferA pointer to the buffer where to store the formatted string
countThe maximum number of characters to store in the buffer, including a terminating null character
formatA string that specifies the format of the output
Returns
The number of characters that are WRITTEN into the buffer, not counting the terminating null character If the formatted string is truncated the buffer size (count) is returned

◆ sprintf()

int sprintf ( char *  buffer,
const char *  format,
  ... 
)

Tiny sprintf implementation Due to security reasons (buffer overflow) YOU SHOULD CONSIDER USING (V)SNPRINTF INSTEAD!

Parameters
bufferA pointer to the buffer where to store the formatted string. MUST be big enough to store the output!
formatA string that specifies the format of the output
Returns
The number of characters that are WRITTEN into the buffer, not counting the terminating null character

◆ vsnprintf()

int vsnprintf ( char *  buffer,
size_t  count,
const char *  format,
va_list  va 
)