diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2016-10-13 00:51:03 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-11-02 19:46:36 +0100 |
commit | c3f43e832a8062169f999f3a5c298fe3f40ab9e8 (patch) | |
tree | 66a22e5bcb425aac46cdffed61f6525402364051 /nx-X11/lib/xtrans/Xtransint.h | |
parent | c4b775f6dc6f8361dc27ace5d2b40ec42c3381bf (diff) | |
download | nx-libs-c3f43e832a8062169f999f3a5c298fe3f40ab9e8.tar.gz nx-libs-c3f43e832a8062169f999f3a5c298fe3f40ab9e8.tar.bz2 nx-libs-c3f43e832a8062169f999f3a5c298fe3f40ab9e8.zip |
replace PRMSG by prmsg
Diffstat (limited to 'nx-X11/lib/xtrans/Xtransint.h')
-rw-r--r-- | nx-X11/lib/xtrans/Xtransint.h | 105 |
1 files changed, 58 insertions, 47 deletions
diff --git a/nx-X11/lib/xtrans/Xtransint.h b/nx-X11/lib/xtrans/Xtransint.h index b7ca80541..0da59f71d 100644 --- a/nx-X11/lib/xtrans/Xtransint.h +++ b/nx-X11/lib/xtrans/Xtransint.h @@ -306,6 +306,9 @@ typedef struct _Xtransport_table { /* Flags to preserve when setting others */ #define TRANS_KEEPFLAGS (TRANS_NOUNLINK|TRANS_ABSTRACT) +#ifdef XTRANS_TRANSPORT_C /* only provide static function prototypes when + building the transport.c file that has them in */ + /* * readv() and writev() don't exist or don't work correctly on some * systems, so they may be emulated. @@ -360,54 +363,62 @@ static int trans_mkdir ( * Some XTRANSDEBUG stuff */ -#if defined(XTRANSDEBUG) -/* add hack to the format string to avoid warnings about extra arguments - * to fprintf. +#ifdef XTRANSDEBUG +#include <stdarg.h> + +/* + * The X server provides ErrorF() & VErrorF(), for other software that uses + * xtrans, we provide our own simple versions. */ -#ifdef XTRANSDEBUGTIMESTAMP -#if defined(XSERV_t) && defined(TRANS_SERVER) -/* Use ErrorF() for the X server */ -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - struct timeval tp;\ - gettimeofday(&tp,0); \ - ErrorF("%s",__xtransname); \ - ErrorF(x+hack,a,b,c); \ - ErrorF("timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \ - errno=saveerrno; \ - } else ((void)0) -#else -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - struct timeval tp;\ - gettimeofday(&tp,0); \ - fprintf(stderr, "%s",__xtransname); fflush(stderr); \ - fprintf(stderr, x+hack,a,b,c); fflush(stderr); \ - fprintf(stderr, "timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \ - fflush(stderr); \ - errno=saveerrno; \ - } else ((void)0) -#endif /* XSERV_t && TRANS_SERVER */ -#else /* XTRANSDEBUGTIMESTAMP */ -#if defined(XSERV_t) && defined(TRANS_SERVER) -/* Use ErrorF() for the X server */ -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - ErrorF("%s",__xtransname); \ - ErrorF(x+hack,a,b,c); \ - errno=saveerrno; \ - } else ((void)0) -#else -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - fprintf(stderr, "%s",__xtransname); fflush(stderr); \ - fprintf(stderr, x+hack,a,b,c); fflush(stderr); \ - errno=saveerrno; \ - } else ((void)0) -#endif /* XSERV_t && TRANS_SERVER */ -#endif /* XTRANSDEBUGTIMESTAMP */ -#else -#define PRMSG(lvl,x,a,b,c) ((void)0) +# if defined(XSERV_t) && defined(TRANS_SERVER) +# include "os.h" +# else +static inline void _X_ATTRIBUTE_PRINTF(1, 0) +VErrorF(const char *f, va_list args) +{ + vfprintf(stderr, f, args); + fflush(stderr); +} + +static inline void _X_ATTRIBUTE_PRINTF(1, 2) +ErrorF(const char *f, ...) +{ + va_list args; + + va_start(args, f); + VErrorF(f, args); + va_end(args); +} +# endif /* xserver */ +#endif /* XTRANSDEBUG */ + +static inline void _X_ATTRIBUTE_PRINTF(2, 3) +prmsg(int lvl, const char *f, ...) +{ +#ifdef XTRANSDEBUG + va_list args; + + va_start(args, f); + if (lvl <= XTRANSDEBUG) { + int saveerrno = errno; + + ErrorF("%s", __xtransname); + VErrorF(f, args); + +# ifdef XTRANSDEBUGTIMESTAMP + { + struct timeval tp; + gettimeofday(&tp, 0); + ErrorF("timestamp (ms): %d\n", + tp.tv_sec * 1000 + tp.tv_usec / 1000); + } +# endif + errno = saveerrno; + } + va_end(args); #endif /* XTRANSDEBUG */ +} + +#endif /* XTRANS_TRANSPORT_C */ #endif /* _XTRANSINT_H_ */ |