summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/split.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-03-02 23:49:38 +0000
committerJens Arnold <amiconn@rockbox.org>2005-03-02 23:49:38 +0000
commit384de102469fee4e0792df8fe38586d3206774ed (patch)
treeee5342103e17738acfb8421328ea7c57433f55e6 /apps/plugins/rockboy/split.c
parent48dad47df98bdec632e8930b6a97359dc2c428f5 (diff)
downloadrockbox-384de102469fee4e0792df8fe38586d3206774ed.zip
rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.gz
rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.bz2
rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.xz
Rockboy - gameboy emulation for rockbox, based on gnuboy. Still a bit early, but already playable on iRiver H1xx and the simulators. The archos recorder version is currently rather slow...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6104 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/split.c')
-rw-r--r--apps/plugins/rockboy/split.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/split.c b/apps/plugins/rockboy/split.c
new file mode 100644
index 0000000..5d8af08
--- /dev/null
+++ b/apps/plugins/rockboy/split.c
@@ -0,0 +1,59 @@
+
+#include "rockmacros.h"
+
+/*
+ * splitline is a destructive argument parser, much like a very primitive
+ * form of a shell parser. it supports quotes for embedded spaces and
+ * literal quotes with the backslash escape.
+ */
+
+char *splitnext(char **pos)
+{
+ char *a, *d, *s;
+
+ d = s = *pos;
+ while (*s == ' ' || *s == '\t') s++;
+ a = s;
+ while (*s && *s != ' ' && *s != '\t')
+ {
+ if (*s == '"')
+ {
+ s++;
+ while (*s && *s != '"')
+ {
+ if (*s == '\\')
+ s++;
+ if (*s)
+ *(d++) = *(s++);
+ }
+ if (*s == '"') s++;
+ }
+ else
+ {
+ if (*s == '\\')
+ s++;
+ *(d++) = *(s++);
+ }
+ }
+ while (*s == ' ' || *s == '\t') s++;
+ *d = 0;
+ *pos = s;
+ return a;
+}
+
+int splitline(char **argv, int max, char *line)
+{
+ char *s;
+ int i;
+
+ s = line;
+ for (i = 0; *s && i < max + 1; i++)
+ argv[i] = splitnext(&s);
+ argv[i] = 0;
+ return i;
+}
+
+
+
+
+