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

Function tr_parse_nparam

transformations.c:2752–2821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2750}
2751
2752char *tr_parse_nparam(char *p, str *in, tr_param_t **tp)
2753{
2754 char *p0;
2755 pv_spec_t *spec = NULL;
2756 int n, sign;
2757 str s;
2758
2759 while (is_in_str(p, in) && is_ws(*p)) p++;
2760
2761 if(*p == PV_MARKER) { /* pseudo-variable */
2762 spec = pkg_malloc(sizeof(pv_spec_t));
2763 if (spec == NULL) {
2764 LM_ERR("no more private memory!\n");
2765 goto error;
2766 }
2767 s.s = p;
2768 s.len = in->s + in->len - p;
2769 p0 = pv_parse_spec(&s, spec);
2770 if(p0 == NULL) {
2771 LM_ERR("invalid spec in substr transformation: %.*s!\n",
2772 in->len, in->s);
2773 goto error;
2774 }
2775 p = p0;
2776 *tp = pkg_malloc(sizeof(tr_param_t));
2777 if(*tp == NULL) {
2778 LM_ERR("no more private memory!\n");
2779 goto error;
2780 }
2781 memset(*tp, 0, sizeof(tr_param_t));
2782 (*tp)->type = TR_PARAM_SPEC;
2783 (*tp)->v.data = (void*)spec;
2784
2785 return p;
2786 } else {
2787 if (*p == '+' || *p == '-' || (*p >= '0' && *p <= '9')) { /* number */
2788 sign = 1;
2789 if (*p == '-') {
2790 p++;
2791 sign = -1;
2792 } else if (*p == '+') p++;
2793 n = 0;
2794 while (is_in_str(p, in) && is_ws(*p))
2795 p++;
2796 while (is_in_str(p, in) && *p >= '0' && *p <= '9') {
2797 n = n*10 + *p - '0';
2798 p++;
2799 }
2800 *tp = pkg_malloc(sizeof(tr_param_t));
2801 if (*tp == NULL) {
2802 LM_ERR("no more private memory!\n");
2803 goto error;
2804 }
2805 memset(*tp, 0, sizeof(tr_param_t));
2806 (*tp)->type = TR_PARAM_NUMBER;
2807 (*tp)->v.n = sign*n;
2808 } else {
2809 LM_ERR("invalid param in transformation: %.*s!!\n",

Callers 5

tr_parse_stringFunction · 0.85
tr_parse_paramlistFunction · 0.85
tr_parse_nameaddrFunction · 0.85
tr_parse_csvFunction · 0.85
tr_parse_sdpFunction · 0.85

Calls 3

is_wsFunction · 0.85
pv_parse_specFunction · 0.85
pv_spec_freeFunction · 0.85

Tested by

no test coverage detected