dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / hal / addons / acpi / addon-acpi.c
blob2f87da2bc054cc3faca72d3d93c5f6e75614f90b
1 /***************************************************************************
3 * addon-acpi.c : Poll battery and AC adapter devices and update
4 * properties
6 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
9 * Licensed under the Academic Free License version 2.1
11 **************************************************************************/
13 #pragma ident "%Z%%M% %I% %E% SMI"
15 #ifdef HAVE_CONFIG_H
16 #include <config.h>
17 #endif
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <stdlib.h>
22 #include <fcntl.h>
23 #include <sys/dkio.h>
24 #include <sys/stat.h>
25 #include <glib.h>
27 #include <libhal.h>
28 #include "../../hald/logger.h"
29 #include "../../hald/util_helper.h"
30 #include "../../utils/acpi.h"
32 int
33 main(int argc, char **argv)
35 LibHalContext *ctx = NULL;
36 DBusError error;
38 GMainLoop *loop = g_main_loop_new(NULL, FALSE);
40 drop_privileges(0);
41 setup_logger();
43 dbus_error_init(&error);
44 if ((ctx = libhal_ctx_init_direct(&error)) == NULL) {
45 printf("main(): init_direct failed\n");
46 return (0);
48 dbus_error_init(&error);
49 if (!libhal_device_addon_is_ready(ctx, getenv("UDI"), &error)) {
50 return (0);
53 g_timeout_add(BATTERY_POLL_TIMER, update_devices, ctx);
55 g_main_loop_run(loop);