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

Function cpl_invoke_script

modules/cpl_c/cpl.c:572–655  ·  view source on GitHub ↗

Params: * str1 - as unsigned int - can be CPL_RUN_INCOMING or CPL_RUN_OUTGOING * str2 - as unsigned int - flags regarding state(less)|(ful) */

Source from the content-addressed store, hash-verified

570 * str2 - as unsigned int - flags regarding state(less)|(ful)
571 */
572static int cpl_invoke_script(struct sip_msg* msg, void* type, void* mode)
573{
574 struct cpl_interpreter *cpl_intr;
575 str username = {0,0};
576 str domain = {0,0};
577 str loc;
578 str script;
579
580 /* get the user_name */
581 if ( ((unsigned long)type)&CPL_RUN_INCOMING ) {
582 /* if it's incoming -> get the destination user name */
583 if (get_dest_user( msg, &username, &domain)==-1)
584 goto error0;
585 } else {
586 /* if it's outgoing -> get the origin user name */
587 if (get_orig_user( msg, &username, &domain)==-1)
588 goto error0;
589 }
590
591 /* get the script for this user */
592 if (get_user_script(&username, cpl_env.use_domain?&domain:0,
593 &script, &cpl_bin_col)==-1)
594 goto error0;
595
596 /* has the user a non-empty script? if not, return normally, allowing the
597 * script execution to continue */
598 if ( !script.s || !script.len )
599 return 2;
600
601 /* build a new script interpreter */
602 if ( (cpl_intr=new_cpl_interpreter(msg,&script))==0 )
603 goto error1;
604 /* set the flags */
605 cpl_intr->flags =(unsigned int)((unsigned long)type)|((unsigned long)mode);
606 /* build user AOR */
607 if (build_user_AOR( &username, &domain, &(cpl_intr->user), 0)!=0 )
608 goto error2;
609 /* for OUTGOING we need also the destination user for init. with him
610 * the location set */
611 if ( ((unsigned long)type)&CPL_RUN_OUTGOING ) {
612 /* build user initial location -> get the destination user name */
613 if (get_dest_user( msg, &username, &domain)==-1)
614 goto error2;
615 if (build_user_AOR( &username, &domain, &loc, 1)!=0 )
616 goto error2;
617 if (add_location( &(cpl_intr->loc_set), &loc, 0, 10,CPL_LOC_DUPL)==-1){
618 shm_free(loc.s);
619 goto error2;
620 }
621 shm_free(loc.s);
622 }
623
624 /* run the script */
625 switch (cpl_run_script( cpl_intr )) {
626 case SCRIPT_DEFAULT:
627 if ( cpl_intr->flags&CPL_DO_NOT_FREE )
628 cpl_intr->flags |= CPL_ENDED;
629 else

Callers

nothing calls this directly

Calls 9

get_dest_userFunction · 0.85
get_orig_userFunction · 0.85
get_user_scriptFunction · 0.85
new_cpl_interpreterFunction · 0.85
build_user_AORFunction · 0.85
add_locationFunction · 0.85
shm_freeFunction · 0.85
cpl_run_scriptFunction · 0.85
free_cpl_interpreterFunction · 0.85

Tested by

no test coverage detected