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

Function tmrec_expr_parse

time_rec.c:1932–2142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1930
1931
1932tmrec_expr *tmrec_expr_parse(const char *trx, char alloc_type)
1933{
1934 enum {
1935 NEED_OPERAND,
1936 NEED_OPERATOR,
1937 } state = NEED_OPERAND;
1938
1939 tmrec_expr_t *exp, *e;
1940 osips_malloc_t malloc_f;
1941 char *p, *q, bkp, need_close, invert_next = 0, is_valid;
1942 str aux;
1943 int rc;
1944
1945 LM_DBG("checking: %s\n", trx);
1946
1947 if (!trx)
1948 return NULL;
1949
1950 malloc_f = (alloc_type & PKG_ALLOC ?
1951 osips_pkg_malloc : osips_shm_malloc);
1952 exp = malloc_f(sizeof *exp);
1953 if (!exp) {
1954 LM_ERR("oom\n");
1955 return NULL;
1956 }
1957
1958 tmrec_expr_init(exp);
1959 exp->flags = alloc_type;
1960
1961 for (p = (char *)trx; *p != '\0'; p++) {
1962 if (is_ws(*p))
1963 continue;
1964
1965 switch (state) {
1966 case NEED_OPERAND:
1967 switch (*p) {
1968 case ')':
1969 case '&':
1970 case '/':
1971 LM_ERR("failed to parse time rec (unexpected '%c')\n", *p);
1972 goto parse_err;
1973
1974 case '!':
1975 invert_next = !invert_next;
1976 continue;
1977
1978 case '(':
1979 for (need_close = 1, q = p + 1; *q != '\0'; q++) {
1980 switch (*q) {
1981 case '(':
1982 need_close++;
1983 break;
1984
1985 case ')':
1986 need_close--;
1987 break;
1988
1989 default:

Callers 3

cmtrFunction · 0.85
build_ruleFunction · 0.85
dr_load_routing_infoFunction · 0.85

Calls 6

tmrec_expr_initFunction · 0.85
is_wsFunction · 0.85
trimFunction · 0.85
list_add_tailFunction · 0.85
_tmrec_parseFunction · 0.85
tmrec_expr_freeFunction · 0.85

Tested by 1

cmtrFunction · 0.68