maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
Micro-PrintF API

Independently-implemented printf API for old compilers. More...

Files

file  uprintf.h
 

Data Structures

union  MAUG_FMT_SPEC
 

Macros

#define UPRINTF_S16_FMT   "%d"
 
#define UPRINTF_U16_FMT   "%u"
 
#define UPRINTF_S16_DIGITS   5
 
#define UPRINTF_S32_FMT   "%ld"
 
#define UPRINTF_U32_FMT   "%lu"
 
#define UPRINTF_X32_FMT   "%lx"
 
#define NEWLINE_STR   "\n"
 
#define UPRINTF_BUFFER_SZ_MAX   1024
 
#define platform_file   FILE*
 
#define platform_fprintf   fprintf
 
#define platform_vfprintf   vfprintf
 
#define platform_fopen   fopen
 
#define platform_fflush   fflush
 
#define platform_fclose   fclose
 
#define LOG_ERR_TARGET   stderr
 
#define LOG_STD_TARGET   stdout
 
#define SIZE_T_FMT   "%u"
 
#define SSIZE_T_FMT   "%d"
 
#define OFF_T_FMT   "%lu"
 
#define UPRINTF_MS_FMT   UPRINTF_U32_FMT
 
#define DEBUG_THRESHOLD   1
 
#define debug_printf(...)
 
#define error_printf(...)
 
#define size_printf(...)
 
#define size_multi_printf(...)
 
#define logging_init()
 
#define logging_shutdown()
 
#define maug_bufcat(c, buf, buf_idx, buf_sz, cleanup)
 
#define maug_bufpad(pad_c, pad_sz, i, buf, buf_idx, buf_sz, cleanup)
 
#define maug_xtoa(num, base, rem, dest, dest_idx, digits, digits_done, pad)
 
#define maug_hctoi(c)
 Convert a single char hex digit to the int it represents.
 

Functions

int maug_digits (long int num, int base)
 
int maug_zdigits (size_t num, int base)
 
int maug_is_num (const char *str, size_t str_sz, uint8_t base, uint8_t sign)
 
int maug_is_float (const char *str, size_t str_sz)
 
int maug_itoa (long int num, char *dest, int dest_sz, int base)
 
int maug_utoa (uint32_t num, char *dest, int dest_sz, int base)
 
int maug_ztoa (size_t num, char *dest, int dest_sz, int base)
 
uint32_t maug_atou32 (const char *buffer, size_t buffer_sz, uint8_t base)
 
int32_t maug_atos32 (const char *buffer, size_t buffer_sz)
 
float maug_atof (const char *buffer, size_t buffer_sz)
 
void maug_str_upper (char *line, size_t line_sz)
 
void maug_str_lower (char *line, size_t line_sz)
 
MERROR_RETVAL maug_tok_str (size_t idx, const char *line, size_t line_sz, char *out, size_t out_sz)
 
MERROR_RETVAL maug_tok_int (size_t idx, const char *line, size_t line_sz, int16_t *out)
 
void maug_vsnprintf (char *buffer, int buffer_sz, const char *fmt, va_list vargs)
 
void maug_snprintf (char *buffer, int buffer_sz, const char *fmt,...)
 
void maug_printf (const char *fmt,...)
 

Variables

uint32_t g_maug_printf_line
 

Detailed Description

Independently-implemented printf API for old compilers.

Macro Definition Documentation

◆ maug_bufcat

#define maug_bufcat ( c,
buf,
buf_idx,
buf_sz,
cleanup )
Value:
buf[buf_idx++] = c; \
if( buf_idx >= buf_sz ) { goto cleanup; }

◆ maug_bufpad

#define maug_bufpad ( pad_c,
pad_sz,
i,
buf,
buf_idx,
buf_sz,
cleanup )
Value:
i = 0; \
while( i < pad_sz ) { \
maug_bufcat( pad_c, buffer, buffer_idx, buffer_sz, cleanup ); \
i++; \
}

◆ maug_hctoi

#define maug_hctoi ( c)
Value:
('9' > (c) ? (c) - '0' : 'a' > (c) ? 10 + (c) - 'A' : 10 + (c) - 'a')

Convert a single char hex digit to the int it represents.

◆ maug_xtoa

#define maug_xtoa ( num,
base,
rem,
dest,
dest_idx,
digits,
digits_done,
pad )
Value:
dest_idx += digits; \
while( 0 != num ) { \
/* Get the 1's place. */ \
rem = num % base; \
dest[--dest_idx] = (9 < rem) ? \
/* > 10, so it's a letter. */ \
(rem - 10) + 'a' : \
/* < 10, so it's a number. */ \
rem + '0'; \
/* Move the next place value into range. */ \
num /= base; \
digits_done++; \
} \
while( digits_done < digits ) { \
dest[--dest_idx] = '0'; \
digits_done++; \
}