47 lines
1.6 KiB
C
47 lines
1.6 KiB
C
/*
|
|
* this is free software: you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published
|
|
* by the Free Software Foundation, either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* this is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
|
|
*
|
|
* (c) Alexander Vdolainen 2007, 2026 <alex@vapaa.xyz>
|
|
* subrelay: a minimalistic maillist server based on external IMAPs/SMTPs
|
|
*
|
|
* template.h: expand templates
|
|
*
|
|
*/
|
|
#ifndef __TEMPLATE_H__
|
|
#define __TEMPLATE_H__
|
|
|
|
#include <stddef.h>
|
|
|
|
typedef struct template_var {
|
|
const char *key;
|
|
const char *val;
|
|
} 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__ */
|