All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 07/11] Introduce get_next_param_value
Date: Fri, 08 May 2009 12:34:18 +0200	[thread overview]
Message-ID: <20090508103418.6080.20642.stgit@mchn012c.ww002.siemens.net> (raw)
In-Reply-To: <20090508103416.6080.44298.stgit@mchn012c.ww002.siemens.net>

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 <jan.kiszka@siemens.com>
---

 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)
 {

  parent reply	other threads:[~2009-05-08 10:42 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-08 10:34 [Qemu-devel] [PATCH 00/11] Networking fixes and slirp enhancements Jan Kiszka
2009-05-08 10:34 ` [Qemu-devel] [PATCH 04/11] net: Real fix for check_params users Jan Kiszka
2009-05-19  7:57   ` Mark McLoughlin
2009-05-19  9:34     ` Jan Kiszka
2009-05-19  9:57       ` Mark McLoughlin
2009-05-28 15:04   ` Mark McLoughlin
2009-05-28 15:05     ` [Qemu-devel] [PATCH 1/3] Revert "Fix output of uninitialized strings" Mark McLoughlin
2009-05-28 15:06       ` [Qemu-devel] [PATCH 2/3] net: Real fix for check_params users Mark McLoughlin
2009-05-28 15:06         ` [Qemu-devel] [PATCH 3/3] net: fix error reporting for some net parameter checks Mark McLoughlin
2009-05-28 15:56           ` [Qemu-devel] " Jan Kiszka
2009-05-28 15:22     ` [Qemu-devel] [PATCH 04/11] net: Real fix for check_params users Kevin Wolf
2009-05-08 10:34 ` [Qemu-devel] [PATCH 01/11] net: Don't deliver to disabled interfaces in qemu_sendv_packet Jan Kiszka
2009-05-08 15:20   ` Mark McLoughlin
2009-05-08 22:27     ` [Qemu-devel] "FLOSS bounty" ( FB )for running QEMU on SheevaPlug AGSCalabrese
2009-05-08 22:47       ` Marek Vasut
2009-05-08 22:58       ` Paul Brook
2009-05-08 10:34 ` [Qemu-devel] [PATCH 02/11] net: Fix and improved ordered packet delivery Jan Kiszka
2009-05-08 15:24   ` Mark McLoughlin
2009-05-08 10:34 ` [Qemu-devel] [PATCH 03/11] slirp: Avoid zombie processes after fork_exec Jan Kiszka
2009-05-08 10:34 ` [Qemu-devel] [PATCH 06/11] slirp: Reorder initialization Jan Kiszka
2009-05-08 10:34 ` [Qemu-devel] [PATCH 10/11] slirp: Rework external configuration interface Jan Kiszka
2009-05-28 15:07   ` Mark McLoughlin
2009-05-28 15:55     ` Jan Kiszka
2009-05-28 17:23       ` Mark McLoughlin
2009-05-28 20:41         ` Jan Kiszka
2009-05-08 10:34 ` Jan Kiszka [this message]
2009-05-08 10:34 ` [Qemu-devel] [PATCH 05/11] net: Improve parameter error reporting Jan Kiszka
2009-05-08 10:34 ` [Qemu-devel] [PATCH 08/11] slirp: Move smb, redir, tftp and bootp parameters and -net channel Jan Kiszka
2009-05-28 15:07   ` Mark McLoughlin
2009-05-28 15:52     ` Jan Kiszka
2009-05-29 11:42     ` Paul Brook
2009-05-29 14:19       ` Jan Kiszka
2009-05-29 15:36         ` Paul Brook
2009-05-08 10:34 ` [Qemu-devel] [PATCH 09/11] slirp: Rework internal configuration Jan Kiszka
2009-05-08 10:34 ` [Qemu-devel] [PATCH 11/11] slirp: Bind support for host forwarding rules Jan Kiszka
2009-05-08 16:25 ` [Qemu-devel] [PATCH 00/11] Networking fixes and slirp enhancements Anthony Liguori
2009-05-08 17:01   ` Jan Kiszka
2009-05-09  7:41     ` [Qemu-devel] [PATCH 08/11 v2] slirp: Move smb, redir, tftp and bootp parameters and -net channel Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090508103418.6080.20642.stgit@mchn012c.ww002.siemens.net \
    --to=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.