| summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/device/axis/axis_option.c')
| -rw-r--r-- | src/device/axis/axis_option.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/device/axis/axis_option.c b/src/device/axis/axis_option.c new file mode 100644 index 0000000..fd1cb9c --- /dev/null +++ b/src/device/axis/axis_option.c @@ -0,0 +1,71 @@ +/**** POSIX *******************************************************************/ +#include <string.h> + +/**** RELABSD *****************************************************************/ +#include <relabsd/debug.h> + +#include <relabsd/device/axis.h> + +/******************************************************************************/ +/**** LOCAL FUNCTIONS *********************************************************/ +/******************************************************************************/ + +/******************************************************************************/ +/**** EXPORTED FUNCTIONS ******************************************************/ +/******************************************************************************/ +/* + * Returns -1 if the option was discarded (an error has been reported), + * 0 if the option was successfully parsed. + */ +int relabsd_axis_enable_option_from_name +( + const char option_name [const restrict static 1], + const char axis_name [const restrict static 1], + struct relabsd_axis axis [const restrict static 1] +) +{ + + if (strcmp(option_name, "direct") == 0) + { + axis->flags[RELABSD_DIRECT] = 1; + + if (axis->flags[RELABSD_FRAMED]) + { + RELABSD_WARNING + ( + "Option 'direct' on axis '%s' supersedes its 'framed' option.", + axis_name + ); + } + } + else if (strcmp(option_name, "real_fuzz") == 0) + { + axis->flags[RELABSD_REAL_FUZZ] = 1; + } + else if (strcmp(option_name, "framed") == 0) + { + axis->flags[RELABSD_FRAMED] = 1; + + if (axis->flags[RELABSD_DIRECT]) + { + RELABSD_WARNING + ( + "Option 'direct' on axis '%s' supersedes its 'framed' option.", + axis_name + ); + } + } + else + { + RELABSD_ERROR + ( + "Unknown option '%s' for axis '%s'.", + option_name, + axis_name + ); + + return -1; + } + + return 0; +} |


