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

Function fixup_named_flags

mod_fix.c:538–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536}
537
538int fixup_named_flags(void** param, str *flag_names, str *kv_flag_names,
539 str *kv_flag_vals)
540{
541 str *s = (str*)*param;
542 csv_record *list, *rec;
543 int i;
544 unsigned int flags = 0;
545 char *p;
546 str name;
547
548 list = parse_csv_record(s);
549 if (!list) {
550 LM_ERR("Failed to parse list of flags\n");
551 return -1;
552 }
553
554 if (kv_flag_names)
555 for (i = 0; kv_flag_names[i].s ; i++) {
556 kv_flag_vals[i].s = NULL;
557 kv_flag_vals[i].len = 0;
558 }
559
560 for (rec = list; rec; rec = rec->next) {
561 if (flag_names) {
562 for (i = 0; flag_names[i].s && !str_match(&rec->s, &flag_names[i]);
563 i++) ;
564
565 if (!flag_names[i].s) {
566 if (!kv_flag_names) {
567 LM_ERR("Unknown flag: %.*s\n", rec->s.len, rec->s.s);
568 goto error;
569 }
570 } else {
571 flags |= (1<<i);
572 continue;
573 }
574 }
575
576 /* the current flag must be a key-value flag at this point */
577 if (kv_flag_names) {
578 p = q_memchr(rec->s.s, '=', rec->s.len);
579
580 name.s = rec->s.s;
581 name.len = p ? (p - rec->s.s) : rec->s.len;
582
583 for (i = 0; kv_flag_names[i].s &&
584 !str_match(&name, &kv_flag_names[i]); i++) ;
585
586 if (!kv_flag_names[i].s) {
587 LM_ERR("Unknown flag: %.*s\n", name.len, name.s);
588 goto error;
589 }
590
591 if (!p || (rec->s.len - (p - rec->s.s) - 1) == 0) {
592 LM_ERR("Bad format for key-value flag: %.*s\n",
593 rec->s.len, rec->s.s);
594 goto error;
595 }

Callers 15

fixup_via_hdlFunction · 0.85
get_mysql_tls_domFunction · 0.85
sock_mgm_parse_flagsFunction · 0.85
fixup_flags_uac_testFunction · 0.85
fixup_flags_sdpFunction · 0.85
flag_fixupFunction · 0.85
fixup_init_flagsFunction · 0.85
fixup_client_flagsFunction · 0.85
fixup_reply_flagsFunction · 0.85
fixup_bridge_flagsFunction · 0.85

Calls 3

str_matchFunction · 0.85
q_memchrFunction · 0.85
free_csv_recordFunction · 0.85

Tested by 1

test_utFunction · 0.68