... | ... |
@@ -136,6 +136,7 @@ static int in_list_prefix_f(struct sip_msg* _msg, char* _subject, char* _list, |
136 | 136 |
static int cmp_str_f(struct sip_msg *msg, char *str1, char *str2 ); |
137 | 137 |
static int cmp_istr_f(struct sip_msg *msg, char *str1, char *str2 ); |
138 | 138 |
static int starts_with_f(struct sip_msg *msg, char *str1, char *str2 ); |
139 |
+static int ends_with_f(struct sip_msg *msg, char *str1, char *str2 ); |
|
139 | 140 |
static int remove_hf_re_f(struct sip_msg* msg, char* key, char* foo); |
140 | 141 |
static int remove_hf_exp_f(sip_msg_t* msg, char* ematch, char* eskip); |
141 | 142 |
static int is_present_hf_re_f(struct sip_msg* msg, char* key, char* foo); |
... | ... |
@@ -316,6 +317,9 @@ static cmd_export_t cmds[]={ |
316 | 317 |
{"starts_with", (cmd_function)starts_with_f, 2, |
317 | 318 |
fixup_spve_spve, 0, |
318 | 319 |
ANY_ROUTE}, |
320 |
+ {"ends_with", (cmd_function)ends_with_f, 2, |
|
321 |
+ fixup_spve_spve, 0, |
|
322 |
+ ANY_ROUTE}, |
|
319 | 323 |
{"is_audio_on_hold", (cmd_function)is_audio_on_hold_f, 0, |
320 | 324 |
0, 0, |
321 | 325 |
ANY_ROUTE}, |
... | ... |
@@ -4220,6 +4224,49 @@ static int ki_starts_with(sip_msg_t *msg, str *s1, str *s2 ) |
4220 | 4224 |
return -2; |
4221 | 4225 |
} |
4222 | 4226 |
|
4227 |
+static int ends_with_f(struct sip_msg *msg, char *str1, char *str2 ) |
|
4228 |
+{ |
|
4229 |
+ str s1; |
|
4230 |
+ str s2; |
|
4231 |
+ int ret; |
|
4232 |
+ |
|
4233 |
+ if(fixup_get_svalue(msg, (gparam_p)str1, &s1)!=0) { |
|
4234 |
+ LM_ERR("cannot get first parameter\n"); |
|
4235 |
+ return -8; |
|
4236 |
+ } |
|
4237 |
+ if(fixup_get_svalue(msg, (gparam_p)str2, &s2)!=0) { |
|
4238 |
+ LM_ERR("cannot get second parameter\n"); |
|
4239 |
+ return -8; |
|
4240 |
+ } |
|
4241 |
+ if(s2.len > s1.len) { |
|
4242 |
+ return -1; |
|
4243 |
+ } |
|
4244 |
+ ret = strncmp(s1.s + s1.len - s2.len, s2.s, s2.len); |
|
4245 |
+ if(ret==0) |
|
4246 |
+ return 1; |
|
4247 |
+ if(ret>0) |
|
4248 |
+ return -1; |
|
4249 |
+ return -2; |
|
4250 |
+} |
|
4251 |
+ |
|
4252 |
+static int ki_ends_with(sip_msg_t *msg, str *vstr, str *vsuffix ) |
|
4253 |
+{ |
|
4254 |
+ int ret; |
|
4255 |
+ |
|
4256 |
+ if(vstr==NULL || vsuffix==NULL) { |
|
4257 |
+ return -1; |
|
4258 |
+ } |
|
4259 |
+ if(vsuffix->len > vstr->len) { |
|
4260 |
+ return -1; |
|
4261 |
+ } |
|
4262 |
+ ret = strncmp(vstr->s + vstr->len - vsuffix->len, vsuffix->s, vsuffix->len); |
|
4263 |
+ if(ret==0) |
|
4264 |
+ return 1; |
|
4265 |
+ if(ret>0) |
|
4266 |
+ return -1; |
|
4267 |
+ return -2; |
|
4268 |
+} |
|
4269 |
+ |
|
4223 | 4270 |
static int ki_is_audio_on_hold(sip_msg_t *msg) |
4224 | 4271 |
{ |
4225 | 4272 |
int sdp_session_num = 0, sdp_stream_num; |
... | ... |
@@ -4903,6 +4950,11 @@ static sr_kemi_t sr_kemi_textops_exports[] = { |
4903 | 4950 |
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, |
4904 | 4951 |
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
4905 | 4952 |
}, |
4953 |
+ { str_init("textops"), str_init("ends_with"), |
|
4954 |
+ SR_KEMIP_INT, ki_ends_with, |
|
4955 |
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, |
|
4956 |
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } |
|
4957 |
+ }, |
|
4906 | 4958 |
{ str_init("textops"), str_init("is_audio_on_hold"), |
4907 | 4959 |
SR_KEMIP_INT, ki_is_audio_on_hold, |
4908 | 4960 |
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE, |