]> Git Repo - qemu.git/commitdiff
Introduce get_next_param_value
authorJan Kiszka <[email protected]>
Wed, 24 Jun 2009 12:42:28 +0000 (14:42 +0200)
committerAnthony Liguori <[email protected]>
Mon, 29 Jun 2009 13:52:44 +0000 (08:52 -0500)
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 <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
sysemu.h
vl.c

index aa036bfd1f610ccc8823342116ca50ab7b544fad..8744347f28b2a984a5263a52fa6d4ce462687212 100644 (file)
--- a/sysemu.h
+++ b/sysemu.h
@@ -275,6 +275,8 @@ void usb_info(Monitor *mon);
 
 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 1c077b4c86b8158a1856f85390507e7d6dd69a4c..4cb9f0bf6dca9a957a76debd650fe769848748f1 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1812,20 +1812,23 @@ static int socket_init(void)
 }
 #endif
 
-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);
@@ -1837,6 +1840,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)
 {
This page took 0.036088 seconds and 4 git commands to generate.