summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nxt_conf.c')
-rw-r--r--src/nxt_conf.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c
index 8546e2b7..79e776a0 100644
--- a/src/nxt_conf.c
+++ b/src/nxt_conf.c
@@ -393,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) {
@@ -750,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 *))