The Pubnub C-core library. It's home is on https://github.com/pubnub/c_core, this is a copy
Dependents: Pubnub_c_core_mbed2_pal Pubnub_c_core_mbed2_pal Pubnub_c_core_mbed2_pal2
Diff: pubnub_assert_std.cpp
- Revision:
- 0:d13755cfb705
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pubnub_assert_std.cpp Thu Nov 10 22:20:11 2016 +0000 @@ -0,0 +1,51 @@ +/* -*- c-file-style:"stroustrup"; indent-tabs-mode: nil -*- */ +#include "pubnub_assert.h" + +#include <stdlib.h> +#include <stdio.h> + + +static pubnub_assert_handler_t m_handler; + + +void pubnub_assert_set_handler(pubnub_assert_handler_t handler) +{ + if (handler == NULL) { + handler = pubnub_assert_handler_abort; + } + m_handler = handler; +} + + +void pubnub_assert_failed(char const *s, char const *file, long line) +{ + if (m_handler == NULL) { + m_handler = pubnub_assert_handler_abort; + } + m_handler(s, file, line); +} + + +static void report(char const *s, char const *file, long line) +{ + printf("Pubnub assert failed '%s', file '%s', line %ld\n", s, file, line); +} + + +void pubnub_assert_handler_loop(char const *s, char const *file, long line) +{ + report(s, file, line); + for (;;) continue; +} + + +void pubnub_assert_handler_abort(char const *s, char const *file, long line) +{ + report(s, file, line); + abort(); +} + +void pubnub_assert_handler_printf(char const *s, char const *file, long line) +{ + report(s, file, line); +}