diff options
author | Zhidao HONG <z.hong@f5.com> | 2022-11-20 23:16:51 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2022-11-20 23:16:51 +0800 |
commit | 4d6d146e920667a8afeacd355e4fb6a94387066e (patch) | |
tree | d25e70f93a4f91960434c4d631072e9936f80e36 /src/nxt_tstr.h | |
parent | 4735931ace321752c387dae04c8b217ef22897ee (diff) | |
download | unit-4d6d146e920667a8afeacd355e4fb6a94387066e.tar.gz unit-4d6d146e920667a8afeacd355e4fb6a94387066e.tar.bz2 |
Basic njs support.
Diffstat (limited to 'src/nxt_tstr.h')
-rw-r--r-- | src/nxt_tstr.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/nxt_tstr.h b/src/nxt_tstr.h index 692b9d28..0cc24292 100644 --- a/src/nxt_tstr.h +++ b/src/nxt_tstr.h @@ -7,6 +7,8 @@ #define _NXT_TSTR_H_INCLUDED_ +#include <nxt_js.h> + typedef struct nxt_tstr_s nxt_tstr_t; typedef struct nxt_tstr_query_s nxt_tstr_query_t; @@ -14,25 +16,38 @@ typedef struct nxt_tstr_query_s nxt_tstr_query_t; typedef struct { nxt_mp_t *pool; nxt_array_t *var_fields; +#if (NXT_HAVE_NJS) + nxt_js_conf_t *jcf; +#endif + uint8_t test; /* 1 bit */ } nxt_tstr_state_t; +typedef struct { + nxt_var_cache_t var; +#if (NXT_HAVE_NJS) + nxt_js_cache_t js; +#endif +} nxt_tstr_cache_t; + + typedef enum { NXT_TSTR_STRZ = 1 << 0, NXT_TSTR_LOGGING = 1 << 1, } nxt_tstr_flags_t; -nxt_tstr_state_t *nxt_tstr_state_new(nxt_mp_t *mp); +nxt_tstr_state_t *nxt_tstr_state_new(nxt_mp_t *mp, nxt_bool_t test); nxt_tstr_t *nxt_tstr_compile(nxt_tstr_state_t *state, nxt_str_t *str, nxt_tstr_flags_t flags); nxt_int_t nxt_tstr_test(nxt_tstr_state_t *state, nxt_str_t *str, u_char *error); +nxt_int_t nxt_tstr_state_done(nxt_tstr_state_t *state, u_char *error); nxt_bool_t nxt_tstr_is_const(nxt_tstr_t *tstr); void nxt_tstr_str(nxt_tstr_t *tstr, nxt_str_t *str); nxt_int_t nxt_tstr_query_init(nxt_tstr_query_t **query_p, - nxt_tstr_state_t *state, nxt_var_cache_t *cache, void *ctx, + nxt_tstr_state_t *state, nxt_tstr_cache_t *cache, void *ctx, nxt_mp_t *mp); void nxt_tstr_query(nxt_task_t *task, nxt_tstr_query_t *query, nxt_tstr_t *tstr, nxt_str_t *val); @@ -42,4 +57,23 @@ void nxt_tstr_query_handle(nxt_task_t *task, nxt_tstr_query_t *query, nxt_bool_t failed); +nxt_inline nxt_bool_t +nxt_is_tstr(nxt_str_t *str) +{ + u_char *p; + + p = memchr(str->start, '`', str->length); + if (p != NULL) { + return 1; + } + + p = memchr(str->start, '$', str->length); + if (p != NULL) { + return 1; + } + + return 0; +} + + #endif /* _NXT_TSTR_H_INCLUDED_ */ |