FreeCalypso > hg > freecalypso-sw
comparison loadtools/ltdispatch.c @ 29:dacf45e3d20f
loadtool: scripting functionality implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 04 May 2013 07:15:51 +0000 |
parents | ae6294b8a015 |
children | 05af070c4b60 |
comparison
equal
deleted
inserted
replaced
28:768a3d012931 | 29:dacf45e3d20f |
---|---|
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <strings.h> | 8 #include <strings.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
11 extern char loadtool_command[]; | 11 extern int cmd_exec(); |
12 | |
13 extern int cmd_exit(); | 12 extern int cmd_exit(); |
14 extern int loadtool_cmd_passthru(); | 13 extern int loadtool_cmd_passthru(); |
15 | 14 |
16 static struct cmdtab { | 15 static struct cmdtab { |
17 char *cmd; | 16 char *cmd; |
18 int minargs; | 17 int minargs; |
19 int maxargs; | 18 int maxargs; |
20 int (*func)(); | 19 int (*func)(); |
21 } cmdtab[] = { | 20 } cmdtab[] = { |
22 {"dump", 2, 2, loadtool_cmd_passthru}, | 21 {"dump", 2, 2, loadtool_cmd_passthru}, |
22 {"exec", 1, 1, cmd_exec}, | |
23 {"exit", 0, 1, cmd_exit}, | 23 {"exit", 0, 1, cmd_exit}, |
24 {"quit", 0, 1, cmd_exit}, | 24 {"quit", 0, 1, cmd_exit}, |
25 {"r8", 1, 1, loadtool_cmd_passthru}, | 25 {"r8", 1, 1, loadtool_cmd_passthru}, |
26 {"r16", 1, 1, loadtool_cmd_passthru}, | 26 {"r16", 1, 1, loadtool_cmd_passthru}, |
27 {"r32", 1, 1, loadtool_cmd_passthru}, | 27 {"r32", 1, 1, loadtool_cmd_passthru}, |
29 {"w16", 2, 2, loadtool_cmd_passthru}, | 29 {"w16", 2, 2, loadtool_cmd_passthru}, |
30 {"w32", 2, 2, loadtool_cmd_passthru}, | 30 {"w32", 2, 2, loadtool_cmd_passthru}, |
31 {0, 0, 0, 0} | 31 {0, 0, 0, 0} |
32 }; | 32 }; |
33 | 33 |
34 loadtool_dispatch_cmd() | 34 loadtool_dispatch_cmd(cmd, is_script) |
35 char *cmd; | |
35 { | 36 { |
36 char *argv[10]; | 37 char *argv[10]; |
37 char *cp, **ap; | 38 char *cp, **ap; |
38 struct cmdtab *tp; | 39 struct cmdtab *tp; |
39 | 40 |
40 for (cp = loadtool_command; isspace(*cp); cp++) | 41 for (cp = cmd; isspace(*cp); cp++) |
41 ; | 42 ; |
42 if (!*cp || *cp == '#') | 43 if (!*cp || *cp == '#') |
43 return(0); | 44 return(0); |
45 if (is_script) | |
46 printf("Script command: %s\n", cp); | |
44 argv[0] = cp; | 47 argv[0] = cp; |
45 while (*cp && !isspace(*cp)) | 48 while (*cp && !isspace(*cp)) |
46 cp++; | 49 cp++; |
47 if (*cp) | 50 if (*cp) |
48 *cp++ = '\0'; | 51 *cp++ = '\0'; |