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

Function mi_xmlrpc_parse_params

modules/mi_xmlrpc/http_fnc.c:474–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472}
473
474static int mi_xmlrpc_parse_params(xmlNodePtr params_node, mi_request_t *req_item)
475{
476 xmlNodePtr struct_node;
477 xmlNodePtr param_node;
478 xmlNodePtr value_node;
479 int rc;
480
481 param_node = mi_xmlNodeGetNodeByName(params_node->children,
482 MI_XMLRPC_XML_PARAM_NODE);
483 if (!param_node)
484 return 0;
485
486 value_node = mi_xmlNodeGetNodeByName(param_node->children,
487 MI_XMLRPC_XML_VALUE_NODE);
488 if (value_node==NULL) {
489 LM_ERR("missing node %s\n", MI_XMLRPC_XML_VALUE_NODE);
490 req_item->invalid = 1;
491 return 0;
492 }
493
494 struct_node = mi_xmlNodeGetNodeByName(value_node->children,
495 MI_XMLRPC_XML_STRUCT_NODE);
496 if (struct_node) {
497 req_item->params = cJSON_CreateObject();
498 if (!req_item->params) {
499 LM_ERR("Failed to add 'params' to temporary json request\n");
500 return -1;
501 }
502 cJSON_AddItemToObject(req_item->req_obj, JSONRPC_PARAMS_S,
503 req_item->params);
504
505 rc = mi_xmlrpc_get_named_params(struct_node, req_item->params);
506 if (rc<0)
507 return -1;
508 else if (rc>0)
509 req_item->invalid = 1;
510
511 return 0;
512 }
513
514 /* positional parameters */
515
516 req_item->params = cJSON_CreateArray();
517 if (!req_item->params) {
518 LM_ERR("Failed to add 'params' to temporary json request\n");
519 return -1;
520 }
521 cJSON_AddItemToObject(req_item->req_obj, JSONRPC_PARAMS_S,
522 req_item->params);
523
524 rc = mi_xmlrpc_get_param(value_node, req_item->params, NULL);
525 if (rc<0)
526 return -1;
527 else if (rc>0) {
528 req_item->invalid = 1;
529 return 0;
530 }
531

Callers 1

mi_xmlrpc_run_mi_cmdFunction · 0.85

Calls 6

mi_xmlNodeGetNodeByNameFunction · 0.85
mi_xmlrpc_get_paramFunction · 0.85
cJSON_CreateObjectFunction · 0.50
cJSON_AddItemToObjectFunction · 0.50
cJSON_CreateArrayFunction · 0.50

Tested by

no test coverage detected