#ifndef __STDIO_UTIL_H__
#define __STDIO_UTIL_H__

#include <stdio.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif


/* char ESC=27
 * printf("%c[1m",ESC); // turn on bold
 * printf("%c[0m",ESC); // turn off bold
 */
#define stdiou_printfb(...)                     \
    printf ("%c[1m",27);                        \
    printf (__VA_ARGS__);                       \
    printf ("%c[0m",27)
    

/* Function with behaviour like `mkdir -p'
 * e.g., mode = 0775 
 * returns 0 success; -1 error */
int
stdiou_mkpath (const char *s, mode_t mode);

/* prints buf as a hexadecimal stream in big-endian order 
 * 
 * if prefix is NULL, the default '0x' is used
*/
int
stdiou_hexdump (const void *buf, size_t len, const char *prefix);

int
stdiou_shexdump (char *str, const void *buf, size_t len, const char *prefix);
int
stdiou_fhexdump (FILE *stream, const void *buf, size_t len, const char *prefix);

/* prints buf as a binary stream in big-endian order
 *
 * if prefix is NULL, the default '0b' is used
*/
int
stdiou_bindump (const void *buf, size_t len, const char *prefix);
int
stdiou_sbindump (char *str, const void *buf, size_t len, const char *prefix);
int
stdiou_fbindump (FILE *stream, const void *buf, size_t len, const char *prefix);

#ifdef __cplusplus
}
#endif

#endif // __STDIO_UTIL_H__
