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

Function pv_parse_branch_index

modules/tm/tm.c:2512–2550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2510
2511# define BRANCH_IDX_ACTIVE_MASK (1<<16)
2512static int pv_parse_branch_index(pv_spec_p sp, const str *in)
2513{
2514 #define BRANCH_IDX_SUFFIX_ALL "all"
2515 #define BRANCH_IDX_SUFFIX_ACTIVE "active"
2516 char *p;
2517 str suffix, new_in;
2518 unsigned int mask = 0;
2519
2520 if(in==NULL || in->s==NULL || sp==NULL)
2521 return -1;
2522
2523 new_in = *in;
2524
2525 if ( (p=q_memrchr( in->s, '/', in->len))!=NULL) {
2526 /* we do may have a suffix */
2527 suffix.s = p+1;
2528 suffix.len = in->s+in->len - suffix.s;
2529 if ( (suffix.len==(sizeof(BRANCH_IDX_SUFFIX_ALL)-1)) &&
2530 strncasecmp(suffix.s,BRANCH_IDX_SUFFIX_ALL,suffix.len)==0) {
2531 /* ok, this is the default, nothing to change */
2532 mask = 0;
2533 new_in.len = p - in->s;
2534 } else
2535 if ( (suffix.len==(sizeof(BRANCH_IDX_SUFFIX_ACTIVE)-1)) &&
2536 strncasecmp(suffix.s,BRANCH_IDX_SUFFIX_ACTIVE,suffix.len)==0) {
2537 mask = BRANCH_IDX_ACTIVE_MASK;
2538 new_in.len = p - in->s;
2539 } else {
2540 /* just ignore, do not take it into consideration, we do not
2541 * know what it is, maybe part of a pvar as index */
2542 }
2543 }
2544 if (pv_parse_index( sp, &new_in)<0)
2545 return -1;
2546 sp->pvp.pvi.type |= mask; /* take care and remove this mask BEFORE
2547 * evaluating the idx with the generic functions (as the type will
2548 * not be recognized */
2549 return 0;
2550}
2551
2552
2553static inline int _pv_get_tm_branch_field(struct sip_msg *msg,

Callers

nothing calls this directly

Calls 2

q_memrchrFunction · 0.85
pv_parse_indexFunction · 0.85

Tested by

no test coverage detected