8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / hal / tools / sunos / hal-system-lcd-get-brightness-sunos.c
blob5193d671e28469015d96bc5327b5e8ba05b50def
1 /***************************************************************************
3 * hal-system-lcd-get-brightness-sunos.c : Get LCD brightness
5 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6 * Use is subject to license terms.
8 * Licensed under the Academic Free License version 2.1
10 **************************************************************************/
12 #pragma ident "%Z%%M% %I% %E% SMI"
14 #ifdef HAVE_CONFIG_H
15 #include <config.h>
16 #endif
18 #include <errno.h>
19 #include <string.h>
20 #include <strings.h>
21 #include <ctype.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <sys/ioctl.h>
25 #include <fcntl.h>
26 #include <unistd.h>
27 #include "../../hald/util.h"
28 #include <sys/acpi_drv.h>
30 int
31 main(int argc, char *argv[])
33 struct acpi_drv_output_status status;
34 int fd = -1;
35 char *udi;
36 char device_file[HAL_PATH_MAX] = "/devices";
37 char *devfs_path;
39 if ((udi = getenv("UDI")) == NULL) {
40 return (-1);
42 if ((devfs_path = getenv("HAL_PROP_SOLARIS_DEVFS_PATH")) == NULL) {
43 return (-1);
46 strlcat(device_file, devfs_path, HAL_PATH_MAX);
47 fprintf(stderr, "Getting brightness on %s (udi=%s)",
48 device_file, udi);
49 if ((fd = open(device_file, O_RDONLY | O_NONBLOCK)) < 0) {
50 fprintf(stderr, "Cannot open %s: %s", device_file,
51 strerror(errno));
52 return (-1);
55 bzero(&status, sizeof (status));
56 if (ioctl(fd, ACPI_DRV_IOC_STATUS, &status) < 0) {
57 close(fd);
58 return (-1);
59 } else {
60 close(fd);
61 return (status.cur_level_index);