hal/hald/linux2/addons Makefile.am,1.1,1.2 addon-acpi.c,NONE,1.1
David Zeuthen
david at freedesktop.org
Tue Feb 8 08:44:22 PST 2005
- Previous message: hal/hald Makefile.am, 1.41, 1.42 hald.c, 1.22, 1.23 property.c, 1.9,
1.10 run-hald.sh, 1.1, 1.2 util.c, NONE, 1.1 util.h, NONE, 1.1
- Next message: hal/hald/linux2 Makefile.am, 1.6, 1.7 acpi.c, 1.4, 1.5 apm.c, 1.1,
1.2 blockdev.c, 1.1, 1.2 classdev.c, 1.8, 1.9 coldplug.c, 1.6,
1.7 hotplug.c, 1.7, 1.8 osspec.c, 1.7, 1.8 physdev.c, 1.5,
1.6 pmu.c, 1.1, 1.2 util.c, 1.6, NONE util.h, 1.5, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/hald/linux2/addons
In directory gabe:/tmp/cvs-serv19159/hald/linux2/addons
Modified Files:
Makefile.am
Added Files:
addon-acpi.c
Log Message:
2005-02-08 David Zeuthen <davidz at redhat.com>
* hald/run-hald.sh: Update to include a few more paths
* hald/linux2/addons/Makefile.am: Add build rules for hald-addon-acpi
* hald/linux2/addons/addon-acpi.c: New file
* hald/linux2/pmu.c (pmu_synthesize_hotplug_events): Also look for
computer in the TDL
* hald/linux2/osspec.c (computer_callouts_add_done): New function
(osspec_probe): Run callouts for computer
* hald/linux2/classdev.c (add_classdev_probing_helper_done): Fix up
for the new helper
* hald/linux2/apm.c (apm_synthesize_hotplug_events): Also look for
computer in the TDL
* hald/linux2/acpi.c (acpi_synthesize_hotplug_events): Also look for
computer in the TDL
(acpi_generic_remove): Don't remove the device
(acpi_callouts_add_done): New function
(acpi_callouts_remove_done): New function
(hotplug_event_begin_add_acpi): Run add callouts
(hotplug_event_begin_remove_acpi): Run remove callouts
* hald/property.c (hal_property_to_string): Add code for string lists
* hald/hald.c (addon_terminated): New function
(gdl_store_changed): Run addons
(gdl_property_changed): Don't run property.d callouts
(gdl_capability_added): Don't run capability.d callouts
* hald/util.h: Move from hald/linux2 since this is generic.
Export the HalHelperData structure when doing
hal_util_helper invoke. Add prototypes for hal_util_terminate_
helper, hal_util_dup_strv_from_g_slist,
hal_util_callout_device_add, hal_util_callout_device_remove.
* hald/util.c: Move from hald/linux2 since this is generic.
(hal_util_terminate_helper): New function
(hal_util_helper_invoke): Renamed from helper_invoke. Accept
command line parameters (through g_shell_parse_argv). Accept a
strv of extra environement to set. Introduce that timeout==0 means
no timeout. Return the HalHelperData structure
(hal_util_dup_strv_from_g_slist): New convenience function; create
a new NULL-terminated string vector from a GSList of strings.
(callout_terminated): New function
(callout_do_next): New function
(hal_callout_device): New function
(hal_util_callout_device_add): New function
(hal_util_callout_device_remove): New function
* hald/linux2/util.[ch]: Remove
* hald/callout.[ch]: Remove since this functionality is now in util.[ch]
* hald/Makefile.am: Add util.[ch]
* hald/linux2/Makefile.am: Remove util.[ch]
Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/addons/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am 4 Feb 2005 05:24:25 -0000 1.1
+++ Makefile.am 8 Feb 2005 16:44:20 -0000 1.2
@@ -8,11 +8,15 @@
-I$(top_srcdir) \
@PACKAGE_CFLAGS@
-libexec_PROGRAMS = hald-addon-hid-ups
+libexec_PROGRAMS = hald-addon-hid-ups hald-addon-acpi
hald_addon_hid_ups_SOURCES = addon-hid-ups.c
hald_addon_hid_ups_LDADD = $(top_builddir)/libhal/libhal.la
+hald_addon_acpi_SOURCES = addon-acpi.c
+hald_addon_acpi_LDADD = $(top_builddir)/libhal/libhal.la
+
+
--- NEW FILE: addon-acpi.c ---
/***************************************************************************
* CVSID: $Id: addon-acpi.c,v 1.1 2005/02/08 16:44:20 david Exp $
*
* addon-acpi.c : Listen to ACPI events and modify hal device objects
*
* Copyright (C) 2005 David Zeuthen, <david at fubar.dk>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
#include "libhal/libhal.h"
#define MAX_BUFLEN 1024
static char *
read_line(int fd)
{
static char *buf;
int buflen = 64;
int i = 0;
int r;
int searching = 1;
while (searching) {
buf = realloc(buf, buflen);
if (!buf) {
fprintf(stderr, "ERR: malloc(%d): %s\n",
buflen, strerror(errno));
return NULL;
}
memset(buf+i, 0, buflen-i);
while (i < buflen) {
r = read(fd, buf+i, 1);
if (r < 0 && errno != EINTR) {
/* we should do something with the data */
fprintf(stderr, "ERR: read(): %s\n",
strerror(errno));
return NULL;
} else if (r == 0) {
/* signal this in an almost standard way */
errno = EPIPE;
return NULL;
} else if (r == 1) {
/* scan for a newline */
if (buf[i] == '\n') {
searching = 0;
buf[i] = '\0';
break;
}
i++;
}
}
if (buflen >= MAX_BUFLEN) {
break;
}
buflen *= 2;
}
return buf;
}
int
main (int argc, char *argv[])
{
int fd;
struct sockaddr_un addr;
LibHalContext *ctx = NULL;
DBusError error;
DBusConnection *conn;
char buf[256];
dbus_error_init (&error);
if ((conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error)) == NULL)
goto out;
if ((ctx = libhal_ctx_new ()) == NULL)
goto out;
if (!libhal_ctx_set_dbus_connection (ctx, conn))
goto out;
if (!libhal_ctx_init (ctx, &error))
goto out;
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
return fd;
}
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
/*sprintf(addr.sun_path, "%s", "/proc/acpi/socket");*/
sprintf(addr.sun_path, "%s", "/var/run/acpid.socket");
if (connect (fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
goto out;
}
/* main loop */
while (1) {
char *event;
/* read and handle an event */
event = read_line (fd);
if (event) {
fprintf(stdout, "%s\n", event);
} else if (errno == EPIPE) {
fprintf(stderr, "connection closed\n");
break;
}
/* TODO: handle event and do stuff */
}
out:
if (fd >= 0)
close (fd);
return 0;
}
- Previous message: hal/hald Makefile.am, 1.41, 1.42 hald.c, 1.22, 1.23 property.c, 1.9,
1.10 run-hald.sh, 1.1, 1.2 util.c, NONE, 1.1 util.h, NONE, 1.1
- Next message: hal/hald/linux2 Makefile.am, 1.6, 1.7 acpi.c, 1.4, 1.5 apm.c, 1.1,
1.2 blockdev.c, 1.1, 1.2 classdev.c, 1.8, 1.9 coldplug.c, 1.6,
1.7 hotplug.c, 1.7, 1.8 osspec.c, 1.7, 1.8 physdev.c, 1.5,
1.6 pmu.c, 1.1, 1.2 util.c, 1.6, NONE util.h, 1.5, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list