hal/hald/linux2 util.c,1.3,1.4 util.h,1.3,1.4

David Zeuthen david at freedesktop.org
Mon Jan 31 21:50:42 PST 2005


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

Modified Files:
	util.c util.h 
Log Message:
2005-02-01  David Zeuthen  <davidz at redhat.com>

	Patch from Pierre Ossman <drzeus-list at drzeus.cx>.

	* hald/linux2/util.c (hal_util_get_string_from_file): New function
	(hal_util_set_string_from_file): Use the new function mentioned above



Index: util.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/util.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.c	1 Feb 2005 05:17:55 -0000	1.3
+++ util.c	1 Feb 2005 05:50:40 -0000	1.4
@@ -473,17 +473,17 @@
 	return ret;
 }
 
-gboolean
-hal_util_set_string_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file)
+gchar *
+hal_util_get_string_from_file (const gchar *directory, const gchar *file)
 {
 	FILE *f;
-	gchar buf[256];
+	static gchar buf[256];
 	gchar path[HAL_PATH_MAX];
-	gboolean ret;
+	gchar *result;
 	gsize len;
-
+	
 	f = NULL;
-	ret = FALSE;
+	result = NULL;
 
 	g_snprintf (path, sizeof (path), "%s/%s", directory, file);
 
@@ -502,12 +502,26 @@
 	if (len>0)
 		buf[len-1] = '\0';
 
-	ret = hal_device_property_set_string (d, key, buf);
+	result = buf;
 
 out:
 	if (f != NULL)
 		fclose (f);
 
+	return result;
+}
+
+gboolean
+hal_util_set_string_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file)
+{
+	gchar *buf;
+	gboolean ret;
+
+	ret = FALSE;
+
+	if ((buf = hal_util_get_string_from_file (directory, file)) != NULL)
+		ret = hal_device_property_set_string (d, key, buf);
+
 	return ret;
 }
 

Index: util.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/util.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.h	1 Feb 2005 05:17:55 -0000	1.3
+++ util.h	1 Feb 2005 05:50:40 -0000	1.4
@@ -47,6 +47,8 @@
 
 gboolean hal_util_set_int_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file, gint base);
 
+gchar *hal_util_get_string_from_file (const gchar *directory, const gchar *file);
+
 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);




More information about the hal-commit mailing list