diff options
author | Zhidao HONG <z.hong@f5.com> | 2024-08-16 00:06:45 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2024-08-20 09:17:23 +0800 |
commit | 82e168fe01306cf03f8eaba284f31f7285347424 (patch) | |
tree | f04ed5df9b62e967315fc87916ad48137135c674 /src/nxt_tstr.c | |
parent | 5f6ae1a189b1736eb7cc35f1ff8018fd8606db9b (diff) | |
download | unit-82e168fe01306cf03f8eaba284f31f7285347424.tar.gz unit-82e168fe01306cf03f8eaba284f31f7285347424.tar.bz2 |
http: Refactor out nxt_tstr_cond_t from the access log module
This nxt_tstr_cond_t will be reused for the feature of adding "if"
option to the "match" object. The two "if" options have the same usage.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_tstr.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nxt_tstr.c b/src/nxt_tstr.c index a6d2e7ad..50df4c47 100644 --- a/src/nxt_tstr.c +++ b/src/nxt_tstr.c @@ -196,6 +196,26 @@ nxt_tstr_state_release(nxt_tstr_state_t *state) } +nxt_int_t +nxt_tstr_cond_compile(nxt_tstr_state_t *state, nxt_str_t *str, + nxt_tstr_cond_t *cond) +{ + if (str->length > 0 && str->start[0] == '!') { + cond->negate = 1; + + str->start++; + str->length--; + } + + cond->expr = nxt_tstr_compile(state, str, 0); + if (nxt_slow_path(cond->expr == NULL)) { + return NXT_ERROR; + } + + return NXT_OK; +} + + nxt_bool_t nxt_tstr_is_const(nxt_tstr_t *tstr) { |