static int acc_fixup(void** param, int param_no) { struct acc_param *accp; char *p; p = (char*)*param; if (p==0 || p[0]==0) { LM_ERR("first parameter is empty\n"); return E_SCRIPT; } if (param_no == 1) { accp = (struct acc_param*)pkg_malloc(sizeof(struct acc_param)); if (!accp) { LM_ERR("no more pkg mem\n"); return E_OUT_OF_MEM; } memset( accp, 0, sizeof(struct acc_param)); accp->reason.s = p; accp->reason.len = strlen(p); if (strchr(p,PV_MARKER)!=NULL) { /* is a variable $xxxxx */ if (pv_parse_format(&accp->reason, &accp->elem)<0) { LM_ERR("bad param 1 - parse format error [%.*s]\n", accp->reason.len, accp->reason.s); pkg_free(accp); return E_UNSPEC; } } else { if(acc_parse_code(p,accp)<0) { LM_ERR("bad param 1 - parse code error\n"); pkg_free(accp); return E_UNSPEC; } } *param = (void*)accp; #ifdef SQL_ACC } else if (param_no == 2) { /* only for db acc - the table name */ if (db_url.s==0) { pkg_free(p); *param = 0; } else { return fixup_var_pve_str_12(param, 2); } #endif } return 0; }
int acc_get_param_value(struct sip_msg *rq, struct acc_param *param) { if(param->elem!=NULL) { if(pv_printf_s(rq, param->elem, ¶m->reason)==-1) { LM_ERR("Can't get value for %.*s\n", param->reason.len, param->reason.s); return -1; } if(acc_parse_code(param->reason.s, param)<0) { LM_ERR("Can't parse code\n"); return -1; } } return 0; }