diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-02-06 10:14:48 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-02-06 10:14:48 -0500 |
commit | 906b120e249c7d73fcd03477bafbdd80ce61b7eb (patch) | |
tree | f728224fa9629085c259714810d6c8033691a7e0 /include | |
parent | bf3a29fbe20b0b2bd0339c76c3b279cea63b59f2 (diff) | |
download | stasis-906b120e249c7d73fcd03477bafbdd80ce61b7eb.tar.gz |
Fix addressing issue...
* Store the address of the pointer to template variable, instead of the pointer. Whoops!
* Pre-declare all template pointers as early as possible to make them available to the entire program
* Comment tpl_*() prototypes
Diffstat (limited to 'include')
-rw-r--r-- | include/template.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/include/template.h b/include/template.h index 36d3c2a..24ca98f 100644 --- a/include/template.h +++ b/include/template.h @@ -7,10 +7,32 @@ #include "omc.h" -void tpl_register(char *key, char *ptr); +/** + * Map a text value to a pointer in memory + * + * @param key in-text variable name + * @param ptr pointer to string + */ +void tpl_register(char *key, char **ptr); + +/** + * Free the template engine + */ void tpl_free(); + +/** + * Retrieve the value of a key mapped by the template engine + * @param key string registered by `tpl_register` + * @return a pointer to value, or NULL if the key is not present + */ char *tpl_getval(char *key); -char *tpl_render(char *str); +/** + * Replaces occurrences of all registered key value pairs in `str` + * @param str the text data to render + * @return a rendered copy of `str`, or NULL. + * The caller is responsible for free()ing memory allocated by this function + */ +char *tpl_render(char *str); #endif //OMC_TEMPLATE_H |