TS_ERROR_FN(3)
π TS_ERROR_FN(3) π
okay bestie, welcome to the tslib manual, section 3 β this is the page about ts_error_fn, and it's lowkey one of the cutest little hooks in the whole library. let's get into it π«Ά
β¨ NAME β¨
ts_error_fn β use a custom error function for libts library errors
like, you get to decide where your errors go. iconic behaviour, honestly. π
πΈ SYNOPSIS πΈ
#include <tslib.h>
int (*ts_error_fn)(const char *fmt, va_list ap);
so it's a function pointer, bestie. a pointer to a function that takes a const char *fmt and a va_list ap, and hands you back an int. that's the whole vibe check. β¨
π DESCRIPTION π
okay so here's the tea. ts_error_fn() is, by default, implemented similar like this:
static int errfn(const char *fmt, va_list ap)
{
return vfprintf(stderr, fmt, ap);
}
that lives inside the library. it's the default, it's the factory setting, it's the plain vanilla of error handling. π¦
but β and this is the good part β it is exposed to the user and can be replaced by a custom error function. simply assign your custom implementation to ts_error_fn like:
ts_error_fn = my_custom_errfn;
and boom. that's it. that's the whole ritual. π
what's it good for? writing to the system log files, for example. so if you've ever been like "why is my error just going to stderr when i need it in syslog", yeah, this is your moment. the ts_print_mt test program has an example, so go peek at it if you want to see it in the wild. π¦
β RETURN VALUE β
user defined. yeah, that's the whole answer β you decide what it returns. main character energy: the return value is whatever you make it. π«Ά
π SEE ALSO π
π heads up bestie: the return value is literally "user defined". that's not me being vague, that's the actual spec. whatever you return is on you. no cap.
and that's the page!! this lil beauty comes to you straight from the tslib manual, section 3 β TS_ERROR_FN(3), signed, sealed, slayed. mwah π go write some custom error functions, i believe in you πβ¨
π¦ where this page comes from
- alpine 3.24: tslib-doc 1.24-r0 Β· LGPL-2.0-or-later
- arch rolling: tslib 1.24-1 Β· LGPL-2.1-only
- debian bookworm: libts0 1.22-1+b1 Β· LGPL-2.0-or-later
- debian trixie: libts0t64 1.22-1.1+b1 Β· LGPL-2.0-or-later
- epel 10: tslib 1.23-2.el10_2 Β· LGPL-2.1-only
- epel 9: tslib 1.22-5.el9 Β· LGPLv2
- fedora 43: tslib 1.23-2.fc43 Β· LGPL-2.1-only
- fedora 43: tslib 1.23-2.fc43 Β· LGPL-2.1-only
- fedora 44: tslib 1.24-2.fc44 Β· LGPL-2.1-only
- fedora 44: tslib 1.24-2.fc44 Β· LGPL-2.1-only
- nixos 26.05: tslib 1.24
- nixpkgs unstable: tslib 1.24
- opensuse-leap 16.0: tslib 1.22-160000.2.2 Β· LGPL-2.1-or-later AND GPL-2.0-only
- opensuse-leap 16.0: tslib 1.22-160000.2.2 Β· LGPL-2.1-or-later AND GPL-2.0-only
- opensuse-leap 16.0: tslib 1.22-160000.2.2 Β· LGPL-2.1-or-later AND GPL-2.0-only
- opensuse-leap 16.0: tslib 1.22-160000.2.2 Β· LGPL-2.1-or-later AND GPL-2.0-only
- ubuntu jammy: libts0 1.22-1 Β· LGPL-2.0-or-later
- ubuntu noble: libts0t64 1.22-1.1build1 Β· LGPL-2.0-or-later
- ubuntu questing: libts0t64 1.22-1.1build1
- ubuntu resolute: libts0t64 1.22-1.1build2 Β· LGPL-2.0-or-later
- ubuntu stonking: libts0t64 1.22-1.1build2 Β· LGPL-2.0-or-later
- Copyright (c) 2017, Martin Kepplinger <martink@posteo.de>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms