From c2da0971bff60d89d5a2fb19885184cd2c58c5b3 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 26 Jun 2024 13:11:00 -0400 Subject: Add template_func_proto.c and template_func_proto.h --- include/template_func_proto.h | 8 ++++++++ src/template_func_proto.c | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 include/template_func_proto.h create mode 100644 src/template_func_proto.c diff --git a/include/template_func_proto.h b/include/template_func_proto.h new file mode 100644 index 0000000..5516421 --- /dev/null +++ b/include/template_func_proto.h @@ -0,0 +1,8 @@ +#ifndef TEMPLATE_FUNC_PROTO_H +#define TEMPLATE_FUNC_PROTO_H + +#include "template.h" + +int get_github_release_notes_tplfunc_entrypoint(void *frame, void *ptr); + +#endif //TEMPLATE_FUNC_PROTO_H \ No newline at end of file diff --git a/src/template_func_proto.c b/src/template_func_proto.c new file mode 100644 index 0000000..459a3a6 --- /dev/null +++ b/src/template_func_proto.c @@ -0,0 +1,18 @@ +#include "template_func_proto.h" + +int get_github_release_notes_tplfunc_entrypoint(void *frame, void *ptr) { + int result; + char **output = (char **) ptr; + struct tplfunc_frame *f = (struct tplfunc_frame *) frame; + char *api_token = getenv("STASIS_GITHUB_TOKEN"); + if (!api_token) { + api_token = getenv("GITHUB_TOKEN"); + } + result = get_github_release_notes(api_token ? api_token : "anonymous", + (const char *) f->argv[0].t_char_ptr, + (const char *) f->argv[1].t_char_ptr, + (const char *) f->argv[2].t_char_ptr, + output); + return result; +} + -- cgit