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

Function canonize_headername

modules/exec/exec_hf.c:163–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161
162
163static int canonize_headername(str *orig, char **hname, int *hlen )
164{
165 char *c;
166 int i;
167
168 *hlen=orig->len;
169 *hname=pkg_malloc(*hlen);
170 if (!*hname) {
171 LM_ERR("no pkg mem for hname\n");
172 return 0;
173 }
174 for (c=orig->s, i=0; i<*hlen; i++, c++) {
175 /* lowercase to uppercase */
176 if (*c>='a' && *c<='z')
177 *((*hname)+i)=*c-('a'-'A');
178 /* uppercase and numbers stay "as is" */
179 else if ((*c>='A' && *c<='Z')||(*c>='0' && *c<='9'))
180 *((*hname)+i)=*c;
181 /* legal symbols will be translated to underscore */
182 else if (strchr(UNRESERVED_MARK HNV_UNRESERVED, *c)
183 || (*c==ESCAPE))
184 *((*hname)+i)=HFN_SYMBOL;
185 else {
186 LM_ERR("print_var unexpected char '%c' in hfname %.*s\n",
187 *c, *hlen, orig->s );
188 *((*hname)+i)=HFN_SYMBOL;
189 }
190 }
191 return 1;
192}
193
194
195static int print_av_var(struct hf_wrapper *w)

Callers 1

print_hf_varFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected