return 1;
}
}
+
+struct psensor **lmsensor_psensor_list_add(struct psensor **sensors,
+ int vn)
+{
+ const sensors_chip_name *chip;
+ int chip_nr = 0;
+ struct psensor **tmp, **result;
+ const sensors_feature *feature;
+ struct psensor *s;
+ int i;
+
+ result = sensors;
+ while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
+
+ i = 0;
+ while ((feature = sensors_get_features(chip, &i))) {
+
+ if (feature->type == SENSORS_FEATURE_TEMP
+ || feature->type == SENSORS_FEATURE_FAN) {
+
+ s = lmsensor_psensor_create(chip, feature, vn);
+
+ if (s) {
+ tmp = psensor_list_add(result, s);
+
+ if (tmp != sensors)
+ free(result);
+
+ result = tmp;
+ }
+ }
+ }
+ }
+
+ return result;
+}
int lmsensor_init();
void lmsensor_psensor_list_update(struct psensor **sensors);
+/*
+ Adds sensors to a given list of sensors.
+
+ Returns the new allocated list of sensors if sensors have been added
+ otherwise returns 'sensors'. The list is 'NULL' terminated.
+ */
+struct psensor **lmsensor_psensor_list_add(struct psensor **sensors,
+ int values_max_length);
+
+
+
#endif
#include <libintl.h>
#define _(str) gettext(str)
-#include <sensors/sensors.h>
-#include <sensors/error.h>
-
#include "hdd.h"
#include "psensor.h"
#include "lmsensor.h"
struct psensor **get_all_sensors(int values_max_length)
{
struct psensor **psensors = NULL;
- int count = 0;
- const sensors_chip_name *chip;
- int chip_nr = 0;
struct psensor **tmp_psensors;
- const sensors_feature *feature;
- struct psensor *psensor;
- int i;
-
- while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
- i = 0;
- while ((feature = sensors_get_features(chip, &i))) {
-
- if (feature->type == SENSORS_FEATURE_TEMP
- || feature->type == SENSORS_FEATURE_FAN) {
-
- psensor = lmsensor_psensor_create
- (chip, feature, values_max_length);
-
- if (psensor) {
- tmp_psensors
- = psensor_list_add(psensors,
- psensor);
- free(psensors);
-
- psensors = tmp_psensors;
-
- count++;
- }
- }
- }
- }
+ psensors = lmsensor_psensor_list_add(NULL, values_max_length);
tmp_psensors = hdd_psensor_list_add(psensors, values_max_length);