diff options
author | Valentin Bartenev <vbart@nginx.com> | 2020-08-13 02:46:54 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2020-08-13 02:46:54 +0300 |
commit | 93146616cf56a94fc2979cb978c7b451c5592594 (patch) | |
tree | db840e75ef2c08731e699b4eb44641ad6639c2ca /src/nxt_var.h | |
parent | 21ac95f17e70f2f20fe8e2a99bbe9cc7328a6e62 (diff) | |
download | unit-93146616cf56a94fc2979cb978c7b451c5592594.tar.gz unit-93146616cf56a94fc2979cb978c7b451c5592594.tar.bz2 |
Basic variables support.
Diffstat (limited to 'src/nxt_var.h')
-rw-r--r-- | src/nxt_var.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/nxt_var.h b/src/nxt_var.h new file mode 100644 index 00000000..7e0a2a21 --- /dev/null +++ b/src/nxt_var.h @@ -0,0 +1,48 @@ + +/* + * Copyright (C) NGINX, Inc. + */ + +#ifndef _NXT_VAR_H_INCLUDED_ +#define _NXT_VAR_H_INCLUDED_ + + +typedef struct nxt_var_s nxt_var_t; +typedef struct nxt_var_query_s nxt_var_query_t; + + +typedef nxt_int_t (*nxt_var_handler_t)(nxt_task_t *task, + nxt_var_query_t *query, + nxt_str_t *str, + void *ctx); + +typedef struct { + nxt_str_t name; + nxt_var_handler_t handler; + uint32_t index; +} nxt_var_decl_t; + + +nxt_inline nxt_bool_t +nxt_is_var(nxt_str_t *str) +{ + return (nxt_memchr(str->start, '$', str->length) != NULL); +} + + +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_int_t nxt_var_test(nxt_str_t *str, u_char *error); + +nxt_int_t nxt_var_query_init(nxt_var_query_t **query_p, void *ctx, + nxt_mp_t *mp); +void nxt_var_query(nxt_task_t *task, nxt_var_query_t *query, + nxt_var_t *var, nxt_str_t *str); +void nxt_var_query_resolve(nxt_task_t *task, nxt_var_query_t *query, void *data, + nxt_work_handler_t ready, nxt_work_handler_t error); +void nxt_var_query_handle(nxt_task_t *task, nxt_var_query_t *query, + nxt_bool_t failed); + + +#endif /* _NXT_VAR_H_INCLUDED_ */ |