1 /***************************************************************************
3 * probe-acpi.c : Probe for ACPI device information
5 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms.
8 * Licensed under the Academic Free License version 2.1
10 **************************************************************************/
22 #include <sys/ioctl.h>
29 #include "../utils/acpi.h"
32 main(int argc
, char *argv
[])
37 char device_file
[HAL_PATH_MAX
] = "/devices";
39 LibHalContext
*ctx
= NULL
;
42 if ((udi
= getenv("UDI")) == NULL
)
44 if ((devfs_path
= getenv("HAL_PROP_SOLARIS_DEVFS_PATH")) == NULL
)
46 strlcat(device_file
, devfs_path
, HAL_PATH_MAX
);
50 dbus_error_init(&error
);
51 if ((ctx
= libhal_ctx_init_direct(&error
)) == NULL
)
54 HAL_DEBUG(("Doing probe-acpi for %s (udi=%s)",
57 if ((fd
= open(device_file
, O_RDONLY
| O_NONBLOCK
)) < 0) {
58 HAL_DEBUG(("Cannot open %s: %s", device_file
, strerror(errno
)));
61 if (strstr(udi
, "_ac")) {
62 ac_adapter_update(ctx
, udi
, fd
);
63 } else if (strstr(udi
, "_battery")) {
64 battery_update(ctx
, udi
, fd
);
65 } else if (strstr(udi
, "_lid")) {
66 lid_update(ctx
, udi
, fd
);
67 } else if (strstr(udi
, "_hotkey")) {
68 laptop_panel_update(ctx
, udi
, fd
);
79 libhal_ctx_shutdown(ctx
, &error
);
81 if (dbus_error_is_set(&error
)) {
82 dbus_error_free(&error
);