FreeCalypso > hg > freecalypso-tools
comparison rvinterf/tmsh/usercmd.c @ 71:27c41e4b21ae
fc-tmsh one-shot operation mode implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 26 Oct 2016 23:51:47 +0000 |
parents | 2159f260ed13 |
children | 2825d79bb151 |
comparison
equal
deleted
inserted
replaced
70:2c6dca514a20 | 71:27c41e4b21ae |
---|---|
6 #include <ctype.h> | 6 #include <ctype.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <strings.h> | 9 #include <strings.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
11 #include "exitcodes.h" | |
11 | 12 |
12 extern char usercmd[]; | 13 extern char usercmd[]; |
13 | 14 |
14 extern int cmd_abbr(); | 15 extern int cmd_abbr(); |
15 extern int cmd_abbw(); | 16 extern int cmd_abbw(); |
118 return; | 119 return; |
119 } | 120 } |
120 *ap = 0; | 121 *ap = 0; |
121 tp->func(ap - argv, argv); | 122 tp->func(ap - argv, argv); |
122 } | 123 } |
124 | |
125 dispatch_oneshot_cmd(argc, argv) | |
126 char **argv; | |
127 { | |
128 struct cmdtab *tp; | |
129 | |
130 for (tp = cmdtab; tp->cmd; tp++) | |
131 if (!strcmp(tp->cmd, argv[0])) | |
132 break; | |
133 if (!tp->func) { | |
134 fprintf(stderr, | |
135 "error: \"%s\" is not a valid command\n", argv[0]); | |
136 exit(ERROR_USAGE); | |
137 } | |
138 if (argc - 1 > tp->maxargs) { | |
139 fprintf(stderr, "%s: too many arguments\n", tp->cmd); | |
140 exit(ERROR_USAGE); | |
141 } | |
142 if (argc - 1 < tp->minargs) { | |
143 fprintf(stderr, "%s: too few arguments\n", tp->cmd); | |
144 exit(ERROR_USAGE); | |
145 } | |
146 return tp->func(argc, argv); | |
147 } |