* Parse quoted string in a parameter body * return the string without quotes in _r * parameter and update _s to point behind the * closing quote */
| 66 | * closing quote |
| 67 | */ |
| 68 | static inline int parse_quoted(str* _s, str* _r) |
| 69 | { |
| 70 | char* end_quote; |
| 71 | |
| 72 | /* The string must have at least |
| 73 | * surrounding quotes |
| 74 | */ |
| 75 | if (_s->len < 2) { |
| 76 | return -1; |
| 77 | } |
| 78 | |
| 79 | /* Skip opening quote */ |
| 80 | _s->s++; |
| 81 | _s->len--; |
| 82 | |
| 83 | |
| 84 | /* Find closing quote */ |
| 85 | end_quote = q_memchr(_s->s, '\"', _s->len); |
| 86 | |
| 87 | /* Not found, return error */ |
| 88 | if (!end_quote) { |
| 89 | return -2; |
| 90 | } |
| 91 | |
| 92 | /* Let _r point to the string without |
| 93 | * surrounding quotes |
| 94 | */ |
| 95 | _r->s = _s->s; |
| 96 | _r->len = end_quote - _s->s; |
| 97 | |
| 98 | /* Update _s parameter to point |
| 99 | * behind the closing quote |
| 100 | */ |
| 101 | _s->len -= (end_quote - _s->s + 1); |
| 102 | _s->s = end_quote + 1; |
| 103 | |
| 104 | /* Everything went OK */ |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | /* |
no test coverage detected