* Convert char* method to str* parameter */
| 766 | * Convert char* method to str* parameter |
| 767 | */ |
| 768 | static int fixup_method(void** param) |
| 769 | { |
| 770 | str* s; |
| 771 | char *p; |
| 772 | int m; |
| 773 | unsigned int method; |
| 774 | |
| 775 | s = (str*)pkg_malloc(sizeof(str)); |
| 776 | if (!s) { |
| 777 | LM_ERR("no pkg memory left\n"); |
| 778 | return E_UNSPEC; |
| 779 | } |
| 780 | |
| 781 | *s = *(str *)*param; |
| 782 | if(s->len==0) |
| 783 | { |
| 784 | LM_ERR("empty method name\n"); |
| 785 | pkg_free(s); |
| 786 | return E_UNSPEC; |
| 787 | } |
| 788 | m=0; |
| 789 | p=s->s; |
| 790 | while(*p) |
| 791 | { |
| 792 | if(*p=='|') |
| 793 | { |
| 794 | *p = ','; |
| 795 | m=1; |
| 796 | } |
| 797 | p++; |
| 798 | } |
| 799 | if(parse_methods(s, &method)!=0) |
| 800 | { |
| 801 | LM_ERR("bad method names\n"); |
| 802 | pkg_free(s); |
| 803 | return E_UNSPEC; |
| 804 | } |
| 805 | |
| 806 | if(m==1) |
| 807 | { |
| 808 | if(method==METHOD_UNDEF || method&METHOD_OTHER) |
| 809 | { |
| 810 | LM_ERR("unknown method in list [%.*s/%d] - must be " |
| 811 | "only defined methods\n", s->len, s->s, method); |
| 812 | return E_UNSPEC; |
| 813 | } |
| 814 | LM_DBG("using id for methods [%.*s/%d]\n", |
| 815 | s->len, s->s, method); |
| 816 | s->s = 0; |
| 817 | s->len = method; |
| 818 | } else { |
| 819 | if(method!=METHOD_UNDEF && method!=METHOD_OTHER) |
| 820 | { |
| 821 | LM_DBG("using id for method [%.*s/%d]\n", |
| 822 | s->len, s->s, method); |
| 823 | s->s = 0; |
| 824 | s->len = method; |
| 825 | } else |
nothing calls this directly
no test coverage detected