annotate target-utils/libcommon/dispatch.c @ 283:88eed3327682

fc-fsio: ll command implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 28 Feb 2014 04:54:47 +0000
parents f4fc449a64ea
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module implements the dispatch of interactively entered
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * commands to their respective implementation functions via cmdtab.
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "cmdtab.h"
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 extern char command[];
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 extern struct cmdtab cmdtab[];
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 void
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 command_dispatch()
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 {
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 char *cp, *np;
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 struct cmdtab *tp;
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 for (cp = command; *cp == ' '; cp++)
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 ;
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 if (!*cp)
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 return;
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 for (np = cp; *cp && *cp != ' '; cp++)
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 ;
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 if (*cp)
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 *cp++ = '\0';
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 for (tp = cmdtab; tp->cmd; tp++)
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 if (!strcmp(tp->cmd, np))
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 break;
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 if (tp->func)
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 tp->func(cp);
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 else
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 printf("ERROR: unknown or unimplemented command\n");
f4fc449a64ea target-utils libcommon infrastructure for interactive commands
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 }