printf.h File Reference
#include <stdarg.h>
#include <stddef.h>

Go to the source code of this file.

Macros

#define printf   printf_
 
#define sprintf   sprintf_
 
#define snprintf   snprintf_
 
#define vsnprintf   vsnprintf_
 
#define vprintf   vprintf_
 

Functions

void _putchar (char character)
 
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 vprintf_ (const char *format, va_list va)
 
int fctprintf (void(*out)(char character, void *arg), void *arg, const char *format,...)
 
int fctvprintf (void(*out)(char character, void *arg), void *arg, const char *format, va_list va)
 

Macro Definition Documentation

◆ printf

◆ snprintf

#define snprintf   snprintf_

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
vaA value identifying a variable arguments list
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
Examples
acc_processing_helpers.c, example_control_helper.c, example_service.c, example_service_low_power_sensor_disable.c, example_service_low_power_sensor_hibernate.c, example_service_multiple_configurations.c, example_service_sensor_disable.c, example_service_sensor_hibernate.c, example_service_sensor_off.c, and example_service_subsweeps.c.

Definition at line 84 of file printf.h.

◆ sprintf

#define sprintf   sprintf_

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

Definition at line 71 of file printf.h.

◆ vprintf

#define vprintf   vprintf_

Tiny vprintf implementation

Parameters
formatA string that specifies the format of the output
vaA value identifying a variable arguments list
Returns
The number of characters that are WRITTEN into the buffer, not counting the terminating null character

Definition at line 96 of file printf.h.

◆ vsnprintf

#define vsnprintf   vsnprintf_

Definition at line 85 of file printf.h.

Function Documentation

◆ _putchar()

void _putchar ( char  character)

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

◆ 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

Definition at line 905 of file printf.c.

◆ fctvprintf()

int fctvprintf ( void(*)(char character, void *arg)  out,
void *  arg,
const char *  format,
va_list  va 
)

vprintf with output function You may use this as dynamic alternative to vprintf() 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
vaA value identifying a variable arguments list
Returns
The number of characters that are sent to the output function, not counting the terminating null character

Definition at line 915 of file printf.c.

◆ printf_()

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

Definition at line 861 of file printf.c.

◆ snprintf_()

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

Definition at line 882 of file printf.c.

◆ sprintf_()

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

Definition at line 872 of file printf.c.

◆ vprintf_()

int vprintf_ ( const char *  format,
va_list  va 
)

Definition at line 892 of file printf.c.

◆ vsnprintf_()

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

Definition at line 899 of file printf.c.