summaryrefslogtreecommitdiffstats
path: root/src/shared/compare-operator.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-08-26 16:56:04 +0200
committerLennart Poettering <lennart@poettering.net>2022-09-01 23:15:14 +0200
commit57610982f73162ec37b1de03734250bb5a3222da (patch)
tree7de7a2abf6b07482a67f6c7e3656ece1fe03068d /src/shared/compare-operator.h
parentcompare: add a proper flags field for parse_compare_operator() (diff)
downloadsystemd-57610982f73162ec37b1de03734250bb5a3222da.tar.xz
systemd-57610982f73162ec37b1de03734250bb5a3222da.zip
compare: add flag for parse_compare_operator() to do equality/inequality comparison via simple string compares
This allows us to switch condition_test_osrelease() to use generic version_or_fnmatch_compare() for executing the comparison.
Diffstat (limited to 'src/shared/compare-operator.h')
-rw-r--r--src/shared/compare-operator.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shared/compare-operator.h b/src/shared/compare-operator.h
index f7137bba1a..363b4bdc75 100644
--- a/src/shared/compare-operator.h
+++ b/src/shared/compare-operator.h
@@ -8,6 +8,12 @@ typedef enum CompareOperator {
/* Listed in order of checking. Note that some comparators are prefixes of others, hence the longest
* should be listed first. */
+ /* Simple string compare operators */
+ _COMPARE_OPERATOR_STRING_FIRST,
+ COMPARE_STRING_EQUAL = _COMPARE_OPERATOR_STRING_FIRST,
+ COMPARE_STRING_UNEQUAL,
+ _COMPARE_OPERATOR_STRING_LAST = COMPARE_STRING_UNEQUAL,
+
/* fnmatch() compare operators */
_COMPARE_OPERATOR_FNMATCH_FIRST,
COMPARE_FNMATCH_EQUAL = _COMPARE_OPERATOR_FNMATCH_FIRST,
@@ -28,6 +34,10 @@ typedef enum CompareOperator {
_COMPARE_OPERATOR_INVALID = -EINVAL,
} CompareOperator;
+static inline bool COMPARE_OPERATOR_IS_STRING(CompareOperator c) {
+ return c >= _COMPARE_OPERATOR_STRING_FIRST && c <= _COMPARE_OPERATOR_STRING_LAST;
+}
+
static inline bool COMPARE_OPERATOR_IS_FNMATCH(CompareOperator c) {
return c >= _COMPARE_OPERATOR_FNMATCH_FIRST && c <= _COMPARE_OPERATOR_FNMATCH_LAST;
}
@@ -38,6 +48,7 @@ static inline bool COMPARE_OPERATOR_IS_ORDER(CompareOperator c) {
typedef enum CompareOperatorParseFlags {
COMPARE_ALLOW_FNMATCH = 1 << 0,
+ COMPARE_EQUAL_BY_STRING = 1 << 1,
} CompareOperatorParseFlags;
CompareOperator parse_compare_operator(const char **s, CompareOperatorParseFlags flags);