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.tar.gz
rockbox-384de102469fee4e0792df8fe38586d3206774ed.zip
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 0000000000..5d8af08ee1
--- /dev/null
+++ b/apps/plugins/rockboy/split.c
@@ -0,0 +1,59 @@
1
2#include "rockmacros.h"
3
4/*
5 * splitline is a destructive argument parser, much like a very primitive
6 * form of a shell parser. it supports quotes for embedded spaces and
7 * literal quotes with the backslash escape.
8 */
9
10char *splitnext(char **pos)
11{
12 char *a, *d, *s;
13
14 d = s = *pos;
15 while (*s == ' ' || *s == '\t') s++;
16 a = s;
17 while (*s && *s != ' ' && *s != '\t')
18 {
19 if (*s == '"')
20 {
21 s++;
22 while (*s && *s != '"')
23 {
24 if (*s == '\\')
25 s++;
26 if (*s)
27 *(d++) = *(s++);
28 }
29 if (*s == '"') s++;
30 }
31 else
32 {
33 if (*s == '\\')
34 s++;
35 *(d++) = *(s++);
36 }
37 }
38 while (*s == ' ' || *s == '\t') s++;
39 *d = 0;
40 *pos = s;
41 return a;
42}
43
44int splitline(char **argv, int max, char *line)
45{
46 char *s;
47 int i;
48
49 s = line;
50 for (i = 0; *s && i < max + 1; i++)
51 argv[i] = splitnext(&s);
52 argv[i] = 0;
53 return i;
54}
55
56
57
58
59