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

Function parse_methods

parser/parse_methods.c:344–402  ·  view source on GitHub ↗

* Parse comma separated list of methods pointed by _body and assign their * enum bits to _methods. Returns 0 on success and -1 on failure. */

Source from the content-addressed store, hash-verified

342 * enum bits to _methods. Returns 0 on success and -1 on failure.
343 */
344int parse_methods(str* _body, unsigned int* _methods)
345{
346 str next;
347 char *p;
348 char *p0;
349 unsigned int method;
350
351 if (!_body || !_methods) {
352 LM_ERR("invalid parameter value\n");
353 return -1;
354 }
355
356 next.len = _body->len;
357 next.s = _body->s;
358
359 trim_leading(&next);
360
361 *_methods = 0;
362 if (next.len == 0) {
363 goto done;
364 }
365
366 method = 0;
367 p = next.s;
368
369 while (p<next.s+next.len) {
370 if((p0=parse_method(p, next.s+next.len, &method))!=NULL) {
371 *_methods |= method;
372 p = p0;
373 } else {
374 LM_ERR("invalid method [%.*s]\n", next.len, next.s);
375 return -1;
376 }
377
378 while(p<next.s+next.len && (*p==' ' || *p=='\t'
379 || *p=='\r' || *p=='\n'))
380 p++;
381 if(p>=next.s+next.len || *p == '\0')
382 goto done;
383
384
385 if (*p == ',')
386 {
387 p++;
388 while(p<next.s+next.len && (*p==' ' || *p=='\t'
389 || *p=='\r' || *p=='\n'))
390 p++;
391 if(p>=next.s+next.len)
392 goto done;
393 } else {
394 LM_ERR("comma expected\n");
395 return -1;
396 }
397 }
398
399done:
400 LM_DBG("methods 0x%X\n", *_methods);
401 return 0;

Callers 5

fixup_methodFunction · 0.85
check_message_supportFunction · 0.85
dup_req_infoFunction · 0.85
parse_allowFunction · 0.85
pack_ciFunction · 0.85

Calls 2

trim_leadingFunction · 0.85
parse_methodFunction · 0.85

Tested by

no test coverage detected