FreeCalypso > hg > freecalypso-sw
comparison target-utils/libcommon/dispatch.c @ 13:f4fc449a64ea
target-utils libcommon infrastructure for interactive commands
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 03 May 2013 06:42:03 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
12:165040ce4929 | 13:f4fc449a64ea |
---|---|
1 /* | |
2 * This module implements the dispatch of interactively entered | |
3 * commands to their respective implementation functions via cmdtab. | |
4 */ | |
5 | |
6 #include "cmdtab.h" | |
7 | |
8 extern char command[]; | |
9 extern struct cmdtab cmdtab[]; | |
10 | |
11 void | |
12 command_dispatch() | |
13 { | |
14 char *cp, *np; | |
15 struct cmdtab *tp; | |
16 | |
17 for (cp = command; *cp == ' '; cp++) | |
18 ; | |
19 if (!*cp) | |
20 return; | |
21 for (np = cp; *cp && *cp != ' '; cp++) | |
22 ; | |
23 if (*cp) | |
24 *cp++ = '\0'; | |
25 for (tp = cmdtab; tp->cmd; tp++) | |
26 if (!strcmp(tp->cmd, np)) | |
27 break; | |
28 if (tp->func) | |
29 tp->func(cp); | |
30 else | |
31 printf("ERROR: unknown or unimplemented command\n"); | |
32 } |