MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / mi_xmlrpc_get_array_param

Function mi_xmlrpc_get_array_param

modules/mi_xmlrpc/http_fnc.c:274–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274static int mi_xmlrpc_get_array_param(xmlNodePtr array_node,
275 mi_item_t *req_params_item, const char *name)
276{
277 xmlNodePtr node;
278 mi_item_t *p_arr;
279 int rc;
280
281 node = mi_xmlNodeGetNodeByName(array_node->children,
282 MI_XMLRPC_XML_DATA_NODE);
283 if (node==NULL) {
284 LM_ERR("missing node %s\n", MI_XMLRPC_XML_DATA_NODE);
285 return 1;
286 }
287
288 p_arr = cJSON_CreateArray();
289 if (!p_arr) {
290 LM_ERR("Failed to create array item in temporary json request\n");
291 return -1;
292 }
293
294 if (req_params_item->type & cJSON_Array)
295 cJSON_AddItemToArray(req_params_item, p_arr);
296 else if (req_params_item->type & cJSON_Object)
297 cJSON_AddItemToObject(req_params_item, name, p_arr);
298 else {
299 LM_ERR("Bad params item type\n");
300 return -1;
301 }
302
303 for (node = node->children; node; node=node->next) {
304 if (xmlStrcasecmp(node->name,
305 (const xmlChar*)MI_XMLRPC_XML_VALUE_NODE) != 0)
306 continue;
307
308 rc = mi_xmlrpc_get_param(node, p_arr, NULL);
309 if (rc != 0)
310 return rc;
311 }
312
313 return 0;
314}
315
316static int mi_xmlrpc_get_param(xmlNodePtr value_node, mi_item_t *req_params_item,
317 const char *name)

Callers 1

mi_xmlrpc_get_paramFunction · 0.85

Calls 5

mi_xmlNodeGetNodeByNameFunction · 0.85
mi_xmlrpc_get_paramFunction · 0.85
cJSON_CreateArrayFunction · 0.50
cJSON_AddItemToArrayFunction · 0.50
cJSON_AddItemToObjectFunction · 0.50

Tested by

no test coverage detected