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

Function mi_http_write_resp

modules/mi_html/http_fnc.c:628–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626}
627
628static int mi_http_write_resp(char** p, char *buf, int max_page_len,
629 mi_response_t *resp)
630{
631 mi_item_t *res;
632 str unesc_buf;
633 str tmp_s;
634 int tmp_i;
635
636 res = cJSON_GetObjectItem(resp, JSONRPC_ERROR_S);
637 if (!res)
638 res = cJSON_GetObjectItem(resp, JSONRPC_RESULT_S);
639 if (!res) {
640 LM_ERR("Invalid jsonrpc response object\n");
641 return -1;
642 }
643
644 unesc_buf.s = cJSON_Print(res);
645 if (!unesc_buf.s) {
646 LM_ERR("Failed to print json response\n");
647 return -1;
648 }
649 unesc_buf.len = strlen(unesc_buf.s);
650
651 MI_HTTP_ESC_COPY(*p, unesc_buf, tmp_s, tmp_i);
652
653 cJSON_PurgeString(unesc_buf.s);
654
655 return 0;
656
657error:
658 LM_ERR("buffer 2 small\n");
659 return -1;
660}
661
662int mi_http_build_content(str *page, int max_page_len,
663 int mod, int cmd, mi_response_t *response)

Callers 1

mi_http_build_contentFunction · 0.85

Calls 3

cJSON_PurgeStringFunction · 0.85
cJSON_GetObjectItemFunction · 0.50
cJSON_PrintFunction · 0.50

Tested by

no test coverage detected