28 lines
969 B
C
28 lines
969 B
C
/* template.h - Template parser and string variable substitution engine */
|
|
#ifndef __TEMPLATE_H__
|
|
#define __TEMPLATE_H__
|
|
|
|
#include <stddef.h>
|
|
|
|
typedef struct template_var {
|
|
const char *key; /* e.g., "MAILLIST_NAME" (without the '$') */
|
|
const char *val; /* e.g., "Civilisation List" */
|
|
} template_var_t;
|
|
|
|
/*
|
|
* Renders a template file from disk, substituting all $KEY matches.
|
|
*
|
|
* @param template_path Path to the template text file
|
|
* @param vars Array of key-value replacement pairs
|
|
* @param var_count Number of entries in vars array
|
|
* @return Dynamically allocated string (caller must free()), or NULL on error.
|
|
*/
|
|
char *template_render_file(const char *template_path, const template_var_t *vars, size_t var_count);
|
|
|
|
/*
|
|
* Renders a template string from memory, substituting all $KEY matches.
|
|
*/
|
|
char *template_render_string(const char *template_src, const template_var_t *vars, size_t var_count);
|
|
|
|
#endif /* __TEMPLATE_H__ */
|