summaryrefslogtreecommitdiff
path: root/hald
diff options
context:
space:
mode:
authorDanny Kukawka <danny.kukawka@web.de>2007-03-07 10:05:22 +0100
committerDanny Kukawka <danny.kukawka@web.de>2007-03-07 10:05:22 +0100
commitf284167711acb400aff1b22c16b9cc5368ca00ff (patch)
treedb8cf747263daae6d6d6aad4db9f4ca8a3ec09c5 /hald
parentc31c32b8b7c0fed9c871da947f35922e03ad6ed3 (diff)
added new fdi match attribute 'contains_not' for strings and strlist
Added a new attribute for FDI file match tag for string lists (strlist) and strings. The new attribute named contains_not and allow you to match if a given string is not contained in the string list/strins as in such cases for example: <match key="info.callouts" contains_not="foobar"> <append key="info.callouts" type="strlist">foobar</append> </match> This allow you to add e.g. callouts to the list without to double entries and allow some kind of if/else clause in FDI files
Diffstat (limited to 'hald')
-rw-r--r--hald/create_cache.c2
-rw-r--r--hald/device_info.c13
-rw-r--r--hald/rule.h3
3 files changed, 14 insertions, 4 deletions
diff --git a/hald/create_cache.c b/hald/create_cache.c
index 5374051d..97349f9a 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -134,6 +134,8 @@ get_match_type(const char *str)
return MATCH_COMPARE_GE;
if (strcmp (str, "compare_ne") == 0)
return MATCH_COMPARE_NE;
+ if (strcmp (str, "contains_not") == 0)
+ return MATCH_CONTAINS_NOT;
return MATCH_UNKNOWN;
}
diff --git a/hald/device_info.c b/hald/device_info.c
index 09f6eb2b..83550116 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -105,6 +105,8 @@ get_match_type_str (enum match_type type)
return "compare_ne";
case MATCH_UNKNOWN:
return "unknown match type";
+ case MATCH_CONTAINS_NOT:
+ return "contains_not";
}
return "invalid match type";
}
@@ -441,6 +443,7 @@ handle_match (struct rule *rule, HalDevice *d)
}
case MATCH_CONTAINS:
+ case MATCH_CONTAINS_NOT:
{
dbus_bool_t contains = FALSE;
@@ -449,7 +452,7 @@ handle_match (struct rule *rule, HalDevice *d)
const char *haystack;
haystack = hal_device_property_get_string (d, prop_to_check);
- if (value != NULL && haystack != NULL && strstr (haystack, value))
+ if (value != NULL && haystack != NULL && (strstr(haystack, value) != NULL))
contains = TRUE;
}
} else if (hal_device_property_get_type (d, prop_to_check) == HAL_PROPERTY_TYPE_STRLIST && value != NULL) {
@@ -466,8 +469,12 @@ handle_match (struct rule *rule, HalDevice *d)
} else {
return FALSE;
}
-
- return contains;
+
+ if (rule->type_match == MATCH_CONTAINS) {
+ return contains;
+ } else {
+ return !contains; /* rule->type_match == MATCH_CONTAINS_NOT */
+ }
}
case MATCH_SIBLING_CONTAINS:
diff --git a/hald/rule.h b/hald/rule.h
index b57d2827..c73f4c6c 100644
--- a/hald/rule.h
+++ b/hald/rule.h
@@ -78,7 +78,8 @@ typedef enum {
MATCH_COMPARE_GT,
MATCH_COMPARE_GE,
MATCH_SIBLING_CONTAINS,
- MATCH_COMPARE_NE
+ MATCH_COMPARE_NE,
+ MATCH_CONTAINS_NOT
} match_type;
/* a "rule" structure that is a generic node of the fdi file */