diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-08 06:26:12 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-03-08 06:26:12 +0100 |
| commit | 110e079f81277b40ec76be0b86b074a632496109 (patch) | |
| tree | 45c725b7ade224f12647566311f56f0f7df469f0 /src/solvers/coord/coord_common.h | |
| parent | fd71dea0577ddcafa335ed56b0fe498306d9fb99 (diff) | |
| download | nissy-core-110e079f81277b40ec76be0b86b074a632496109.tar.gz nissy-core-110e079f81277b40ec76be0b86b074a632496109.zip | |
renamed some files
Diffstat (limited to 'src/solvers/coord/coord_common.h')
| -rw-r--r-- | src/solvers/coord/coord_common.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/solvers/coord/coord_common.h b/src/solvers/coord/coord_common.h new file mode 100644 index 0000000..d827665 --- /dev/null +++ b/src/solvers/coord/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 | } | ||
