root/lm-sensors/tags/V2-10-4/lib/sensors.h

Revision 4287, 6.0 kB (checked in by mmh, 2 years ago)

The sensors library relied on one structure having an identical layout in
memory as part of another structure. This rather large patch fixes that by
making the smaller piece an explicit member of the larger.

I brought this patch into sync with the latest SVN, and tested it by comparing
objects files from the tree pre- and post- patch.

The remaining 99% of the credit goes to Bob Schlärmann <bob2@dsv.nl> for
creating the original patch... thanks Bob!

* Bob Schlärmann <bob2@dsv.nl> [2006-12-24 18:29:39 +0100]:

The following patch changes all of the lib/chips.c entries and any function
that uses sensors_chip_feature. Most of the conversion was done through a
perl script, so if you don't agree with the syntax it'll be easy to change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2     sensors.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_SENSORS_H
21 #define LIB_SENSORS_SENSORS_H
22
23 #include <stdio.h>
24
25 /* Publicly accessible library functions */
26
27 #define SENSORS_CHIP_NAME_PREFIX_ANY NULL
28 #define SENSORS_CHIP_NAME_BUS_ISA -1
29 #define SENSORS_CHIP_NAME_BUS_ANY -2
30 #define SENSORS_CHIP_NAME_BUS_ANY_I2C -3
31 #define SENSORS_CHIP_NAME_BUS_DUMMY -4
32 #define SENSORS_CHIP_NAME_BUS_PCI -5
33 #define SENSORS_CHIP_NAME_ADDR_ANY -1
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39 /* A chip name is encoded is in this structure */
40 typedef struct sensors_chip_name {
41   char *prefix;
42   int bus;
43   int addr;
44   char *busname;        /* if dummy */
45 } sensors_chip_name;
46
47 /* (Re)load the configuration file and the detected chips list. If this
48     returns a value unequal to zero, you are in trouble; you can not
49     assume anything will be initialized properly. */
50 extern int sensors_init(FILE *input);
51
52 /* Clean-up function: You can't access anything after
53    this, until the next sensors_init() call! */
54 extern void sensors_cleanup(void);
55
56 /* Parse a chip name to the internal representation. Return 0 on succes, <0
57    on error. */
58 extern int sensors_parse_chip_name(const char *orig_name,
59                                    sensors_chip_name *res);
60
61 /* Compare two chips name descriptions, to see whether they could match.
62    Return 0 if it does not match, return 1 if it does match. */
63 extern int sensors_match_chip(sensors_chip_name chip1,
64                               sensors_chip_name chip2);
65
66 /* Check whether the chip name is an 'absolute' name, which can only match
67    one chip, or whether it has wildcards. Returns 0 if it is absolute, 1
68    if there are wildcards. */
69 extern int sensors_chip_name_has_wildcards(sensors_chip_name chip);
70
71 /* This function returns the adapter name of a bus number,
72    as used within the sensors_chip_name structure. If it could not be found,
73    it returns NULL */
74 extern const char *sensors_get_adapter_name(int bus_nr);
75
76 /* This function is deprecated and will be dropped soon. */
77 extern const char *sensors_get_algorithm_name(int bus_nr);
78
79 /* Look up the label which belongs to this chip. Note that chip should not
80    contain wildcard values! *result is newly allocated (free it yourself).
81    This function will return 0 on success, and <0 on failure.  This
82    function takes logical mappings into account. */
83 extern int sensors_get_label(sensors_chip_name name, int feature,
84                              char **result);
85
86 /* Looks up whether a feature should be ignored. Returns <0 on failure,
87    0 if it should be ignored, 1 if it is valid. This function takes
88    logical mappings into account. */
89 extern int sensors_get_ignored(sensors_chip_name name, int fature);
90
91 /* Read the value of a feature of a certain chip. Note that chip should not
92    contain wildcard values! This function will return 0 on success, and <0
93    on failure.  */
94 extern int sensors_get_feature(sensors_chip_name name, int feature,
95                                double *result);
96
97 /* Set the value of a feature of a certain chip. Note that chip should not
98    contain wildcard values! This function will return 0 on success, and <0
99    on failure. */
100 extern int sensors_set_feature(sensors_chip_name name, int feature,
101                                double value);
102
103 /* Execute all set statements for this particular chip. The chip may contain
104    wildcards!  This function will return 0 on success, and <0 on failure. */
105 extern int sensors_do_chip_sets(sensors_chip_name name);
106
107 /* Execute all set statements for all detected chips. This is the same as
108    calling sensors_do_chip_sets with an all wildcards chip name */
109 extern int sensors_do_all_sets(void);
110
111 /* This function returns all detected chips, one by one. To start at the
112    beginning of the list, use 0 for nr; NULL is returned if we are
113    at the end of the list. Do not try to change these chip names, as
114    they point to internal structures! Do not use nr for anything else. */
115 extern const sensors_chip_name *sensors_get_detected_chips(int *nr);
116
117
118 /* These defines are used in the mode field of sensors_feature_data */
119 #define SENSORS_MODE_NO_RW 0
120 #define SENSORS_MODE_R 1
121 #define SENSORS_MODE_W 2
122 #define SENSORS_MODE_RW 3
123
124 /* This define is used in the mapping field of sensors_feature_data if no
125    mapping is available */
126 #define SENSORS_NO_MAPPING -1
127
128 /* This structure is used when you want to get all features of a specific
129    chip. */
130 typedef struct sensors_feature_data {
131   int number;
132   const char *name;
133   int mapping;
134   int compute_mapping;
135   int mode;
136 } sensors_feature_data;
137
138 /* This returns all features of a specific chip. They are returned in
139    bunches: everything with the same mapping is returned just after each
140    other, with the master feature in front (that feature does not map to
141    itself, but has SENSORS_NO_MAPPING as mapping field). nr1 and nr2 are
142    two internally used variables. Set both to zero to start again at the
143    begin of the list. If no more features are found NULL is returned.
144    Do not try to change the returned structure; you will corrupt internal
145    data structures. */
146 extern const sensors_feature_data *sensors_get_all_features
147              (sensors_chip_name name, int *nr1,int *nr2);
148
149 #ifdef __cplusplus
150 }
151 #endif /* __cplusplus */
152
153 #endif /* def LIB_SENSORS_ERROR_H */
Note: See TracBrowser for help on using the browser.