File: acpi.h

package info (click to toggle)
xfce4-sensors-plugin 0.10.99.5~svn-r4998-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,032 kB
  • ctags: 307
  • sloc: sh: 9,815; ansic: 3,174; makefile: 100
file content (135 lines) | stat: -rw-r--r-- 4,114 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*  Copyright 2004-2007 Fabian Nowak (timystery@arcor.de)
 *
 *  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.
 */

/* Note for programmers and editors: Try to use 4 spaces instead of Tab! */

#ifndef XFCE4_SENSORS_ACPI_H
#define XFCE4_SENSORS_ACPI_H

#define ACPI_PATH               "/proc/acpi"
#define ACPI_DIR_THERMAL        "thermal_zone"
#define ACPI_DIR_BATTERY        "battery"
#define ACPI_DIR_FAN            "fan"
#define ACPI_FILE_THERMAL       "temperature"
#define ACPI_FILE_BATTERY_STATE "state"
#define ACPI_FILE_BATTERY_INFO  "info"
#define ACPI_FILE_FAN           "state"

#define ACPI_INFO               "info_"

#include <glib/garray.h>

#include <dirent.h>    /* directory listing and reading */

#include "types.h"

/*
 * Initialize ACPI by ?
 * @Return: Number of initialized chips
 * @Param: Pointer to array of chips
 */
int initialize_ACPI (GPtrArray *chips);


/*
 * Refreshs an ACPI chip's feature in sense of raw and formatted value
 * @Param chip_feature: Pointer to feature
 */
void refresh_acpi (gpointer chip_feature, gpointer data);


/*
 * Read a double value from zone. Calls get_acpi_value with prolonged path.
 * @Param zone: zone name under /proc/acpi including the subdir for one zone.
 * @Param file: file to read information from, e.g. info.
 * @Return: value read in first line of file after keyword and colon.
 */
double get_acpi_zone_value (char *zone, char *file);


/*
 * Read a double value from status file for fans.
 * When status is on, result is 1.0; else it is 0.0.
 * @Param zone: file to read information from, e.g. state.
 * @Return: valued read in any line starting with "status:", converted to 1 or 0
 */
double get_fan_zone_value (char *zone);

/*
 * Read a double value from special subzone denoted by name.
 * @Param name: name in the /pro/acpi/battery directory.
 * @Param chipfeature: pointer to chipfeature to get a max value.
 */
void get_battery_max_value (char *name, t_chipfeature *chipfeature);

/*
 * Read information from the thermal zone.
 * @Param chip: Pointer to already allocated chip, where values can be added.
 * @Return: 0 on success
 */
int read_thermal_zone (t_chip *chip);


/*
 * Read information from the battery zone.
 * @Param chip: Pointer to already allocated chip, where values can be added.
 * @Return: 0 on success
 */
int read_battery_zone (t_chip *chip);


/*
 * Read information from the fan zone.
 * @Param chip: Pointer to already allocated chip, where values can be added.
 * @Return: 0 on success
 */
int read_fan_zone (t_chip *chip);


/*
 * Returns the ACPI version number from /proc/acpi/info file.
 * @Return: versionnumber as string!
 */
char * get_acpi_info ();


/*
 * Get the string found in filename after the colon. To make a double out of
 * it, strtod is suitable.
 * @Param filename: Complete path to file to be inspected.
 * @Return: String of value found, "<Unknown>" otherwise.
 */
char * get_acpi_value (char *filename);


/*
 * Get the battery percentage from the battery information.
 * @Param zone: Complete zone path including both e.g. "battery" and "BAT0"
 * @Return double value of current battery power
 */
double get_battery_zone_value (char *zone);


/*
 * Indicates whether a given directory entry should be ignored as it's not
 *  "temperature".
 * @Param de: pointer to directory entry.
 * @Return: 1 on ignore, else 0
 */
int acpi_ignore_directory_entry (struct dirent *de);

#endif /* XFCE4_SENSORS_ACPI_H */