Skip to content

File lt_utils.h

FileList > api > lt_utils.h

Go to the source code of this file.

  • #include <libretiny.h>

Public Functions

Type Name
void hexdump (const uint8_t * buf, size_t len, uint32_t offset=0, uint8_t width=16)
Print data pointed to by buf in hexdump-like format (hex+ASCII).
char * lt_btox (const uint8_t * src, int len, char * dest)
Convert a byte array to hexadecimal string.
void lt_rand_bytes (uint8_t * buf, size_t len)
Generate random bytes using rand().
uint8_t * lt_xtob (const char * src, int len, uint8_t * dest)
Convert a hexadecimal string to byte array.

Macros

Type Name
define MAX (a, b)
define MIN (a, b)

Public Functions Documentation

function hexdump

Print data pointed to by buf in hexdump-like format (hex+ASCII).

void hexdump (
    const uint8_t * buf,
    size_t len,
    uint32_t offset=0,
    uint8_t width=16
) 

Parameters:

  • buf source pointer
  • len how many bytes to print
  • offset increment printed offset by this value
  • width how many bytes on a line

function lt_btox

Convert a byte array to hexadecimal string.

char * lt_btox (
    const uint8_t * src,
    int len,
    char * dest
) 

Parameters:

  • src source byte array
  • len source length (bytes)
  • dest destination string

Returns:

destination string

function lt_rand_bytes

Generate random bytes using rand().

void lt_rand_bytes (
    uint8_t * buf,
    size_t len
) 

Parameters:

  • buf destination pointer
  • len how many bytes to generate

function lt_xtob

Convert a hexadecimal string to byte array.

uint8_t * lt_xtob (
    const char * src,
    int len,
    uint8_t * dest
) 

Parameters:

  • src source string
  • len source length (chars)
  • dest destination byte array

Returns:

destination byte array

Macro Definition Documentation

define MAX

#define MAX (
    a,
    b
) ({                                                                                                                 \
        __typeof__(a) _a = (a);                                                                                        \
        __typeof__(b) _b = (b);                                                                                        \
        _a > _b ? _a : _b;                                                                                             \
    })

define MIN

#define MIN (
    a,
    b
) ({                                                                                                                 \
        __typeof__(a) _a = (a);                                                                                        \
        __typeof__(b) _b = (b);                                                                                        \
        _a < _b ? _a : _b;                                                                                             \
    })

The documentation for this class was generated from the following file cores/common/base/api/lt_utils.h