|
@@ -27,6 +27,7 @@
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
+#include <fnmatch.h>
|
|
|
|
|
|
#include "../../sr_module.h"
|
|
#include "../../sr_module.h"
|
|
#include "../../dprint.h"
|
|
#include "../../dprint.h"
|
|
@@ -40,10 +41,14 @@ MODULE_VERSION
|
|
|
|
|
|
static int msg_apply_changes_f(sip_msg_t *msg, char *str1, char *str2);
|
|
static int msg_apply_changes_f(sip_msg_t *msg, char *str1, char *str2);
|
|
|
|
|
|
-static int change_reply_status_f(struct sip_msg*, char*, char *);
|
|
|
|
|
|
+static int change_reply_status_f(sip_msg_t*, char*, char*);
|
|
static int change_reply_status_fixup(void** param, int param_no);
|
|
static int change_reply_status_fixup(void** param, int param_no);
|
|
|
|
|
|
-static int w_keep_hf_f(struct sip_msg*, char*, char *);
|
|
|
|
|
|
+static int w_keep_hf_f(sip_msg_t*, char*, char*);
|
|
|
|
+
|
|
|
|
+static int w_fnmatch2_f(sip_msg_t*, char*, char*);
|
|
|
|
+static int w_fnmatch3_f(sip_msg_t*, char*, char*, char*);
|
|
|
|
+static int fixup_fnmatch(void** param, int param_no);
|
|
|
|
|
|
static int w_remove_body_f(struct sip_msg*, char*, char *);
|
|
static int w_remove_body_f(struct sip_msg*, char*, char *);
|
|
static int bind_textopsx(textopsx_api_t *tob);
|
|
static int bind_textopsx(textopsx_api_t *tob);
|
|
@@ -58,6 +63,10 @@ static cmd_export_t cmds[] = {
|
|
0, ANY_ROUTE },
|
|
0, ANY_ROUTE },
|
|
{"keep_hf", (cmd_function)w_keep_hf_f, 1,
|
|
{"keep_hf", (cmd_function)w_keep_hf_f, 1,
|
|
fixup_regexp_null, ANY_ROUTE },
|
|
fixup_regexp_null, ANY_ROUTE },
|
|
|
|
+ {"fnmatch", (cmd_function)w_fnmatch2_f, 2,
|
|
|
|
+ fixup_fnmatch, ANY_ROUTE },
|
|
|
|
+ {"fnmatch", (cmd_function)w_fnmatch3_f, 3,
|
|
|
|
+ fixup_fnmatch, ANY_ROUTE },
|
|
{"bind_textopsx", (cmd_function)bind_textopsx, 1,
|
|
{"bind_textopsx", (cmd_function)bind_textopsx, 1,
|
|
0, ANY_ROUTE },
|
|
0, ANY_ROUTE },
|
|
|
|
|
|
@@ -323,6 +332,77 @@ static int w_keep_hf_f(struct sip_msg* msg, char* key, char* foo)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+static int w_fnmatch(str *val, str *match, str *flags)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+ i = 0;
|
|
|
|
+#ifdef FNM_CASEFOLD
|
|
|
|
+ if(flags && (flags->s[0]=='i' || flags->s[0]=='I'))
|
|
|
|
+ i = FNM_CASEFOLD;
|
|
|
|
+#endif
|
|
|
|
+ if(fnmatch(match->s, val->s, i)==0)
|
|
|
|
+ return 0;
|
|
|
|
+ return -1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+static int w_fnmatch2_f(sip_msg_t *msg, char *val, char *match)
|
|
|
|
+{
|
|
|
|
+ str sval;
|
|
|
|
+ str smatch;
|
|
|
|
+ if(get_str_fparam(&sval, msg, (fparam_t*)val)<0
|
|
|
|
+ || get_str_fparam(&smatch, msg, (fparam_t*)match)<0)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("invalid parameters");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(w_fnmatch(&sval, &smatch, NULL)<0)
|
|
|
|
+ return -1;
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+static int w_fnmatch3_f(sip_msg_t *msg, char *val, char *match, char *flags)
|
|
|
|
+{
|
|
|
|
+ str sval;
|
|
|
|
+ str smatch;
|
|
|
|
+ str sflags;
|
|
|
|
+ if(get_str_fparam(&sval, msg, (fparam_t*)val)<0
|
|
|
|
+ || get_str_fparam(&smatch, msg, (fparam_t*)match)<0
|
|
|
|
+ || get_str_fparam(&sflags, msg, (fparam_t*)flags)<0)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("invalid parameters");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(w_fnmatch(&sval, &smatch, &sflags)<0)
|
|
|
|
+ return -1;
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+static int fixup_fnmatch(void** param, int param_no)
|
|
|
|
+{
|
|
|
|
+ if (param_no == 1) {
|
|
|
|
+ return fixup_var_pve_12(param, param_no);
|
|
|
|
+ } else if (param_no == 2) {
|
|
|
|
+ return fixup_var_pve_12(param, param_no);
|
|
|
|
+ } else if (param_no == 3) {
|
|
|
|
+ return fixup_var_pve_12(param, param_no);
|
|
|
|
+ } else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* Function to load the textops api.
|
|
* Function to load the textops api.
|
|
*/
|
|
*/
|