* Parse name-addr part, the given string can be longer, * parsing will stop when closing > is found */
| 35 | * parsing will stop when closing > is found |
| 36 | */ |
| 37 | int parse_nameaddr(str* _s, name_addr_t* _a) |
| 38 | { |
| 39 | char* uri_end; |
| 40 | |
| 41 | if (!_s || !_a) { |
| 42 | LM_ERR("invalid parameter value\n"); |
| 43 | return -1; |
| 44 | } |
| 45 | |
| 46 | _a->name.s = _s->s; |
| 47 | |
| 48 | _a->uri.s = find_not_quoted(_s, '<'); |
| 49 | if (_a->uri.s) { |
| 50 | _a->name.len = _a->uri.s - _a->name.s; |
| 51 | _a->uri.s++; /* We will skip < character */ |
| 52 | } else { |
| 53 | LM_ERR("no < found\n"); |
| 54 | return -3; |
| 55 | } |
| 56 | |
| 57 | _a->uri.len = _s->len - _a->name.len - 1; |
| 58 | uri_end = find_not_quoted(&_a->uri, '>'); |
| 59 | |
| 60 | if (!uri_end) { |
| 61 | LM_ERR("no > found\n"); |
| 62 | return -4; |
| 63 | } |
| 64 | |
| 65 | /* Total length of the field including <> */ |
| 66 | _a->len = uri_end - _a->name.s + 1; |
| 67 | |
| 68 | _a->uri.len = uri_end - _a->uri.s; |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /* |
no test coverage detected