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

Function mi_script_handle_response

modules/mi_script/mi_script.c:422–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422static int mi_script_handle_response(mi_response_t *resp, char **res, int *release)
423{
424
425 int ret = 1;
426 mi_item_t *item, *tmp;
427 char *r = NULL;
428
429 *release = 0;
430
431 item = cJSON_GetObjectItem(resp, JSONRPC_ERROR_S);
432 if (item) {
433 tmp = cJSON_GetObjectItem(item, JSONRPC_ERR_CODE_S);
434 if (!tmp)
435 ret = -3;
436 else if (tmp->valueint > 0)
437 ret = -tmp->valueint;
438 else
439 ret = tmp->valueint;
440
441 tmp = cJSON_GetObjectItem(item, JSONRPC_ERR_MSG_S);
442 if (!tmp)
443 r = "no error message provided";
444 else
445 r = tmp->valuestring;
446 } else if (res) {
447 tmp = cJSON_GetObjectItem(resp, JSONRPC_RESULT_S);
448 if (tmp) {
449 if (mi_script_pp)
450 r = cJSON_Print(tmp);
451 else
452 r = cJSON_PrintUnformatted(tmp);
453 *release = 1;
454 }
455 }
456 if (res)
457 *res = r;
458 return ret;
459}
460
461static int mi_script_handle_sync_response(struct sip_msg *msg,
462 mi_response_t *resp, pv_spec_p r)

Callers 2

mi_script_async_jobFunction · 0.85

Calls 3

cJSON_GetObjectItemFunction · 0.50
cJSON_PrintFunction · 0.50
cJSON_PrintUnformattedFunction · 0.50

Tested by

no test coverage detected