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

pubnub_assert_std.cpp

Committer:
sveljko
Date:
2016-11-22
Revision:
2:d85e42c1125d
Parent:
0:d13755cfb705

File content as of revision 2:d85e42c1125d:

/* -*- 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);
}