comparison target-utils/libcommon/dispatch.c @ 0:e7502631a0f9

initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Jun 2016 00:13:35 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e7502631a0f9
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 }