root/lm-sensors/branches/lm-sensors-3.0.0/lib/data.h @ 4545

Revision 4545, 5.7 KB (checked in by khali, 7 years ago)

Add some more warning flags, and fix these warnings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2    data.h - Part of libsensors, a Linux library for reading sensor data.
3    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/
19
20#ifndef LIB_SENSORS_DATA_H
21#define LIB_SENSORS_DATA_H
22
23#include "sensors.h"
24
25/* This header file contains all kinds of data structures which are used
26   for the representation of the config file data and the /proc/...
27   data. */
28
29/* Kinds of expression operators recognized */
30typedef enum sensors_operation { 
31  sensors_add, sensors_sub, sensors_multiply, sensors_divide, 
32  sensors_negate, sensors_exp, sensors_log } sensors_operation;
33
34/* An expression can have several forms */
35typedef enum sensors_expr_kind {
36  sensors_kind_val, sensors_kind_source, sensors_kind_var, 
37  sensors_kind_sub } sensors_expr_kind;
38
39/* An expression. It is either a floating point value, a variable name,
40   an operation on subexpressions, or the special value 'sub' } */
41struct sensors_expr;
42
43typedef struct sensors_subexpr {
44  sensors_operation op;
45  struct sensors_expr *sub1;
46  struct sensors_expr *sub2;
47} sensors_subexpr;
48
49typedef struct sensors_expr {
50  sensors_expr_kind kind;
51  union {
52    double val;
53    char *var;
54    sensors_subexpr subexpr;
55  } data;
56} sensors_expr;
57
58/* Config file label declaration: a feature name, combined with the label
59   value */
60typedef struct sensors_label {
61  char *name;
62  char *value;
63  int lineno;
64} sensors_label;
65
66/* Config file set declaration: a feature name, combined with an expression */
67typedef struct sensors_set {
68  char *name;
69  sensors_expr *value;
70  int lineno;
71} sensors_set;
72
73/* Config file compute declaration: a feature name, combined with two
74   expressions */
75typedef struct sensors_compute {
76  char *name;
77  sensors_expr *from_proc;
78  sensors_expr *to_proc;
79  int lineno;
80} sensors_compute;
81
82/* Config file ignore declaration: a feature name */
83typedef struct sensors_ignore {
84  char *name;
85  int lineno;
86} sensors_ignore;
87
88/* A list of chip names, used to represent a config file chips declaration */
89typedef struct sensors_chip_name_list {
90  sensors_chip_name *fits;
91  int fits_count;
92  int fits_max;
93} sensors_chip_name_list;
94
95/* A config file chip block */
96typedef struct sensors_chip {
97  sensors_chip_name_list chips;
98  sensors_label *labels;
99  int labels_count;
100  int labels_max;
101  sensors_set *sets;
102  int sets_count;
103  int sets_max;
104  sensors_compute *computes;
105  int computes_count;
106  int computes_max;
107  sensors_ignore *ignores;
108  int ignores_count;
109  int ignores_max;
110  int lineno;
111} sensors_chip;
112
113/* Config file bus declaration: the i2c bus number, combined with adapter
114   name */
115typedef struct sensors_bus {
116  int number;
117  char *adapter;
118  int lineno;
119} sensors_bus;
120
121/* Internal data about a single chip feature.
122   name is the string name used to refer to this feature (both in config
123     files and through user functions);
124   number is the internal feature number, used in many functions to refer
125     to this feature
126   logical_mapping is either SENSORS_NO_MAPPING if this is feature is the
127     main element of category; or it is the number of a feature with which
128     this feature is logically grouped (a group could be fan, fan_max and
129     fan_div)
130   compute_mapping is like logical_mapping, only it refers to another
131     feature whose compute line will be inherited (a group could be fan and
132     fan_max, but not fan_div)
133   mode is SENSORS_MODE_NO_RW, SENSORS_MODE_R, SENSORS_MODE_W or
134     SENSORS_MODE_RW, for unaccessible, readable, writable, and both readable
135     and writable.
136   scaling is the number of decimal points to scale by.
137     Divide the read value by 10**scaling to get the real value. */
138typedef struct sensors_chip_feature {
139  sensors_feature_data data;
140  int scaling;
141} sensors_chip_feature;
142
143/* Internal data about all features of a type of chip */
144typedef struct sensors_chip_features {
145  struct sensors_chip_name chip;
146  struct sensors_chip_feature *feature;
147} sensors_chip_features;
148
149extern sensors_chip *sensors_config_chips;
150extern int sensors_config_chips_count;
151extern int sensors_config_chips_max;
152
153extern sensors_bus *sensors_config_busses;
154extern int sensors_config_busses_count;
155extern int sensors_config_busses_max;
156
157extern sensors_chip_features *sensors_proc_chips;
158extern int sensors_proc_chips_count;
159extern int sensors_proc_chips_max;
160
161#define sensors_add_proc_chips(el) sensors_add_array_el( \
162        (el), &sensors_proc_chips, &sensors_proc_chips_count,\
163        &sensors_proc_chips_max, sizeof(struct sensors_chip_features))
164
165extern sensors_bus *sensors_proc_bus;
166extern int sensors_proc_bus_count;
167extern int sensors_proc_bus_max;
168
169#define sensors_add_proc_bus(el) sensors_add_array_el( \
170        (el), &sensors_proc_bus, &sensors_proc_bus_count,\
171        &sensors_proc_bus_max, sizeof(struct sensors_bus))
172
173/* Substitute configuration bus numbers with real-world /proc bus numbers
174   in the chips lists */
175int sensors_substitute_busses(void);
176
177
178/* Parse an i2c bus name into its components. Returns 0 on succes, a value from
179   error.h on failure. */
180int sensors_parse_i2cbus_name(const char *name, int *res);
181
182#endif /* def LIB_SENSORS_DATA_H */
Note: See TracBrowser for help on using the browser.