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

Function parse_whitelist

modules/compression/compression_helpers.c:142–211  ·  view source on GitHub ↗

* Function that parses whitelist string */

Source from the content-addressed store, hash-verified

140 * Function that parses whitelist string
141 */
142int parse_whitelist(str* param, mc_whitelist_p* wh_list_p, unsigned char* def_hdrs_mask)
143{
144 mc_whitelist_p wh_list;
145 char *sparam, *sparam_end;
146 str hdr_name;
147 int new_hdr = 1, eoh=0;
148
149 wh_list = pkg_malloc(sizeof(mc_whitelist_t));
150 if (!wh_list) {
151 LM_ERR("no more pkg mem\n");
152 return -1;
153 }
154 memset(wh_list, 0, sizeof (*wh_list));
155
156 if (def_hdrs_mask)
157 memcpy(wh_list->hdr_mask, def_hdrs_mask, HDR_MASK_SIZE);
158
159 if (param == NULL)
160 goto end;
161
162 sparam_end = param->s + param->len;
163 for (sparam = param->s ; sparam != sparam_end; sparam++) {
164 switch (*sparam) {
165 case ' ' :
166 case ';' :
167 case HDR_DELIM :
168 /* The first charcter after header name have
169 have to be ':' for parse_hname2 */
170 if (eoh) {
171 eoh = 0;
172 if (search_hdr(wh_list, &hdr_name)) {
173 LM_ERR("cannot find given header [%.*s]\n",
174 hdr_name.len, hdr_name.s);
175 return -1;
176 }
177 }
178
179 if (*sparam == ' ' || *sparam == ';')
180 break;
181
182 /* A new header name was found if ','*/
183 new_hdr = 1;
184
185 break;
186 default :
187 /* found the first char in header name */
188 if (new_hdr) {
189 new_hdr = 0;
190 hdr_name.len = 1;
191 hdr_name.s = sparam;
192 eoh = 1;
193 } else {
194 hdr_name.len++;
195 }
196 break;
197 }
198 }
199

Callers 3

fixup_whitelist_compactFunction · 0.85
fixup_whitelist_compressFunction · 0.85
mc_compressFunction · 0.85

Calls 1

search_hdrFunction · 0.85

Tested by

no test coverage detected