From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M2NXQ-0002b9-VD for qemu-devel@nongnu.org; Fri, 08 May 2009 06:42:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M2NXI-0002X1-9S for qemu-devel@nongnu.org; Fri, 08 May 2009 06:42:41 -0400 Received: from [199.232.76.173] (port=33626 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M2NXH-0002WH-AE for qemu-devel@nongnu.org; Fri, 08 May 2009 06:42:35 -0400 Received: from gecko.sbs.de ([194.138.37.40]:16659) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M2NXG-0000fy-GB for qemu-devel@nongnu.org; Fri, 08 May 2009 06:42:35 -0400 Received: from mail2.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n48AgW9R028775 for ; Fri, 8 May 2009 12:42:32 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail2.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n48AgWrI023196 for ; Fri, 8 May 2009 12:42:32 +0200 Resent-To: qemu-devel Resent-Message-Id: <4A040C96.4060401@siemens.com> From: Jan Kiszka Date: Fri, 08 May 2009 12:34:18 +0200 Message-ID: <20090508103418.6080.20642.stgit@mchn012c.ww002.siemens.net> In-Reply-To: <20090508103416.6080.44298.stgit@mchn012c.ww002.siemens.net> References: <20090508103416.6080.44298.stgit@mchn012c.ww002.siemens.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 07/11] Introduce get_next_param_value List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org In order to parse multiple instances of the same param=value pair, introduce get_next_param_value which can pass back to string parsing position after reading a parameter value. Signed-off-by: Jan Kiszka --- sysemu.h | 2 ++ vl.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sysemu.h b/sysemu.h index 50438a6..4b0ae99 100644 --- a/sysemu.h +++ b/sysemu.h @@ -257,6 +257,8 @@ const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); const char *get_opt_value(char *buf, int buf_size, const char *p); int get_param_value(char *buf, int buf_size, const char *tag, const char *str); +int get_next_param_value(char *buf, int buf_size, + const char *tag, const char **pstr); int check_params(char *buf, int buf_size, const char * const *params, const char *str); diff --git a/vl.c b/vl.c index 8b641f5..4982486 100644 --- a/vl.c +++ b/vl.c @@ -1844,20 +1844,23 @@ const char *get_opt_value(char *buf, int buf_size, const char *p) return p; } -int get_param_value(char *buf, int buf_size, - const char *tag, const char *str) +int get_next_param_value(char *buf, int buf_size, + const char *tag, const char **pstr) { const char *p; char option[128]; - p = str; + p = *pstr; for(;;) { p = get_opt_name(option, sizeof(option), p, '='); if (*p != '=') break; p++; if (!strcmp(tag, option)) { - (void)get_opt_value(buf, buf_size, p); + *pstr = get_opt_value(buf, buf_size, p); + if (**pstr == ',') { + (*pstr)++; + } return strlen(buf); } else { p = get_opt_value(NULL, 0, p); @@ -1869,6 +1872,12 @@ int get_param_value(char *buf, int buf_size, return 0; } +int get_param_value(char *buf, int buf_size, + const char *tag, const char *str) +{ + return get_next_param_value(buf, buf_size, tag, &str); +} + int check_params(char *buf, int buf_size, const char * const *params, const char *str) {