Env to check for assert
Use the env LKT_NO_ASSERT
to disable asserts in lektord
and lkt
. Make a function pointer named lkt_assert
which
will be set to assert
when LKT_NO_ASSERT
don't exists or when the value is an empty string.
Do something like this:
void
__no_assert(int _true)
{
(void) _true;
}
void
__yes_assert(int _true)
{
if (!_true) {
LOG_CRITICAL("Assert failed");
exit(EXIT_FAILURE);
}
}
void (*lkt_assert)(int);
/* extern void (*lkt_assert)(int); in header file */
void
lkt_set_assert_mode(void)
{
char *no_assert = getenv("LKT_NO_ASSERT");
if (NULL == no_assert || strlen(no_assert) == 0)
/* __yes_assert */
else
/* __no_assert */
}