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

Function insert_hf

modules/exec/exec_hf.c:56–91  ·  view source on GitHub ↗

insert a new header field into the structure; */

Source from the content-addressed store, hash-verified

54
55/* insert a new header field into the structure; */
56static int insert_hf( struct hf_wrapper **list, struct hdr_field *hf )
57{
58 struct hf_wrapper *w; /* new wrapper */
59 struct hf_wrapper *i;
60
61 w=(struct hf_wrapper *)pkg_malloc(sizeof(struct hf_wrapper));
62 if (!w) {
63 LM_ERR("ran out of pkg mem\n");
64 return 0;
65 }
66 memset(w, 0, sizeof(struct hf_wrapper));
67 w->var_type=W_HF;w->u.hf=hf;
68 w->prefix=HF_PREFIX; w->prefix_len=HF_PREFIX_LEN;
69
70 /* is there another hf of the same type?... */
71 for(i=*list; i; i=i->next_other) {
72 if (i->var_type==W_HF && i->u.hf->type==hf->type) {
73 /* if it is OTHER, check name too */
74 if (hf->type==HDR_OTHER_T && (hf->name.len!=i->u.hf->name.len
75 || strncasecmp(i->u.hf->name.s, hf->name.s,
76 hf->name.len)!=0))
77 continue;
78 /* yes, we found a hf of same type */
79 w->next_same=i->next_same;
80 w->next_other=i->next_other;
81 i->next_same=w;
82 break;
83 }
84 }
85 /* ... no previous HF of the same type found */
86 if (i==0) {
87 w->next_other=*list;
88 *list=w;
89 }
90 return 1;
91}
92
93void release_hf_struct( struct hf_wrapper *list )
94{

Callers 1

build_hf_structFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected