libsml
libsml copied to clipboard
WIP: add sml_error function pointer, allow user to intercept error messages
a basic attempt at fixing #17 .
replaces hardcoded fprintf()
calls with an sml_error
function pointer that can be overwritten by code using the library.
a default is provided that mimics the old behaviour (write to stderr with a "libsml:" prefix and appended newline.
includes a test, test also demonstrates usage.
note that this breaks backwards compatibility (code assuming sml_error
exists won't build or run with older versions of the library),
so we should probably bump the version when merging this.
also we should consider if we maybe want a more sophisticated interface.
@jahir: you beat me to mentioning this in #109 . it's sad that this is stalled for 1.5 years, but it got very little feedback after i submitted it. maybe you can add some? i'm mostly wondering if the API is sensible, see https://github.com/volkszaehler/libsml/pull/93#discussion_r549201545 .