FreeRTOS port on GAP8/RISC-V
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
printf.c File Reference

Data Structures

struct  out_fct_wrap_type
 

Macros

#define PRINTF_NTOA_BUFFER_SIZE
 
#define PRINTF_FTOA_BUFFER_SIZE
 
#define PRINTF_SUPPORT_FLOAT
 
#define PRINTF_SUPPORT_EXPONENTIAL
 
#define PRINTF_DEFAULT_FLOAT_PRECISION
 
#define PRINTF_MAX_FLOAT
 
#define PRINTF_SUPPORT_LONG_LONG
 
#define PRINTF_SUPPORT_PTRDIFF_T
 
#define FLAGS_ZEROPAD
 
#define FLAGS_LEFT
 
#define FLAGS_PLUS
 
#define FLAGS_SPACE
 
#define FLAGS_HASH
 
#define FLAGS_UPPERCASE
 
#define FLAGS_CHAR
 
#define FLAGS_SHORT
 
#define FLAGS_LONG
 
#define FLAGS_LONG_LONG
 
#define FLAGS_PRECISION
 
#define FLAGS_ADAPT_EXP
 
#define PRINTF_SUPPORT_FLOAT
 
#define PRINTF_SUPPORT_EXPONENTIAL
 
#define PRINTF_SUPPORT_LONG_LONG
 
#define PRINTF_SUPPORT_PTRDIFF_T
 
#define FLAGS_ZEROPAD
 
#define FLAGS_LEFT
 
#define FLAGS_PLUS
 
#define FLAGS_SPACE
 
#define FLAGS_HASH
 
#define FLAGS_UPPERCASE
 
#define FLAGS_CHAR
 
#define FLAGS_SHORT
 
#define FLAGS_LONG
 
#define FLAGS_LONG_LONG
 
#define FLAGS_PRECISION
 
#define FLAGS_ADAPT_EXP
 

Typedefs

typedef void(* out_fct_type )(char character, void *buffer, size_t idx, size_t maxlen)
 

Functions

static void _out_buffer (char character, void *buffer, size_t idx, size_t maxlen)
 
static void _out_null (char character, void *buffer, size_t idx, size_t maxlen)
 
static void _out_char (char character, void *buffer, size_t idx, size_t maxlen)
 
static void _out_fct (char character, void *buffer, size_t idx, size_t maxlen)
 
static unsigned int _strnlen_s (const char *str, size_t maxsize)
 
static bool _is_digit (char ch)
 
static unsigned int _atoi (const char **str)
 
static size_t _out_rev (out_fct_type out, char *buffer, size_t idx, size_t maxlen, const char *buf, size_t len, unsigned int width, unsigned int flags)
 
static size_t _ntoa_format (out_fct_type out, char *buffer, size_t idx, size_t maxlen, char *buf, size_t len, bool negative, unsigned int base, unsigned int prec, unsigned int width, unsigned int flags)
 
static size_t _ntoa_long (out_fct_type out, char *buffer, size_t idx, size_t maxlen, unsigned long value, bool negative, unsigned long base, unsigned int prec, unsigned int width, unsigned int flags)
 
static size_t _ntoa_long_long (out_fct_type out, char *buffer, size_t idx, size_t maxlen, unsigned long long value, bool negative, unsigned long long base, unsigned int prec, unsigned int width, unsigned int flags)
 
static size_t _etoa (out_fct_type out, char *buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags)
 
static size_t _ftoa (out_fct_type out, char *buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags)
 
static int _vsnprintf (out_fct_type out, char *buffer, const size_t maxlen, const char *format, va_list va)
 
int printf_ (const char *format,...)
 
int sprintf_ (char *buffer, const char *format,...)
 
int snprintf_ (char *buffer, size_t count, const char *format,...)
 
int vprintf_ (const char *format, va_list va)
 
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

#define FLAGS_ADAPT_EXP

Referenced by _etoa(), and _vsnprintf().

#define FLAGS_ADAPT_EXP
#define FLAGS_CHAR

Referenced by _vsnprintf().

#define FLAGS_CHAR
#define FLAGS_HASH
#define FLAGS_HASH
#define FLAGS_LEFT
#define FLAGS_LEFT
#define FLAGS_LONG
#define FLAGS_LONG

Referenced by _vsnprintf().

#define FLAGS_LONG_LONG

Referenced by _vsnprintf().

#define FLAGS_LONG_LONG
#define FLAGS_PLUS

Referenced by _etoa(), _ftoa(), _ntoa_format(), and _vsnprintf().

#define FLAGS_PLUS
#define FLAGS_PRECISION
#define FLAGS_PRECISION
#define FLAGS_SHORT

Referenced by _vsnprintf().

#define FLAGS_SHORT
#define FLAGS_SPACE

Referenced by _ftoa(), _ntoa_format(), and _vsnprintf().

#define FLAGS_SPACE
#define FLAGS_UPPERCASE
#define FLAGS_UPPERCASE
#define FLAGS_ZEROPAD
#define FLAGS_ZEROPAD
#define PRINTF_DEFAULT_FLOAT_PRECISION

Referenced by _etoa(), and _ftoa().

#define PRINTF_FTOA_BUFFER_SIZE

Referenced by _ftoa().

#define PRINTF_MAX_FLOAT

Referenced by _ftoa().

#define PRINTF_NTOA_BUFFER_SIZE
#define PRINTF_SUPPORT_EXPONENTIAL
#define PRINTF_SUPPORT_EXPONENTIAL
#define PRINTF_SUPPORT_FLOAT
#define PRINTF_SUPPORT_FLOAT
#define PRINTF_SUPPORT_LONG_LONG
#define PRINTF_SUPPORT_LONG_LONG
#define PRINTF_SUPPORT_PTRDIFF_T
#define PRINTF_SUPPORT_PTRDIFF_T

Typedef Documentation

typedef void(* out_fct_type)(char character, void *buffer, size_t idx, size_t maxlen)

Function Documentation

static unsigned int _atoi ( const char **  str)
static

References _is_digit().

Referenced by _vsnprintf().

static size_t _etoa ( out_fct_type  out,
char *  buffer,
size_t  idx,
size_t  maxlen,
double  value,
unsigned int  prec,
unsigned int  width,
unsigned int  flags 
)
static
static size_t _ftoa ( out_fct_type  out,
char *  buffer,
size_t  idx,
size_t  maxlen,
double  value,
unsigned int  prec,
unsigned int  width,
unsigned int  flags 
)
static
static bool _is_digit ( char  ch)
inlinestatic

Referenced by _atoi(), and _vsnprintf().

static size_t _ntoa_format ( out_fct_type  out,
char *  buffer,
size_t  idx,
size_t  maxlen,
char *  buf,
size_t  len,
bool  negative,
unsigned int  base,
unsigned int  prec,
unsigned int  width,
unsigned int  flags 
)
static
static size_t _ntoa_long ( out_fct_type  out,
char *  buffer,
size_t  idx,
size_t  maxlen,
unsigned long  value,
bool  negative,
unsigned long  base,
unsigned int  prec,
unsigned int  width,
unsigned int  flags 
)
static
static size_t _ntoa_long_long ( out_fct_type  out,
char *  buffer,
size_t  idx,
size_t  maxlen,
unsigned long long  value,
bool  negative,
unsigned long long  base,
unsigned int  prec,
unsigned int  width,
unsigned int  flags 
)
static
static void _out_buffer ( char  character,
void *  buffer,
size_t  idx,
size_t  maxlen 
)
inlinestatic

Referenced by snprintf_(), sprintf_(), and vsnprintf_().

static void _out_char ( char  character,
void *  buffer,
size_t  idx,
size_t  maxlen 
)
inlinestatic

References _putchar().

Referenced by printf_(), and vprintf_().

static void _out_fct ( char  character,
void *  buffer,
size_t  idx,
size_t  maxlen 
)
inlinestatic

Referenced by fctprintf().

static void _out_null ( char  character,
void *  buffer,
size_t  idx,
size_t  maxlen 
)
inlinestatic

Referenced by _vsnprintf().

static size_t _out_rev ( out_fct_type  out,
char *  buffer,
size_t  idx,
size_t  maxlen,
const char *  buf,
size_t  len,
unsigned int  width,
unsigned int  flags 
)
static

References FLAGS_LEFT, and FLAGS_ZEROPAD.

Referenced by _ftoa(), and _ntoa_format().

static unsigned int _strnlen_s ( const char *  str,
size_t  maxsize 
)
inlinestatic

Referenced by _vsnprintf().

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
int printf_ ( const char *  format,
  ... 
)
int snprintf_ ( char *  buffer,
size_t  count,
const char *  format,
  ... 
)
int sprintf_ ( char *  buffer,
const char *  format,
  ... 
)
int vprintf_ ( const char *  format,
va_list  va 
)
int vsnprintf_ ( char *  buffer,
size_t  count,
const char *  format,
va_list  va 
)