aboutsummaryrefslogtreecommitdiff
path: root/include/template.h
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2024-07-06 09:49:51 -0400
committerGitHub <noreply@github.com>2024-07-06 09:49:51 -0400
commit8ce824ac4b2f526331093a7150e643700efd4d20 (patch)
tree99e27dee24e82d78941ded4c510e1bac57c3f015 /include/template.h
parentabe87056faa6ed02aff3bbf77c1fd78b713a0864 (diff)
downloadstasis-8ce824ac4b2f526331093a7150e643700efd4d20.tar.gz
Add github.c and github.h (#9)
* Add github.c and github.h * Implements get_github_release_notes() * Remove unused variables * 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 * Improve template function error handling and return/output management * Remove redundant extern statement * Include github.h and template_func_proto.h in core.h * Expose get_github_release_notes_tplfunc_entrypoint function to template engine * Add template_func_proto.c and template_func_proto.h * Replace free() with guard variant * Fix test_template::test_tpl_register_func * Fix tests * Fix tests * cmd should be at least PATH_MAX in size. * Magic number caused failure to install conda with a long installation path * Implement get_github_release_notes_auto function that bases release note data off test contexts * Disable overwriting releases by default * Add automatic release note generation function call to release_notes.md.in * Fix test_tpl_register_func() * Add enough space for tar command plus a path * Fix circular include * Github functions do not require access to core.h anyway * Add comments to union * Update README to mention template function availability * Add EnvCtl structure * Add runtime checks to avoid running all the way to the end only to be met with a configuration error. * Rename GITHUB to GH * Development docs pre-rough-draft
Diffstat (limited to 'include/template.h')
-rw-r--r--include/template.h52
1 files changed, 33 insertions, 19 deletions
diff --git a/include/template.h b/include/template.h
index ba62667..e3d83fb 100644
--- a/include/template.h
+++ b/include/template.h
@@ -40,28 +40,42 @@ 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 *data_out);
+
struct tplfunc_frame {
- char *key;
- tplfunc *func;
- int argc;
+ char *key; ///< Name of the function
+ tplfunc *func; ///< Pointer to the function
+ void *data_in; ///< Pointer to internal data (can be NULL)
+ int argc; ///< Maximum number of arguments to accept
union {
- char **t_char_refptr;
- char *t_char_ptr;
- void *t_void_ptr;
- int *t_int_ptr;
- unsigned *t_uint_ptr;
- float *t_float_ptr;
- double *t_double_ptr;
- char t_char;
- int t_int;
- unsigned t_uint;
- float t_float;
- double t_double;
+ char **t_char_refptr; ///< &pointer
+ char *t_char_ptr; ///< pointer
+ void *t_void_ptr; ///< pointer to void
+ int *t_int_ptr; ///< pointer to int
+ unsigned *t_uint_ptr; ///< pointer to unsigned int
+ float *t_float_ptr; ///< pointer to float
+ double *t_double_ptr; ///< pointer to double
+ char t_char; ///< type of char
+ int t_int; ///< type of int
+ unsigned t_uint; ///< type of unsigned int
+ float t_float; ///< type of float
+ double t_double; ///< type of 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, void *data_in);
+
+/**
+ * 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