hal: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Mon Apr 23 12:56:31 PDT 2007
doc/spec/hal-spec-fdi-files.xml | 87 +++++++++++++++++++++++++++-------------
hald/device_info.c | 17 ++++++-
hald/rule.h | 3 -
3 files changed, 77 insertions(+), 30 deletions(-)
New commits:
diff-tree b44ce6775fc8a8a3c0dbe9ebbee68879777c38ee (from e6ab4d554f21bfa1df56022b0e007da5c6e7363f)
Author: Doug Goldstein <cardoe at gentoo.org>
Date: Mon Apr 23 15:56:31 2007 -0400
fdi spec fixes and correct implementation
For fdi matching the "prefix", "prefix_ncase", "suffix", and
"suffix_ncase" were missing from the spec. This patch adds them to the
spec. Also "double" was never implemented and this patch implements it
as well. It also reorders the code/spec to match the same order.
diff --git a/doc/spec/hal-spec-fdi-files.xml b/doc/spec/hal-spec-fdi-files.xml
index 1fdb8d6..9739a21 100644
--- a/doc/spec/hal-spec-fdi-files.xml
+++ b/doc/spec/hal-spec-fdi-files.xml
@@ -100,6 +100,12 @@
</listitem>
<listitem>
<para>
+ <literal>is_ascii</literal> - matches only when a string property
+ contain only ASCII characters. Can be used with 'true' or 'false'.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<literal>is_absolute_path</literal> - matches only when a string
property represents an absolute path (the path doesn't have to exist).
Can be used with 'true' or 'false'.
@@ -107,65 +113,92 @@
</listitem>
<listitem>
<para>
- <literal>is_ascii</literal> - matches only when a string property
- contain only ASCII characters. Can be used with 'true' or 'false'.
+ <literal>sibling_contains</literal> - can only be used with string and
+ strlist (string list).
+ For a string key this matches when a sibling item contains the
+ (sub-)string in the same property. For a string list, this is if a string
+ matches an item in the list.
</para>
</listitem>
<listitem>
<para>
- <literal>compare_lt</literal> - can be used on int, uint64, double
- and string properties to compare with a constant.
- Matches when the given property is less than the given constant
- using the default ordering.
+ <literal>contains</literal> - can only be used with string and
+ strlist (string list).
+ For a string key this matches when the property contains the given
+ (sub-)string. For a string list this match if the given string match
+ a item of the list.
</para>
</listitem>
<listitem>
<para>
- <literal>compare_le</literal> - like <literal>compare_lt</literal>
- but matches when less than or equal.
+ <literal>contains_ncase</literal> - like <literal>contains</literal>
+ but the property and the given key are converted to lowercase before check.
</para>
</listitem>
<listitem>
<para>
- <literal>compare_gt</literal> - like <literal>compare_lt</literal>
- but matches when greater than.
+ <literal>contains_not</literal> - can only be used with strlist (string list)
+ and string properties.
+ For a string list this match if the given string not match any of the
+ item of the list (or the property is not set for the device). For a string
+ this match of the property not contains the (sub-)string. You can use this
+ attribute to construct if/else blocks together with e.g. <literal>contains</literal>.
</para>
</listitem>
<listitem>
<para>
- <literal>compare_ge</literal> - like <literal>compare_lt</literal>
- but matches when greater than or equal.
+ <literal>prefix</literal> - can only be used with string properties.
+ Matches if property begins with the key.
</para>
</listitem>
<listitem>
<para>
- <literal>compare_ne</literal> - like <literal>compare_lt</literal>
- but matches when not equal.
+ <literal>prefix_ncase</literal> - like <literal>prefix</literal> but the
+ property and the given key are converted to lowercase before the check.
</para>
</listitem>
<listitem>
<para>
- <literal>contains</literal> - can only be used with string and
- strlist (string list).
- For a string key this matches when the property contains the given
- (sub-)string. For a string list this match if the given string match
- a item of the list.
+ <literal>suffix</literal> - can only be used with string properties.
+ Matches if property ends with the key.
</para>
</listitem>
<listitem>
<para>
- <literal>contains_not</literal> - can only be used with strlist (string list)
- and string properties.
- For a string list this match if the given string not match any of the
- item of the list (or the property is not set for the device). For a string
- this match of the property not contains the (sub-)string. You can use this
- attribute to construct if/else blocks together with e.g. <literal>contains</literal>.
+ <literal>suffix_ncase</literal> - like <literal>suffix</literal> but the
+ property and the given key are converted to lowercase before the check.
</para>
</listitem>
<listitem>
<para>
- <literal>contains_ncase</literal> - like <literal>contains</literal>
- but the property and the given key are converted to lowercase before check.
+ <literal>compare_lt</literal> - can be used on int, uint64, double
+ and string properties to compare with a constant.
+ Matches when the given property is less than the given constant
+ using the default ordering.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>compare_le</literal> - like <literal>compare_lt</literal>
+ but matches when less than or equal.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>compare_gt</literal> - like <literal>compare_lt</literal>
+ but matches when greater than.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>compare_ge</literal> - like <literal>compare_lt</literal>
+ but matches when greater than or equal.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>compare_ne</literal> - like <literal>compare_lt</literal>
+ but matches when not equal.
</para>
</listitem>
</itemizedlist>
diff --git a/hald/device_info.c b/hald/device_info.c
index 577eb2c..d1a73c1 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -71,6 +71,8 @@ get_match_type_str (enum match_type type
return "uint64";
case MATCH_BOOL:
return "bool";
+ case MATCH_DOUBLE:
+ return "double";
case MATCH_EXISTS:
return "exists";
case MATCH_EMPTY:
@@ -85,6 +87,8 @@ get_match_type_str (enum match_type type
return "contains";
case MATCH_CONTAINS_NCASE:
return "contains_ncase";
+ case MATCH_CONTAINS_NOT:
+ return "contains_not";
case MATCH_PREFIX:
return "prefix";
case MATCH_PREFIX_NCASE:
@@ -105,8 +109,6 @@ 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";
}
@@ -331,6 +333,17 @@ handle_match (struct rule *rule, HalDevi
return TRUE;
}
+ case MATCH_DOUBLE:
+ {
+ double val = atof (value);
+
+ if (hal_device_property_get_type (d, prop_to_check) != HAL_PROPERTY_TYPE_DOUBLE)
+ return FALSE;
+ if (hal_device_property_get_double (d, prop_to_check) != val)
+ return FALSE;
+ return TRUE;
+ }
+
case MATCH_EXISTS:
{
dbus_bool_t should_exist = TRUE;
diff --git a/hald/rule.h b/hald/rule.h
index c73f4c6..971c5f6 100644
--- a/hald/rule.h
+++ b/hald/rule.h
@@ -79,7 +79,8 @@ typedef enum {
MATCH_COMPARE_GE,
MATCH_SIBLING_CONTAINS,
MATCH_COMPARE_NE,
- MATCH_CONTAINS_NOT
+ MATCH_CONTAINS_NOT,
+ MATCH_DOUBLE
} match_type;
/* a "rule" structure that is a generic node of the fdi file */
More information about the hal-commit
mailing list