diff options
Diffstat (limited to 'shell.c')
| -rw-r--r-- | shell.c | 112 |
1 files changed, 56 insertions, 56 deletions
| @@ -13,30 +13,30 @@ | |||
| 13 | #define SOLUTIONS_BUFFER_SIZE 500000 /* Should be enough */ | 13 | #define SOLUTIONS_BUFFER_SIZE 500000 /* Should be enough */ |
| 14 | #define MAX_PATH_LENGTH 10000 /* Should be enough */ | 14 | #define MAX_PATH_LENGTH 10000 /* Should be enough */ |
| 15 | 15 | ||
| 16 | #define _flag_cube "-cube" | 16 | #define FLAG_CUBE "-cube" |
| 17 | #define _flag_perm "-perm" | 17 | #define FLAG_PERM "-perm" |
| 18 | #define _flag_command "-command" | 18 | #define FLAG_COMMAND "-command" |
| 19 | #define _flag_str_cube "-cubestr" | 19 | #define FLAG_STR_CUBE "-cubestr" |
| 20 | #define _flag_format "-format" | 20 | #define FLAG_FORMAT "-format" |
| 21 | #define _flag_format_in "-fin" | 21 | #define FLAG_FORMAT_IN "-fin" |
| 22 | #define _flag_format_out "-fout" | 22 | #define FLAG_FORMAT_OUT "-fout" |
| 23 | #define _flag_moves "-moves" | 23 | #define FLAG_MOVES "-moves" |
| 24 | #define _flag_trans "-trans" | 24 | #define FLAG_TRANS "-trans" |
| 25 | #define _flag_solver "-solver" | 25 | #define FLAG_SOLVER "-solver" |
| 26 | #define _flag_options "-options" | 26 | #define FLAG_OPTIONS "-options" |
| 27 | #define _flag_nisstype "-nisstype" | 27 | #define FLAG_NISSTYPE "-nisstype" |
| 28 | #define _flag_minmoves "-m" | 28 | #define FLAG_MINMOVES "-m" |
| 29 | #define _flag_maxmoves "-M" | 29 | #define FLAG_MAXMOVES "-M" |
| 30 | #define _flag_optimal "-O" | 30 | #define FLAG_OPTIMAL "-O" |
| 31 | #define _flag_maxsolutions "-n" | 31 | #define FLAG_MAXSOLUTIONS "-n" |
| 32 | 32 | ||
| 33 | #define _info_cubeformat(cube) cube " must be given in B32 format." | 33 | #define INFO_CUBEFORMAT(cube) cube " must be given in B32 format." |
| 34 | #define _info_movesformat "The accepted moves are U, D, R, L, F and B, " \ | 34 | #define INFO_MOVESFORMAT "The accepted moves are U, D, R, L, F and B, " \ |
| 35 | "optionally followed by a 2, a ' or a 3." | 35 | "optionally followed by a 2, a ' or a 3." |
| 36 | #define _info_transformat "The transformation must be given in the format " \ | 36 | #define INFO_TRANSFORMAT "The transformation must be given in the format " \ |
| 37 | "(rotation|mirrored) (2 letters), for exmple " \ | 37 | "(rotation|mirrored) (2 letters), for exmple " \ |
| 38 | "'rotation UF' or 'mirrored BL'." | 38 | "'rotation UF' or 'mirrored BL'." |
| 39 | #define _info_formats "The available formats are H48, B32 and SRC." | 39 | #define INFO_FORMATS "The available formats are H48, B32 and SRC." |
| 40 | 40 | ||
| 41 | typedef struct { | 41 | typedef struct { |
| 42 | int command_index; | 42 | int command_index; |
| @@ -103,22 +103,22 @@ struct { | |||
| 103 | int nargs; | 103 | int nargs; |
| 104 | bool (*set)(int, char **, args_t *); | 104 | bool (*set)(int, char **, args_t *); |
| 105 | } options[] = { | 105 | } options[] = { |
| 106 | OPTION(_flag_cube, 1, set_cube), | 106 | OPTION(FLAG_CUBE, 1, set_cube), |
| 107 | OPTION(_flag_perm, 1, set_cube_perm), | 107 | OPTION(FLAG_PERM, 1, set_cube_perm), |
| 108 | OPTION(_flag_command, 1, set_str_command), | 108 | OPTION(FLAG_COMMAND, 1, set_str_command), |
| 109 | OPTION(_flag_str_cube, 1, set_str_cube), | 109 | OPTION(FLAG_STR_CUBE, 1, set_str_cube), |
| 110 | OPTION(_flag_format, 1, set_str_format), | 110 | OPTION(FLAG_FORMAT, 1, set_str_format), |
| 111 | OPTION(_flag_format_in, 1, set_str_format_in), | 111 | OPTION(FLAG_FORMAT_IN, 1, set_str_format_in), |
| 112 | OPTION(_flag_format_out, 1, set_str_format_out), | 112 | OPTION(FLAG_FORMAT_OUT, 1, set_str_format_out), |
| 113 | OPTION(_flag_moves, 1, set_str_moves), | 113 | OPTION(FLAG_MOVES, 1, set_str_moves), |
| 114 | OPTION(_flag_trans, 1, set_str_trans), | 114 | OPTION(FLAG_TRANS, 1, set_str_trans), |
| 115 | OPTION(_flag_solver, 1, set_str_solver), | 115 | OPTION(FLAG_SOLVER, 1, set_str_solver), |
| 116 | OPTION(_flag_options, 1, set_str_options), /* TODO: remove, use only solver */ | 116 | OPTION(FLAG_OPTIONS, 1, set_str_options), /* TODO: remove, use only solver */ |
| 117 | OPTION(_flag_nisstype, 1, set_str_nisstype), /* TODO: remove, use flags */ | 117 | OPTION(FLAG_NISSTYPE, 1, set_str_nisstype), /* TODO: remove, use flags */ |
| 118 | OPTION(_flag_minmoves, 1, set_minmoves), | 118 | OPTION(FLAG_MINMOVES, 1, set_minmoves), |
| 119 | OPTION(_flag_maxmoves, 1, set_maxmoves), | 119 | OPTION(FLAG_MAXMOVES, 1, set_maxmoves), |
| 120 | OPTION(_flag_optimal, 1, set_optimal), | 120 | OPTION(FLAG_OPTIMAL, 1, set_optimal), |
| 121 | OPTION(_flag_maxsolutions, 1, set_maxsolutions), | 121 | OPTION(FLAG_MAXSOLUTIONS, 1, set_maxsolutions), |
| 122 | OPTION(NULL, 0, NULL) | 122 | OPTION(NULL, 0, NULL) |
| 123 | }; | 123 | }; |
| 124 | 124 | ||
| @@ -132,46 +132,46 @@ struct { | |||
| 132 | /* TODO: add synopsis and description here */ | 132 | /* TODO: add synopsis and description here */ |
| 133 | COMMAND( | 133 | COMMAND( |
| 134 | "compose", | 134 | "compose", |
| 135 | "compose " _flag_cube " CUBE " _flag_perm " PERM", | 135 | "compose " FLAG_CUBE " CUBE " FLAG_PERM " PERM", |
| 136 | "Apply on CUBE the permutation defined by PERM. " | 136 | "Apply on CUBE the permutation defined by PERM. " |
| 137 | _info_cubeformat("CUBE and PERM"), | 137 | INFO_CUBEFORMAT("CUBE and PERM"), |
| 138 | compose_exec | 138 | compose_exec |
| 139 | ), | 139 | ), |
| 140 | COMMAND( | 140 | COMMAND( |
| 141 | "inverse", | 141 | "inverse", |
| 142 | "inverse " _flag_cube " CUBE ", | 142 | "inverse " FLAG_CUBE " CUBE ", |
| 143 | "Compute the inverse of the given CUBE. " | 143 | "Compute the inverse of the given CUBE. " |
| 144 | _info_cubeformat("CUBE"), | 144 | INFO_CUBEFORMAT("CUBE"), |
| 145 | inverse_exec | 145 | inverse_exec |
| 146 | ), | 146 | ), |
| 147 | COMMAND( | 147 | COMMAND( |
| 148 | "applymoves", | 148 | "applymoves", |
| 149 | "applymoves " _flag_cube " CUBE " _flag_moves " MOVES", | 149 | "applymoves " FLAG_CUBE " CUBE " FLAG_MOVES " MOVES", |
| 150 | "Apply the given MOVES to the given CUBE. " | 150 | "Apply the given MOVES to the given CUBE. " |
| 151 | _info_cubeformat("CUBE") " " _info_movesformat, | 151 | INFO_CUBEFORMAT("CUBE") " " INFO_MOVESFORMAT, |
| 152 | applymoves_exec | 152 | applymoves_exec |
| 153 | ), | 153 | ), |
| 154 | COMMAND( | 154 | COMMAND( |
| 155 | "applytrans", | 155 | "applytrans", |
| 156 | "applytrans " _flag_cube " CUBE " _flag_trans " TRANS", | 156 | "applytrans " FLAG_CUBE " CUBE " FLAG_TRANS " TRANS", |
| 157 | "Apply the single transformation TRANS to the given CUBE. " | 157 | "Apply the single transformation TRANS to the given CUBE. " |
| 158 | _info_cubeformat("CUBE") " " _info_transformat, | 158 | INFO_CUBEFORMAT("CUBE") " " INFO_TRANSFORMAT, |
| 159 | applytrans_exec | 159 | applytrans_exec |
| 160 | ), | 160 | ), |
| 161 | COMMAND( | 161 | COMMAND( |
| 162 | "frommoves", | 162 | "frommoves", |
| 163 | "frommoves " _flag_moves " MOVES", | 163 | "frommoves " FLAG_MOVES " MOVES", |
| 164 | "Return the cube obtained by applying the given MOVES " | 164 | "Return the cube obtained by applying the given MOVES " |
| 165 | "to a solved cube. " _info_movesformat, | 165 | "to a solved cube. " INFO_MOVESFORMAT, |
| 166 | frommoves_exec | 166 | frommoves_exec |
| 167 | ), | 167 | ), |
| 168 | COMMAND( | 168 | COMMAND( |
| 169 | "convert", | 169 | "convert", |
| 170 | "convert " _flag_str_cube " CUBESTR " | 170 | "convert " FLAG_STR_CUBE " CUBESTR " |
| 171 | _flag_format_in " FORMAT_IN " _flag_format_out " FORMAT_OUT", | 171 | FLAG_FORMAT_IN " FORMAT_IN " FLAG_FORMAT_OUT " FORMAT_OUT", |
| 172 | "Convert the cube described by CUBESTR from FORMAT_IN to " | 172 | "Convert the cube described by CUBESTR from FORMAT_IN to " |
| 173 | "FORMAT_OUT." | 173 | "FORMAT_OUT." |
| 174 | _info_formats " " | 174 | INFO_FORMATS " " |
| 175 | "CUBESTR must be a valid cube in the FORMAT_IN format.", | 175 | "CUBESTR must be a valid cube in the FORMAT_IN format.", |
| 176 | convert_exec | 176 | convert_exec |
| 177 | ), | 177 | ), |
| @@ -183,31 +183,31 @@ struct { | |||
| 183 | ), | 183 | ), |
| 184 | COMMAND( | 184 | COMMAND( |
| 185 | "datasize", | 185 | "datasize", |
| 186 | "datasize " _flag_solver " SOLVER " _flag_options " OPTIONS", | 186 | "datasize " FLAG_SOLVER " SOLVER " FLAG_OPTIONS " OPTIONS", |
| 187 | "Return the size in bytes of the data table used by " | 187 | "Return the size in bytes of the data table used by " |
| 188 | "SOLVER when called with the given OPTIONS.", | 188 | "SOLVER when called with the given OPTIONS.", |
| 189 | datasize_exec | 189 | datasize_exec |
| 190 | ), | 190 | ), |
| 191 | COMMAND( | 191 | COMMAND( |
| 192 | "gendata", | 192 | "gendata", |
| 193 | "gendata " _flag_solver " SOLVER " _flag_options " OPTIONS", | 193 | "gendata " FLAG_SOLVER " SOLVER " FLAG_OPTIONS " OPTIONS", |
| 194 | "Generate the data table used by " | 194 | "Generate the data table used by " |
| 195 | "SOLVER when called with the given OPTIONS.", | 195 | "SOLVER when called with the given OPTIONS.", |
| 196 | gendata_exec | 196 | gendata_exec |
| 197 | ), | 197 | ), |
| 198 | COMMAND( | 198 | COMMAND( |
| 199 | "solve", | 199 | "solve", |
| 200 | "solve " _flag_solver " SOLVER " _flag_options " OPTIONS " | 200 | "solve " FLAG_SOLVER " SOLVER " FLAG_OPTIONS " OPTIONS " |
| 201 | "[" _flag_minmoves " n] [" _flag_maxmoves " N] " | 201 | "[" FLAG_MINMOVES " n] [" FLAG_MAXMOVES " N] " |
| 202 | _flag_cube " CUBE", | 202 | FLAG_CUBE " CUBE", |
| 203 | "Solve the given CUBE using SOLVER with the given OPTIONS, " | 203 | "Solve the given CUBE using SOLVER with the given OPTIONS, " |
| 204 | "using at least n and at most N moves. " | 204 | "using at least n and at most N moves. " |
| 205 | _info_cubeformat("CUBE"), | 205 | INFO_CUBEFORMAT("CUBE"), |
| 206 | solve_exec | 206 | solve_exec |
| 207 | ), | 207 | ), |
| 208 | COMMAND( | 208 | COMMAND( |
| 209 | "help", | 209 | "help", |
| 210 | "help [" _flag_command " COMMAND]", | 210 | "help [" FLAG_COMMAND " COMMAND]", |
| 211 | "If no COMMAND is specified, prints some generic information " | 211 | "If no COMMAND is specified, prints some generic information " |
| 212 | "and the list of commands. Otherwise it prints detailed " | 212 | "and the list of commands. Otherwise it prints detailed " |
| 213 | "information about the specified COMMAND.", | 213 | "information about the specified COMMAND.", |
