aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/main.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-08-27 09:47:49 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-08-27 09:47:49 +0100
commit839dac782f71db78b082416f5d115a44891f7216 (patch)
tree1bb68279dee70ca6a2687d2d6a735166bc2df90c /extras/mini-os/main.c
parentfe2998c24a7163659b848897b54219b5f0b03120 (diff)
downloadxen-839dac782f71db78b082416f5d115a44891f7216.tar.gz
xen-839dac782f71db78b082416f5d115a44891f7216.tar.bz2
xen-839dac782f71db78b082416f5d115a44891f7216.zip
stubdom: support quotes in argument passing
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/main.c')
-rw-r--r--extras/mini-os/main.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/extras/mini-os/main.c b/extras/mini-os/main.c
index 5857c0bd4c..3289c638e4 100644
--- a/extras/mini-os/main.c
+++ b/extras/mini-os/main.c
@@ -42,7 +42,7 @@ void _fini(void)
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;