Module: sip-router Branch: tirpi/cfg_framework_multivalue Commit: ef18280cf6d5fc0650d0432166c639654e6cc9f7 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ef18280c...
Author: Miklos Tirpak miklos@iptel.org Committer: Miklos Tirpak miklos@iptel.org Date: Thu Oct 7 13:32:30 2010 +0200
xmlrpc: scan resets the error code
This way, the scan can be retried, and RPC functions with multi-type parameters can be supported:
if (rpc->scan(c, "d",&i) == 1) /* int parameter */ else if (rpc->scan(c, "s",&ch) == 1) /* char* parameter */ else return /* error */
---
modules/xmlrpc/xmlrpc.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/modules/xmlrpc/xmlrpc.c b/modules/xmlrpc/xmlrpc.c index b4cee98..deacf74 100644 --- a/modules/xmlrpc/xmlrpc.c +++ b/modules/xmlrpc/xmlrpc.c @@ -634,6 +634,15 @@ static int init_xmlrpc_reply(struct xmlrpc_reply* reply) return 0; }
+/** Clear the XML-RPC reply code and sets it back to a success reply. + * + * @param reply XML-RPC reply structure to be cleared. + */ +static void clear_xmlrpc_reply(struct xmlrpc_reply* reply) +{ + reply->code = 200; + reply->reason = "OK"; +}
/* if this a delayed reply context, and it's never been use before, fix it */ @@ -1445,6 +1454,9 @@ static int rpc_scan(rpc_ctx_t* ctx, char* fmt, ...) va_list ap;
reply = &ctx->reply; + /* clear the previously saved error code */ + clear_xmlrpc_reply(reply); + fmt_len = strlen(fmt); va_start(ap, fmt); modifiers=0; @@ -1768,6 +1780,8 @@ static int rpc_struct_scan(struct rpc_struct* s, char* fmt, ...) while(*fmt) { member_name = va_arg(ap, char*); reply = s->reply; + /* clear the previously saved error code */ + clear_xmlrpc_reply(reply); ret = find_member(&value, s->doc, s->struct_in, reply, member_name); if (ret != 0) goto error;