WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] stubdom: support quotes in argument passi

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] stubdom: support quotes in argument passing
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Aug 2008 11:23:50 -0700
Delivery-date: Wed, 27 Aug 2008 11:24:19 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1219826869 -3600
# Node ID f17ab0889f3ba866c8df4ec607cf2ed63a0ab4ee
# Parent  846590f850624742ebe98e070b2b4c1a96693eac
stubdom: support quotes in argument passing

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
---
 extras/mini-os/main.c |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff -r 846590f85062 -r f17ab0889f3b extras/mini-os/main.c
--- a/extras/mini-os/main.c     Wed Aug 27 09:47:24 2008 +0100
+++ b/extras/mini-os/main.c     Wed Aug 27 09:47:49 2008 +0100
@@ -42,7 +42,7 @@ extern char __app_bss_start, __app_bss_e
 extern char __app_bss_start, __app_bss_end;
 static void call_main(void *p)
 {
-    char *c;
+    char *c, quote;
 #ifdef CONFIG_QEMU
     char *domargs, *msg;
 #endif
@@ -101,32 +101,53 @@ static void call_main(void *p)
 
     argc = 1;
 
-#define PARSE_ARGS(ARGS,START,END) \
+#define PARSE_ARGS(ARGS,START,QUOTE,END) \
     c = ARGS; \
+    quote = 0; \
     while (*c) { \
        if (*c != ' ') { \
            START; \
-           while (*c && *c != ' ') \
+           while (*c) { \
+               if (quote) { \
+                   if (*c == quote) { \
+                       quote = 0; \
+                       QUOTE; \
+                       continue; \
+                   } \
+               } else if (*c == ' ') \
+                   break; \
+               if (*c == '"' || *c == '\'') { \
+                   quote = *c; \
+                   QUOTE; \
+                   continue; \
+               } \
                c++; \
+           } \
        } else { \
             END; \
            while (*c == ' ') \
                c++; \
        } \
+    } \
+    if (quote) {\
+       printk("Warning: unterminated quotation %c\n", quote); \
+       quote = 0; \
     }
+#define PARSE_ARGS_COUNT(ARGS) PARSE_ARGS(ARGS, argc++, c++, )
+#define PARSE_ARGS_STORE(ARGS) PARSE_ARGS(ARGS, argv[argc++] = c, memmove(c, c 
+ 1, strlen(c + 1) + 1), *c++ = 0)
 
-    PARSE_ARGS((char*)start_info.cmd_line, argc++, );
+    PARSE_ARGS_COUNT((char*)start_info.cmd_line);
 #ifdef CONFIG_QEMU
-    PARSE_ARGS(domargs, argc++, );
+    PARSE_ARGS_COUNT(domargs);
 #endif
 
     argv = alloca((argc + 1) * sizeof(char *));
     argv[0] = "main";
     argc = 1;
 
-    PARSE_ARGS((char*)start_info.cmd_line, argv[argc++] = c, *c++ = 0)
+    PARSE_ARGS_STORE((char*)start_info.cmd_line)
 #ifdef CONFIG_QEMU
-    PARSE_ARGS(domargs, argv[argc++] = c, *c++ = 0)
+    PARSE_ARGS_STORE(domargs)
 #endif
 
     argv[argc] = NULL;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] stubdom: support quotes in argument passing, Xen patchbot-unstable <=