aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-13 13:38:51 +0200
committerChristian Grothoff <christian@grothoff.org>2016-07-13 13:38:51 +0200
commit442078e737beac4161236ebe1ee67b7c483f24df (patch)
treedf8178df6661fa41c439fadc13c227ca0ccfd5de /util.h
parentae6f37b6298e855dbe998637cffba15493a62c0d (diff)
parent8a1d2917f64d425212f0a3d2e8d91ca9f3c20122 (diff)
Merge branch 'master' of gnunet.org:libbrandt
Diffstat (limited to 'util.h')
-rw-r--r--util.h60
1 files changed, 40 insertions, 20 deletions
diff --git a/util.h b/util.h
index d21cc89..faf893a 100644
--- a/util.h
+++ b/util.h
@@ -16,38 +16,58 @@
/**
* @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) do { \
+ (expr) ? (void)(0) : eprintf ( \
+ "Assertion failed in file %s line %d function %s: %s", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ (# expr)); \
+} while (0)
-# 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) do { \
+ !(errnum) ? (void)(0) : eprintf ( \
+ "Assertion failed in file %s line %d function %s:", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__); \
+} while (0)
-#else
+#define brandt_assert_gpgerr(errnum) do { \
+ !(errnum) ? (void)(0) : eprintf ( \
+ "Assertion failed in file %s line %d function %s: %s", \
+ __FILE__, \
+ __LINE__, \
+ __PRETTY_FUNCTION__, \
+ gcry_strerror ((errnum))); \
+} while (0)
-# define brandt_assert(expr) ((void)(expr))
-# define brandt_assert_perror(errnum) ((void)(errnum))
-# define brandt_assert_gpgerr(errnum) ((void)(errnum))
+#define DP(point) ((void)(gcry_log_debugpnt (# point, point, ec_ctx)))
+#define DM(mpi) ((void)(gcry_log_debugmpi (# mpi, mpi, ec_ctx)))
-#endif
+#else /* ifdef NDEBUG */
-#endif
+#define brandt_assert(expr) ((void)(expr))
+#define brandt_assert_perror(errnum) ((void)(errnum))
+#define brandt_assert_gpgerr(errnum) ((void)(errnum))
+
+#endif /* ifdef NDEBUG */
+
+#endif /* ifndef _BRANDT_UTIL_H */