This commit is contained in:
parent
4f4b780b28
commit
0c8c6c2b63
5 changed files with 183 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue