| 765 | } |
| 766 | |
| 767 | apr_status_t md_json_seta(apr_array_header_t *a, md_json_to_cb *cb, void *baton, |
| 768 | md_json_t *json, ...) |
| 769 | { |
| 770 | json_t *j, *nj; |
| 771 | md_json_t wrap; |
| 772 | apr_status_t rv = APR_SUCCESS; |
| 773 | va_list ap; |
| 774 | int i; |
| 775 | |
| 776 | va_start(ap, json); |
| 777 | j = jselect(json, ap); |
| 778 | va_end(ap); |
| 779 | |
| 780 | if (!j || !json_is_array(j)) { |
| 781 | const char *key; |
| 782 | |
| 783 | va_start(ap, json); |
| 784 | j = jselect_parent(&key, 1, json, ap); |
| 785 | va_end(ap); |
| 786 | |
| 787 | if (!key || !j || !json_is_object(j)) { |
| 788 | return APR_EINVAL; |
| 789 | } |
| 790 | nj = json_array(); |
| 791 | json_object_set_new(j, key, nj); |
| 792 | j = nj; |
| 793 | } |
| 794 | |
| 795 | json_array_clear(j); |
| 796 | wrap.p = json->p; |
| 797 | for (i = 0; i < a->nelts; ++i) { |
| 798 | if (!cb) { |
| 799 | return APR_EINVAL; |
| 800 | } |
| 801 | wrap.j = json_string(""); |
| 802 | if (APR_SUCCESS == (rv = cb(APR_ARRAY_IDX(a, i, void*), &wrap, json->p, baton))) { |
| 803 | json_array_append_new(j, wrap.j); |
| 804 | } |
| 805 | } |
| 806 | return rv; |
| 807 | } |
| 808 | |
| 809 | int md_json_itera(md_json_itera_cb *cb, void *baton, md_json_t *json, ...) |
| 810 | { |
no test coverage detected