Files
Toy/source/toy_print.c
Kayne Ruse 1a36c14247 Expanded array tests, read more
Getting the array's length is still not available yet, so I'm not
marking arrays as done - but everything that is there is tested.

I've also tweaked the assert output callbacks to also print 'assert failure'.
2024-12-09 12:11:31 +11:00

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() {
printCallback = outDefault;
}
void Toy_resetErrorCallback() {
errorCallback = errDefault;
}
void Toy_resetAssertFailureCallback() {
assertCallback = assertDefault;
}