diff options
author | Markus Teich <markus.teich@stusta.mhn.de> | 2016-07-13 12:21:40 +0200 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2016-07-13 12:21:40 +0200 |
commit | 1636ff8c4977e416499006c2571edf41f6e96c67 (patch) | |
tree | 48336449c62034aa75060a1d9985f0bf3083c88e /util.h | |
parent | b700ddb4372e3de25ffe5748f1f58cbbbddfc16e (diff) |
allow different logging targets
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 48 |
1 files changed, 31 insertions, 17 deletions
@@ -16,37 +16,51 @@ /** * @file util.h - * @brief \todo + * @brief Interface for the common utility functions. * @author Markus Teich */ #ifndef _BRANDT_UTIL_H #define _BRANDT_UTIL_H -void eprintf(const char *fmt, ...); -void weprintf(const char *fmt, ...); +void setlog (FILE *stream); +void eprintf (const char *fmt, ...); +void weprintf (const char *fmt, ...); -# undef brandt_assert -# undef brandt_assert_perror -# undef brandt_assert_gpgerr +#undef brandt_assert +#undef brandt_assert_perror +#undef brandt_assert_gpgerr #ifdef NDEBUG -# define brandt_assert(expr) ((expr) ? (void)(0) : \ -eprintf("Assertion failed in file %s line %d function %s: %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, (#expr))) -# define brandt_assert_perror(errnum) (!(errnum) ? (void)(0) : \ -eprintf("Assertion failed in file %s line %d function %s:", __FILE__, __LINE__, __PRETTY_FUNCTION__)) -# define brandt_assert_gpgerr(errnum) (!(errnum) ? (void)(0) : \ -eprintf("Assertion failed in file %s line %d function %s: %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, gcry_strerror((errnum)))) +#define brandt_assert(expr) ((expr) ? (void)(0) : \ +eprintf("Assertion failed in file %s line %d function %s: %s", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + (#expr))) -# define DP(point) ((void)(gcry_log_debugpnt (#point, point, ec_ctx))) -# define DM(mpi) ((void)(gcry_log_debugmpi (#mpi, mpi, ec_ctx))) +#define brandt_assert_perror(errnum) (!(errnum) ? (void)(0) : \ +eprintf("Assertion failed in file %s line %d function %s:", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__)) + +#define brandt_assert_gpgerr(errnum) (!(errnum) ? (void)(0) : \ +eprintf("Assertion failed in file %s line %d function %s: %s", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + gcry_strerror((errnum)))) + +#define DP(point) ((void)(gcry_log_debugpnt (#point, point, ec_ctx))) +#define DM(mpi) ((void)(gcry_log_debugmpi (#mpi, mpi, ec_ctx))) #else -# define brandt_assert(expr) ((void)(expr)) -# define brandt_assert_perror(errnum) ((void)(errnum)) -# define brandt_assert_gpgerr(errnum) ((void)(errnum)) +#define brandt_assert(expr) ((void)(expr)) +#define brandt_assert_perror(errnum) ((void)(errnum)) +#define brandt_assert_gpgerr(errnum) ((void)(errnum)) #endif |