annotate rvinterf/etm/usercmd.c @ 182:13a0348ffce4

rvinterf/etm: checkpointing not-yet-compilable code
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 24 Nov 2013 06:59:09 +0000
parents
children a95d253ef952
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
182
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module implements fc-tmsh user command dispatch.
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <ctype.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdlib.h>
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 extern char usercmd[];
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 extern void cmd_etmpkt();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 void
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 cmd_exit()
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 tty_cleanup();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 exit(0);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 }
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 static struct cmdtab {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 char *cmd;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 int minargs;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 int maxargs;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 void (*func)();
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 } cmdtab[] = {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 {"etmpkt", 1, 253, cmd_etmpkt},
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 {"exit", 0, 0, cmd_exit},
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 {"quit", 0, 0, cmd_exit},
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 {0, 0, 0, 0}
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 };
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 void
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 dispatch_user_cmd()
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 char *argv[257];
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 char *cp, **ap;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 struct cmdtab *tp;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 for (cp = usercmd; isspace(*cp); cp++)
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 ;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 if (!*cp || *cp == '#')
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 return;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 argv[0] = cp;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 while (*cp && !isspace(*cp))
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 cp++;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 if (*cp)
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 *cp++ = '\0';
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 for (tp = cmdtab; tp->cmd; tp++)
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 if (!strcmp(tp->cmd, argv[0]))
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 break;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 if (!tp->func) {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 printf("error: no such command\n");
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 return;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 }
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 for (ap = argv + 1; ; ) {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 while (isspace(*cp))
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 cp++;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 if (!*cp || *cp == '#')
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 break;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 if (ap - argv - 1 >= tp->maxargs) {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 printf("error: too many arguments\n");
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 return;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 }
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 *ap++ = cp;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 while (*cp && !isspace(*cp))
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 cp++;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 if (*cp)
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 *cp++ = '\0';
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 }
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 if (ap - argv - 1 < tp->minargs) {
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 printf("error: too few arguments\n");
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 return;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 }
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 *ap = 0;
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 tp->func(ap - argv, argv);
13a0348ffce4 rvinterf/etm: checkpointing not-yet-compilable code
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 }