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

Function init_mi_error_extra

mi/item.c:143–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143mi_response_t *init_mi_error_extra(int code, const char *msg, int msg_len,
144 const char *details, int details_len)
145{
146 mi_response_t *res;
147 mi_item_t *err_item = NULL, *msg_item = NULL, *code_item = NULL, *data_item;
148 mi_item_t *jsonrpc_vers;
149
150 _init_mi_sys_mem_hooks();
151
152 res = cJSON_CreateObject();
153 if (!res)
154 goto error;
155
156 jsonrpc_vers = cJSON_CreateString(JSONRPC_VERS_S);
157 if (!jsonrpc_vers)
158 goto error;
159 cJSON_AddItemToObject(res, JSONRPC_S, jsonrpc_vers);
160
161 err_item = cJSON_CreateObject();
162 if (!err_item)
163 goto error;
164 cJSON_AddItemToObject(res, JSONRPC_ERROR_S, err_item);
165
166 code_item = cJSON_CreateNumber(code);
167 if (!code_item)
168 goto error;
169 cJSON_AddItemToObject(err_item, JSONRPC_ERR_CODE_S, code_item);
170
171 msg_item = cJSON_CreateStr(msg, msg_len);
172 if (!msg_item)
173 goto error;
174 cJSON_AddItemToObject(err_item, JSONRPC_ERR_MSG_S, msg_item);
175
176 if (details && details_len) {
177 data_item = cJSON_CreateStr(details, details_len);
178 if (!data_item)
179 goto error;
180 cJSON_AddItemToObject(err_item, JSONRPC_ERR_DATA_S, data_item);
181 }
182
183 _init_mi_pkg_mem_hooks();
184 return res;
185
186error:
187 if (res)
188 cJSON_Delete(res);
189
190 _init_mi_pkg_mem_hooks();
191 return NULL;
192}
193
194void free_mi_response(mi_response_t *response)
195{

Callers 15

build_err_respFunction · 0.85
mi_log_levelFunction · 0.85
w_profiling_procFunction · 0.85
mi_cachestoreFunction · 0.85
w_cachestore_1Function · 0.85
mi_cachefetchFunction · 0.85
mi_cacheremoveFunction · 0.85
init_mi_errorFunction · 0.85
init_mi_param_errorFunction · 0.85
wss_trace_mi_1Function · 0.85
tls_trace_mi_1Function · 0.85
ws_trace_mi_1Function · 0.85

Calls 8

_init_mi_sys_mem_hooksFunction · 0.85
cJSON_CreateStrFunction · 0.85
_init_mi_pkg_mem_hooksFunction · 0.85
cJSON_CreateObjectFunction · 0.50
cJSON_CreateStringFunction · 0.50
cJSON_AddItemToObjectFunction · 0.50
cJSON_CreateNumberFunction · 0.50
cJSON_DeleteFunction · 0.50

Tested by

no test coverage detected