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

Function parse_token_param

parser/parse_param.c:217–271  ·  view source on GitHub ↗

* Parse unquoted token in a parameter body * let _r point to the token and update _s * to point right behind the token */

Source from the content-addressed store, hash-verified

215 * to point right behind the token
216 */
217static inline int parse_token_param(str* _s, str* _r)
218{
219 int i;
220
221 /* There is nothing to parse,
222 * return error
223 */
224 if (_s->len == 0) {
225 return -1;
226 }
227
228 /* Save the beginning of the
229 * token in _r->s
230 */
231 _r->s = _s->s;
232
233 /* Iterate through the
234 * token body
235 */
236 for(i = 0; i < _s->len; i++) {
237
238 /* All these characters
239 * mark end of the token
240 */
241 switch(_s->s[i]) {
242 case ' ':
243 case '\t':
244 case '\r':
245 case '\n':
246 case ',':
247 case ';':
248 /* So if you find
249 * any of them
250 * stop iterating
251 */
252 goto out;
253 }
254 }
255 out:
256 if (i == 0) {
257 return -1;
258 }
259
260 /* Save length of the token */
261 _r->len = i;
262
263 /* Update _s parameter so it points
264 * right behind the end of the token
265 */
266 _s->s = _s->s + i;
267 _s->len -= i;
268
269 /* Everything went OK */
270 return 0;
271}
272
273
274/*

Callers 1

parse_param_bodyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected