| 348 | } |
| 349 | |
| 350 | int wrap_msg_func(str* buf, struct sip_msg* p_msg, int type) |
| 351 | { |
| 352 | int ret = 0; |
| 353 | struct mc_comp_args* args; |
| 354 | struct mc_compact_args *mc_compact_args = NULL; |
| 355 | mc_whitelist_p wh_list = NULL; |
| 356 | int olen=buf->len; |
| 357 | |
| 358 | if (current_processing_ctx == NULL) { |
| 359 | LM_DBG("null context. cb shall not be removed\n"); |
| 360 | return 1; |
| 361 | } |
| 362 | |
| 363 | switch (type) { |
| 364 | case COMPRESS_CB: |
| 365 | if ((args = GET_GLOBAL_CTX(compress_ctx_pos))==NULL) |
| 366 | break; |
| 367 | |
| 368 | if ((ret = mc_compress_cb(&buf->s, args, PROCESSING_CB, &olen)) < 0) |
| 369 | LM_ERR("compression failed. Probably not requested message\n"); |
| 370 | |
| 371 | wh_list = args->hdr2compress_list; |
| 372 | pkg_free(args); |
| 373 | SET_GLOBAL_CTX(compress_ctx_pos, NULL); |
| 374 | break; |
| 375 | |
| 376 | case COMPACT_CB: |
| 377 | if ((mc_compact_args = GET_GLOBAL_CTX(compact_ctx_pos))==NULL) |
| 378 | break; |
| 379 | |
| 380 | if ((ret = mc_compact_cb(&buf->s, mc_compact_args, PROCESSING_CB, &olen)) < 0) |
| 381 | LM_ERR("compaction failed\n"); |
| 382 | |
| 383 | SET_GLOBAL_CTX(compact_ctx_pos, NULL); |
| 384 | break; |
| 385 | } |
| 386 | |
| 387 | /* free whitelists for both actions */ |
| 388 | if (wh_list) |
| 389 | free_whitelist(wh_list); |
| 390 | free_mc_compact_args(mc_compact_args); |
| 391 | if (ret < 0) |
| 392 | return -1; |
| 393 | |
| 394 | buf->len = olen; |
| 395 | |
| 396 | return 0; |
| 397 | } |
| 398 | |
| 399 | /* |
| 400 | * |
no test coverage detected