X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Fprint.h;h=2f449706114ab234d7d598d0281a05998d13bb6d;hp=73df046f9c0d7cf98f153939784e249bbe3c4ec8;hb=2adb4f588fa1a6a16876af1bfaeebebc8bbbc748;hpb=43f088652419e08b7426b2c689591b280c0f2330 diff --git a/src/print.h b/src/print.h index 73df046..2f44970 100644 --- a/src/print.h +++ b/src/print.h @@ -11,22 +11,45 @@ #ifndef DEBUG #define DEBUG 0 #endif -#define do_warn(...) do { \ +/* wprintf callback, may be defined prior to include + or undefined and redefined later +*/ +#ifndef wprintf_callback +#define wprintf_callback(...) do { \ } while (0) -#define wprintf(...) do { \ - ulc_fprintf(stderr, __VA_ARGS__); \ - do_warn(__VA_ARGS__); \ +#endif +/* eprintf callback, may be defined prior to include + or undefined and redefined later +*/ +#ifndef eprintf_callback +#define eprintf_callback(...) do { \ + } while (0) +#endif + +/* Print a unicode string */ +#define uprintf(...) do { \ + ulc_fprintf(stdout, __VA_ARGS__); \ + } while (0) +/* Print a unicode string to a filestream */ +#define ufprintf(_STREAM,...) do { \ + ulc_fprintf(_STREAM, __VA_ARGS__); \ } while (0) -#define do_error(...) do { \ +/* Print a warning message to stderr, then do_warn */ +#define wprintf(...) do { \ + ufprintf(stderr, __VA_ARGS__); \ + wprintf_callback(__VA_ARGS__); \ } while (0) +/* Print an error message to stderr, then do_error */ #define eprintf(...) do { \ - ulc_fprintf(stderr, __VA_ARGS__); \ - do_error(__VA_ARGS_); \ + ufprintf(stderr, __VA_ARGS__); \ + eprintf_callback(__VA_ARGS_); \ } while (0) +/* Print only when the provided boolean is true */ #define bprintf(_BOOL,...) do { \ if (_BOOL) \ - ulc_fprintf(stdout, __VA_ARGS__); \ + ufprintf(stdout, __VA_ARGS__); \ } while (0) +/* Print only when DEBUG is set to a value */ #define dprintf(...) do { \ bprintf(DEBUG, __VA_ARGS__); \ } while (0)