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

Function set_env

modules/exec/exec_hf.c:503–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501}
502
503environment_t *set_env(struct sip_msg *msg)
504{
505 struct hf_wrapper *hf_list;
506 environment_t *backup_env;
507
508 /* parse all so that we can pass all header fields to script */
509 if (parse_headers(msg, HDR_EOH_F, 0)==-1) {
510 LM_ERR("parsing failed\n");
511 return 0;
512 }
513
514 hf_list=0;
515 /* create a temporary structure with ordered header fields
516 * and create environment variables out of it */
517 if (!build_hf_struct(msg, &hf_list)) {
518 LM_ERR("build_hf_struct failed\n");
519 return 0;
520 }
521 if (!append_fixed_vars(msg, &hf_list)) {
522 LM_ERR("append_fixed_vars failed\n");
523 goto error01;
524 }
525 /* create now the strings for environment variables */
526 if (!create_vars(hf_list, 0)) {
527 LM_ERR("create_vars failed\n");
528 goto error00;
529 }
530 /* install the variables in current environment */
531 backup_env=replace_env(hf_list);
532 if (!backup_env) {
533 LM_ERR("replace_env failed\n");
534 goto error00;
535 }
536 /* release the ordered HF structure -- we only need the vars now */
537 release_hf_struct(hf_list);
538 return backup_env;
539
540error00:
541 release_vars(hf_list); /* release variables */
542error01:
543 release_hf_struct(hf_list); /* release temporary ordered HF struct */
544 return 0;
545}
546

Callers

nothing calls this directly

Calls 6

build_hf_structFunction · 0.85
append_fixed_varsFunction · 0.85
create_varsFunction · 0.85
replace_envFunction · 0.85
release_hf_structFunction · 0.85
release_varsFunction · 0.85

Tested by

no test coverage detected