qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 07/11] Introduce get_next_param_value


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH 07/11] Introduce get_next_param_value
Date: Fri, 08 May 2009 12:34:18 +0200
User-agent: StGIT/0.14.2

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 <address@hidden>
---

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]