summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_var.h
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2022-07-14 04:32:49 +0800
committerZhidao HONG <z.hong@f5.com>2022-07-14 04:32:49 +0800
commit45b89e32577eef18e473d0c7ae24562e7efedcc0 (patch)
treed7058ec9ad0fb257897873cc1429182425d17b9b /src/nxt_var.h
parent7b80186f097fda3d1c0758a30efa889ec89c5a9d (diff)
downloadunit-45b89e32577eef18e473d0c7ae24562e7efedcc0.tar.gz
unit-45b89e32577eef18e473d0c7ae24562e7efedcc0.tar.bz2
Var: dynamic variables support.
This commit adds the variables $arg_NAME, $header_NAME, and $cookie_NAME.
Diffstat (limited to 'src/nxt_var.h')
-rw-r--r--src/nxt_var.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/nxt_var.h b/src/nxt_var.h
index 1322d507..3c38be36 100644
--- a/src/nxt_var.h
+++ b/src/nxt_var.h
@@ -13,15 +13,25 @@ typedef struct nxt_var_query_s nxt_var_query_t;
typedef nxt_int_t (*nxt_var_handler_t)(nxt_task_t *task,
nxt_str_t *str,
- void *ctx);
+ void *ctx, uint16_t field);
+
+typedef int64_t (*nxt_var_field_hash_t)(nxt_mp_t *mp, nxt_str_t *str);
typedef struct {
- nxt_str_t name;
- nxt_var_handler_t handler;
- uint32_t index;
+ nxt_str_t name;
+ nxt_var_handler_t handler;
+ nxt_var_field_hash_t field_hash;
+ uint32_t index;
} nxt_var_decl_t;
+typedef struct {
+ nxt_str_t name;
+ uint16_t hash;
+ uint32_t index;
+} nxt_var_field_t;
+
+
nxt_inline nxt_bool_t
nxt_is_var(nxt_str_t *str)
{
@@ -31,11 +41,15 @@ nxt_is_var(nxt_str_t *str)
nxt_int_t nxt_var_register(nxt_var_decl_t *decl, size_t n);
nxt_int_t nxt_var_index_init(void);
-nxt_var_t *nxt_var_compile(nxt_str_t *str, nxt_mp_t *mp, nxt_bool_t strz);
-nxt_int_t nxt_var_test(nxt_str_t *str, u_char *error);
-void nxt_var_raw(nxt_var_t *var, nxt_str_t *str);
+nxt_var_field_t *nxt_var_field_get(nxt_array_t *fields, uint16_t index);
+
+nxt_var_t *nxt_var_compile(nxt_str_t *str, nxt_mp_t *mp, nxt_array_t *fields,
+ nxt_bool_t strz);
+nxt_int_t nxt_var_test(nxt_str_t *str, nxt_array_t *fields, u_char *error);
+
nxt_bool_t nxt_var_is_const(nxt_var_t *var);
+void nxt_var_raw(nxt_var_t *var, nxt_str_t *str);
nxt_int_t nxt_var_query_init(nxt_var_query_t **query_p, void *ctx,
nxt_mp_t *mp);