~mmach/netext73/lm-sensors

« back to all changes in this revision

Viewing changes to lib/data.h

  • Committer: mmach
  • Date: 2020-02-05 20:28:34 UTC
  • Revision ID: netbit73@gmail.com-20200205202834-zc3sla47j9e700w5
3.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
    Copyright (C) 2007-2010   Jean Delvare <jdelvare@suse.de>
 
5
 
 
6
    This library is free software; you can redistribute it and/or
 
7
    modify it under the terms of the GNU Lesser General Public
 
8
    License as published by the Free Software Foundation; either
 
9
    version 2.1 of the License, or (at your option) any later version.
 
10
 
 
11
    This library is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU Lesser General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
19
    MA 02110-1301 USA.
 
20
*/
 
21
 
 
22
#ifndef LIB_SENSORS_DATA_H
 
23
#define LIB_SENSORS_DATA_H
 
24
 
 
25
#include "sensors.h"
 
26
#include "general.h"
 
27
 
 
28
/* This header file contains all kinds of data structures which are used
 
29
   for the representation of the config file data and the sensors
 
30
   data. */
 
31
 
 
32
/* Kinds of expression operators recognized */
 
33
typedef enum sensors_operation {
 
34
        sensors_add, sensors_sub, sensors_multiply, sensors_divide,
 
35
        sensors_negate, sensors_exp, sensors_log,
 
36
} sensors_operation;
 
37
 
 
38
/* An expression can have several forms */
 
39
typedef enum sensors_expr_kind {
 
40
        sensors_kind_val, sensors_kind_source, sensors_kind_var,
 
41
        sensors_kind_sub
 
42
} sensors_expr_kind;
 
43
 
 
44
/* An expression. It is either a floating point value, a variable name,
 
45
   an operation on subexpressions, or the special value 'sub' } */
 
46
struct sensors_expr;
 
47
 
 
48
typedef struct sensors_subexpr {
 
49
        sensors_operation op;
 
50
        struct sensors_expr *sub1;
 
51
        struct sensors_expr *sub2;
 
52
} sensors_subexpr;
 
53
 
 
54
typedef struct sensors_expr {
 
55
        sensors_expr_kind kind;
 
56
        union {
 
57
                double val;
 
58
                char *var;
 
59
                sensors_subexpr subexpr;
 
60
        } data;
 
61
} sensors_expr;
 
62
 
 
63
/* Config file line reference */
 
64
typedef struct sensors_config_line {
 
65
        const char *filename;
 
66
        int lineno;
 
67
} sensors_config_line;
 
68
 
 
69
/* Config file label declaration: a feature name, combined with the label
 
70
   value */
 
71
typedef struct sensors_label {
 
72
        char *name;
 
73
        char *value;
 
74
        sensors_config_line line;
 
75
} sensors_label;
 
76
 
 
77
/* Config file set declaration: a subfeature name, combined with an
 
78
   expression */
 
79
typedef struct sensors_set {
 
80
        char *name;
 
81
        sensors_expr *value;
 
82
        sensors_config_line line;
 
83
} sensors_set;
 
84
 
 
85
/* Config file compute declaration: a feature name, combined with two
 
86
   expressions */
 
87
typedef struct sensors_compute {
 
88
        char *name;
 
89
        sensors_expr *from_proc;
 
90
        sensors_expr *to_proc;
 
91
        sensors_config_line line;
 
92
} sensors_compute;
 
93
 
 
94
/* Config file ignore declaration: a feature name */
 
95
typedef struct sensors_ignore {
 
96
        char *name;
 
97
        sensors_config_line line;
 
98
} sensors_ignore;
 
99
 
 
100
/* A list of chip names, used to represent a config file chips declaration */
 
101
typedef struct sensors_chip_name_list {
 
102
        sensors_chip_name *fits;
 
103
        int fits_count;
 
104
        int fits_max;
 
105
} sensors_chip_name_list;
 
106
 
 
107
/* A config file chip block */
 
108
typedef struct sensors_chip {
 
109
        sensors_chip_name_list chips;
 
110
        sensors_label *labels;
 
111
        int labels_count;
 
112
        int labels_max;
 
113
        sensors_set *sets;
 
114
        int sets_count;
 
115
        int sets_max;
 
116
        sensors_compute *computes;
 
117
        int computes_count;
 
118
        int computes_max;
 
119
        sensors_ignore *ignores;
 
120
        int ignores_count;
 
121
        int ignores_max;
 
122
        sensors_config_line line;
 
123
} sensors_chip;
 
124
 
 
125
/* Config file bus declaration: the bus type and number, combined with adapter
 
126
   name */
 
127
typedef struct sensors_bus {
 
128
        char *adapter;
 
129
        sensors_bus_id bus;
 
130
        sensors_config_line line;
 
131
} sensors_bus;
 
132
 
 
133
/* Internal data about all features and subfeatures of a chip */
 
134
typedef struct sensors_chip_features {
 
135
        struct sensors_chip_name chip;
 
136
        struct sensors_feature *feature;
 
137
        struct sensors_subfeature *subfeature;
 
138
        int feature_count;
 
139
        int subfeature_count;
 
140
} sensors_chip_features;
 
141
 
 
142
extern char **sensors_config_files;
 
143
extern int sensors_config_files_count;
 
144
extern int sensors_config_files_max;
 
145
 
 
146
#define sensors_add_config_files(el) sensors_add_array_el( \
 
147
        (el), &sensors_config_files, &sensors_config_files_count, \
 
148
        &sensors_config_files_max, sizeof(char *))
 
149
 
 
150
extern sensors_chip *sensors_config_chips;
 
151
extern int sensors_config_chips_count;
 
152
extern int sensors_config_chips_subst;
 
153
extern int sensors_config_chips_max;
 
154
 
 
155
extern sensors_bus *sensors_config_busses;
 
156
extern int sensors_config_busses_count;
 
157
extern int sensors_config_busses_max;
 
158
 
 
159
extern sensors_chip_features *sensors_proc_chips;
 
160
extern int sensors_proc_chips_count;
 
161
extern int sensors_proc_chips_max;
 
162
 
 
163
#define sensors_add_proc_chips(el) sensors_add_array_el( \
 
164
        (el), &sensors_proc_chips, &sensors_proc_chips_count,\
 
165
        &sensors_proc_chips_max, sizeof(struct sensors_chip_features))
 
166
 
 
167
extern sensors_bus *sensors_proc_bus;
 
168
extern int sensors_proc_bus_count;
 
169
extern int sensors_proc_bus_max;
 
170
 
 
171
#define sensors_add_proc_bus(el) sensors_add_array_el( \
 
172
        (el), &sensors_proc_bus, &sensors_proc_bus_count,\
 
173
        &sensors_proc_bus_max, sizeof(struct sensors_bus))
 
174
 
 
175
/* Substitute configuration bus numbers with real-world bus numbers
 
176
   in the chips lists */
 
177
int sensors_substitute_busses(void);
 
178
 
 
179
 
 
180
/* Parse a bus id into its components. Returns 0 on success, a value from
 
181
   error.h on failure. */
 
182
int sensors_parse_bus_id(const char *name, sensors_bus_id *bus);
 
183
 
 
184
#endif /* def LIB_SENSORS_DATA_H */