mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-20 19:41:47 +00:00
New public library function: sensors_get_subfeature(). Applications can
use it to retrieve a specific subfeature by type. While it is slighly less efficient than looping over sensors_get_all_subfeatures(), it often makes the application code much more elegant. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4846 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
c08a168342
commit
e01466d993
5 files changed
+210
-206
No files matched your search
@@ -393,6 +393,25 @@ sensors_get_all_subfeatures(const sensors_chip_name *name,
|
||||
return NULL; /* end of subfeature list */
|
||||
}
|
||||
|
||||
const sensors_subfeature *
|
||||
sensors_get_subfeature(const sensors_chip_name *name,
|
||||
const sensors_feature *feature,
|
||||
sensors_subfeature_type type)
|
||||
{
|
||||
const sensors_chip_features *chip;
|
||||
int i;
|
||||
|
||||
if (!(chip = sensors_lookup_chip(name)))
|
||||
return NULL; /* No such chip */
|
||||
|
||||
for (i = feature->first_subfeature; i < chip->subfeature_count &&
|
||||
chip->subfeature[i].mapping == feature->number; i++) {
|
||||
if (chip->subfeature[i].type == type)
|
||||
return &chip->subfeature[i];
|
||||
}
|
||||
return NULL; /* No such subfeature */
|
||||
}
|
||||
|
||||
/* Evaluate an expression */
|
||||
int sensors_eval_expr(const sensors_chip_features *chip_features,
|
||||
const sensors_expr *expr,
|
||||
|
||||
@@ -46,6 +46,7 @@ libsensors \- publicly accessible functions provided by the sensors library
|
||||
\fB*match, int *nr);\fP
|
||||
.B const sensors_feature *sensors_get_features(const sensors_chip_name *name, int *nr);\fP
|
||||
.B const sensors_subfeature *sensors_get_all_subfeatures(const sensors_chip_name *name, const sensors_feature *feature, int *nr);\fP
|
||||
.B const sensors_subfeature *sensors_get_subfeature(const sensors_chip_name *name, const sensors_feature *feature, sensors_subfeature_type type);\fP
|
||||
.B const char *libsensors_version;
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
@@ -140,6 +141,13 @@ more subfeatures are found NULL is returned.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures.
|
||||
|
||||
\fBconst sensors_subfeature *sensors_get_subfeature(const sensors_chip_name *name, const sensors_feature *feature, sensors_subfeature_type type);\fP
|
||||
.br
|
||||
This returns the subfeature of the given type for a given main feature,
|
||||
if it exists, NULL otherwise.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures.
|
||||
|
||||
\fBconst char *libsensors_version;\fP
|
||||
.br
|
||||
A string representing the version of libsensors.
|
||||
|
||||
@@ -221,6 +221,15 @@ const sensors_subfeature *
|
||||
sensors_get_all_subfeatures(const sensors_chip_name *name,
|
||||
const sensors_feature *feature, int *nr);
|
||||
|
||||
/* This returns the subfeature of the given type for a given main feature,
|
||||
if it exists, NULL otherwise.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures. */
|
||||
const sensors_subfeature *
|
||||
sensors_get_subfeature(const sensors_chip_name *name,
|
||||
const sensors_feature *feature,
|
||||
sensors_subfeature_type type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in new issue
Block a user