Define a separate structure to represent main features. This allows

for faster main features lookup. One side effect of this change is
that subfeatures can no longer have labels nor be ignored. I do not
think that this is a problem in practice, and actually this makes a
lot of sense.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4834 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2007-09-23 12:05:16 +00:00
1 parent bfe337fe76
commit 96c914bfda
11 files changed
+160 -126

No files matched your search

+14 -3
View File
@@ -82,11 +82,14 @@ int sensors_snprintf_chip_name(char *str, size_t size,
it returns NULL */
const char *sensors_get_adapter_name(const sensors_bus_id *bus);
typedef struct sensors_feature sensors_feature;
/* Look up the label which belongs to this chip. Note that chip should not
contain wildcard values! The returned string is newly allocated (free it
yourself). On failure, NULL is returned.
If no label exists for this feature, its name is returned itself. */
char *sensors_get_label(const sensors_chip_name *name, int feature);
char *sensors_get_label(const sensors_chip_name *name,
const sensors_feature *feature);
/* Read the value of a feature of a certain chip. Note that chip should not
contain wildcard values! This function will return 0 on success, and <0
@@ -163,6 +166,13 @@ typedef enum sensors_feature_type {
SENSORS_FEATURE_UNKNOWN = INT_MAX,
} sensors_feature_type;
/* Data about a single chip feature (or category leader) */
struct sensors_feature {
char *name;
int first_subfeature;
sensors_feature_type type;
};
/* Data about a single chip subfeature:
name is the string name used to refer to this subfeature (in config files)
number is the internal subfeature number, used in many functions to refer
@@ -188,7 +198,7 @@ typedef struct sensors_subfeature {
more features are found NULL is returned.
Do not try to change the returned structure; you will corrupt internal
data structures. */
const sensors_subfeature *
const sensors_feature *
sensors_get_features(const sensors_chip_name *name, int *nr);
/* This returns all subfeatures of a given main feature (including that
@@ -198,7 +208,8 @@ sensors_get_features(const sensors_chip_name *name, int *nr);
Do not try to change the returned structure; you will corrupt internal
data structures. */
const sensors_subfeature *
sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr);
sensors_get_all_subfeatures(const sensors_chip_name *name,
const sensors_feature *feature, int *nr);
#ifdef __cplusplus
}