diff options
Diffstat (limited to 'src/nxt_conf.c')
-rw-r--r-- | src/nxt_conf.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c index 1aca0a7e..79e776a0 100644 --- a/src/nxt_conf.c +++ b/src/nxt_conf.c @@ -192,7 +192,8 @@ nxt_conf_set_string(nxt_conf_value_t *value, nxt_str_t *str) nxt_int_t -nxt_conf_set_string_dup(nxt_conf_value_t *value, nxt_mp_t *mp, nxt_str_t *str) +nxt_conf_set_string_dup(nxt_conf_value_t *value, nxt_mp_t *mp, + const nxt_str_t *str) { nxt_str_t tmp, *ptr; @@ -392,6 +393,13 @@ nxt_conf_array_elements_count(nxt_conf_value_t *value) nxt_uint_t +nxt_conf_array_elements_count_or_1(nxt_conf_value_t *value) +{ + return (value->type == NXT_CONF_VALUE_ARRAY) ? value->u.array->count : 1; +} + + +nxt_uint_t nxt_conf_type(nxt_conf_value_t *value) { switch (value->type) { @@ -749,6 +757,25 @@ nxt_conf_get_array_element(nxt_conf_value_t *value, uint32_t index) } +nxt_conf_value_t * +nxt_conf_get_array_element_or_itself(nxt_conf_value_t *value, uint32_t index) +{ + nxt_conf_array_t *array; + + if (value->type != NXT_CONF_VALUE_ARRAY) { + return (index == 0) ? value : NULL; + } + + array = value->u.array; + + if (index >= array->count) { + return NULL; + } + + return &array->elements[index]; +} + + void nxt_conf_array_qsort(nxt_conf_value_t *value, int (*compare)(const void *, const void *)) |