Module: sip-router
Branch: master
Commit: b23a74a4732f276315176d9b438bd2596e616799
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b23a74a…
Author: Carsten Bock <carsten(a)ng-voice.com>
Committer: Carsten Bock <carsten(a)ng-voice.com>
Date: Wed Aug 21 20:14:16 2013 +0200
Fix fixup functions.
---
modules/utils/utils.c | 61 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/modules/utils/utils.c b/modules/utils/utils.c
index 8109a11..735ea0d 100644
--- a/modules/utils/utils.c
+++ b/modules/utils/utils.c
@@ -101,11 +101,11 @@ int utils_forward(struct sip_msg *msg, int id, int proto);
/* Exported functions */
static cmd_export_t cmds[] = {
- {"http_query", (cmd_function)w_http_query, 2, fixup_http_query,
- fixup_free_http_query,
+ {"http_query", (cmd_function)w_http_query, 2, fixup_http_query_get,
+ fixup_free_http_query_get,
REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
- {"http_query", (cmd_function)w_http_query_post, 3, fixup_http_query,
- fixup_free_http_query,
+ {"http_query", (cmd_function)w_http_query_post, 3, fixup_http_query_post,
+ fixup_free_http_query_post,
REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
{"xcap_auth_status", (cmd_function)xcap_auth_status, 2, fixup_pvar_pvar,
fixup_free_pvar_pvar, REQUEST_ROUTE},
@@ -327,13 +327,13 @@ static void destroy(void)
* Fix http_query params: url (string that may contain pvars) and
* result (writable pvar).
*/
-static int fixup_http_query(void** param, int param_no)
+static int fixup_http_query_get(void** param, int param_no)
{
if (param_no == 1) {
return fixup_spve_null(param, 1);
}
- if ((param_no == 2) || (param_no == 3)) {
+ if (param_no == 2) {
if (fixup_pvar_null(param, 1) != 0) {
LM_ERR("failed to fixup result pvar\n");
return -1;
@@ -352,14 +352,59 @@ static int fixup_http_query(void** param, int param_no)
/*
* Free http_query params.
*/
-static int fixup_free_http_query(void** param, int param_no)
+static int fixup_free_http_query_get(void** param, int param_no)
{
if (param_no == 1) {
LM_WARN("free function has not been defined for spve\n");
return 0;
}
- if ((param_no == 2) || (param_no == 3)) {
+ if (param_no == 2) {
+ return fixup_free_pvar_null(param, 1);
+ }
+
+ LM_ERR("invalid parameter number <%d>\n", param_no);
+ return -1;
+}
+
+
+/*
+ * Fix http_query params: url (string that may contain pvars) and
+ * result (writable pvar).
+ */
+static int fixup_http_query_post(void** param, int param_no)
+{
+ if ((param_no == 1) || (param_no == 2)) {
+ return fixup_spve_null(param, 1);
+ }
+
+ if (param_no == 3) {
+ if (fixup_pvar_null(param, 1) != 0) {
+ LM_ERR("failed to fixup result pvar\n");
+ return -1;
+ }
+ if (((pv_spec_t *)(*param))->setf == NULL) {
+ LM_ERR("result pvar is not writeble\n");
+ return -1;
+ }
+ return 0;
+ }
+
+ LM_ERR("invalid parameter number <%d>\n", param_no);
+ return -1;
+}
+
+/*
+ * Free http_query params.
+ */
+static int fixup_free_http_query_post(void** param, int param_no)
+{
+ if ((param_no == 1) || (param_no == 2)) {
+ LM_WARN("free function has not been defined for spve\n");
+ return 0;
+ }
+
+ if (param_no == 3) {
return fixup_free_pvar_null(param, 1);
}