| 2895 | } |
| 2896 | |
| 2897 | int tr_parse_string(str* in, trans_t *t) |
| 2898 | { |
| 2899 | char *p, *cp; |
| 2900 | str name; |
| 2901 | tr_param_t *tp = NULL; |
| 2902 | |
| 2903 | if(in==NULL || t==NULL) |
| 2904 | return -1; |
| 2905 | |
| 2906 | p = in->s; |
| 2907 | name.s = in->s; |
| 2908 | |
| 2909 | /* find next token */ |
| 2910 | while(is_in_str(p, in) && *p!=TR_PARAM_MARKER && *p!=TR_RBRACKET) p++; |
| 2911 | if(*p=='\0') |
| 2912 | { |
| 2913 | LM_ERR("invalid transformation: %.*s\n", |
| 2914 | in->len, in->s); |
| 2915 | goto error; |
| 2916 | } |
| 2917 | name.len = p - name.s; |
| 2918 | trim(&name); |
| 2919 | |
| 2920 | if(name.len==3 && strncasecmp(name.s, "len", 3)==0) |
| 2921 | { |
| 2922 | t->subtype = TR_S_LEN; |
| 2923 | return 0; |
| 2924 | } else if(name.len==3 && strncasecmp(name.s, "int", 3)==0) { |
| 2925 | t->subtype = TR_S_INT; |
| 2926 | return 0; |
| 2927 | } else if(name.len==3 && strncasecmp(name.s, "md5", 3)==0) { |
| 2928 | t->subtype = TR_S_MD5; |
| 2929 | return 0; |
| 2930 | } else if(name.len==5 && strncasecmp(name.s, "crc32", 5)==0) { |
| 2931 | t->subtype = TR_S_CRC32; |
| 2932 | return 0; |
| 2933 | } else if(name.len==7 && strncasecmp(name.s, "tolower", 7)==0) { |
| 2934 | t->subtype = TR_S_TOLOWER; |
| 2935 | return 0; |
| 2936 | } else if(name.len==7 && strncasecmp(name.s, "toupper", 7)==0) { |
| 2937 | t->subtype = TR_S_TOUPPER; |
| 2938 | return 0; |
| 2939 | } else if(name.len==11 && strncasecmp(name.s, "encode.hexa", 11)==0) { |
| 2940 | t->subtype = TR_S_ENCODEHEXA; |
| 2941 | return 0; |
| 2942 | } else if(name.len==11 && strncasecmp(name.s, "decode.hexa", 11)==0) { |
| 2943 | t->subtype = TR_S_DECODEHEXA; |
| 2944 | return 0; |
| 2945 | } else if(name.len==7 && strncasecmp(name.s, "hex2dec", 7)==0) { |
| 2946 | t->subtype = TR_S_HEX2DEC; |
| 2947 | return 0; |
| 2948 | } else if(name.len==7 && strncasecmp(name.s, "dec2hex", 7)==0) { |
| 2949 | t->subtype = TR_S_DEC2HEX; |
| 2950 | return 0; |
| 2951 | } else if(name.len==9 && strncasecmp(name.s, "date2unix", 9)==0) { |
| 2952 | t->subtype = TR_S_DATE2UNIX; |
| 2953 | return 0; |
| 2954 | } else if(name.len==13 && strncasecmp(name.s, "escape.common", 13)==0) { |
nothing calls this directly
no test coverage detected