Browse code

Merge branch 'master' of https://github.com/kamailio/kamailio

Arsen Semenov authored on 15/10/2020 10:50:12
Showing 6 changed files
... ...
@@ -145,22 +145,22 @@ if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
145 145
 /* sip request */
146 146
 #define IS_SIP(req)                                     \
147 147
 	(((req)->first_line.type == SIP_REQUEST) &&           \
148
-	((req)->first_line.type & FLINE_FLAG_PROTO_SIP))
148
+	((req)->first_line.flags & FLINE_FLAG_PROTO_SIP))
149 149
 
150 150
 /* sip reply */
151 151
 #define IS_SIP_REPLY(rpl)                               \
152 152
 	(((rpl)->first_line.type == SIP_REPLY) &&             \
153
-	((rpl)->first_line.type & FLINE_FLAG_PROTO_SIP))
153
+	((rpl)->first_line.flags & FLINE_FLAG_PROTO_SIP))
154 154
 
155 155
 /* http request */
156 156
 #define IS_HTTP(req)                                    \
157 157
 	(((req)->first_line.type == SIP_REQUEST) &&           \
158
-	((req)->first_line.type & FLINE_FLAG_PROTO_HTTP))
158
+	((req)->first_line.flags & FLINE_FLAG_PROTO_HTTP))
159 159
 
160 160
 /* http reply */
161 161
 #define IS_HTTP_REPLY(rpl)                              \
162 162
 	(((rpl)->first_line.type == SIP_REPLY) &&             \
163
-	((rpl)->first_line.type & FLINE_FLAG_PROTO_HTTP))
163
+	((rpl)->first_line.flags & FLINE_FLAG_PROTO_HTTP))
164 164
 
165 165
 /*! \brief
166 166
  * Return a URI to which the message should be really sent (not what should
... ...
@@ -47,23 +47,24 @@ Daniel-Constantin Mierla
47 47
 
48 48
               4.8. xavp_params_explode(sparams, xname)
49 49
               4.9. xavp_params_implode(xname, pvname)
50
-              4.10. xavp_child_seti(rname, cname, ival)
51
-              4.11. xavi_child_seti(rname, cname, ival)
52
-              4.12. xavp_child_sets(rname, cname, sval)
53
-              4.13. xavi_child_sets(rname, cname, sval)
54
-              4.14. xavp_rm(rname)
55
-              4.15. xavi_rm(rname)
56
-              4.16. xavp_child_rm(rname, cname)
57
-              4.17. xavi_child_rm(rname, cname)
58
-              4.18. sbranch_set_ruri()
59
-              4.19. sbranch_append()
60
-              4.20. sbranch_reset()
61
-              4.21. pv_xavp_print()
62
-              4.22. pv_xavu_print()
63
-              4.23. pv_xavi_print()
64
-              4.24. pv_var_to_xavp(varname, xname)
65
-              4.25. pv_xavp_to_var(xname)
66
-              4.26. pv_evalx(dst, fmt)
50
+              4.10. xavp_slist_explode(slist, sep, mode, xname)
51
+              4.11. xavp_child_seti(rname, cname, ival)
52
+              4.12. xavi_child_seti(rname, cname, ival)
53
+              4.13. xavp_child_sets(rname, cname, sval)
54
+              4.14. xavi_child_sets(rname, cname, sval)
55
+              4.15. xavp_rm(rname)
56
+              4.16. xavi_rm(rname)
57
+              4.17. xavp_child_rm(rname, cname)
58
+              4.18. xavi_child_rm(rname, cname)
59
+              4.19. sbranch_set_ruri()
60
+              4.20. sbranch_append()
61
+              4.21. sbranch_reset()
62
+              4.22. pv_xavp_print()
63
+              4.23. pv_xavu_print()
64
+              4.24. pv_xavi_print()
65
+              4.25. pv_var_to_xavp(varname, xname)
66
+              4.26. pv_xavp_to_var(xname)
67
+              4.27. pv_evalx(dst, fmt)
67 68
 
68 69
         5. RPC Commands
69 70
 
... ...
@@ -84,25 +85,26 @@ Daniel-Constantin Mierla
84 85
    1.10. xavp_copy usage
85 86
    1.11. xavp_params_explode usage
86 87
    1.12. xavp_params_implode usage
87
-   1.13. xavp_child_seti usage
88
-   1.14. xavi_child_seti usage
89
-   1.15. xavp_child_sets usage
90
-   1.16. xavi_child_sets usage
91
-   1.17. xavp_rm usage
92
-   1.18. xavi_rm usage
93
-   1.19. xavp_child_rm usage
94
-   1.20. xavi_child_rm usage
95
-   1.21. sbranch_set_ruri() usage
96
-   1.22. sbranch_append() usage
88
+   1.13. xavp_slist_explode usage
89
+   1.14. xavp_child_seti usage
90
+   1.15. xavi_child_seti usage
91
+   1.16. xavp_child_sets usage
92
+   1.17. xavi_child_sets usage
93
+   1.18. xavp_rm usage
94
+   1.19. xavi_rm usage
95
+   1.20. xavp_child_rm usage
96
+   1.21. xavi_child_rm usage
97
+   1.22. sbranch_set_ruri() usage
97 98
    1.23. sbranch_append() usage
98
-   1.24. pv_xavp_print() usage
99
-   1.25. pv_xavu_print() usage
100
-   1.26. pv_xavi_print() usage
101
-   1.27. pv_var_to_xavp() usage
102
-   1.28. pv_xavp_to_var() usage
99
+   1.24. sbranch_append() usage
100
+   1.25. pv_xavp_print() usage
101
+   1.26. pv_xavu_print() usage
102
+   1.27. pv_xavi_print() usage
103
+   1.28. pv_var_to_xavp() usage
103 104
    1.29. pv_xavp_to_var() usage
104
-   1.30. pv.shvSet usage
105
-   1.31. pv.shvGet usage
105
+   1.30. pv_xavp_to_var() usage
106
+   1.31. pv.shvSet usage
107
+   1.32. pv.shvGet usage
106 108
 
107 109
 Chapter 1. Admin Guide
108 110
 
... ...
@@ -133,23 +135,24 @@ Chapter 1. Admin Guide
133 135
 
134 136
         4.8. xavp_params_explode(sparams, xname)
135 137
         4.9. xavp_params_implode(xname, pvname)
136
-        4.10. xavp_child_seti(rname, cname, ival)
137
-        4.11. xavi_child_seti(rname, cname, ival)
138
-        4.12. xavp_child_sets(rname, cname, sval)
139
-        4.13. xavi_child_sets(rname, cname, sval)
140
-        4.14. xavp_rm(rname)
141
-        4.15. xavi_rm(rname)
142
-        4.16. xavp_child_rm(rname, cname)
143
-        4.17. xavi_child_rm(rname, cname)
144
-        4.18. sbranch_set_ruri()
145
-        4.19. sbranch_append()
146
-        4.20. sbranch_reset()
147
-        4.21. pv_xavp_print()
148
-        4.22. pv_xavu_print()
149
-        4.23. pv_xavi_print()
150
-        4.24. pv_var_to_xavp(varname, xname)
151
-        4.25. pv_xavp_to_var(xname)
152
-        4.26. pv_evalx(dst, fmt)
138
+        4.10. xavp_slist_explode(slist, sep, mode, xname)
139
+        4.11. xavp_child_seti(rname, cname, ival)
140
+        4.12. xavi_child_seti(rname, cname, ival)
141
+        4.13. xavp_child_sets(rname, cname, sval)
142
+        4.14. xavi_child_sets(rname, cname, sval)
143
+        4.15. xavp_rm(rname)
144
+        4.16. xavi_rm(rname)
145
+        4.17. xavp_child_rm(rname, cname)
146
+        4.18. xavi_child_rm(rname, cname)
147
+        4.19. sbranch_set_ruri()
148
+        4.20. sbranch_append()
149
+        4.21. sbranch_reset()
150
+        4.22. pv_xavp_print()
151
+        4.23. pv_xavu_print()
152
+        4.24. pv_xavi_print()
153
+        4.25. pv_var_to_xavp(varname, xname)
154
+        4.26. pv_xavp_to_var(xname)
155
+        4.27. pv_evalx(dst, fmt)
153 156
 
154 157
    5. RPC Commands
155 158
 
... ...
@@ -250,23 +253,24 @@ modparam("pv","avp_aliases","email=s:email_addr;tmp=i:100")
250 253
 
251 254
    4.8. xavp_params_explode(sparams, xname)
252 255
    4.9. xavp_params_implode(xname, pvname)
253
-   4.10. xavp_child_seti(rname, cname, ival)
254
-   4.11. xavi_child_seti(rname, cname, ival)
255
-   4.12. xavp_child_sets(rname, cname, sval)
256
-   4.13. xavi_child_sets(rname, cname, sval)
257
-   4.14. xavp_rm(rname)
258
-   4.15. xavi_rm(rname)
259
-   4.16. xavp_child_rm(rname, cname)
260
-   4.17. xavi_child_rm(rname, cname)
261
-   4.18. sbranch_set_ruri()
262
-   4.19. sbranch_append()
263
-   4.20. sbranch_reset()
264
-   4.21. pv_xavp_print()
265
-   4.22. pv_xavu_print()
266
-   4.23. pv_xavi_print()
267
-   4.24. pv_var_to_xavp(varname, xname)
268
-   4.25. pv_xavp_to_var(xname)
269
-   4.26. pv_evalx(dst, fmt)
256
+   4.10. xavp_slist_explode(slist, sep, mode, xname)
257
+   4.11. xavp_child_seti(rname, cname, ival)
258
+   4.12. xavi_child_seti(rname, cname, ival)
259
+   4.13. xavp_child_sets(rname, cname, sval)
260
+   4.14. xavi_child_sets(rname, cname, sval)
261
+   4.15. xavp_rm(rname)
262
+   4.16. xavi_rm(rname)
263
+   4.17. xavp_child_rm(rname, cname)
264
+   4.18. xavi_child_rm(rname, cname)
265
+   4.19. sbranch_set_ruri()
266
+   4.20. sbranch_append()
267
+   4.21. sbranch_reset()
268
+   4.22. pv_xavp_print()
269
+   4.23. pv_xavu_print()
270
+   4.24. pv_xavi_print()
271
+   4.25. pv_var_to_xavp(varname, xname)
272
+   4.26. pv_xavp_to_var(xname)
273
+   4.27. pv_evalx(dst, fmt)
270 274
 
271 275
 4.1. pv_isset(pvar)
272 276
 
... ...
@@ -457,7 +461,38 @@ xavp_params_implode("x", "$var(out)");
457 461
 # results in: $var(out) is "a=b;c=d;e=f;"
458 462
 ...
459 463
 
460
-4.10.  xavp_child_seti(rname, cname, ival)
464
+4.10.  xavp_slist_explode(slist, sep, mode, xname)
465
+
466
+   Breaks a string list in tokens by separators and stores them in XAVPs.
467
+   Note that is not storing empty values.
468
+
469
+   The first parameter has to be a string (static or with variables).
470
+
471
+   The second parameter has to contain separator characters (they can be
472
+   many).
473
+
474
+   The third parameter is mode, controlling the behaviour of extracting
475
+   the tokens, the supported mode right now is 't', which trims the white
476
+   spaces around the value.
477
+
478
+   The fourth parameter is the name of the root xavp to hold the tokens in
479
+   fields named 'v' and indexed from 0.
480
+
481
+   The values are stored as string type.
482
+
483
+   Function can be used from ANY ROUTE.
484
+
485
+   Example 1.13. xavp_slist_explode usage
486
+...
487
+xavp_slist_explode("a=b; c=d;", "=;", "t", "x");
488
+# results in:
489
+#    $xavp(x[0]=>v[0]) = "a";
490
+#    $xavp(x[0]=>v[1]) = "b";
491
+#    $xavp(x[0]=>v[2]) = "c";
492
+#    $xavp(x[0]=>v[3]) = "d";
493
+...
494
+
495
+4.11.  xavp_child_seti(rname, cname, ival)
461 496
 
462 497
    Set the value of $xavp(rname=>cname) to integer value ival.
463 498
 
... ...
@@ -467,14 +502,14 @@ xavp_params_implode("x", "$var(out)");
467 502
 
468 503
    Function can be used from ANY ROUTE.
469 504
 
470
-   Example 1.13. xavp_child_seti usage
505
+   Example 1.14. xavp_child_seti usage
471 506
 ...
472 507
 $var(n) = 10;
473 508
 xavp_child_seti("x", "y", "$var(n)");
474 509
 # results in: $xavp(x=>y) is 10
475 510
 ...
476 511
 
477
-4.11.  xavi_child_seti(rname, cname, ival)
512
+4.12.  xavi_child_seti(rname, cname, ival)
478 513
 
479 514
    Set the value of $xavi(rname=>cname) to integer value ival.
480 515
 
... ...
@@ -484,14 +519,14 @@ xavp_child_seti("x", "y", "$var(n)");
484 519
 
485 520
    Function can be used from ANY ROUTE.
486 521
 
487
-   Example 1.14. xavi_child_seti usage
522
+   Example 1.15. xavi_child_seti usage
488 523
 ...
489 524
 $var(n) = 10;
490 525
 xavi_child_seti("WhatEver", "FoO", "$var(n)");
491 526
 # results in: $xavi(whatever=>foo) is 10
492 527
 ...
493 528
 
494
-4.12.  xavp_child_sets(rname, cname, sval)
529
+4.13.  xavp_child_sets(rname, cname, sval)
495 530
 
496 531
    Set the value of $xavp(rname=>cname) to string value sval.
497 532
 
... ...
@@ -501,14 +536,14 @@ xavi_child_seti("WhatEver", "FoO", "$var(n)");
501 536
 
502 537
    Function can be used from ANY ROUTE.
503 538
 
504
-   Example 1.15. xavp_child_sets usage
539
+   Example 1.16. xavp_child_sets usage
505 540
 ...
506 541
 $var(n) = 10;
507 542
 xavp_child_sets("x", "y", "Count: $var(n)");
508 543
 # results in: $xavp(x=>y) is "Count: 10"
509 544
 ...
510 545
 
511
-4.13.  xavi_child_sets(rname, cname, sval)
546
+4.14.  xavi_child_sets(rname, cname, sval)
512 547
 
513 548
    Set the value of $xavi(rname=>cname) to string value sval.
514 549
 
... ...
@@ -518,14 +553,14 @@ xavp_child_sets("x", "y", "Count: $var(n)");
518 553
 
519 554
    Function can be used from ANY ROUTE.
520 555
 
521
-   Example 1.16. xavi_child_sets usage
556
+   Example 1.17. xavi_child_sets usage
522 557
 ...
523 558
 $var(n) = 10;
524 559
 xavi_child_sets("WhatEver", "FoO", "Count: $var(n)");
525 560
 # results in: $xavi(whatever=>foo) is "Count: 10"
526 561
 ...
527 562
 
528
-4.14.  xavp_rm(rname)
563
+4.15.  xavp_rm(rname)
529 564
 
530 565
    Remove the value of $xavp(rname).
531 566
 
... ...
@@ -534,13 +569,13 @@ xavi_child_sets("WhatEver", "FoO", "Count: $var(n)");
534 569
 
535 570
    Function can be used from ANY ROUTE.
536 571
 
537
-   Example 1.17. xavp_rm usage
572
+   Example 1.18. xavp_rm usage
538 573
 ...
539 574
 xavp_rm("x");
540 575
 # same result as: $xavp(x) = $null;
541 576
 ...
542 577
 
543
-4.15.  xavi_rm(rname)
578
+4.16.  xavi_rm(rname)
544 579
 
545 580
    Remove the value of $xavi(rname).
546 581
 
... ...
@@ -549,13 +584,13 @@ xavp_rm("x");
549 584
 
550 585
    Function can be used from ANY ROUTE.
551 586
 
552
-   Example 1.18. xavi_rm usage
587
+   Example 1.19. xavi_rm usage
553 588
 ...
554 589
 xavi_rm("WhatEver");
555 590
 # same result as: $xavi(whatever) = $null;
556 591
 ...
557 592
 
558
-4.16.  xavp_child_rm(rname, cname)
593
+4.17.  xavp_child_rm(rname, cname)
559 594
 
560 595
    Remove the value of $xavp(rname=>cname).
561 596
 
... ...
@@ -565,13 +600,13 @@ xavi_rm("WhatEver");
565 600
 
566 601
    Function can be used from ANY ROUTE.
567 602
 
568
-   Example 1.19. xavp_child_rm usage
603
+   Example 1.20. xavp_child_rm usage
569 604
 ...
570 605
 xavp_child_rm("x", "y");
571 606
 # same result as: $xavp(x=>y) = $null;
572 607
 ...
573 608
 
574
-4.17.  xavi_child_rm(rname, cname)
609
+4.18.  xavi_child_rm(rname, cname)
575 610
 
576 611
    Remove the value of $xavi(rname=>cname).
577 612
 
... ...
@@ -581,13 +616,13 @@ xavp_child_rm("x", "y");
581 616
 
582 617
    Function can be used from ANY ROUTE.
583 618
 
584
-   Example 1.20. xavi_child_rm usage
619
+   Example 1.21. xavi_child_rm usage
585 620
 ...
586 621
 xavi_child_rm("WhatEver", "FoO");
587 622
 # same result as: $xavi(whatever=>foo) = $null;
588 623
 ...
589 624
 
590
-4.18.  sbranch_set_ruri()
625
+4.19.  sbranch_set_ruri()
591 626
 
592 627
    Use the attributes from static branch ($sbranch(key) variable) to set
593 628
    request URI and the other fields of the branch associated with request
... ...
@@ -598,7 +633,7 @@ xavi_child_rm("WhatEver", "FoO");
598 633
 
599 634
    Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
600 635
 
601
-   Example 1.21. sbranch_set_ruri() usage
636
+   Example 1.22. sbranch_set_ruri() usage
602 637
 ...
603 638
 sbranch_reset();
604 639
 $sbranch(uri) = "sip:127.0.0.1:5080";
... ...
@@ -608,7 +643,7 @@ $sbranch(send_socket) =  "udp:127.0.0.1:5060";
608 643
 sbranch_set_ruri();
609 644
 ...
610 645
 
611
-4.19.  sbranch_append()
646
+4.20.  sbranch_append()
612 647
 
613 648
    Use the attributes from static branch ($sbranch(key) variable) to
614 649
    append a new branch to destination set. It is an alternative to
... ...
@@ -620,7 +655,7 @@ sbranch_set_ruri();
620 655
 
621 656
    Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
622 657
 
623
-   Example 1.22. sbranch_append() usage
658
+   Example 1.23. sbranch_append() usage
624 659
 ...
625 660
 sbranch_reset();
626 661
 $sbranch(uri) = "sip:127.0.0.1:5080";
... ...
@@ -629,51 +664,51 @@ $sbranch(send_socket) =  "udp:127.0.0.1:5060";
629 664
 sbranch_append();
630 665
 ...
631 666
 
632
-4.20.  sbranch_reset()
667
+4.21.  sbranch_reset()
633 668
 
634 669
    Reset the content of static branch ($sbranch(key) variable.
635 670
 
636 671
    Function can be used from REQUEST_ROUTE, BRANCH_ROUTE or FAILURE_ROUTE.
637 672
 
638
-   Example 1.23. sbranch_append() usage
673
+   Example 1.24. sbranch_append() usage
639 674
 ...
640 675
 sbranch_reset();
641 676
 ...
642 677
 
643
-4.21.  pv_xavp_print()
678
+4.22.  pv_xavp_print()
644 679
 
645 680
    Print all XAVPs to the syslog using INFO log level.
646 681
 
647 682
    Function can be used from ANY_ROUTE.
648 683
 
649
-   Example 1.24. pv_xavp_print() usage
684
+   Example 1.25. pv_xavp_print() usage
650 685
 ...
651 686
 pv_xavp_print();
652 687
 ...
653 688
 
654
-4.22.  pv_xavu_print()
689
+4.23.  pv_xavu_print()
655 690
 
656 691
    Print all XAVUs to the syslog using INFO log level.
657 692
 
658 693
    Function can be used from ANY_ROUTE.
659 694
 
660
-   Example 1.25. pv_xavu_print() usage
695
+   Example 1.26. pv_xavu_print() usage
661 696
 ...
662 697
 pv_xavu_print();
663 698
 ...
664 699
 
665
-4.23.  pv_xavi_print()
700
+4.24.  pv_xavi_print()
666 701
 
667 702
    Print all XAVIs to the syslog using INFO log level.
668 703
 
669 704
    Function can be used from ANY_ROUTE.
670 705
 
671
-   Example 1.26. pv_xavi_print() usage
706
+   Example 1.27. pv_xavi_print() usage
672 707
 ...
673 708
 pv_xavi_print();
674 709
 ...
675 710
 
676
-4.24.  pv_var_to_xavp(varname, xname)
711
+4.25.  pv_var_to_xavp(varname, xname)
677 712
 
678 713
    Copy the script variable value into an xavp.
679 714
 
... ...
@@ -685,7 +720,7 @@ pv_xavi_print();
685 720
 
686 721
    Function can be used from ANY_ROUTE.
687 722
 
688
-   Example 1.27. pv_var_to_xavp() usage
723
+   Example 1.28. pv_var_to_xavp() usage
689 724
 ...
690 725
 $var("temp") = 3;
691 726
 $var("foo") = "foo indeed";
... ...
@@ -699,7 +734,7 @@ $xavp("ok[0]=>temp") now is 3
699 734
 $xavp("ok[0]=>foo") now is "foo indeed"
700 735
 ...
701 736
 
702
-4.25.  pv_xavp_to_var(xname)
737
+4.26.  pv_xavp_to_var(xname)
703 738
 
704 739
    Copy xavp values into vars. Reverse of pv_var_to_xavp().
705 740
 
... ...
@@ -707,7 +742,7 @@ $xavp("ok[0]=>foo") now is "foo indeed"
707 742
 
708 743
    Function can be used from ANY_ROUTE.
709 744
 
710
-   Example 1.28. pv_xavp_to_var() usage
745
+   Example 1.29. pv_xavp_to_var() usage
711 746
 ...
712 747
 $xavp("bar=>temp") = 3;
713 748
 $xavp("bar[0]=>foo") = "foo indeed";
... ...
@@ -717,7 +752,7 @@ $var("temp") now is 3
717 752
 $var("foo") now is "foo indeed"
718 753
 ...
719 754
 
720
-4.26.  pv_evalx(dst, fmt)
755
+4.27.  pv_evalx(dst, fmt)
721 756
 
722 757
    The fmt string is evaluated twice for exiting variables, the result is
723 758
    stored in dst variable. The dst must be the name of a writable
... ...
@@ -726,7 +761,7 @@ $var("foo") now is "foo indeed"
726 761
 
727 762
    Function can be used from ANY_ROUTE.
728 763
 
729
-   Example 1.29. pv_xavp_to_var() usage
764
+   Example 1.30. pv_xavp_to_var() usage
730 765
 ...
731 766
 $var(x) = "test";
732 767
 $var(y) = "$var(x)"
... ...
@@ -751,7 +786,7 @@ pv_evalx("$var(z)", "$var(y) one");
751 786
           + “str”: string value
752 787
      * _value_: value to be set
753 788
 
754
-   Example 1.30. pv.shvSet usage
789
+   Example 1.31. pv.shvSet usage
755 790
 ...
756 791
 $ kamcmd pv.shvSet debug int 3
757 792
 ...
... ...
@@ -765,7 +800,7 @@ $ kamcmd pv.shvSet debug int 3
765 800
 
766 801
    If no name is given, all shared variables are listed.
767 802
 
768
-   Example 1.31. pv.shvGet usage
803
+   Example 1.32. pv.shvGet usage
769 804
 ...
770 805
 $ kamcmd pv.shvGet debug
771 806
 ...
... ...
@@ -413,6 +413,50 @@ $xavp(x[0]=>c) = "d";
413 413
 $xavp(x[0]=>a) = "b";
414 414
 xavp_params_implode("x", "$var(out)");
415 415
 # results in: $var(out) is "a=b;c=d;e=f;"
416
+...
417
+				</programlisting>
418
+			</example>
419
+		</section>
420
+		<section id="pv.f.xavp_slist_explode">
421
+			<title>
422
+				<function moreinfo="none">xavp_slist_explode(slist, sep, mode, xname)</function>
423
+			</title>
424
+			<para>
425
+				Breaks a string list in tokens by separators and stores them
426
+				in XAVPs. Note that is not storing empty values.
427
+			</para>
428
+			<para>
429
+				The first parameter has to be a string (static or with variables).
430
+			</para>
431
+			<para>
432
+				The second parameter has to contain separator characters (they
433
+				can be many).
434
+			</para>
435
+			<para>
436
+				The third parameter is mode, controlling the behaviour of extracting
437
+				the tokens, the supported mode right now is 't', which trims
438
+				the white spaces around the value.
439
+			</para>
440
+			<para>
441
+				The fourth parameter is the name of the root xavp to hold the tokens
442
+				in fields named 'v' and indexed from 0.
443
+			</para>
444
+			<para>
445
+				The values are stored as string type.
446
+			</para>
447
+			<para>
448
+			Function can be used from ANY ROUTE.
449
+			</para>
450
+			<example>
451
+				<title><function>xavp_slist_explode</function> usage</title>
452
+				<programlisting format="linespecific">
453
+...
454
+xavp_slist_explode("a=b; c=d;", "=;", "t", "x");
455
+# results in:
456
+#    $xavp(x[0]=&gt;v[0]) = "a";
457
+#    $xavp(x[0]=&gt;v[1]) = "b";
458
+#    $xavp(x[0]=&gt;v[2]) = "c";
459
+#    $xavp(x[0]=&gt;v[3]) = "d";
416 460
 ...
417 461
 				</programlisting>
418 462
 			</example>
... ...
@@ -559,6 +559,8 @@ static int w_xavp_copy_dst(sip_msg_t *msg, char *src_name, char *src_idx,
559 559
 		char *dst_name, char *dst_idx);
560 560
 static int w_xavp_params_explode(sip_msg_t *msg, char *pparams, char *pxname);
561 561
 static int w_xavp_params_implode(sip_msg_t *msg, char *pxname, char *pvname);
562
+static int w_xavp_slist_explode(sip_msg_t *msg, char *pslist, char *psep,
563
+		char *pmode, char *pxname);
562 564
 static int w_xavp_child_seti(sip_msg_t *msg, char *prname, char *pcname,
563 565
 		char *pval);
564 566
 static int w_xavp_child_sets(sip_msg_t *msg, char *prname, char *pcname,
... ...
@@ -611,6 +613,9 @@ static cmd_export_t cmds[]={
611 613
 	{"not_empty", (cmd_function)pv_not_empty, 1, fixup_pvar_null,
612 614
 		fixup_free_pvar_null,
613 615
 		ANY_ROUTE},
616
+	{"xavp_slist_explode", (cmd_function)w_xavp_slist_explode,
617
+		4, fixup_spve_all, fixup_free_spve_all,
618
+		ANY_ROUTE},
614 619
 	{"xavp_params_explode", (cmd_function)w_xavp_params_explode,
615 620
 		2, fixup_spve_spve, fixup_free_spve_spve,
616 621
 		ANY_ROUTE},
... ...
@@ -1111,6 +1116,53 @@ static int w_xavp_params_implode(sip_msg_t *msg, char *pxname, char *pvname)
1111 1116
 	return ki_xavp_params_implode(msg, &sxname, (str*)pvname);
1112 1117
 }
1113 1118
 
1119
+/**
1120
+ *
1121
+ */
1122
+static int w_xavp_slist_explode(sip_msg_t *msg, char *pslist, char *psep,
1123
+		char *pmode, char *pxname)
1124
+{
1125
+	str slist;
1126
+	str sep;
1127
+	str smode;
1128
+	str sxname;
1129
+
1130
+	if(fixup_get_svalue(msg, (gparam_t*)pslist, &slist)!=0) {
1131
+		LM_ERR("cannot get the params\n");
1132
+		return -1;
1133
+	}
1134
+	if(fixup_get_svalue(msg, (gparam_t*)psep, &sep)!=0) {
1135
+		LM_ERR("cannot get the params\n");
1136
+		return -1;
1137
+	}
1138
+	if(fixup_get_svalue(msg, (gparam_t*)pmode, &smode)!=0) {
1139
+		LM_ERR("cannot get the params\n");
1140
+		return -1;
1141
+	}
1142
+	if(fixup_get_svalue(msg, (gparam_t*)pxname, &sxname)!=0) {
1143
+		LM_ERR("cannot get the xavp name\n");
1144
+		return -1;
1145
+	}
1146
+
1147
+	if(xavp_slist_explode(&slist, &sep, &smode, &sxname)<0)
1148
+		return -1;
1149
+
1150
+	return 1;
1151
+}
1152
+
1153
+/**
1154
+ *
1155
+ */
1156
+static int ki_xavp_slist_explode(sip_msg_t *msg, str *slist, str *sep, str *mode,
1157
+		str *sxname)
1158
+{
1159
+	if(xavp_slist_explode(slist, sep, mode, sxname)<0)
1160
+		return -1;
1161
+
1162
+	return 1;
1163
+}
1164
+
1165
+
1114 1166
 /**
1115 1167
  *
1116 1168
  */
... ...
@@ -2687,6 +2739,11 @@ static sr_kemi_t sr_kemi_pvx_exports[] = {
2687 2739
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
2688 2740
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
2689 2741
 	},
2742
+	{ str_init("pvx"), str_init("xavp_slist_explode"),
2743
+		SR_KEMIP_INT, ki_xavp_slist_explode,
2744
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
2745
+			SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
2746
+	},
2690 2747
 	{ str_init("pvx"), str_init("xavp_seti"),
2691 2748
 		SR_KEMIP_INT, ki_xavp_seti,
2692 2749
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
... ...
@@ -580,6 +580,110 @@ int pv_xavi_print(sip_msg_t* msg, char* s1, char *s2)
580 580
 	return 1;
581 581
 }
582 582
 
583
+/**
584
+ *
585
+ */
586
+int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname)
587
+{
588
+	str s;
589
+	sr_xavp_t *xavp_list=NULL;
590
+	sr_xavp_t *xavp=NULL;
591
+	sr_xval_t xval;
592
+	str itname = str_init("v");
593
+	int i;
594
+	int j;
595
+	int sfound;
596
+
597
+	if(slist==NULL || xname==NULL || slist->s==NULL || xname->s==NULL
598
+			|| slist->len<=0 || xname->len<=0 || sep==NULL  || sep->s==NULL
599
+			|| sep->len<=0 || mode==NULL) {
600
+		LM_ERR("invalid parameters\n");
601
+		return -1;
602
+	}
603
+
604
+	s.s = slist->s;
605
+	for(i=0; i<slist->len; i++) {
606
+		LM_DBG("==== %d = %c\n", i, slist->s[i]);
607
+		sfound = 0;
608
+		for(j=0; j<sep->len; j++) {
609
+			if(slist->s[i]==sep->s[j]) {
610
+				sfound = 1;
611
+			}
612
+		}
613
+		if(sfound) {
614
+			s.len = slist->s + i - s.s;
615
+			if(s.len > 0 && mode->len > 0) {
616
+				if(mode->s[0]=='t') {
617
+					trim(&s);
618
+				}
619
+			}
620
+			if(s.len>0) {
621
+				LM_DBG("token found: [%.*s]\n", s.len, s.s);
622
+				memset(&xval, 0, sizeof(sr_xval_t));
623
+				xval.type = SR_XTYPE_STR;
624
+				xval.v.s = s;
625
+				if(xavp_list == NULL) {
626
+					if(xavp_add_value(&itname, &xval, &xavp_list)==NULL) {
627
+						LM_ERR("failed to add item in the list: [%.*s]\n",
628
+								s.len, s.s);
629
+						return -1;
630
+					}
631
+					xavp = xavp_list;
632
+				} else {
633
+					xavp = xavp_add_value_after(&itname, &xval, xavp);
634
+					if(xavp == NULL) {
635
+						LM_ERR("failed to add item in the list: [%.*s]\n",
636
+								s.len, s.s);
637
+						xavp_destroy_list(&xavp_list);
638
+						return -1;
639
+					}
640
+				}
641
+			}
642
+			s.s = slist->s + i + 1;
643
+		}
644
+	}
645
+	/* last tocken */
646
+	s.len = slist->s + i - s.s;
647
+	if(s.len > 0 && mode->len > 0) {
648
+		if(mode->s[0]=='t') {
649
+			trim(&s);
650
+		}
651
+	}
652
+	if(s.len>0) {
653
+		LM_DBG("last token found: [%.*s]\n", s.len, s.s);
654
+		memset(&xval, 0, sizeof(sr_xval_t));
655
+		xval.type = SR_XTYPE_STR;
656
+		xval.v.s = s;
657
+		if(xavp_list == NULL) {
658
+			if(xavp_add_value(&itname, &xval, &xavp_list)==NULL) {
659
+				LM_ERR("failed to add item in the list: [%.*s]\n",
660
+						s.len, s.s);
661
+				return -1;
662
+			}
663
+			xavp = xavp_list;
664
+		} else {
665
+			xavp = xavp_add_value_after(&itname, &xval, xavp);
666
+			if(xavp == NULL) {
667
+				LM_ERR("failed to add item in the list: [%.*s]\n",
668
+						s.len, s.s);
669
+				xavp_destroy_list(&xavp_list);
670
+				return -1;
671
+			}
672
+		}
673
+	}
674
+
675
+	/* add main xavp in root list */
676
+	memset(&xval, 0, sizeof(sr_xval_t));
677
+	xval.type = SR_XTYPE_XAVP;
678
+	xval.v.xavp = xavp_list;
679
+	if(xavp_add_value(xname, &xval, NULL)==NULL) {
680
+		xavp_destroy_list(&xavp);
681
+		return -1;
682
+	}
683
+
684
+	return 0;
685
+}
686
+
583 687
 /**
584 688
  *
585 689
  */
... ...
@@ -42,6 +42,7 @@ int pv_xavp_print(struct sip_msg* msg, char* s1, char *s2);
42 42
 int pv_xavu_print(struct sip_msg* msg, char* s1, char *s2);
43 43
 int pv_xavi_print(struct sip_msg* msg, char* s1, char *s2);
44 44
 
45
+int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname);
45 46
 int xavp_params_explode(str *params, str *xname);
46 47
 
47 48
 int pv_var_to_xavp(str *varname, str *xname);