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

Function pv_get_hdrcnt

pvar.c:2926–2952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2924}
2925
2926static int pv_get_hdrcnt(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
2927{
2928 pv_value_t tv;
2929 struct hdr_field *hf;
2930 unsigned int n;
2931 int ret;
2932
2933 if ( (ret=pv_get_hdr_prolog(msg, param, res, &tv)) <= 0 )
2934 return ret;
2935
2936 n = 0;
2937 if (tv.flags==0) {
2938 /* it is a known header -> use type to find it */
2939 for (hf=msg->headers; hf; hf=hf->next) {
2940 if (tv.ri==hf->type)
2941 ++n;
2942 }
2943 } else {
2944 /* it is an un-known header -> use name to find it */
2945 for (hf=msg->headers; hf; hf=hf->next) {
2946 if (hf->type==HDR_OTHER_T && hf->name.len==tv.rs.len
2947 && strncasecmp(hf->name.s, tv.rs.s, hf->name.len)==0)
2948 ++n;
2949 }
2950 }
2951 return pv_get_uintval(msg, param, res, n);
2952}
2953
2954static int pv_get_hdr(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
2955{

Callers

nothing calls this directly

Calls 2

pv_get_hdr_prologFunction · 0.85
pv_get_uintvalFunction · 0.85

Tested by

no test coverage detected