From a4841776b6e1751232d46482731836a7c17b896f Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 3 Jan 2020 03:50:24 +0100 Subject: Still working on it... --- src/device/axis/axis_option.c | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/device/axis/axis_option.c (limited to 'src/device/axis/axis_option.c') 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 + +/**** RELABSD *****************************************************************/ +#include + +#include + +/******************************************************************************/ +/**** 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; +} -- cgit v1.2.3-70-g09d2