STASIS
A pipeline delivery generator
Loading...
Searching...
No Matches
template.h File Reference
#include "core.h"
Include dependency graph for template.h:

Go to the source code of this file.

Data Structures

struct  tplfunc_frame
 

Typedefs

typedef int tplfunc(struct tplfunc_frame *frame, void *data_out)
 

Functions

void tpl_register (char *key, char **ptr)
 
void tpl_free ()
 
char * tpl_getval (char *key)
 
char * tpl_render (char *str)
 
int tpl_render_to_file (char *str, const char *filename)
 
void tpl_register_func (char *key, tplfunc *tplfunc_ptr, int argc, void *data_in)
 
struct tplfunc_frametpl_getfunc (char *key)
 

Function Documentation

◆ tpl_free()

void tpl_free ( )

Free the template engine

Here is the call graph for this function:

◆ tpl_getfunc()

struct tplfunc_frame * tpl_getfunc ( char * key)

Get the function frame associated with a template function

Parameters
keyfunction name
Returns
tplfunc_frame structure

◆ tpl_getval()

char * tpl_getval ( char * key)

Retrieve the value of a key mapped by the template engine

Parameters
keystring registered by tpl_register
Returns
a pointer to value, or NULL if the key is not present

◆ tpl_register()

void tpl_register ( char * key,
char ** ptr )

Map a text value to a pointer in memory

Parameters
keyin-text variable name
ptrpointer to string

◆ tpl_register_func()

void tpl_register_func ( char * key,
tplfunc * tplfunc_ptr,
int argc,
void * data_in )

Register a template function

Parameters
keyfunction name to expose to "func:" interface
tplfunc_ptrpointer to function of type tplfunc
argcnumber of function arguments to accept
data_inpointer to function input data

◆ tpl_render()

char * tpl_render ( char * str)

Replaces occurrences of all registered key value pairs in str

Parameters
strthe text data to render
Returns
a rendered copy of str, or NULL. The caller is responsible for free()ing memory allocated by this function
Here is the call graph for this function:

◆ tpl_render_to_file()

int tpl_render_to_file ( char * str,
const char * filename )

Write tpl_render() output to a file

Parameters
strthe text to render
filenamethe output file name
Returns
0 on success, <0 on error
Here is the call graph for this function: