diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-10-26 14:37:29 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-10-26 14:37:39 +0200 |
commit | eccd4b993a7cc47e96ddab486197570c38f21701 (patch) | |
tree | 5680d3bc73336019607c6c6bf81febaeb3bb355e /core/errorhelper.c | |
parent | 6ec7d2d87764e25d58dcb7ffdcb02b58bcce18d8 (diff) | |
download | subsurface-eccd4b993a7cc47e96ddab486197570c38f21701.tar.gz |
Set error callback helper
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/errorhelper.c')
-rw-r--r-- | core/errorhelper.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/errorhelper.c b/core/errorhelper.c index c8e6ae956..66c01fd21 100644 --- a/core/errorhelper.c +++ b/core/errorhelper.c @@ -9,6 +9,7 @@ #define VA_BUF(b, fmt) do { va_list args; va_start(args, fmt); put_vformat(b, fmt, args); va_end(args); } while (0) static struct membuffer error_string_buffer = { 0 }; +static void (*error_cb)(void) = NULL; /* * Note that the act of "getting" the error string * buffer doesn't de-allocate the buffer, but it does @@ -37,6 +38,10 @@ int report_error(const char *fmt, ...) VA_BUF(buf, fmt); mb_cstring(buf); + /* if an error callback is registered, call it */ + if (error_cb) + error_cb(); + return -1; } @@ -44,3 +49,7 @@ void report_message(const char *msg) { (void)report_error("%s", msg); } + +void set_error_cb(void(*cb)(void)) { + error_cb = cb; +} |