hal/hald/linux2 Makefile.am, 1.2, 1.3 acpi.c, NONE, 1.1 acpi.h, NONE, 1.1 coldplug.c, 1.3, 1.4 hotplug.c, 1.3, 1.4 osspec.c, 1.3, 1.4 util.c, 1.2, 1.3 util.h, 1.2, 1.3

David Zeuthen david at freedesktop.org
Mon Jan 31 21:17:57 PST 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv2777/hald/linux2

Modified Files:
	Makefile.am coldplug.c hotplug.c osspec.c util.c util.h 
Added Files:
	acpi.c acpi.h 
Log Message:
2005-02-01  David Zeuthen  <davidz at redhat.com>

	This is largely based on this patch

	 http://lists.freedesktop.org/archives/hal/2005-January/002002.html

	from Richard Hughes <ee21rh at surrey.ac.uk> but much mangled by
	myself

	* hald/linux2/util.c (hal_util_get_parent_path): Renamed from
	hal_util_get_parent_sysfs_path.
	(hal_util_grep_file): New function
	(hal_util_set_string_elem_from_file): New function
	(hal_util_set_int_elem_from_file): New function
	(hal_util_set_bool_elem_from_file): New function

	* hald/linux2/util.h: Add new prototypes

	* hald/linux2/osspec.c (osspec_probe): Call acpi_probe.

	* hald/linux2/acpi.[ch]: New files

	* hald/linux2/Makefile.am (libhald_linux2_la_SOURCES): Add acpi.[ch]



Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am	22 Jan 2005 20:13:42 -0000	1.2
+++ Makefile.am	1 Feb 2005 05:17:55 -0000	1.3
@@ -20,6 +20,7 @@
 	classdev.h		classdev.c			\
 	blockdev.h		blockdev.c			\
 	util.h			util.c				\
+	acpi.h			acpi.c				\
 	ids.h			ids.c				\
 	pcmcia_utils.h		pcmcia_utils.c
 

--- NEW FILE: acpi.c ---
/***************************************************************************
 * CVSID: $Id: acpi.c,v 1.1 2005/02/01 05:17:55 david Exp $
 *
 * Copyright (C) 2005 Richard Hughes <richard at hughsie.com>
 * Copyright (C) 2005 David Zeuthen, Red Hat Inc., <davidz at redhat.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 **************************************************************************/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <string.h>

#include "../callout.h"
#include "../logger.h"
#include "../hald_dbus.h"
#include "util.h"

#include "acpi.h"

static void
acpi_refresh_ac_adapter (HalDevice *d, const gchar *path)
{
	hal_device_property_set_string (d, "info.product", "AC Adapter");
	hal_device_property_set_string (d, "info.category", "system.ac_adapter");
	hal_device_add_capability (d, "system.ac_adapter");
	hal_util_set_bool_elem_from_file (d, "system.ac_adapter.present", path, "state", "state", 0, "on-line");
}

static void
acpi_refresh_button (HalDevice *d, const gchar *path)
{
	gchar *parent_path = hal_util_get_parent_path (path);
	const gchar *button_type = hal_util_get_last_element (parent_path);

	hal_device_property_set_string (d, "system.button.type", button_type);

	if (strcmp (button_type, "power") == 0)   
		hal_device_property_set_string (d, "info.product", "Power Button");
	else if (strcmp (button_type, "lid") == 0)   
		hal_device_property_set_string (d, "info.product", "Lid Switch");
	else if (strcmp (button_type, "sleep") == 0)   
		hal_device_property_set_string (d, "info.product", "Sleep Button");

	hal_device_property_set_string (d, "info.category", "system.button");
	hal_device_add_capability (d, "system.button");
	if (!hal_util_set_bool_elem_from_file (d, "system.button.state.value", path, "state", "state", 0, "closed")) {
		hal_device_property_set_bool (d, "system.button.has_state", FALSE);
	} else {
		hal_device_property_set_bool (d, "system.button.has_state", TRUE);
	}

	g_free (parent_path);
}

static void
acpi_refresh_battery (HalDevice *d, const gchar *path)
{
	hal_device_property_set_string (d, "info.product", "Battery Bay");
	hal_device_property_set_string (d, "battery.type", "primary");
	hal_device_property_set_string (d, "info.category", "battery");
	hal_device_add_capability (d, "battery");

	hal_util_set_bool_elem_from_file (d, "battery.present", path, "info", "present", 0, "yes");
	if (!hal_device_property_get_bool (d, "battery.present")) {
		device_property_atomic_update_begin ();
		hal_device_property_remove (d, "battery.is_rechargeable");
		hal_device_property_remove (d, "battery.rechargeable.is_charging");
		hal_device_property_remove (d, "battery.rechargeable.is_discharging");
		hal_device_property_remove (d, "battery.vendor");
		hal_device_property_remove (d, "battery.model");
		hal_device_property_remove (d, "battery.serial");
		hal_device_property_remove (d, "battery.technology");
		hal_device_property_remove (d, "battery.vendor");
		hal_device_property_remove (d, "battery.charge_level.unit");
		hal_device_property_remove (d, "battery.charge_level.current");
		hal_device_property_remove (d, "battery.charge_level.maximum_specified");
		device_property_atomic_update_end ();		
	} else {
		device_property_atomic_update_begin ();
		hal_device_property_set_bool (d, "battery.is_rechargeable", TRUE);
		hal_util_set_bool_elem_from_file (d, "battery.rechargeable.is_charging", path, 
						  "state", "charging state", 0, "charging");

		hal_util_set_bool_elem_from_file (d, "battery.rechargeable.is_discharging", path, 
						  "state", "charging state", 0, "discharging");
		
		hal_util_set_string_elem_from_file (d, "battery.vendor", path, "info", "OEM info", 0);
		hal_util_set_string_elem_from_file (d, "battery.model", path, "info", "model number", 0);
		hal_util_set_string_elem_from_file (d, "battery.serial", path, "info", "serial number", 0);
		hal_util_set_string_elem_from_file (d, "battery.technology", path, "info", "battery type", 0);
		hal_util_set_string_elem_from_file (d, "battery.vendor", path, "info", "OEM info", 0);
		hal_util_set_string_elem_from_file (d, "battery.charge_level.unit", path, "info", "design capacity", 1);

		hal_util_set_int_elem_from_file (d, "battery.charge_level.current", path, 
						 "state", "remaining capacity", 0);

		hal_util_set_int_elem_from_file (d, "battery.charge_level.maximum_specified", path, 
						 "info", "design capacity", 0);
		device_property_atomic_update_end ();
	}
}

static void
acpi_add_objects (const gchar *path, void (*refresh_handler)(HalDevice *d, const gchar *path))
{
	const gchar *f;
	GDir *dir;
	GError *error;

	dir = g_dir_open (path, 0, &error);
	if (dir == NULL) {
		HAL_ERROR (("Couldn't open %s", path));
		goto out;
	}

	while ((f = g_dir_read_name (dir)) != NULL) {
		gchar buf[HAL_PATH_MAX];
		gchar buf2[HAL_PATH_MAX];
		HalDevice *d;

		snprintf (buf, sizeof (buf), "%s/%s", path, f);
		HAL_INFO (("Processing %s", buf));

		d = hal_device_new ();
		snprintf (buf2, sizeof (buf2), "/org/freedesktop/Hal/devices/acpi_%s", f);
		hal_device_set_udi (d, buf2);
		hal_device_property_set_string (d, "info.udi", buf2);
		hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
		hal_device_property_set_string (d, "linux.acpi_path", buf);

		refresh_handler (d, buf);

		hal_device_store_add (hald_get_gdl (), d);
	}

	/* close directory */
	g_dir_close (dir);

out:
	;
}

static gboolean
poll_acpi_device (HalDeviceStore *store,
		  HalDevice      *device,
		  gpointer        user_data)
{
	if (hal_device_has_property (device, "linux.acpi_path")) {
		const char *path;

		path = hal_device_property_get_string (device, "linux.acpi_path");

		if (hal_device_has_capability (device, "battery"))
			acpi_refresh_battery (device, path);
		else if (hal_device_has_capability (device, "system.button"))
			acpi_refresh_button (device, path);
		else if (hal_device_has_capability (device, "system.ac_adapter"))
			acpi_refresh_ac_adapter (device, path);
	}

	return TRUE;
}


static gboolean
poll_acpi (gpointer data)
{
	hal_device_store_foreach (hald_get_gdl (), poll_acpi_device, NULL);
	return TRUE;
}


/** Scan the data structures exported by the kernel and build
 *  device objects representing ACPI objects
 */
void
acpi_probe (void)
{
	HalDevice *computer;
	gchar path[HAL_PATH_MAX];

	if (!g_file_test ("/proc/acpi/info", G_FILE_TEST_EXISTS))
		goto out;

	HAL_INFO (("Adding device objects for ACPI"));

	if ((computer = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer")) == NULL) {
		HAL_ERROR (("No computer object?"));
		goto out;
	}

	/* only do ACPI specific options */
	hal_device_property_set_bool (computer, "power_management.is_enabled", TRUE);
	hal_device_property_set_string (computer, "power_management.type", "acpi");
	hal_util_set_string_elem_from_file (computer, "power_management.acpi.linux.version", 
					    "/proc/acpi", "info", "version", 0);

	/* collect batteries */
	snprintf (path, sizeof (path), "%s/acpi/battery", hal_proc_path);
	acpi_add_objects (path, acpi_refresh_battery);

	/* collect AC adapters */
	snprintf (path, sizeof (path), "%s/acpi/ac_adapter", hal_proc_path);
	acpi_add_objects (path, acpi_refresh_ac_adapter);

	/* collect buttons */
	snprintf (path, sizeof (path), "%s/acpi/button/lid", hal_proc_path);
	acpi_add_objects (path, acpi_refresh_button);
	snprintf (path, sizeof (path), "%s/acpi/button/power", hal_proc_path);
	acpi_add_objects (path, acpi_refresh_button);
	snprintf (path, sizeof (path), "%s/acpi/button/sleep", hal_proc_path);
	acpi_add_objects (path, acpi_refresh_button);

	/* For fun, poll the objects..
	 *
	 * This needs to be replaced with listening to the ACPI socket! Uhm, also
	 * because this is the only way to catch when someone presses a button
	 * without state.
	 */
	g_timeout_add (2000, poll_acpi, NULL);	

out:
	;
}

--- NEW FILE: acpi.h ---
/***************************************************************************
 * CVSID: $Id: acpi.h,v 1.1 2005/02/01 05:17:55 david Exp $
 *
 * Copyright (C) 2005 Richard Hughes <richard at hughsie.com>
 * Copyright (C) 2005 David Zeuthen, Red Hat Inc., <davidz at redhat.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 **************************************************************************/

#ifndef ACPI_H
#define ACPI_H

#include "../hald.h"

void acpi_probe (void);

#endif /* ACPI_H */

Index: coldplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/coldplug.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- coldplug.c	25 Jan 2005 16:55:09 -0000	1.3
+++ coldplug.c	1 Feb 2005 05:17:55 -0000	1.4
@@ -384,7 +384,7 @@
 		g_strlcpy (hotplug_event->sysfs_path, path, sizeof (hotplug_event->sysfs_path));
 		hotplug_event->net_ifindex = -1;
 
-		parent_sysfs_path = hal_util_get_parent_sysfs_path (path);
+		parent_sysfs_path = hal_util_get_parent_path (path);
 		g_strlcpy (hotplug_event->wait_for_sysfs_path, parent_sysfs_path, sizeof (hotplug_event->wait_for_sysfs_path));
 		g_free (parent_sysfs_path);
 

Index: hotplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/hotplug.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- hotplug.c	26 Jan 2005 20:14:59 -0000	1.3
+++ hotplug.c	1 Feb 2005 05:17:55 -0000	1.4
@@ -209,7 +209,7 @@
 		gchar *parent_path;
 		gboolean is_partition;
 		
-		parent_path = hal_util_get_parent_sysfs_path (hotplug_event->sysfs_path);
+		parent_path = hal_util_get_parent_path (hotplug_event->sysfs_path);
 		is_partition = (strcmp (parent_path, sys_block_path) != 0);
 		
 		if (hotplug_event->is_add) {

Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- osspec.c	26 Jan 2005 20:14:59 -0000	1.3
+++ osspec.c	1 Feb 2005 05:17:55 -0000	1.4
@@ -79,6 +79,8 @@
 
 #include "ids.h"
 
+#include "acpi.h"
+
 char hal_sysfs_path [HAL_PATH_MAX];
 char hal_proc_path [HAL_PATH_MAX];
 
@@ -471,6 +473,9 @@
 	/* start processing events */
 	hotplug_event_process_queue ();
 
+	/* ACPI */
+	acpi_probe ();
+
 	/*osspec_probe_done ();*/
 }
 

Index: util.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- util.c	23 Jan 2005 23:11:59 -0000	1.2
+++ util.c	1 Feb 2005 05:17:55 -0000	1.3
@@ -139,15 +139,14 @@
 	return s;
 }
 
-/** Given a sysfs-path for a device, this functions finds the sysfs
- *  path representing the parent of the given device by truncation.
+/** Given a path, this functions finds the path representing the
+ *  parent directory by truncation.
  *
- *  @param  path                Sysfs-path of device to find parent for
- *  @return                     Path for parent or NULL if there is no parent; 
- *                              must be freed by caller
+ *  @param  path                Path
+ *  @return                     Path for parent or NULL. Must be freed by caller
  */
 gchar *
-hal_util_get_parent_sysfs_path (const gchar *path)
+hal_util_get_parent_path (const gchar *path)
 {
 	guint i;
 	guint len;
@@ -720,3 +719,249 @@
 	*p = '\0';
 	return TRUE;
 }
+
+/** Given a directory and filename, open the file and search for the
+ *  first line that starts with the given linestart string. Returns
+ *  the rest of the line as a string if found.
+ *
+ *  @param  directory           Directory, e.g. "/proc/acpi/battery/BAT0"
+ *  @param  file                File, e.g. "info"
+ *  @param  linestart           Start of line, e.g. "serial number"
+ *  @return                     NULL if not found, otherwise the remainder
+ *                              of the line, e.g. ":           21805" if
+ *                              the file /proc/acpi/battery/BAT0 contains
+ *                              this line "serial number:           21805"
+ *                              The string is only valid until the next
+ *                              invocation of this function.
+ */
+gchar *
+hal_util_grep_file (const gchar *directory, const gchar *file, const gchar *linestart)
+{
+	FILE *f;
+	static gchar buf[512];
+	static gchar filename[HAL_PATH_MAX];
+	gchar *result;
+	gsize linestart_len;
+
+	result = NULL;
+
+	snprintf (filename, sizeof (filename), "%s/%s", directory, file);
+	f = fopen (filename, "r");
+	if (f == NULL)
+		goto out;
+
+	linestart_len = strlen (linestart);
+
+	do {
+		if (fgets (buf, sizeof (buf), f) == NULL)
+			goto out;
+
+		if (strncmp (buf, linestart, linestart_len) == 0) {
+			guint i;
+			gsize len;
+
+			len = strlen (buf);
+			for (i = len - 1; i > 0; --i) {
+				if (buf[i] == '\n' || buf[i] == '\r')
+					buf[i] = '\0';
+				else
+					break;
+			}
+			break;
+		}
+	} while (TRUE);
+
+	result = buf + linestart_len;
+
+out:
+	if (f != NULL)
+		fclose (f);
+	return result;
+}
+
+/** Get a string value from a formatted text file and assign it to
+ *  a property on a device object.
+ *
+ *  Example: Given that the file /proc/acpi/battery/BAT0/info contains
+ *  the line
+ *
+ *    "design voltage:          10800 mV"
+ *
+ *  then hal_util_set_string_elem_from_file (d, "system.battery.foo",
+ *  "/proc/acpi/battery/BAT0", "info", "design voltage", 1) will assign
+ *  the string "mV" to the property "system.battery.foo" on d.
+ *
+ *  @param  d                   Device object
+ *  @param  key                 Property name
+ *  @param  directory           Directory, e.g. "/proc/acpi/battery/BAT0"
+ *  @param  file                File, e.g. "info"
+ *  @param  linestart           Start of line, e.g. "design voltage"
+ *  @param  elem                Element number after linestart to extract
+ *                              excluding whitespace and ':' characters.
+ *  @return                     TRUE, if, and only if, the value could be
+ *                              extracted and the property was set
+ */
+gboolean
+hal_util_set_string_elem_from_file (HalDevice *d, const gchar *key, 
+				    const gchar *directory, const gchar *file, 
+				    const gchar *linestart, guint elem)
+{
+	gchar *line;
+	gboolean res;
+	gchar **tokens;
+	guint i, j;
+
+	res = FALSE;
+	tokens = NULL;
+
+	if (((line = hal_util_grep_file (directory, file, linestart)) == NULL) || (strlen (line) == 0))
+		goto out;
+
+	tokens = g_strsplit_set (line, " \t:", 0);
+	for (i = 0, j = 0; tokens[i] != NULL; i++) {
+		if (strlen (tokens[i]) == 0)
+			continue;
+		if (j == elem) {
+			hal_device_property_set_string (d, key, tokens[i]);
+			res = TRUE;
+			goto out;
+		}
+		j++;
+	}
+	
+out:
+	if (tokens != NULL)
+		g_strfreev (tokens);
+
+	return res;
+}
+
+/** Get an integer value from a formatted text file and assign it to
+ *  a property on a device object.
+ *
+ *  Example: Given that the file /proc/acpi/battery/BAT0/info contains
+ *  the line
+ *
+ *    "design voltage:          10800 mV"
+ *
+ *  then hal_util_set_int_elem_from_file (d, "system.battery.bar",
+ *  "/proc/acpi/battery/BAT0", "info", "design voltage", 0) will assign
+ *  the integer 10800 to the property "system.battery.foo" on d.
+ *
+ *  @param  d                   Device object
+ *  @param  key                 Property name
+ *  @param  directory           Directory, e.g. "/proc/acpi/battery/BAT0"
+ *  @param  file                File, e.g. "info"
+ *  @param  linestart           Start of line, e.g. "design voltage"
+ *  @param  elem                Element number after linestart to extract
+ *                              excluding whitespace and ':' characters.
+ *  @return                     TRUE, if, and only if, the value could be
+ *                              extracted and the property was set
+ */
+gboolean
+hal_util_set_int_elem_from_file (HalDevice *d, const gchar *key, 
+				 const gchar *directory, const gchar *file, 
+				 const gchar *linestart, guint elem)
+{
+	gchar *line;
+	gboolean res;
+	gchar **tokens;
+	int value;
+	char *endptr;
+	guint i, j;
+
+	res = FALSE;
+	tokens = NULL;
+
+	if (((line = hal_util_grep_file (directory, file, linestart)) == NULL) || (strlen (line) == 0))
+		goto out;
+
+	tokens = g_strsplit_set (line, " \t:", 0);
+
+	for (i = 0, j = 0; tokens[i] != NULL; i++) {
+		if (strlen (tokens[i]) == 0)
+			continue;
+		if (j == elem) {
+			value = strtol (tokens[i], &endptr, 0);
+			if (endptr == tokens[i])
+				goto out;
+			hal_device_property_set_int (d, key, value);
+			res = TRUE;
+			goto out;
+		}
+		j++;
+	}	
+
+out:
+	if (tokens != NULL)
+		g_strfreev (tokens);
+
+	return res;
+}
+
+/** Get a value from a formatted text file, test it against a given
+ *  value, and set a boolean property on a device object with the
+ *  test result.
+ *
+ *  Example: Given that the file /proc/acpi/battery/BAT0/info contains
+ *  the line
+ *
+ *    "present:                 yes"
+ *
+ *  then hal_util_set_bool_elem_from_file (d, "system.battery.baz",
+ *  "/proc/acpi/battery/BAT0", "info", "present", 0, "yes") will assign
+ *  the boolean TRUE to the property "system.battery.baz" on d.
+ *
+ *  If, instead, the line was
+ *
+ *    "present:                 no"
+ *
+ *  the value assigned will be FALSE.
+ *
+ *  @param  d                   Device object
+ *  @param  key                 Property name
+ *  @param  directory           Directory, e.g. "/proc/acpi/battery/BAT0"
+ *  @param  file                File, e.g. "info"
+ *  @param  linestart           Start of line, e.g. "design voltage"
+ *  @param  elem                Element number after linestart to extract
+ *                              excluding whitespace and ':' characters.
+ *  @param  expected            Value to test against
+ *  @return                     TRUE, if, and only if, the value could be
+ *                              extracted and the property was set
+ */
+gboolean
+hal_util_set_bool_elem_from_file (HalDevice *d, const gchar *key, 
+				  const gchar *directory, const gchar *file, 
+				  const gchar *linestart, guint elem, const gchar *expected)
+{
+	gchar *line;
+	gboolean res;
+	gchar **tokens;
+	guint i, j;
+
+	res = FALSE;
+	tokens = NULL;
+
+	if (((line = hal_util_grep_file (directory, file, linestart)) == NULL) || (strlen (line) == 0))
+		goto out;
+
+	tokens = g_strsplit_set (line, " \t:", 0);
+
+	for (i = 0, j = 0; tokens[i] != NULL; i++) {
+		if (strlen (tokens[i]) == 0)
+			continue;
+		if (j == elem) {
+			hal_device_property_set_bool (d, key, strcmp (tokens[i], expected) == 0);
+			res = TRUE;
+			goto out;
+		}
+		j++;
+	}
+
+
+out:
+	if (tokens != NULL)
+		g_strfreev (tokens);
+
+	return res;
+}

Index: util.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/util.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- util.h	23 Jan 2005 23:11:59 -0000	1.2
+++ util.h	1 Feb 2005 05:17:55 -0000	1.3
@@ -27,6 +27,7 @@
 #define UTIL_H
 
 #include "../device.h"
+#include "../device_store.h"
 
 gboolean hal_util_remove_trailing_slash (gchar *path);
 
@@ -34,7 +35,7 @@
 
 const gchar *hal_util_get_last_element (const gchar *s);
 
-gchar *hal_util_get_parent_sysfs_path (const gchar *path);
+gchar *hal_util_get_parent_path (const gchar *path);
 
 gboolean hal_util_get_device_file (const gchar *sysfs_path, gchar *dev_file, gsize dev_file_length);
 
@@ -59,6 +60,20 @@
 gboolean hal_util_path_ascend (gchar *path);
 
 
+gchar *hal_util_grep_file (const gchar *directory, const gchar *file, const gchar *linestart);
+
+gboolean hal_util_set_string_elem_from_file (HalDevice *d, const gchar *key, 
+					     const gchar *directory, const gchar *file, 
+					     const gchar *linestart, guint elem);
+
+gboolean hal_util_set_int_elem_from_file (HalDevice *d, const gchar *key, 
+					  const gchar *directory, const gchar *file, 
+					  const gchar *linestart, guint elem);
+
+gboolean hal_util_set_bool_elem_from_file (HalDevice *d, const gchar *key, 
+					   const gchar *directory, const gchar *file, 
+					   const gchar *linestart, guint elem, const gchar *expected);
+
 typedef void (*HelperTerminatedCB)(HalDevice *d, gboolean timed_out, gint return_code, gpointer data1, gpointer data2);
 
 gboolean helper_invoke (const gchar *path, HalDevice *d, gpointer data1, gpointer data2, HelperTerminatedCB cb, guint timeout);




More information about the hal-commit mailing list