feat(ltm): support custom data reader functions
This commit is contained in:
parent
f37cfc30af
commit
845ec95bf1
4 changed files with 90 additions and 8 deletions
|
|
@ -39,6 +39,9 @@ void ltm_template_free(ltm_template *template);
|
|||
*/
|
||||
typedef struct ltm_instance ltm_instance;
|
||||
|
||||
typedef ltm_err (*ltm_data_fn)(size_t *written, char *buf, size_t len,
|
||||
void *data);
|
||||
|
||||
/**
|
||||
* Create a new instance of the given template.
|
||||
*/
|
||||
|
|
@ -56,6 +59,7 @@ typedef enum ltm_instance_block_type {
|
|||
ltm_instance_block_type_file,
|
||||
ltm_instance_block_type_file_owned,
|
||||
ltm_instance_block_type_nested,
|
||||
ltm_instance_block_type_fn,
|
||||
} ltm_instance_block_type;
|
||||
|
||||
/**
|
||||
|
|
@ -65,6 +69,12 @@ ltm_err ltm_instance_block_add_var(ltm_instance *instance, const char *name,
|
|||
ltm_instance_block_type type, void *data,
|
||||
size_t len);
|
||||
|
||||
/**
|
||||
* Add a new variable to the template whose data is provided by a data function.
|
||||
*/
|
||||
ltm_err ltm_instance_block_add_var_fn(ltm_instance *instance, const char *name,
|
||||
ltm_data_fn fn, void *data, size_t len);
|
||||
|
||||
/**
|
||||
* Add a new nested instance to the instance, returning a handle to the nested
|
||||
* instance.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue