hal: Branch 'master' - 2 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Mon Jul 2 15:22:56 PDT 2007
hald/util.c | 18 ++++++++++++++++++
hald/util.h | 2 ++
hald/util_pm.c | 6 +++++-
3 files changed, 25 insertions(+), 1 deletion(-)
New commits:
diff-tree b6627461f897e0f6886ef73cbf415a28afa53279 (from 38f939ae9b0d600ff71290263a5f13d04527c786)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Jul 2 23:20:48 2007 +0100
add hal_util_get_bool_from_file convenience helper
Patch attached adds a hal_util_get_bool_from_file convenience helper.
I need this for the power_supply class support which will be submitted
soon. util.c needs a massive cleanup, which is another thing on my TODO.
diff --git a/hald/util.c b/hald/util.c
index 4288c29..a21b609 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -409,6 +409,24 @@ out:
return result;
}
+/* return is success, true_val is the value expected for a true value, e.g. "1" or "True" */
+gboolean
+hal_util_get_bool_from_file (const gchar *directory, const gchar *file, gboolean *retval, const gchar *true_val)
+{
+ gchar *value;
+ value = hal_util_get_string_from_file (directory, file);
+ if (value == NULL) {
+ /* no need to free */
+ return FALSE;
+ }
+ if (strcmp (value, true_val) == 0) {
+ *retval = TRUE;
+ } else {
+ *retval = FALSE;
+ }
+ return TRUE;
+}
+
gboolean
hal_util_set_string_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file)
{
diff --git a/hald/util.h b/hald/util.h
index 4542b1b..6a4353a 100644
--- a/hald/util.h
+++ b/hald/util.h
@@ -59,6 +59,8 @@ gboolean hal_util_set_uint64_from_file (
gchar *hal_util_get_string_from_file (const gchar *directory, const gchar *file);
+gboolean hal_util_get_bool_from_file (const gchar *directory, const gchar *file, gboolean *retval, const char *true_val);
+
gboolean hal_util_set_string_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file);
gboolean hal_util_get_bcd2_from_file (const gchar *directory, const gchar *file, gint *result);
diff-tree 38f939ae9b0d600ff71290263a5f13d04527c786 (from 1d38172d34d8bfbb728b9f1cc5fe386f711c1a05)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Jul 2 23:17:49 2007 +0100
add two more strings to the battery technology list
Add a ACPI 'lipo' and OLPC 'lifo' to the battery type list.
diff --git a/hald/util_pm.c b/hald/util_pm.c
index ffbc021..a2a939f 100644
--- a/hald/util_pm.c
+++ b/hald/util_pm.c
@@ -70,12 +70,16 @@ util_get_battery_technology (const char
strcasecmp (type, "pbac") == 0) {
return "lead-acid";
}
- if (strcasecmp (type, "lip") == 0) {
+ if (strcasecmp (type, "lip") == 0 ||
+ strcasecmp (type, "lipo") == 0) {
return "lithium-polymer";
}
if (strcasecmp (type, "nimh") == 0) {
return "nickel-metal-hydride";
}
+ if (strcasecmp (type, "lifo") == 0) {
+ return "lithium-iron-phosphate";
+ }
return "unknown";
}
More information about the hal-commit
mailing list