MCPcopy Create free account
hub / github.com/apache/httpd / jselect_insert

Function jselect_insert

modules/md/md_json.c:190–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190static apr_status_t jselect_insert(json_t *val, size_t index, md_json_t *json, va_list ap)
191{
192 const char *key;
193 json_t *j, *aj;
194
195 j = jselect_parent(&key, 1, json, ap);
196
197 if (!j || !json_is_object(j)) {
198 json_decref(val);
199 return APR_EINVAL;
200 }
201
202 aj = json_object_get(j, key);
203 if (!aj) {
204 aj = json_array();
205 json_object_set_new(j, key, aj);
206 }
207
208 if (!json_is_array(aj)) {
209 json_decref(val);
210 return APR_EINVAL;
211 }
212
213 if (json_array_size(aj) <= index) {
214 json_array_append(aj, val);
215 }
216 else {
217 json_array_insert(aj, index, val);
218 }
219 return APR_SUCCESS;
220}
221
222static apr_status_t jselect_set(json_t *val, md_json_t *json, va_list ap)
223{

Callers 1

md_json_insertjFunction · 0.85

Calls 1

jselect_parentFunction · 0.85

Tested by

no test coverage detected