print.c File Reference

printing utilities to replace the large printf from the standard library (code) More...

Go to the source code of this file.

## Functions

static void | print_printed (size_t *length, size_t printed)
| add printed length to total printed length, and sets error if maximum size is exceeded More...
static size_t | print_char (char **str, size_t *size, char c)
| print character More...
static size_t | print_string (char **str, size_t *size, const char *s)
| print string More...
static size_t | print_unsigned (char **str, size_t *size, uint64_t u, uint32_t padding, bool sign)
| print unsigned integer More...
static size_t | print_signed (char **str, size_t *size, int64_t d, uint32_t padding, bool sign)
| print signed integer More...
static size_t | print_float (char **str, size_t *size, double f, uint32_t padding, uint32_t fractional, bool sign)
| print floating number More...
static size_t | print_nibble (char **str, size_t *size, uint8_t nibble, bool upcase)
| print nibble (half-byte) More...
static size_t | print_hex (char **str, size_t *size, uint64_t hex, uint32_t padding, bool prefix, bool upcase)
| print hex value More...
static size_t | print_bits (char **str, size_t *size, uint64_t u, uint32_t padding, bool prefix)
| print bits More...
static size_t | vsnprintf (char **str, size_t *size, const char *format, va_list va)
| print format string on string or user output More...
size_t | printf (const char *format,...)
| print format string on user output More...
size_t | snprintf (char *str, size_t size, const char *format,...)
| print format string on string or user output More...

## Variables

uint8_t | print_error
| flags to indicate which error(s) occurred within printf or snprintf

## Detailed Description

printing utilities to replace the large printf from the standard library (code)

Author
  King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info

Date
  2017

Definition in file print.c.

## Function Documentation

## print_bits()

static size_t print_bits | ( | char ** | str,
|  | size_t * | size,
|  | uint64_t | u,
|  | uint32_t | padding,
|  | bool | prefix
| ) |  |

static

print bits

Parameters

  [out] | str | string to print bits on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | u | bits to be printed
  [in] | padding | number of 0's to pad
  [in] | prefix | if 0b prefix should be printed

Returns
  number of characters printed

Definition at line 285 of file print.c.

## print_char()

static size_t print_char | ( | char ** | str,
|  | size_t * | size,
|  | char | c
| ) |  |

static

print character

Parameters

  [out] | str | string to print character on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | c | character to be printed

Returns
  number of characters printed

Definition at line 55 of file print.c.

## print_float()

static size_t print_float | ( | char ** | str,
|  | size_t * | size,
|  | double | f,
|  | uint32_t | padding,
|  | uint32_t | fractional,
|  | bool | sign
| ) |  |

static

print floating number

Parameters

  [out] | str | string to print floating number on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | f | floating number to be printed
  [in] | padding | number of 0's to pad
  [in] | fractional | numbers of digits after the decimal point
  [in] | sign | if sign should be printed

Returns
  number of characters printed

Definition at line 143 of file print.c.

## print_hex()

static size_t print_hex | ( | char ** | str,
|  | size_t * | size,
|  | uint64_t | hex,
|  | uint32_t | padding,
|  | bool | prefix,
|  | bool | upcase
| ) |  |

static

print hex value

Parameters

  [out] | str | string to print hex on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | hex | hex value to be printed
  [in] | padding | number of 0's to pad
  [in] | prefix | if 0x prefix should be printed
  [in] | upcase | use upcase digits (A-F)

Returns
  number of characters printed

Definition at line 243 of file print.c.

## print_nibble()

static size_t print_nibble | ( | char ** | str,
|  | size_t * | size,
|  | uint8_t | nibble,
|  | bool | upcase
| ) |  |

static

print nibble (half-byte)

Parameters

  [out] | str | string to print nibble on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | nibble | nibble to be printed
  [in] | upcase | use upcase digits (A-F)

Returns
  number of characters printed

Definition at line 221 of file print.c.

## print_printed()

static void print_printed | ( | size_t * | length,
|  | size_t | printed
| ) |  |

static

add printed length to total printed length, and sets error if maximum size is exceeded

Parameters

  [in,out] | length | total printed length
  [in] | printed | printed length

Definition at line 36 of file print.c.

## print_signed()

static size_t print_signed | ( | char ** | str,
|  | size_t * | size,
|  | int64_t | d,
|  | uint32_t | padding,
|  | bool | sign
| ) |  |

static

print signed integer

Parameters

  [out] | str | string to print signed integer on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | d | signed integer to be printed
  [in] | padding | number of 0's to pad
  [in] | sign | if sign should be printed

Returns
  number of characters printed

Definition at line 123 of file print.c.

## print_string()

static size_t print_string | ( | char ** | str,
|  | size_t * | size,
|  | const char * | s
| ) |  |

static

print string

Parameters

  [out] | str | string to print string on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | s | string to be printed

Returns
  number of characters printed

Definition at line 78 of file print.c.

## print_unsigned()

static size_t print_unsigned | ( | char ** | str,
|  | size_t * | size,
|  | uint64_t | u,
|  | uint32_t | padding,
|  | bool | sign
| ) |  |

static

print unsigned integer

Parameters

  [out] | str | string to print unsigned integer on (use NULL to print on user output)
  [in,out] | size | size of string
  [in] | u | unsigned integer to be printed
  [in] | padding | number of 0's to pad
  [in] | sign | if sign should be printed

Returns
  number of characters printed

Definition at line 95 of file print.c.

## printf()

size_t printf | ( | const char * | format,
|  |  | ...
| ) |  |

print format string on user output

Parameters

  [in] | format | format string to be printed
  [in] | ... | arguments referenced by format string to be printed

Returns
  number of characters printed

Definition at line 448 of file print.c.

## snprintf()

size_t snprintf | ( | char * | str,
|  | size_t | size,
|  | const char * | format,
|  |  | ...
| ) |  |

print format string on string or user output

Parameters

  [out] | str | string to print format string on, or user output if str is set to NULL (str will always be terminated with a null character '\0')
  [in,out] | size | size of string (writes at most size characters on str, including the termination null character '\0')
  [in] | format | format string to be printed
  [in] | ... | arguments referenced by format string to be printed

Returns
  number of characters printed (a return value of size or more means that the output was truncated)

Definition at line 458 of file print.c.

## vsnprintf()

static size_t vsnprintf | ( | char ** | str,
|  | size_t * | size,
|  | const char * | format,
|  | va_list | va
| ) |  |

static

print format string on string or user output

Parameters

  [out] | str | string to print format string on, or user output if str is set to NULL (str will always be terminated with a null character '\0')
  [in,out] | size | size of string (writes at most size characters on str, including the termination null character '\0')
  [in] | format | format string to be printed
  [in] | va | arguments referenced by format string to be printed

Returns
  number of characters printed (a return value of size or more means that the output was truncated)

Definition at line 316 of file print.c.