41 #if defined( MBG_TGT_WIN32 ) && !defined( MBG_TGT_CVI ) 42 #define mbg_vsnprintf _vsnprintf 44 #define mbg_vsnprintf vsnprintf 48 #if defined( MBG_TGT_DOS ) 57 int vsnprintf(
char *s,
size_t max_len,
const char *fmt, va_list args )
61 return vsprintf( s, fmt, args );
120 __attribute__( ( format( printf, 3, 0 ) ) )
155 __attribute__( ( format( printf, 3, 4 ) ) )
161 va_start( args, fmt );
333 for ( cp = &s[strlen( s )]; cp > s; )
359 for ( srcp = s; *srcp; srcp++ )
412 void mbg_memcpy(
void *dst,
const void *src,
size_t n_bytes )
446 *(--dstp) = *(--srcp);
char * strncpy_safe(char *dst, const char *src, size_t max_len)
A portable, safe implementation of strncpy()
static __mbg_inline size_t do_str_copy_safe(char *dst, const char *src, size_t n)
#define _int_from_size_t(_n)
int sn_cpy_str_safe(char *dst, size_t max_len, const char *src)
A function to copy a string safely, returning the number of characters copied.
int vsnprintf_safe(char *s, size_t max_len, const char *fmt, va_list args)
A portable, safe implementation of vsnprintf()
void trim_trailing_whitespace(char *s)
Trim whitespace at the end of a string.
void trim_whitespace(char *s)
Trim both leading and trailing whitespace from a string.
void mbg_memcpy(void *dst, const void *src, size_t n_bytes)
Copy array of bytes starting at beginning of buffer.
static __mbg_inline bool mbg_buffer_specs_valid(char *s, size_t max_len)
Check if the buffer plus size parameters passed to a function are valid.
void mbg_memcpy_reversed(void *dst, const void *src, size_t n_bytes)
Copy an array of bytes in reversed order, starting at end of buffer.
static __mbg_inline int mbg_chk_snprint_results(size_t n, char *s, size_t max_len)
Check the results of an snprintf()-like function.
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
void trim_leading_whitespace(char *s)
Trim whitespace at the beginning of a string.
int sn_cpy_char_safe(char *dst, size_t max_len, char c)
A function to copy a character safely to a string buffer.