From 1762aa42cd86e0bb2631631488bf8b2474378f83 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 14 Feb 2025 10:05:58 -0500 Subject: Move cli/stasis main program to a library stasis_entrypoint.a --- src/lib/entrypoint/entrypoint_callbacks.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/lib/entrypoint/entrypoint_callbacks.c (limited to 'src/lib/entrypoint/entrypoint_callbacks.c') diff --git a/src/lib/entrypoint/entrypoint_callbacks.c b/src/lib/entrypoint/entrypoint_callbacks.c new file mode 100644 index 0000000..502d36b --- /dev/null +++ b/src/lib/entrypoint/entrypoint_callbacks.c @@ -0,0 +1,31 @@ +#include "entrypoint_callbacks.h" + +int callback_except_jf(const void *a, const void *b) { + const struct EnvCtl_Item *item = a; + const char *name = b; + + if (!globals.enable_artifactory) { + return STASIS_ENVCTL_RET_IGNORE; + } + + if (envctl_check_required(item->flags)) { + const char *content = getenv(name); + if (!content || isempty((char *) content)) { + return STASIS_ENVCTL_RET_FAIL; + } + } + + return STASIS_ENVCTL_RET_SUCCESS; +} + +int callback_except_gh(const void *a, const void *b) { + const struct EnvCtl_Item *item = a; + const char *name = b; + //printf("GH exception check: %s\n", name); + if (envctl_check_required(item->flags) && envctl_check_present(item, name)) { + return STASIS_ENVCTL_RET_SUCCESS; + } + + return STASIS_ENVCTL_RET_FAIL; +} + -- cgit