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

Function run_raw_processing_cb

script_cb.c:268–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268int run_raw_processing_cb(int type, str *data, struct sip_msg* msg, struct raw_processing_cb_list* list)
269{
270
271 struct raw_processing_cb_list *foo=NULL, *last_good=NULL, *head=NULL;
272 char *initial_data = data->s, *input_data;
273 int rc;
274
275 if (list == NULL)
276 return 0;
277
278 while (list) {
279 input_data = data->s;
280 /* a return code bigger than 0 means you want to keep the callback */
281 if ((rc = list->f(data, msg)) < 0) {
282 LM_ERR("failed to run callback\n");
283 return -1;
284 }
285
286 if (input_data != initial_data && input_data != data->s)
287 pkg_free(input_data);
288
289 foo = list;
290 list = list->next;
291
292 if (foo != NULL) {
293 if (foo->freeable && rc == 0) {
294 /* foo will be gone so link the last good element
295 * to the next one */
296 if (last_good)
297 last_good->next=list;
298
299 pkg_free(foo);
300 } else {
301 /* keep the first element not to be freed */
302 if (head == NULL)
303 head = foo;
304 /* and keep track of the last viable element to link with the
305 * next viable element */
306 last_good = foo;
307 }
308 }
309 }
310
311 return !(type==PRE_RAW_PROCESSING?(pre_processing_cb_list=head)
312 :(post_processing_cb_list=head));
313}
314

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected