feat(ltm): initial write function

This commit is contained in:
Jef Roosens 2023-12-16 20:42:07 +01:00
parent 750bee27c7
commit c26c8cf18a
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
5 changed files with 130 additions and 7 deletions

View file

@ -17,12 +17,16 @@
} \
}
#define LTM_MIN(x, y) ((x) < (y) ? (x) : (y))
#define LTM_MAX(x, y) ((x) > (y) ? (x) : (y))
typedef enum ltm_err {
ltm_err_ok = 0,
ltm_err_invalid_template,
ltm_err_failed_alloc,
ltm_err_not_found,
ltm_err_wrong_block_type,
ltm_err_done,
} ltm_err;
#endif

View file

@ -70,4 +70,23 @@ ltm_err ltm_instance_block_add_var(ltm_instance *instance, const char *name,
ltm_err ltm_instance_block_add_nested(ltm_instance **out,
ltm_instance *instance, const char *name);
/**
* Calculate the size of the resulting output of this instance.
*/
size_t ltm_instance_size(const ltm_instance *instance);
/**
* Write at most `len` bytes to the given buffer.
*
* @param written outputs how many bytes were written to `buf`
* @param buf buffer to write to
* @param len length of the buffer
* @param instance instance to write
* @return `ltm_err_ok` if write was successful but there's more to be written,
* `ltm_err_done` if everything has been written successfully, or some other
* error code
*/
ltm_err ltm_instance_write(size_t *written, char *buf, size_t len,
ltm_instance *instance);
#endif