summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf.c
diff options
context:
space:
mode:
authoroxpa <iippolitov@gmail.com>2024-09-17 14:21:10 +0100
committeroxpa <iippolitov@gmail.com>2024-09-17 14:21:10 +0100
commit2417826d8bebf921ee1be102ef8ce702f0683d66 (patch)
tree76d29a1705415ed7368870826dbb2f04942ee794 /src/nxt_conf.c
parent0e79d961bb1ea68674961da1703ffedb1ddf6e43 (diff)
parent24ed91f40634372d99f67f0e4e3c2ac0abde81bd (diff)
downloadunit-2417826d8bebf921ee1be102ef8ce702f0683d66.tar.gz
unit-2417826d8bebf921ee1be102ef8ce702f0683d66.tar.bz2
Merge tag '1.33.0' into packaging.
Unit 1.33.0 release.
Diffstat (limited to 'src/nxt_conf.c')
-rw-r--r--src/nxt_conf.c120
1 files changed, 62 insertions, 58 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c
index 008cb968..bb229c33 100644
--- a/src/nxt_conf.c
+++ b/src/nxt_conf.c
@@ -123,23 +123,24 @@ static u_char *nxt_conf_json_parse_number(nxt_mp_t *mp, nxt_conf_value_t *value,
static void nxt_conf_json_parse_error(nxt_conf_json_error_t *error, u_char *pos,
const char *detail);
-static nxt_int_t nxt_conf_copy_value(nxt_mp_t *mp, nxt_conf_op_t *op,
- nxt_conf_value_t *dst, nxt_conf_value_t *src);
-static nxt_int_t nxt_conf_copy_array(nxt_mp_t *mp, nxt_conf_op_t *op,
- nxt_conf_value_t *dst, nxt_conf_value_t *src);
-static nxt_int_t nxt_conf_copy_object(nxt_mp_t *mp, nxt_conf_op_t *op,
- nxt_conf_value_t *dst, nxt_conf_value_t *src);
-
-static size_t nxt_conf_json_string_length(nxt_conf_value_t *value);
-static u_char *nxt_conf_json_print_string(u_char *p, nxt_conf_value_t *value);
-static size_t nxt_conf_json_array_length(nxt_conf_value_t *value,
+static nxt_int_t nxt_conf_copy_value(nxt_mp_t *mp, const nxt_conf_op_t *op,
+ nxt_conf_value_t *dst, const nxt_conf_value_t *src);
+static nxt_int_t nxt_conf_copy_array(nxt_mp_t *mp, const nxt_conf_op_t *op,
+ nxt_conf_value_t *dst, const nxt_conf_value_t *src);
+static nxt_int_t nxt_conf_copy_object(nxt_mp_t *mp, const nxt_conf_op_t *op,
+ nxt_conf_value_t *dst, const nxt_conf_value_t *src);
+
+static size_t nxt_conf_json_string_length(const nxt_conf_value_t *value);
+static u_char *nxt_conf_json_print_string(u_char *p,
+ const nxt_conf_value_t *value);
+static size_t nxt_conf_json_array_length(const nxt_conf_value_t *value,
nxt_conf_json_pretty_t *pretty);
-static u_char *nxt_conf_json_print_array(u_char *p, nxt_conf_value_t *value,
- nxt_conf_json_pretty_t *pretty);
-static size_t nxt_conf_json_object_length(nxt_conf_value_t *value,
- nxt_conf_json_pretty_t *pretty);
-static u_char *nxt_conf_json_print_object(u_char *p, nxt_conf_value_t *value,
+static u_char *nxt_conf_json_print_array(u_char *p,
+ const nxt_conf_value_t *value, nxt_conf_json_pretty_t *pretty);
+static size_t nxt_conf_json_object_length(const nxt_conf_value_t *value,
nxt_conf_json_pretty_t *pretty);
+static u_char *nxt_conf_json_print_object(u_char *p,
+ const nxt_conf_value_t *value, nxt_conf_json_pretty_t *pretty);
static size_t nxt_conf_json_escape_length(u_char *p, size_t size);
static u_char *nxt_conf_json_escape(u_char *dst, u_char *src, size_t size);
@@ -162,21 +163,22 @@ nxt_conf_json_indentation(u_char *p, uint32_t level)
void
-nxt_conf_get_string(nxt_conf_value_t *value, nxt_str_t *str)
+nxt_conf_get_string(const nxt_conf_value_t *value, nxt_str_t *str)
{
if (value->type == NXT_CONF_VALUE_SHORT_STRING) {
str->length = value->u.str.length;
- str->start = value->u.str.start;
+ str->start = (u_char *) value->u.str.start;
} else {
str->length = value->u.string.length;
- str->start = value->u.string.start;
+ str->start = (u_char *) value->u.string.start;
}
}
nxt_str_t *
-nxt_conf_get_string_dup(nxt_conf_value_t *value, nxt_mp_t *mp, nxt_str_t *str)
+nxt_conf_get_string_dup(const nxt_conf_value_t *value, nxt_mp_t *mp,
+ nxt_str_t *str)
{
nxt_str_t s;
@@ -186,7 +188,7 @@ nxt_conf_get_string_dup(nxt_conf_value_t *value, nxt_mp_t *mp, nxt_str_t *str)
void
-nxt_conf_set_string(nxt_conf_value_t *value, nxt_str_t *str)
+nxt_conf_set_string(nxt_conf_value_t *value, const nxt_str_t *str)
{
if (str->length > NXT_CONF_MAX_SHORT_STRING) {
value->type = NXT_CONF_VALUE_STRING;
@@ -245,7 +247,7 @@ nxt_conf_get_boolean(nxt_conf_value_t *value)
nxt_uint_t
-nxt_conf_object_members_count(nxt_conf_value_t *value)
+nxt_conf_object_members_count(const nxt_conf_value_t *value)
{
return value->u.object->count;
}
@@ -276,7 +278,7 @@ nxt_conf_create_object(nxt_mp_t *mp, nxt_uint_t count)
void
-nxt_conf_set_member(nxt_conf_value_t *object, nxt_str_t *name,
+nxt_conf_set_member(nxt_conf_value_t *object, const nxt_str_t *name,
const nxt_conf_value_t *value, uint32_t index)
{
nxt_conf_object_member_t *member;
@@ -290,8 +292,8 @@ nxt_conf_set_member(nxt_conf_value_t *object, nxt_str_t *name,
nxt_int_t
-nxt_conf_set_member_dup(nxt_conf_value_t *object, nxt_mp_t *mp, nxt_str_t *name,
- nxt_conf_value_t *value, uint32_t index)
+nxt_conf_set_member_dup(nxt_conf_value_t *object, nxt_mp_t *mp,
+ const nxt_str_t *name, const nxt_conf_value_t *value, uint32_t index)
{
nxt_conf_object_member_t *member;
@@ -304,8 +306,8 @@ nxt_conf_set_member_dup(nxt_conf_value_t *object, nxt_mp_t *mp, nxt_str_t *name,
void
-nxt_conf_set_member_string(nxt_conf_value_t *object, nxt_str_t *name,
- nxt_str_t *value, uint32_t index)
+nxt_conf_set_member_string(nxt_conf_value_t *object, const nxt_str_t *name,
+ const nxt_str_t *value, uint32_t index)
{
nxt_conf_object_member_t *member;
@@ -319,7 +321,7 @@ nxt_conf_set_member_string(nxt_conf_value_t *object, nxt_str_t *name,
nxt_int_t
nxt_conf_set_member_string_dup(nxt_conf_value_t *object, nxt_mp_t *mp,
- nxt_str_t *name, nxt_str_t *value, uint32_t index)
+ const nxt_str_t *name, const nxt_str_t *value, uint32_t index)
{
nxt_conf_object_member_t *member;
@@ -332,7 +334,7 @@ nxt_conf_set_member_string_dup(nxt_conf_value_t *object, nxt_mp_t *mp,
void
-nxt_conf_set_member_integer(nxt_conf_value_t *object, nxt_str_t *name,
+nxt_conf_set_member_integer(nxt_conf_value_t *object, const nxt_str_t *name,
int64_t value, uint32_t index)
{
u_char *p, *end;
@@ -353,7 +355,7 @@ nxt_conf_set_member_integer(nxt_conf_value_t *object, nxt_str_t *name,
void
-nxt_conf_set_member_null(nxt_conf_value_t *object, nxt_str_t *name,
+nxt_conf_set_member_null(nxt_conf_value_t *object, const nxt_str_t *name,
uint32_t index)
{
nxt_conf_object_member_t *member;
@@ -400,7 +402,7 @@ nxt_conf_set_element(nxt_conf_value_t *array, nxt_uint_t index,
nxt_int_t
nxt_conf_set_element_string_dup(nxt_conf_value_t *array, nxt_mp_t *mp,
- nxt_uint_t index, nxt_str_t *value)
+ nxt_uint_t index, const nxt_str_t *value)
{
nxt_conf_value_t *element;
@@ -411,21 +413,21 @@ nxt_conf_set_element_string_dup(nxt_conf_value_t *array, nxt_mp_t *mp,
nxt_uint_t
-nxt_conf_array_elements_count(nxt_conf_value_t *value)
+nxt_conf_array_elements_count(const nxt_conf_value_t *value)
{
return value->u.array->count;
}
nxt_uint_t
-nxt_conf_array_elements_count_or_1(nxt_conf_value_t *value)
+nxt_conf_array_elements_count_or_1(const 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)
+nxt_conf_type(const nxt_conf_value_t *value)
{
switch (value->type) {
@@ -459,7 +461,7 @@ nxt_conf_type(nxt_conf_value_t *value)
nxt_conf_value_t *
-nxt_conf_get_path(nxt_conf_value_t *value, nxt_str_t *path)
+nxt_conf_get_path(nxt_conf_value_t *value, const nxt_str_t *path)
{
nxt_str_t token;
nxt_int_t ret, index;
@@ -550,7 +552,7 @@ nxt_conf_path_next_token(nxt_conf_path_parse_t *parse, nxt_str_t *token)
nxt_conf_value_t *
-nxt_conf_get_object_member(nxt_conf_value_t *value, nxt_str_t *name,
+nxt_conf_get_object_member(const nxt_conf_value_t *value, const nxt_str_t *name,
uint32_t *index)
{
nxt_str_t str;
@@ -584,8 +586,8 @@ nxt_conf_get_object_member(nxt_conf_value_t *value, nxt_str_t *name,
nxt_int_t
-nxt_conf_map_object(nxt_mp_t *mp, nxt_conf_value_t *value, nxt_conf_map_t *map,
- nxt_uint_t n, void *data)
+nxt_conf_map_object(nxt_mp_t *mp, const nxt_conf_value_t *value,
+ const nxt_conf_map_t *map, nxt_uint_t n, void *data)
{
double num;
nxt_str_t str, *s;
@@ -736,7 +738,7 @@ nxt_conf_map_object(nxt_mp_t *mp, nxt_conf_value_t *value, nxt_conf_map_t *map,
nxt_conf_value_t *
-nxt_conf_next_object_member(nxt_conf_value_t *value, nxt_str_t *name,
+nxt_conf_next_object_member(const nxt_conf_value_t *value, nxt_str_t *name,
uint32_t *next)
{
uint32_t n;
@@ -764,7 +766,7 @@ nxt_conf_next_object_member(nxt_conf_value_t *value, nxt_str_t *name,
nxt_conf_value_t *
-nxt_conf_get_array_element(nxt_conf_value_t *value, uint32_t index)
+nxt_conf_get_array_element(const nxt_conf_value_t *value, uint32_t index)
{
nxt_conf_array_t *array;
@@ -802,7 +804,7 @@ nxt_conf_get_array_element_or_itself(nxt_conf_value_t *value, uint32_t index)
void
-nxt_conf_array_qsort(nxt_conf_value_t *value,
+nxt_conf_array_qsort(const nxt_conf_value_t *value,
int (*compare)(const void *, const void *))
{
nxt_conf_array_t *array;
@@ -818,8 +820,9 @@ nxt_conf_array_qsort(nxt_conf_value_t *value,
nxt_conf_op_ret_t
-nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root,
- nxt_str_t *path, nxt_conf_value_t *value, nxt_bool_t add)
+nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops,
+ const nxt_conf_value_t *root, const nxt_str_t *path,
+ nxt_conf_value_t *value, nxt_bool_t add)
{
nxt_str_t token;
nxt_int_t ret, index;
@@ -956,7 +959,7 @@ nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root,
nxt_conf_value_t *
-nxt_conf_clone(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *value)
+nxt_conf_clone(nxt_mp_t *mp, nxt_conf_op_t *op, const nxt_conf_value_t *value)
{
nxt_int_t rc;
nxt_conf_value_t *copy;
@@ -977,8 +980,8 @@ nxt_conf_clone(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *value)
static nxt_int_t
-nxt_conf_copy_value(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *dst,
- nxt_conf_value_t *src)
+nxt_conf_copy_value(nxt_mp_t *mp, const nxt_conf_op_t *op,
+ nxt_conf_value_t *dst, const nxt_conf_value_t *src)
{
if (op != NULL
&& src->type != NXT_CONF_VALUE_ARRAY
@@ -1020,8 +1023,8 @@ nxt_conf_copy_value(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *dst,
static nxt_int_t
-nxt_conf_copy_array(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *dst,
- nxt_conf_value_t *src)
+nxt_conf_copy_array(nxt_mp_t *mp, const nxt_conf_op_t *op,
+ nxt_conf_value_t *dst, const nxt_conf_value_t *src)
{
size_t size;
nxt_int_t rc;
@@ -1120,8 +1123,8 @@ nxt_conf_copy_array(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *dst,
static nxt_int_t
-nxt_conf_copy_object(nxt_mp_t *mp, nxt_conf_op_t *op, nxt_conf_value_t *dst,
- nxt_conf_value_t *src)
+nxt_conf_copy_object(nxt_mp_t *mp, const nxt_conf_op_t *op,
+ nxt_conf_value_t *dst, const nxt_conf_value_t *src)
{
size_t size;
nxt_int_t rc;
@@ -1441,7 +1444,7 @@ nxt_conf_json_parse_value(nxt_mp_t *mp, nxt_conf_value_t *value, u_char *start,
goto error;
}
- if (nxt_fast_path((ch - '0') <= 9)) {
+ if (nxt_fast_path((u_char)(ch - '0') <= 9)) {
p = nxt_conf_json_parse_number(mp, value, start, end, error);
if (nxt_slow_path(p == NULL)) {
@@ -2232,7 +2235,8 @@ nxt_conf_json_parse_error(nxt_conf_json_error_t *error, u_char *pos,
size_t
-nxt_conf_json_length(nxt_conf_value_t *value, nxt_conf_json_pretty_t *pretty)
+nxt_conf_json_length(const nxt_conf_value_t *value,
+ nxt_conf_json_pretty_t *pretty)
{
switch (value->type) {
@@ -2264,7 +2268,7 @@ nxt_conf_json_length(nxt_conf_value_t *value, nxt_conf_json_pretty_t *pretty)
u_char *
-nxt_conf_json_print(u_char *p, nxt_conf_value_t *value,
+nxt_conf_json_print(u_char *p, const nxt_conf_value_t *value,
nxt_conf_json_pretty_t *pretty)
{
switch (value->type) {
@@ -2298,7 +2302,7 @@ nxt_conf_json_print(u_char *p, nxt_conf_value_t *value,
static size_t
-nxt_conf_json_string_length(nxt_conf_value_t *value)
+nxt_conf_json_string_length(const nxt_conf_value_t *value)
{
nxt_str_t str;
@@ -2309,7 +2313,7 @@ nxt_conf_json_string_length(nxt_conf_value_t *value)
static u_char *
-nxt_conf_json_print_string(u_char *p, nxt_conf_value_t *value)
+nxt_conf_json_print_string(u_char *p, const nxt_conf_value_t *value)
{
nxt_str_t str;
@@ -2326,7 +2330,7 @@ nxt_conf_json_print_string(u_char *p, nxt_conf_value_t *value)
static size_t
-nxt_conf_json_array_length(nxt_conf_value_t *value,
+nxt_conf_json_array_length(const nxt_conf_value_t *value,
nxt_conf_json_pretty_t *pretty)
{
size_t len;
@@ -2368,7 +2372,7 @@ nxt_conf_json_array_length(nxt_conf_value_t *value,
static u_char *
-nxt_conf_json_print_array(u_char *p, nxt_conf_value_t *value,
+nxt_conf_json_print_array(u_char *p, const nxt_conf_value_t *value,
nxt_conf_json_pretty_t *pretty)
{
nxt_uint_t n;
@@ -2420,7 +2424,7 @@ nxt_conf_json_print_array(u_char *p, nxt_conf_value_t *value,
static size_t
-nxt_conf_json_object_length(nxt_conf_value_t *value,
+nxt_conf_json_object_length(const nxt_conf_value_t *value,
nxt_conf_json_pretty_t *pretty)
{
size_t len;
@@ -2464,7 +2468,7 @@ nxt_conf_json_object_length(nxt_conf_value_t *value,
static u_char *
-nxt_conf_json_print_object(u_char *p, nxt_conf_value_t *value,
+nxt_conf_json_print_object(u_char *p, const nxt_conf_value_t *value,
nxt_conf_json_pretty_t *pretty)
{
nxt_uint_t n;