From c5e5ad3f42b16da324cf4cba0ecca2a449f560f0 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 26 Jun 2024 13:03:40 -0400 Subject: Fix circular dependency on tplfunc_frame * Remove predeclaration of tplfunc_frame * tpl_register_func accepts pointer to void instead * tpl_register_func sets maximum number of arguments * Frame is generated within tpl_register_func --- include/template.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'include/template.h') diff --git a/include/template.h b/include/template.h index ba62667..9a34c6a 100644 --- a/include/template.h +++ b/include/template.h @@ -40,9 +40,8 @@ char *tpl_render(char *str); */ int tpl_render_to_file(char *str, const char *filename); -struct tplfunc_frame *tpl_getfunc(char *key); -struct tplfunc_frame; -typedef int tplfunc(struct tplfunc_frame *frame, void *result); +typedef int tplfunc(void *frame, void *result); + struct tplfunc_frame { char *key; tplfunc *func; @@ -62,6 +61,20 @@ struct tplfunc_frame { double t_double; } argv[10]; // accept up to 10 arguments }; -void tpl_register_func(char *key, struct tplfunc_frame *frame); + +/** + * Register a template function + * @param key function name to expose to "func:" interface + * @param tplfunc_ptr pointer to function of type tplfunc + * @param argc number of function arguments to accept + */ +void tpl_register_func(char *key, void *tplfunc_ptr, int argc); + +/** + * Get the function frame associated with a template function + * @param key function name + * @return tplfunc_frame structure + */ +struct tplfunc_frame *tpl_getfunc(char *key); #endif //STASIS_TEMPLATE_H -- cgit