mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Toy now fits into the C spec. Fixed #158 Addendum: MacOS test caught an error: error: a function declaration without a prototype is deprecated in all versions of C That took 3 attempts to fix correctly. Addendum: 'No new line at the end of file' are you shitting me?
56 lines
1.0 KiB
C
56 lines
1.0 KiB
C
#include "toy_print.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
static void outDefault(const char* msg) {
|
|
fprintf(stdout, "%s", msg);
|
|
}
|
|
|
|
static void errDefault(const char* msg) {
|
|
fprintf(stderr, "%s", msg);
|
|
}
|
|
|
|
static void assertDefault(const char* msg) {
|
|
fprintf(stderr, "%s", msg);
|
|
}
|
|
|
|
static Toy_callbackType printCallback = outDefault;
|
|
static Toy_callbackType errorCallback = errDefault;
|
|
static Toy_callbackType assertCallback = assertDefault;
|
|
|
|
void Toy_print(const char* msg) {
|
|
printCallback(msg);
|
|
}
|
|
|
|
void Toy_error(const char* msg) {
|
|
errorCallback(msg);
|
|
}
|
|
|
|
void Toy_assertFailure(const char* msg) {
|
|
assertCallback(msg);
|
|
}
|
|
|
|
void Toy_setPrintCallback(Toy_callbackType cb) {
|
|
printCallback = cb;
|
|
}
|
|
|
|
void Toy_setErrorCallback(Toy_callbackType cb) {
|
|
errorCallback = cb;
|
|
}
|
|
|
|
void Toy_setAssertFailureCallback(Toy_callbackType cb) {
|
|
assertCallback = cb;
|
|
}
|
|
|
|
void Toy_resetPrintCallback(void) {
|
|
printCallback = outDefault;
|
|
}
|
|
|
|
void Toy_resetErrorCallback(void) {
|
|
errorCallback = errDefault;
|
|
}
|
|
|
|
void Toy_resetAssertFailureCallback(void) {
|
|
assertCallback = assertDefault;
|
|
}
|