Example #1
0
static int get_redirect_fixup(void** param, int param_no)
{
	unsigned char maxb,maxt;
	struct acc_param *accp;
	cmd_function fct;
	char *p;
	char *s;

	s = (char*)*param;
	if (param_no==1) {
		if ( (p=strchr(s,':'))!=0 ) {
			/* have max branch also */
			*p = 0;
			if (get_nr_max(p+1, &maxb)!=0)
				return E_UNSPEC;
		} else {
			maxb = 0; /* infinit */
		}

		/* get max total */
		if (get_nr_max(s, &maxt)!=0)
			return E_UNSPEC;

		pkg_free(*param);
		*param=(void*)(long)( (((unsigned short)maxt)<<8) | maxb);

	} else if (param_no==2) {
		/* acc function loaded? */
		if (rd_acc_fct!=0)
			return 0;
		/* must import the acc stuff */
		if (acc_fct_s==0 || acc_fct_s[0]==0) {
			LM_ERR("acc support enabled, but no acc function defined\n");
			return E_UNSPEC;
		}
		fct = find_export(acc_fct_s, 2, REQUEST_ROUTE);
		if ( fct==0 )
			fct = find_export(acc_fct_s, 1, REQUEST_ROUTE);
		if ( fct==0 ) {
			LM_ERR("cannot import %s function; is acc loaded and proper "
				"compiled?\n", acc_fct_s);
			return E_UNSPEC;
		}
		rd_acc_fct = fct;
		/* set the reason str */
		accp = (struct acc_param*)pkg_malloc(sizeof(struct acc_param));
		if (accp==0) {
			LM_ERR("no more pkg mem\n");
			return E_UNSPEC;
		}
		memset( accp, 0, sizeof(struct acc_param));
		if (s!=0 && *s!=0) {
			accp->reason.s = s;
			accp->reason.len = strlen(s);
		} else {
			accp->reason.s = "n/a";
			accp->reason.len = 3;
		}
		*param=(void*)accp;
	}

	return 0;
}
Example #2
0
static int get_redirect_fixup(void** param, int param_no)
{
	unsigned char maxb,maxt;
	cmd_function fct;
	char *p;
	char *s;
	str  *reason;

	s = (char*)*param;
	if (param_no==1) {
		if ( (p=strchr(s,':'))!=0 ) {
			/* have max branch also */
			*p = 0;
			if (get_nr_max(p+1, &maxb)!=0)
				return E_UNSPEC;
		} else {
			maxb = 0; /* infinit */
		}

		/* get max total */
		if (get_nr_max(s, &maxt)!=0)
			return E_UNSPEC;

		pkg_free(*param);
		*param=(void*)( (((unsigned short)maxt)<<8) | maxb);

	} else if (param_no==2) {
		/* acc function loaded? */
		if (rd_acc_fct!=0)
			return 0;
		/* must import the acc stuff */
		if (acc_fct_s==0 || acc_fct_s[0]==0) {
			LOG(L_ERR, "ERROR:uac_redirect:get_redirect_fixup: acc support "
				"enabled, but no acc function defined\n");
			return E_UNSPEC;
		}
		fct = find_export(acc_fct_s, 2, REQUEST_ROUTE);
		if ( fct==0 )
			fct = find_export(acc_fct_s, 1, REQUEST_ROUTE);
		if ( fct==0 ) {
			LOG(L_ERR, "ERROR:uac_redirect:get_redirect_fixup: cannot "
				"import %s function; is acc loaded and proper "
				"compiled?\n", acc_fct_s);
			return E_UNSPEC;
		}
		rd_acc_fct = fct;
		/* set the reason str */
		reason = (str*)pkg_malloc(sizeof(str));
		if (reason==0) {
			LOG(L_ERR,"ERROR:uac_redirect:get_redirect_fixup: no more "
				"pkg mem\n");
			return E_UNSPEC;
		}
		if (s!=0 && *s!=0) {
			reason->s = s;
			reason->len = strlen(s);
		} else {
			reason->s = "n/a";
			reason->len = 3;
		}
		*param=(void*)reason;
	}

	return 0;
}