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

Function parse_quoted_param

parser/parse_param.c:171–209  ·  view source on GitHub ↗

* Parse quoted string in a parameter body * return the string without quotes in _r * parameter and update _s to point behind the * closing quote */

Source from the content-addressed store, hash-verified

169 * closing quote
170 */
171static inline int parse_quoted_param(str* _s, str* _r)
172{
173 char* end_quote;
174
175 /* The string must have at least
176 * surrounding quotes
177 */
178 if (_s->len < 2) {
179 return -1;
180 }
181
182 /* Skip opening quote */
183 _s->s++;
184 _s->len--;
185
186
187 /* Find closing quote */
188 end_quote = q_memchr(_s->s, '\"', _s->len);
189
190 /* Not found, return error */
191 if (!end_quote) {
192 return -2;
193 }
194
195 /* Let _r point to the string without
196 * surrounding quotes
197 */
198 _r->s = _s->s;
199 _r->len = end_quote - _s->s;
200
201 /* Update _s parameter to point
202 * behind the closing quote
203 */
204 _s->len -= (end_quote - _s->s + 1);
205 _s->s = end_quote + 1;
206
207 /* Everything went OK */
208 return 0;
209}
210
211
212/*

Callers 1

parse_param_bodyFunction · 0.85

Calls 1

q_memchrFunction · 0.85

Tested by

no test coverage detected