diff options
author | Valentin Bartenev <vbart@nginx.com> | 2017-08-16 15:45:12 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2017-08-16 15:45:12 +0300 |
commit | 95907e29128c51be79aec0b5149e2639c3fd9042 (patch) | |
tree | 56e266c7a914e2cd8e32a8c3de9f3d41447340f6 /src/nxt_conf.c | |
parent | 2dd8048bf9d80d045f3df8f0930c3325bf8a14f9 (diff) | |
download | unit-95907e29128c51be79aec0b5149e2639c3fd9042.tar.gz unit-95907e29128c51be79aec0b5149e2639c3fd9042.tar.bz2 |
Object mapping interface extended with more string types.
Diffstat (limited to 'src/nxt_conf.c')
-rw-r--r-- | src/nxt_conf.c | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c index d205ca71..12e35ebc 100644 --- a/src/nxt_conf.c +++ b/src/nxt_conf.c @@ -420,9 +420,10 @@ nxt_conf_get_object_member(nxt_conf_value_t *value, nxt_str_t *name, nxt_int_t -nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, nxt_uint_t n, - void *data) +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_str_t str, *s; nxt_uint_t i; nxt_conf_value_t *v; @@ -436,6 +437,7 @@ nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, nxt_uint_t n, nxt_msec_t msec; double dbl; nxt_str_t str; + char *cstrz; void *v; } *ptr; @@ -515,15 +517,48 @@ nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, nxt_uint_t n, break; case NXT_CONF_MAP_STR: + case NXT_CONF_MAP_STR_COPY: + case NXT_CONF_MAP_CSTRZ: - if (v->type == NXT_CONF_VALUE_SHORT_STRING - || v->type == NXT_CONF_VALUE_STRING) + if (v->type != NXT_CONF_VALUE_SHORT_STRING + && v->type != NXT_CONF_VALUE_STRING) { - nxt_conf_get_string(v, &ptr->str); + break; } - break; + nxt_conf_get_string(v, &str); + + switch (map[i].type) { + + case NXT_CONF_MAP_STR: + ptr->str = str; + break; + + case NXT_CONF_MAP_STR_COPY: + + s = nxt_str_dup(mp, &ptr->str, &str); + + if (nxt_slow_path(s == NULL)) { + return NXT_ERROR; + } + + break; + case NXT_CONF_MAP_CSTRZ: + + ptr->cstrz = nxt_str_cstrz(mp, &str); + + if (nxt_slow_path(ptr->cstrz == NULL)) { + return NXT_ERROR; + } + + break; + + default: + nxt_unreachable(); + } + + break; case NXT_CONF_MAP_PTR: |