Renames and reordering of parameters in configuration parser functions.
Requested by Igor.
This commit is contained in:
@@ -14,8 +14,8 @@ typedef struct nxt_conf_json_op_s nxt_conf_json_op_t;
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
nxt_uint_t level;
|
uint32_t level;
|
||||||
nxt_bool_t more_space; /* 1 bit. */
|
uint8_t more_space; /* 1 bit. */
|
||||||
} nxt_conf_json_pretty_t;
|
} nxt_conf_json_pretty_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -24,16 +24,19 @@ nxt_conf_json_value_t *nxt_conf_json_get_value(nxt_conf_json_value_t *value,
|
|||||||
nxt_conf_json_value_t *nxt_conf_json_object_get_member(
|
nxt_conf_json_value_t *nxt_conf_json_object_get_member(
|
||||||
nxt_conf_json_value_t *value, nxt_str_t *name, uint32_t *index);
|
nxt_conf_json_value_t *value, nxt_str_t *name, uint32_t *index);
|
||||||
|
|
||||||
nxt_int_t nxt_conf_json_op_compile(nxt_conf_json_value_t *object,
|
nxt_int_t nxt_conf_json_op_compile(nxt_mp_t *mp, nxt_conf_json_op_t **ops,
|
||||||
nxt_conf_json_value_t *value, nxt_conf_json_op_t **ops, nxt_str_t *path,
|
nxt_conf_json_value_t *root, nxt_str_t *path,
|
||||||
nxt_mp_t *pool);
|
nxt_conf_json_value_t *value);
|
||||||
nxt_conf_json_value_t *nxt_conf_json_clone_value(nxt_conf_json_value_t *value,
|
nxt_conf_json_value_t *nxt_conf_json_clone_value(nxt_mp_t *mp,
|
||||||
nxt_conf_json_op_t *op, nxt_mp_t *pool);
|
nxt_conf_json_op_t *op, nxt_conf_json_value_t *value);
|
||||||
|
|
||||||
nxt_conf_json_value_t *nxt_conf_json_parse(u_char *pos, size_t length,
|
nxt_conf_json_value_t *nxt_conf_json_parse(nxt_mp_t *mp, u_char *start,
|
||||||
nxt_mp_t *pool);
|
u_char *end);
|
||||||
|
|
||||||
uintptr_t nxt_conf_json_print_value(u_char *pos, nxt_conf_json_value_t *value,
|
#define nxt_conf_json_str_parse(mp, str) \
|
||||||
|
nxt_conf_json_parse(mp, (str)->start, (str)->start + (str)->length)
|
||||||
|
|
||||||
|
uintptr_t nxt_conf_json_print_value(u_char *p, nxt_conf_json_value_t *value,
|
||||||
nxt_conf_json_pretty_t *pretty);
|
nxt_conf_json_pretty_t *pretty);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -108,7 +108,7 @@ nxt_controller_start(nxt_task_t *task, nxt_runtime_t *rt)
|
|||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = nxt_conf_json_parse(json.start, json.length, mp);
|
conf = nxt_conf_json_str_parse(mp, &json);
|
||||||
|
|
||||||
if (conf == NULL) {
|
if (conf == NULL) {
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
@@ -591,7 +591,7 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
|
|||||||
|
|
||||||
mbuf = &c->read->mem;
|
mbuf = &c->read->mem;
|
||||||
|
|
||||||
value = nxt_conf_json_parse(mbuf->pos, mbuf->free - mbuf->pos, mp);
|
value = nxt_conf_json_parse(mp, mbuf->pos, mbuf->free);
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
nxt_mp_destroy(mp);
|
nxt_mp_destroy(mp);
|
||||||
@@ -600,8 +600,9 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path.length != 1) {
|
if (path.length != 1) {
|
||||||
rc = nxt_conf_json_op_compile(nxt_controller_conf.root, value,
|
rc = nxt_conf_json_op_compile(c->mem_pool, &ops,
|
||||||
&ops, &path, c->mem_pool);
|
nxt_controller_conf.root,
|
||||||
|
&path, value);
|
||||||
|
|
||||||
if (rc != NXT_OK) {
|
if (rc != NXT_OK) {
|
||||||
if (rc == NXT_DECLINED) {
|
if (rc == NXT_DECLINED) {
|
||||||
@@ -613,8 +614,8 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = nxt_conf_json_clone_value(nxt_controller_conf.root,
|
value = nxt_conf_json_clone_value(mp, ops,
|
||||||
ops, mp);
|
nxt_controller_conf.root);
|
||||||
|
|
||||||
if (nxt_slow_path(value == NULL)) {
|
if (nxt_slow_path(value == NULL)) {
|
||||||
nxt_mp_destroy(mp);
|
nxt_mp_destroy(mp);
|
||||||
@@ -644,11 +645,12 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = nxt_conf_json_parse(empty_obj.start, empty_obj.length, mp);
|
value = nxt_conf_json_str_parse(mp, &empty_obj);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rc = nxt_conf_json_op_compile(nxt_controller_conf.root, NULL, &ops,
|
rc = nxt_conf_json_op_compile(c->mem_pool, &ops,
|
||||||
&path, c->mem_pool);
|
nxt_controller_conf.root,
|
||||||
|
&path, NULL);
|
||||||
|
|
||||||
if (rc != NXT_OK) {
|
if (rc != NXT_OK) {
|
||||||
if (rc == NXT_DECLINED) {
|
if (rc == NXT_DECLINED) {
|
||||||
@@ -667,8 +669,8 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = nxt_conf_json_clone_value(nxt_controller_conf.root,
|
value = nxt_conf_json_clone_value(mp, ops,
|
||||||
ops, mp);
|
nxt_controller_conf.root);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nxt_slow_path(value == NULL)) {
|
if (nxt_slow_path(value == NULL)) {
|
||||||
@@ -775,8 +777,7 @@ nxt_controller_response_body(nxt_controller_response_t *resp, nxt_mp_t *pool)
|
|||||||
value = resp->json_value;
|
value = resp->json_value;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
value = nxt_conf_json_parse(resp->json_string.start,
|
value = nxt_conf_json_str_parse(pool, &resp->json_string);
|
||||||
resp->json_string.length, pool);
|
|
||||||
|
|
||||||
if (nxt_slow_path(value == NULL)) {
|
if (nxt_slow_path(value == NULL)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user