aboutsummaryrefslogtreecommitdiff
path: root/src/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands.c')
-rw-r--r--src/commands.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/commands.c b/src/commands.c
index 5e01e67..287ee67 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -3,12 +3,14 @@
3/* Arg parsing functions *****************************************************/ 3/* Arg parsing functions *****************************************************/
4 4
5CommandArgs * solve_parse_args(int c, char **v); 5CommandArgs * solve_parse_args(int c, char **v);
6CommandArgs * gen_parse_args(int c, char **v);
6CommandArgs * help_parse_args(int c, char **v); 7CommandArgs * help_parse_args(int c, char **v);
7CommandArgs * print_parse_args(int c, char **v); 8CommandArgs * print_parse_args(int c, char **v);
8CommandArgs * parse_no_arg(int c, char **v); 9CommandArgs * parse_no_arg(int c, char **v);
9 10
10/* Exec functions ************************************************************/ 11/* Exec functions ************************************************************/
11 12
13static void gen_exec(CommandArgs *args);
12static void solve_exec(CommandArgs *args); 14static void solve_exec(CommandArgs *args);
13static void steps_exec(CommandArgs *args); 15static void steps_exec(CommandArgs *args);
14static void commands_exec(CommandArgs *args); 16static void commands_exec(CommandArgs *args);
@@ -34,6 +36,15 @@ solve_cmd = {
34}; 36};
35 37
36Command 38Command
39gen_cmd = {
40 .name = "gen",
41 .usage = "gen [-t N]",
42 .description = "Generate all tables [using N threads]",
43 .parse_args = gen_parse_args,
44 .exec = gen_exec
45};
46
47Command
37steps_cmd = { 48steps_cmd = {
38 .name = "steps", 49 .name = "steps",
39 .usage = "steps", 50 .usage = "steps",
@@ -89,6 +100,7 @@ version_cmd = {
89 100
90Command *commands[NCOMMANDS] = { 101Command *commands[NCOMMANDS] = {
91 &commands_cmd, 102 &commands_cmd,
103 &gen_cmd,
92 &help_cmd, 104 &help_cmd,
93 &print_cmd, 105 &print_cmd,
94 &quit_cmd, 106 &quit_cmd,
@@ -173,6 +185,34 @@ solve_parse_args(int c, char **v)
173} 185}
174 186
175CommandArgs * 187CommandArgs *
188gen_parse_args(int c, char **v)
189{
190 int val;
191 CommandArgs *a = new_args();
192
193 a->opts->nthreads = 1;
194 a->success = false;
195
196 if (c == 0) {
197 a->success = true;
198 } else {
199 if (!strcmp(v[0], "-t") && c > 1) {
200 val = strtol(v[1], NULL, 10);
201 if (val < 1 || val > 64) {
202 fprintf(stderr,
203 "Invalid number of threads."
204 "1 <= t <= 64\n");
205 return a;
206 }
207 a->opts->nthreads = val;
208 a->success = true;
209 }
210 }
211
212 return a;
213}
214
215CommandArgs *
176help_parse_args(int c, char **v) 216help_parse_args(int c, char **v)
177{ 217{
178 int i; 218 int i;
@@ -229,6 +269,21 @@ solve_exec(CommandArgs *args)
229} 269}
230 270
231static void 271static void
272gen_exec(CommandArgs *args)
273{
274 int i;
275
276 fprintf(stderr, "Generating coordinates...\n");
277 init_symcoord();
278
279 fprintf(stderr, "Generating pruning tables...\n");
280 for (i = 0; i < NPTABLES && allpd[i] != NULL; i++)
281 genptable(allpd[i], args->opts->nthreads);
282
283 fprintf(stderr, "Done!\n");
284}
285
286static void
232steps_exec(CommandArgs *args) 287steps_exec(CommandArgs *args)
233{ 288{
234 int i; 289 int i;

Generated with cgit - Back to sebastiano.tronto.net