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

Function parse_params

parser/parse_param.c:348–441  ·  view source on GitHub ↗

* Parse parameters * _s is string containing parameters, it will be updated to point behind the parameters * _c is class of parameters * _h is pointer to structure that will be filled with pointer to well known parameters * linked list of parsed parameters will be stored in * the variable _p is pointing to * The function returns 0 on success and negative number * on an error */

Source from the content-addressed store, hash-verified

346 * on an error
347 */
348int parse_params(str* _s, pclass_t _c, param_hooks_t* _h, param_t** _p)
349{
350 param_t* t;
351 param_t* last;
352
353 if (!_s || !_h || !_p) {
354 LM_ERR("invalid parameter value\n");
355 return -1;
356 }
357
358 memset(_h, 0, sizeof(param_hooks_t));
359 last = NULL;
360 *_p = 0;
361
362 if (!_s->s) { /* no parameters at all -- we're done */
363 LM_DBG("empty uri params, skipping\n");
364 return 0;
365 }
366
367 LM_DBG("Parsing params for:[%.*s]\n",_s->len,_s->s);
368
369 while(1) {
370 t = (param_t*)pkg_malloc(sizeof(param_t));
371 if (t == 0) {
372 LM_ERR("no pkg memory left\n");
373 goto error;
374 }
375 memset(t, 0, sizeof(param_t));
376
377 parse_param_name(_s, _c, _h, t);
378 trim_leading(_s);
379
380 if (_s->len == 0) { /* The last parameter without body */
381 t->len = t->name.len;
382 goto ok;
383 }
384
385 if (_s->s[0] == '=') {
386 _s->s++;
387 _s->len--;
388 trim_leading(_s);
389
390 if (_s->len == 0) {
391 LM_ERR("body missing\n");
392 goto error;
393 }
394
395 if (parse_param_body(_s, t) < 0) {
396 LM_ERR("failed to parse param body\n");
397 goto error;
398 }
399
400 t->len = _s->s - t->name.s;
401
402 trim_leading(_s);
403 if (_s->len == 0) {
404 goto ok;
405 }

Callers 15

tr_eval_uriFunction · 0.85
tr_eval_paramlistFunction · 0.85
ruri_has_paramFunction · 0.85
load_reg_info_from_dbFunction · 0.85
mi_reg_upsertFunction · 0.85
ospGetPcvIcidFunction · 0.85
ospGetNpParamFunction · 0.85
ospGetOperatorNameFunction · 0.85
path_rr_callbackFunction · 0.85
assemble_msgFunction · 0.85
parse_identity_hfFunction · 0.85
mq_paramFunction · 0.85

Calls 4

trim_leadingFunction · 0.85
parse_param_bodyFunction · 0.85
free_paramsFunction · 0.85
parse_param_nameFunction · 0.70

Tested by

no test coverage detected