diff options
Diffstat (limited to 'src/solvers/coord/common.h')
| -rw-r--r-- | src/solvers/coord/common.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h new file mode 100644 index 0000000..d827665 --- /dev/null +++ b/src/solvers/coord/common.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | coord_t *all_coordinates[] = { | ||
| 2 | &coordinate_eo, | ||
| 3 | NULL | ||
| 4 | }; | ||
| 5 | |||
| 6 | STATIC void append_coord_name(const coord_t *, char *); | ||
| 7 | STATIC coord_t *parse_coord(const char *, int); | ||
| 8 | STATIC uint8_t parse_axis(const char *, int); | ||
| 9 | |||
| 10 | STATIC void | ||
| 11 | append_coord_name(const coord_t *coord, char *str) | ||
| 12 | { | ||
| 13 | int i, j; | ||
| 14 | |||
| 15 | i = 0; | ||
| 16 | j = strlen(str); | ||
| 17 | while (coord->name[i]) str[j++] = coord->name[i++]; | ||
| 18 | |||
| 19 | str[j] = '\0'; | ||
| 20 | } | ||
| 21 | |||
| 22 | STATIC coord_t * | ||
| 23 | parse_coord(const char *coord, int n) | ||
| 24 | { | ||
| 25 | int i; | ||
| 26 | |||
| 27 | for (i = 0; all_coordinates[i] != NULL; i++) | ||
| 28 | if (!strncmp(all_coordinates[i]->name, coord, n)) | ||
| 29 | return all_coordinates[i]; | ||
| 30 | |||
| 31 | return NULL; | ||
| 32 | } | ||
| 33 | |||
| 34 | STATIC uint8_t | ||
| 35 | parse_axis(const char *axis, int n) | ||
| 36 | { | ||
| 37 | if (!strncmp(axis, "UD", n) || !strncmp(axis, "DU", n)) { | ||
| 38 | return AXIS_UD; | ||
| 39 | } else if (!strncmp(axis, "RL", n) || !strncmp(axis, "LR", n)) { | ||
| 40 | return AXIS_RL; | ||
| 41 | } else if (!strncmp(axis, "FB", n) || !strncmp(axis, "BF", n)) { | ||
| 42 | return AXIS_FB; | ||
| 43 | } | ||
| 44 | |||
| 45 | return UINT8_ERROR; | ||
| 46 | } | ||
