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

Function search_append_f

modules/textops/textops.c:201–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199
200
201static int search_append_f(struct sip_msg* msg, regex_t* key, str* str2)
202{
203 struct lump* l;
204 regmatch_t pmatch;
205 char* s;
206 char *begin;
207 int off;
208
209 begin=get_header(msg); /* msg->orig/buf previously .. uri problems */
210 off=begin-msg->buf;
211
212 if (regexec(key, begin, 1, &pmatch, 0)!=0) return -1;
213 if (pmatch.rm_so!=-1){
214 if ((l=anchor_lump(msg, off+pmatch.rm_eo, 0))==0)
215 return -1;
216 s=pkg_malloc(str2->len);
217 if (s==0){
218 LM_ERR("memory allocation failure\n");
219 return -1;
220 }
221 memcpy(s, str2->s, str2->len);
222 if (insert_new_lump_after(l, s, str2->len, 0)==0){
223 LM_ERR("could not insert new lump\n");
224 pkg_free(s);
225 return -1;
226 }
227 return 1;
228 }
229 return -1;
230}
231
232static int search_append_body_f(struct sip_msg* msg, regex_t* key, str* str2)
233{

Callers

nothing calls this directly

Calls 3

get_headerFunction · 0.85
anchor_lumpFunction · 0.85
insert_new_lump_afterFunction · 0.85

Tested by

no test coverage detected