3 * File name: ir/common/xp_help.h
4 * Purpose: Macros to help writing output handlers.
5 * Author: Markus Armbruster
7 * Created: 1999 by getting from fiasco
9 * Copyright: (c) 1996 Markus Armbruster
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
21 # define XP_ARG1 stream
23 # define XP_GETARG(type, index) (*(type *)args[index])
24 # define XPMR(p,n) fwrite ((p), 1, (n), stream)
25 # define XPR(p) fputs ((p), stream)
26 # define XPF1R(fmt, arg) fprintf (stream, (fmt), (arg))
27 # define XPF3R(fmt, a1, a2, a3) fprintf (stream, (fmt), (a1), (a2), (a3))
28 # define XPCR(p) (putc (*(p), stream) == EOF ? -1 : 1)
29 #else /* !USE_PRINTF */
32 # define XP_GETARG(type, index) va_arg (*ap, type)
33 # define XPMR(p,n) f (a, (p), (n))
34 # define XPR(p) f (a, (p), strlen((p)))
35 # define XPF1R(fmt, arg) xgprintf (f, a, (fmt), (arg))
36 # define XPF3R(fmt, a1, a2, a3) xgprintf (f, a, (fmt), (a1), (a2), (a3))
37 # define XPCR(p) XPMR (p, 1)
38 #endif /* !USE_PRINTF */
40 #define XP(p) XP_CHK (XPR ((p)))
41 #define XPM(p,n) XP_CHK (XPMR ((p), (n)))
42 #define XPSR(p) XPMR ((p), sizeof(p)-1)
43 #define XPS(p) XPM ((p), sizeof(p)-1)
44 #define XPF1(fmt, arg) XP_CHK (XPF1R ((fmt), (arg)))
45 #define XPC(c) XP_CHK (XPCR ((c)))
46 #define XP_CHK(expr) \
49 if (n < 0) return -1; else printed += n; \