comparison gsm-fw/lldbg/parseargs.c @ 865:f5affe83ba2d

lldbg hack (poor girl's substitute for JTAG) implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Fri, 15 May 2015 00:02:03 +0000
parents
children
comparison
equal deleted inserted replaced
864:4fa939eada22 865:f5affe83ba2d
1 /*
2 * This module contains the parse_args() function, which parses the "rest"
3 * part of an entered command into an argc/argv-style argument array.
4 */
5
6 lldbg_parse_args(unparsed, minargs, maxargs, argv, argcp)
7 char *unparsed;
8 int minargs, maxargs;
9 char **argv;
10 int *argcp;
11 {
12 int argc;
13 char *cp;
14
15 argc = 0;
16 for (cp = unparsed; ; ) {
17 while (*cp == ' ')
18 cp++;
19 if (!*cp)
20 break;
21 if (argc >= maxargs) {
22 lldbg_printf("ERROR: too many arguments\n");
23 return(-1);
24 }
25 argv[argc++] = cp;
26 while (*cp && *cp != ' ')
27 cp++;
28 if (*cp)
29 *cp++ = '\0';
30 }
31 if (argc < minargs) {
32 lldbg_printf("ERROR: too few arguments\n");
33 return(-1);
34 }
35 argv[argc] = 0;
36 if (argcp)
37 *argcp = argc;
38 return(0);
39 }