forked from nemequ/vala-extra-vapis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sensors.vapi
243 lines (202 loc) · 6.33 KB
/
sensors.vapi
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* sensors.vapi
*
* Copyright (C) 2011 Nikolay Orlyuk
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Nikolay Orlyuk <[email protected]>
*/
[CCode (lower_case_cprefix = "sensors_", cheader_filename = "sensors/sensors.h")]
namespace Sensors {
[CCode (cname = "libsensors_version")]
public const string version;
[CCode (cname = "SENSORS_API_VERSION")]
public const int api;
/* Data structures */
[CCode (cname = "sensors_feature_type", cprefix = "SENSORS_FEATURE_")]
public enum FeatureType {
IN,
FAN,
TEMP,
POWER,
ENERGY,
CURR,
HUMIDITY,
MAX_MAIN,
VID,
INTRUSION,
BEEP_ENABLE,
UNKNOWN
}
[CCode (cname = "sensors_subfeature_type", cprefix = "SENSORS_SUBFEATURE_")]
public enum SubFeatureType {
IN_INPUT,
IN_MIN,
IN_MAX,
IN_LCRIT,
IN_CRIT,
IN_ALARM,
IN_MIN_ALARM,
IN_MAX_ALARM,
IN_BEEP,
IN_LCRIT_ALARM,
IN_CRIT_ALARM,
FAN_INPUT,
FAN_MIN,
FAN_ALARM,
FAN_FAULT,
FAN_DIV,
FAN_BEEP,
FAN_PULSES,
TEMP_INPUT,
TEMP_MAX,
TEMP_MAX_HYST,
TEMP_MIN,
TEMP_CRIT,
TEMP_CRIT_HYST,
TEMP_LCRIT,
TEMP_EMERGENCY,
TEMP_EMERGENCY_HYST,
TEMP_ALARM,
TEMP_MAX_ALARM,
TEMP_MIN_ALARM,
TEMP_CRIT_ALARM,
TEMP_FAULT,
TEMP_TYPE,
TEMP_OFFSET,
TEMP_BEEP,
TEMP_EMERGENCY_ALARM,
TEMP_LCRIT_ALARM,
POWER_AVERAGE,
POWER_AVERAGE_HIGHEST,
POWER_AVERAGE_LOWEST,
POWER_INPUT,
POWER_INPUT_HIGHEST,
POWER_INPUT_LOWEST,
POWER_CAP,
POWER_CAP_HYST,
POWER_MAX,
POWER_CRIT,
POWER_AVERAGE_INTERVAL,
POWER_ALARM,
POWER_CAP_ALARM,
POWER_MAX_ALARM,
POWER_CRIT_ALARM,
ENERGY_INPUT,
CURR_INPUT,
CURR_MIN,
CURR_MAX,
CURR_LCRIT,
CURR_CRIT,
CURR_ALARM,
CURR_MIN_ALARM,
CURR_MAX_ALARM,
CURR_BEEP,
CURR_LCRIT_ALARM,
CURR_CRIT_ALARM,
HUMIDITY_INPUT,
VID,
INTRUSION_ALARM,
INTRUSION_BEEP,
BEEP_ENABLE,
UNKNOWN
}
[CCode (cprefix = "SENSORS_BUS_TYPE_")]
public enum BusType {
ANY,
I2C,
ISA,
PCI,
SPI,
VIRTUAL,
ACPI,
HID
}
[CCode (cname = "SENSORS_BUS_NR_ANY")]
public const short bus_nr_any;
[CCode (cname = "SENSORS_BUS_NR_IGNORE")]
public const short bus_nr_ignore;
/* Note Feature and SubFeature refs to objects that cleaned up somewhere else */
[CCode (cname = "sensors_feature", ref_function = "", unref_function = "")]
public class Feature {
public unowned string name;
public int number;
public FeatureType type;
}
[CCode (cname = "sensors_subfeature", ref_function = "", unref_function = "")]
public class SubFeature {
public unowned string name; // I guess it should be const in library
public int number;
public SubFeatureType type;
public int mapping;
public uint flags;
}
[CCode (cname = "sensors_bus_id", lower_case_cprefix = "sensors_")]
public struct BusId {
public BusType type;
public short nr;
public unowned string get_adapter_name();
}
/* ChipName and features enumeration
Note: chips have no copy implementation, so no cast from (unowned) to (owned)
*/
[CCode (cname = "sensors_chip_name", lower_case_cprefix = "sensors_", lower_case_csuffix = "_chip_name", destroy_function = "sensors_free_chip_name")]
public struct ChipName {
[CCode (default_value = "SENSORS_CHIP_NAME_PREFIX_ANY")]
public string prefix;
public BusId bus;
[CCode (default_value = "SENSORS_CHIP_NAME_ADDR_ANY")]
public int addr;
public string path;
[CCode (cname = "sensors_parse_chip_name", instance_pos = -1)]
public ChipName(string orig_name);
[CCode (cname = "sensors_parse_chip_name", instance_pos = -1)]
public int parse(string orig_name);
[CCode (cname = "sensors_snprintf_chip_name", instance_pos = -1)]
public int snprintf(char[] buf);
public Feature? get_features(ref int nr);
[CCode (cname = "sensors_get_all_subfeatures")]
public SubFeature? get_subfeatures(Feature feature, ref int nr);
public string get_label(Feature feature);
public string? to_string()
{
int n;
{
char buf[128];
n = snprintf(buf);
if (n < 0 ) return null;
if (n <= buf.length) return (string)buf;
}
// for rare cases
var bigbuf = new char[n];
n = snprintf(bigbuf);
if (n < 0 ) return null;
if (n <= bigbuf.length) return (string)bigbuf;
}
}
/* Library initialization and clean-up */
public int init(Posix.FILE? config = null);
public int init_filename(string name)
{ return init(Posix.FILE.open(name, "r")); }
public void cleanup();
public unowned ChipName? get_detected_chips(ChipName? match, ref int nr);
public string get_label(ChipName name, Feature feature);
public int get_value(ChipName name, int subfeat_nr, out double value);
public int set_value(ChipName name, int subfeat_nr, double value);
/* Error decoding */
[CCode (cheader_file = "sensors/error.h")]
public unowned string strerror(int errnum);
}