+#if SENSORS_API_VERSION < 0x400
+ chip_num = 0;
+ while ((chip = sensors_get_detected_chips(&chip_num)) != NULL) {
+ int feature_num0 = 0;
+ int feature_num1 = 0;
+
+ while (42) {
+ const sensors_feature_data *feature;
+ int feature_type;
+ featurelist_t *fl;
+
+ feature = sensors_get_all_features(*chip, &feature_num0, &feature_num1);
+
+ /* Check if all features have been read. */
+ if (feature == NULL)
+ break;
+
+ /* "master features" only */
+ if (feature->mapping != SENSORS_NO_MAPPING) {
+ DEBUG("sensors plugin: sensors_load_conf: "
+ "Ignoring subfeature `%s', "
+ "because (feature->mapping "
+ "!= SENSORS_NO_MAPPING).",
+ feature->name);
+ continue;
+ }
+
+ /* skip ignored in sensors.conf */
+ if (sensors_get_ignored(*chip, feature->number) == 0) {
+ DEBUG("sensors plugin: sensors_load_conf: "
+ "Ignoring subfeature `%s', "
+ "because "
+ "`sensors_get_ignored' told "
+ "me so.",
+ feature->name);
+ continue;
+ }
+
+ feature_type = sensors_feature_name_to_type(feature->name);
+ if (feature_type == SENSOR_TYPE_UNKNOWN) {
+ DEBUG("sensors plugin: sensors_load_conf: "
+ "Ignoring subfeature `%s', "
+ "because its type is "
+ "unknown.",
+ feature->name);
+ continue;
+ }
+
+ fl = calloc(1, sizeof(*fl));
+ if (fl == NULL) {
+ ERROR("sensors plugin: calloc failed.");
+ continue;
+ }
+
+ fl->chip = chip;
+ fl->data = feature;
+ fl->type = feature_type;
+
+ if (first_feature == NULL)
+ first_feature = fl;
+ else
+ last_feature->next = fl;
+ last_feature = fl;
+ } /* while sensors_get_all_features */
+ } /* while sensors_get_detected_chips */
+/* #endif SENSORS_API_VERSION < 0x400 */
+
+#elif (SENSORS_API_VERSION >= 0x400)