comments updated
[henge/apc.git] / src / print.h
1 /*!@file
2 \brief Macros for printing unicode to streams
3 \details Standardized method of handling unicodes in warnings, and errors
4 \author Jordan Lavatai
5 \date Aug 2016
6 ----------------------------------------------------------------------------*/
7 /* u8 print macros */
8 #ifndef _PRINT_H_
9 #define _PRINT_H_
10 #include <unistdio.h>
11 #ifndef DEBUG
12 #define DEBUG 0
13 #endif
14 /* wprintf callback, may be defined prior to include
15 or undefined and redefined later
16 */
17 #ifndef wprintf_callback
18 #define wprintf_callback(...) do { \
19 } while (0)
20 #endif
21 /* eprintf callback, may be defined prior to include
22 or undefined and redefined later
23 */
24 #ifndef eprintf_callback
25 #define eprintf_callback(...) do { \
26 } while (0)
27 #endif
28
29 /* Print a unicode string */
30 #define uprintf(...) do { \
31 ulc_fprintf(stdout, __VA_ARGS__); \
32 } while (0)
33 /* Print a unicode string to a filestream */
34 #define ufprintf(_STREAM,...) do { \
35 ulc_fprintf(_STREAM, __VA_ARGS__); \
36 } while (0)
37 /* Print a warning message to stderr, then do_warn */
38 #define wprintf(...) do { \
39 ufprintf(stderr, __VA_ARGS__); \
40 wprintf_callback(__VA_ARGS__); \
41 } while (0)
42 /* Print an error message to stderr, then do_error */
43 #define eprintf(...) do { \
44 ufprintf(stderr, __VA_ARGS__); \
45 eprintf_callback(__VA_ARGS_); \
46 } while (0)
47 /* Print only when the provided boolean is true */
48 #define bprintf(_BOOL,...) do { \
49 if (_BOOL) \
50 ufprintf(stdout, __VA_ARGS__); \
51 } while (0)
52 /* Print only when DEBUG is set to a value */
53 #define dprintf(...) do { \
54 bprintf(DEBUG, __VA_ARGS__); \
55 } while (0)
56 #endif