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