From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8gVN-0007nJ-NX for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:42:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8gVI-0007kC-RL for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:42:56 -0500 Received: from [199.232.76.173] (port=33536 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8gVI-0007k7-IO for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:42:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63748) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8gVI-0006gd-4j for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:42:52 -0500 From: Luiz Capitulino Date: Thu, 12 Nov 2009 18:42:26 -0200 Message-Id: <1258058554-22872-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1258058554-22872-1-git-send-email-lcapitulino@redhat.com> References: <1258058554-22872-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 1/9] QJSON: Introduce qobject_from_json_va() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, kraxel@redhat.com, armbru@redhat.com Accepts a va_list, will be used by QError. Signed-off-by: Luiz Capitulino --- qjson.c | 14 ++++++++++++++ qjson.h | 2 ++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/qjson.c b/qjson.c index 7270909..491b61e 100644 --- a/qjson.c +++ b/qjson.c @@ -64,6 +64,20 @@ QObject *qobject_from_jsonf(const char *string, ...) return state.result; } +QObject *qobject_from_json_va(const char *string, va_list *ap) +{ + JSONParsingState state = {}; + + state.ap = ap; + + json_message_parser_init(&state.parser, parse_json); + json_message_parser_feed(&state.parser, string, strlen(string)); + json_message_parser_flush(&state.parser); + json_message_parser_destroy(&state.parser); + + return state.result; +} + typedef struct ToJsonIterState { int count; diff --git a/qjson.h b/qjson.h index 7fce742..8b89e41 100644 --- a/qjson.h +++ b/qjson.h @@ -14,12 +14,14 @@ #ifndef QJSON_H #define QJSON_H +#include #include "qobject.h" #include "qstring.h" QObject *qobject_from_json(const char *string); QObject *qobject_from_jsonf(const char *string, ...) __attribute__((__format__ (__printf__, 1, 2))); +QObject *qobject_from_json_va(const char *string, va_list *ap); QString *qobject_to_json(const QObject *obj); -- 1.6.5.2.155.gbb47