feat(ltm): wip compile
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Jef Roosens 2023-12-14 22:28:56 +01:00
parent 4f4b780b28
commit 0c8c6c2b63
Signed by: Jef Roosens
GPG key ID: 02D4C0997E74717B
5 changed files with 183 additions and 16 deletions

View file

@ -1,8 +1,26 @@
#ifndef LTM_COMMON
#define LTM_COMMON
#define LTM_RES(x) \
{ \
ltm_err res = x; \
if (res != ltm_err_ok) \
return res; \
}
#define LTM_RES2(x, e) \
{ \
ltm_err res = x; \
if (res != ltm_err_ok) { \
e; \
return res; \
} \
}
typedef enum ltm_err {
ltm_err_ok = 0,
ltm_invalid_template,
ltm_failed_alloc,
} ltm_err;
#endif

View file

@ -8,23 +8,23 @@
/**
* Represents a compiled template
*/
typedef struct lnm_template lnm_template;
typedef struct ltm_template ltm_template;
/**
* Compile the given template.
*
* @param out where to store pointer to newly allocated `lnm_template`
* @param out where to store pointer to newly allocated `ltm_template`
* @param template nul-terminated string containing the template
*/
ltm_err lnm_template_compile(lnm_template **out, const char *template);
ltm_err ltm_template_compile(ltm_template **out, const char *template);
/**
* Compile the given template with a given length.
*
* @param out where to store pointer to newly allocated `lnm_template`
* @param out where to store pointer to newly allocated `ltm_template`
* @param template char buffer containing the template
* @param len length of the char buffer
*/
ltm_err lnm_template_compile_n(lnm_template **out, const char *template, size_t len);
ltm_err ltm_template_compile_n(ltm_template **out, const char *template, size_t len);
#endif