diff options
Diffstat (limited to 'apps/plugins/rockboy/split.c')
-rw-r--r-- | apps/plugins/rockboy/split.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/apps/plugins/rockboy/split.c b/apps/plugins/rockboy/split.c deleted file mode 100644 index 5d8af08ee1..0000000000 --- a/apps/plugins/rockboy/split.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
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 | |||
10 | char *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 | |||
44 | int 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 | |||