The exclusive_option() will unify how exclusive options are
determined.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
#ifndef UTIL_LINUX_OPTUTILS_H
#define UTIL_LINUX_OPTUTILS_H
+#include "c.h"
+#include "nls.h"
+
static inline const char *option_to_longopt(int c, const struct option *opts)
{
const struct option *o;
return NULL;
}
+#ifndef OPTUTILS_EXIT_CODE
+# define OPTUTILS_EXIT_CODE EXIT_FAILURE
+#endif
+static inline void exclusive_option(int *what, const int how,
+ const char *errmesg)
+{
+ if (*what == 0) {
+ *what = how;
+ return;
+ }
+ if (*what == how)
+ return;
+ errx(OPTUTILS_EXIT_CODE,
+ _("options %s are mutually exclusive"), errmesg);
+}
+
#endif