root/lm-sensors/trunk/lib/libsensors.3 @ 5654

Revision 5654, 9.4 KB (checked in by khali, 4 years ago)

Document error-related functions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1.\" Copyright (C) 1998, 1999  Adrian Baugh <adrian.baugh@keble.ox.ac.uk>
2.\" Copyright (C) 2007, 2009  Jean Delvare <khali@linux-fr.org>
3.\" based on sensors.h, part of libsensors by Frodo Looijaard
4.\" libsensors is distributed under the GPL
5.\"
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one
14.\"
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date.  The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
18.\" the use of the information contained herein.  The author(s) may not
19.\" have taken the same level of care in the production of this manual,
20.\" which is licensed free of charge, as they might when working
21.\" professionally.
22.\"
23.\" Formatted or processed versions of this manual, if unaccompanied by
24.\" the source, must acknowledge the copyright and authors of this work.
25.\"
26.\" References consulted:
27.\"     libsensors source code
28.TH libsensors 3  "February 2009" "lm-sensors 3" "Linux Programmer's Manual"
29
30.SH NAME
31libsensors \- publicly accessible functions provided by the sensors library
32
33.SH SYNOPSIS
34.nf
35.B #include <sensors/sensors.h>
36
37/* Library initialization and clean-up */
38.BI "int sensors_init(FILE *" input ");"
39.B void sensors_cleanup(void);
40.BI "const char *" libsensors_version ";"
41
42/* Chip name handling */
43.BI "int sensors_parse_chip_name(const char *" orig_name ","
44.BI "                            sensors_chip_name *" res ");"
45.BI "int sensors_snprintf_chip_name(char *" str ", size_t " size ","
46.BI "                               const sensors_chip_name *" chip ");"
47.BI "const char *sensors_get_adapter_name(const sensors_bus_id *" bus ");"
48
49/* Chips and features enumeration */
50.B const sensors_chip_name *
51.BI "sensors_get_detected_chips(const sensors_chip_name *" match ","
52.BI "                           int *" nr ");"
53.B const sensors_feature *
54.BI "sensors_get_features(const sensors_chip_name *" name ","
55.BI "                     int *" nr ");"
56.B const sensors_subfeature *
57.BI "sensors_get_all_subfeatures(const sensors_chip_name *" name ","
58.BI "                            const sensors_feature *" feature ","
59.BI "                            int *" nr ");"
60.B const sensors_subfeature *
61.BI "sensors_get_subfeature(const sensors_chip_name *" name ","
62.BI "                       const sensors_feature *" feature ","
63.BI "                       sensors_subfeature_type " type ");"
64
65/* Features access */
66.BI "char *sensors_get_label(const sensors_chip_name *" name ","
67.BI "                        const sensors_feature *" feature ");"
68.BI "int sensors_get_value(const sensors_chip_name *" name ", int " subfeat_nr ","
69.BI "                      double *" value ");"
70.BI "int sensors_set_value(const sensors_chip_name *" name ", int " subfeat_nr ","
71.BI "                      double " value ");"
72.BI "int sensors_do_chip_sets(const sensors_chip_name *" name ");"
73
74.B #include <sensors/error.h>
75
76/* Error decoding */
77.BI "const char *sensors_strerror(int " errnum ");"
78
79/* Error handlers */
80.BI "void (*sensors_parse_error) (const char *" err ", int " lineno ");"
81.BI "void (*sensors_parse_error_wfn) (const char *" err ","
82.BI "                                 const char *" filename ", int " lineno ");"
83.BI "void (*sensors_fatal_error) (const char *" proc ", const char *" err ");"
84.fi
85
86.SH DESCRIPTION
87.B sensors_init()
88loads the configuration file and the detected chips list. If this returns a
89value unequal to zero, you are in trouble; you can not assume anything will
90be initialized properly. If you want to reload the configuration file, call
91sensors_cleanup() below before calling sensors_init() again.
92
93If FILE is NULL, the default configuration files are used (see the FILES
94section below). Most applications will want to do that.
95
96.B sensors_cleanup()
97cleans everything up: you can't access anything after this, until the next sensors_init() call!
98
99.B libsensors_version
100is a string representing the version of libsensors.
101
102.B sensors_parse_chip_name()
103parses a chip name to the internal representation. Return 0 on success,
104<0 on error.
105
106.B sensors_snprintf_chip_name()
107prints a chip name from its internal representation. Note that chip should
108not contain wildcard values! Return the number of characters printed on
109success (same as snprintf), <0 on error.
110
111.B sensors_get_adapter_name()
112returns the adapter name of a bus number, as used within the
113sensors_chip_name structure. If it could not be found, it returns NULL.
114
115.B sensors_get_detected_chips()
116returns all detected chips that match a given chip name,
117one by one. If no chip name is provided, all detected chips are returned.
118To start at the beginning of the list, use 0 for nr; NULL is returned if
119we are at the end of the list. Do not try to change these chip names, as
120they point to internal structures!
121
122.B sensors_get_features()
123returns all main features of a specific chip. nr is an internally
124used variable. Set it to zero to start at the begin of the list. If no
125more features are found NULL is returned.
126Do not try to change the returned structure; you will corrupt internal
127data structures.
128
129.B sensors_get_all_subfeatures()
130returns all subfeatures of a given main feature. nr is an internally
131used variable. Set it to zero to start at the begin of the list. If no
132more subfeatures are found NULL is returned.
133Do not try to change the returned structure; you will corrupt internal
134data structures.
135
136.B sensors_get_subfeature()
137returns the subfeature of the given type for a given main feature,
138if it exists, NULL otherwise.
139Do not try to change the returned structure; you will corrupt internal
140data structures.
141
142.B sensors_get_label()
143looks up the label which belongs to this chip. Note that chip should not
144contain wildcard values! The returned string is newly allocated (free it
145yourself). On failure, NULL is returned.
146If no label exists for this feature, its name is returned itself.
147
148.B sensors_get_value()
149Reads the value of a subfeature of a certain chip. Note that chip should not
150contain wildcard values! This function will return 0 on success, and <0 on
151failure.
152
153.B sensors_set_value()
154sets the value of a subfeature of a certain chip. Note that chip should not
155contain wildcard values! This function will return 0 on success, and <0 on
156failure.
157
158.B sensors_do_chip_sets()
159executes all set statements for this particular chip. The chip may contain
160wildcards!  This function will return 0 on success, and <0 on failure.
161
162.B sensors_strerror()
163returns a pointer to a string which describes the error.
164errnum may be negative (the corresponding positive error is returned).
165You may not modify the result!
166
167.B sensors_parse_error()
168and
169.B sensors_parse_error_wfn()
170are functions which are called when a parse error is detected. Give them
171new values, and your own functions are called instead of the default (which
172print to stderr). These functions may terminate the program, but they
173usually output an error and return. The first function is the original
174one, the second one was added later when support for multiple
175configuration files was added.
176The library code now only calls the second function. However, for
177backwards compatibility, if an application provides a custom handling
178function for the first function but not the second, then all parse
179errors will be reported using the first function (that is, the filename
180is never reported.)
181Note that filename can be NULL (if filename isn't known) and lineno
182can be 0 (if the error occurs before the actual parsing starts.)
183
184.B sensors_fatal_error()
185Is a function which is called when an immediately fatal error (like no
186memory left) is detected. Give it a new value, and your own function
187is called instead of the default (which prints to stderr and ends
188the program). Never let it return!
189
190.SH DATA STRUCTURES
191
192Structure \fBsensors_feature\fR contains information related to a given
193feature of a specific chip:
194
195\fBtypedef struct sensors_feature {
196.br
197        const char *name;
198.br
199        int number;
200.br
201        sensors_feature_type type;
202.br
203} sensors_feature;\fP
204
205There are other members not documented here, which are only meant for
206libsensors internal use.
207
208Structure \fBsensors_subfeature\fR contains information related to a given
209subfeature of a specific chip feature:
210
211\fBtypedef struct sensors_subfeature {
212.br
213        const char *name;
214.br
215        int number;
216.br
217        sensors_subfeature_type type;
218.br
219        int mapping;
220.br
221        unsigned int flags;
222.br
223} sensors_subfeature;\fP
224
225The flags field is a bitfield, its value is a combination of
226\fBSENSORS_MODE_R\fR (readable), \fBSENSORS_MODE_W\fR (writable) and
227\fBSENSORS_COMPUTE_MAPPING\fR (affected by the computation rules of the
228main feature).
229
230.SH FILES
231.I /etc/sensors3.conf
232.br
233.I /etc/sensors.conf
234.RS
235The system-wide
236.BR libsensors (3)
237configuration file. /etc/sensors3.conf is tried first, and if it doesn't exist,
238/etc/sensors.conf is used instead.
239.RE
240
241.I /etc/sensors.d
242.RS
243A directory where you can put additional libsensors configuration files.
244Files found in this directory will be processed in alphabetical order after
245the default configuration file. Files with names that start with a dot are
246ignored.
247.RE
248
249.SH SEE ALSO
250sensors.conf(5)
251
252.SH AUTHOR
253Frodo Looijaard and the lm_sensors group
254http://www.lm-sensors.org/
255
Note: See TracBrowser for help on using the browser.