[sr-dev] git:master: xmlrpc(s): support for the "*" modifier

Andrei Pelinescu-Onciul andrei at iptel.org
Mon Jun 29 20:49:53 CEST 2009


Module: sip-router
Branch: master
Commit: 6c6e272929fe211467f894fd7bcdcb2dc1327552
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6c6e272929fe211467f894fd7bcdcb2dc1327552

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Mon Jun 29 20:50:47 2009 +0200

xmlrpc(s): support for the "*" modifier

rpc_scan supports now the "*" modifier for marking optional
parameters.

---

 modules_s/xmlrpc/xmlrpc.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules_s/xmlrpc/xmlrpc.c b/modules_s/xmlrpc/xmlrpc.c
index 94dbbd1..4ca7ab2 100644
--- a/modules_s/xmlrpc/xmlrpc.c
+++ b/modules_s/xmlrpc/xmlrpc.c
@@ -1187,18 +1187,24 @@ static int rpc_scan(rpc_ctx_t* ctx, char* fmt, ...)
 	xmlNodePtr value;
 	struct xmlrpc_reply* reply;
 	struct rpc_struct* p;
-
+	int modifiers;
 	va_list ap;
 
 	reply = &ctx->reply;
 	fmt_len = strlen(fmt);
 	va_start(ap, fmt);
+	modifiers=0;
 	read = 0;
 	while(*fmt) {
 		if (!ctx->act_param) goto error;
 		value = ctx->act_param->xmlChildrenNode;
 
 		switch(*fmt) {
+		case '*': /* start of optional parameters */
+			modifiers++;
+			/* no other action needed, for xmlrpc params are treated as
+			   optionals anyway */
+			break;
 		case 'b': /* Bool */
 		case 't': /* Date and time */
 		case 'd': /* Integer */
@@ -1245,11 +1251,11 @@ static int rpc_scan(rpc_ctx_t* ctx, char* fmt, ...)
 		fmt++;
 	}
 	va_end(ap);
-	return read;
+	return read-modifiers;
 
  error:
 	va_end(ap);
-	return -read;
+	return -(read-modifiers);
 }
 
 #define RPC_BUF_SIZE 1024




More information about the sr-dev mailing list