1 /* Macros to help writing output handlers.
2 Copyright (C) 1996 Markus Armbruster */
13 # define XP_ARG1 stream
15 # define XP_GETARG(type, index) (*(type *)args[index])
16 # define XPMR(p,n) fwrite ((p), 1, (n), stream)
17 # define XPR(p) fputs ((p), stream)
18 # define XPF1R(fmt, arg) fprintf (stream, (fmt), (arg))
19 # define XPCR(p) (putc (*(p), stream) == EOF ? -1 : 1)
20 #else /* !USE_PRINTF */
23 # define XP_GETARG(type, index) va_arg (*ap, type)
24 # define XPMR(p,n) f (a, (p), (n))
25 # define XPR(p) f (a, (p), strlen((p)))
26 # define XPF1R(fmt, arg) xgprintf (f, a, (fmt), (arg))
27 # define XPCR(p) XPMR (p, 1)
28 #endif /* !USE_PRINTF */
30 #define XP(p) XP_CHK (XPR ((p)))
31 #define XPM(p,n) XP_CHK (XPMR ((p), (n)))
32 #define XPSR(p) XPMR ((p), sizeof(p)-1)
33 #define XPS(p) XPM ((p), sizeof(p)-1)
34 #define XPF1(fmt, arg) XP_CHK (XPF1R ((fmt), (arg)))
35 #define XPC(c) XP_CHK (XPCR ((c)))
36 #define XP_CHK(expr) \
39 if (n < 0) return -1; else printed += n; \