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

Function add_uri_param

modules/enum/enum.c:391–465  ·  view source on GitHub ↗

* Add parameter to URI. */

Source from the content-addressed store, hash-verified

389 * Add parameter to URI.
390 */
391int add_uri_param(str *uri, str *param, str *new_uri)
392{
393 struct sip_uri puri;
394 char *at;
395
396 if (parse_uri(uri->s, uri->len, &puri) < 0) {
397 return 0;
398 }
399
400 /* if current uri has no headers, pad param to the end of uri */
401 if (puri.headers.len == 0) {
402 memcpy(uri->s + uri->len, param->s, param->len);
403 uri->len = uri->len + param->len;
404 new_uri->len = 0;
405 return 1;
406 }
407
408 /* otherwise take the long path and create new_uri */
409 at = new_uri->s;
410 switch (puri.type) {
411 case SIP_URI_T:
412 memcpy(at, "sip:", 4);
413 at = at + 4;
414 break;
415 case SIPS_URI_T:
416 memcpy(at, "sips:", 5);
417 at = at + 5;
418 break;
419 case TEL_URI_T:
420 memcpy(at, "tel:", 4);
421 at = at + 4;
422 break;
423 case TELS_URI_T:
424 memcpy(at, "tels:", 5);
425 at = at + 5;
426 break;
427 default:
428 LM_ERR("Unknown URI scheme <%d>\n", puri.type);
429 return 0;
430 }
431 if (puri.user.len) {
432 memcpy(at, puri.user.s, puri.user.len);
433 at = at + puri.user.len;
434 if (puri.passwd.len) {
435 *at = ':';
436 at = at + 1;
437 memcpy(at, puri.passwd.s, puri.passwd.len);
438 at = at + puri.passwd.len;
439 };
440 *at = '@';
441 at = at + 1;
442 }
443 memcpy(at, puri.host.s, puri.host.len);
444 at = at + puri.host.len;
445 if (puri.port.len) {
446 *at = ':';
447 at = at + 1;
448 memcpy(at, puri.port.s, puri.port.len);

Callers 1

do_queryFunction · 0.85

Calls 1

parse_uriFunction · 0.85

Tested by

no test coverage detected