41 #if defined( MBG_TGT_KERNEL ) 90 return s != NULL && max_len > 0;
134 if ( n > 0 && n < max_len )
139 for ( n = 0; s[n]; n++ );
152 #define _sn_cpy_str_safe( _dst, _src ) sn_cpy_str_safe( _dst, sizeof( _dst ), _src ) 210 __attribute__( ( format( printf, 3, 0 ) ) ) int
vsnprintf_safe(
char *s,
size_t max_len, const
char *fmt, va_list args ) ;
229 __attribute__( ( format( printf, 3, 4 ) ) )
int snprintf_safe(
char *s,
size_t max_len, const
char * fmt, ... ) ;
253 char *
strncpy_safe(
char *dst, const
char *src,
size_t max_len ) ;
332 void mbg_memcpy(
void *dst, const
void *src,
size_t n_bytes ) ;
void trim_leading_whitespace(char *s)
Trim whitespace at the beginning of a string.
int vsnprintf_safe(char *s, size_t max_len, const char *fmt, va_list args)
A portable, safe implementation of vsnprintf()
int sn_cpy_char_safe(char *dst, size_t max_len, char c)
A function to copy a character safely to a string buffer.
#define _int_from_size_t(_n)
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.
void trim_trailing_whitespace(char *s)
Trim whitespace at the end of a string.
void mbg_memcpy(void *dst, const void *src, size_t n_bytes)
Copy array of bytes starting at beginning of buffer.
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.
char * strncpy_safe(char *dst, const char *src, size_t max_len)
A portable, safe implementation of strncpy()
const char * str_not_avail
int snprintf_safe(char *s, size_t max_len, const char *fmt,...)
A portable, safe implementation of snprintf()
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.
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.
void trim_whitespace(char *s)
Trim both leading and trailing whitespace from a string.