avoid config in the psensor struct
[psensor.git] / src / lib / psensor.c
index f4b01b2..58731d5 100644 (file)
@@ -23,6 +23,8 @@
 #include <libintl.h>
 #define _(str) gettext(str)
 
+#include <stdio.h>
+
 #include <hdd.h>
 #include <psensor.h>
 #include <temperature.h>
@@ -48,7 +50,6 @@ struct psensor *psensor_create(char *id,
        psensor->values_max_length = values_max_length;
        psensor->measures = measures_dbl_create(values_max_length);
 
-       psensor->alarm_enabled = 0;
        psensor->alarm_high_threshold = 0;
        psensor->alarm_low_threshold = 0;
 
@@ -61,7 +62,6 @@ struct psensor *psensor_create(char *id,
        psensor->color = NULL;
 
        psensor->graph_enabled = 1;
-       psensor->appindicator_enabled = 0;
 
        psensor->provider_data = NULL;
        psensor->provider_data_free_fct = &free;
@@ -155,32 +155,15 @@ int psensor_list_size(struct psensor **sensors)
        return size;
 }
 
-int psensor_list_contains_type(struct psensor **sensors, unsigned int type)
-{
-       struct psensor **s;
-
-       if (!sensors)
-               return 0;
-
-       s = sensors;
-       while (*s) {
-               if ((*s)->type & type)
-                       return 1;
-               s++;
-       }
-
-       return 0;
-}
-
 struct psensor **psensor_list_add(struct psensor **sensors,
                                  struct psensor *sensor)
 {
        int size;
+       struct psensor **result;
 
        size = psensor_list_size(sensors);
 
-       struct psensor **result
-           = malloc((size + 1 + 1) * sizeof(struct psensor *));
+       result = malloc((size + 1 + 1) * sizeof(struct psensor *));
 
        if (sensors)
                memcpy(result, sensors, size * sizeof(struct psensor *));
@@ -281,15 +264,13 @@ void psensor_set_current_measure(struct psensor *s, double v, struct timeval tv)
        if (s->max == UNKNOWN_DBL_VALUE || v > s->max)
                s->max = v;
 
-       if (s->alarm_enabled) {
-               if (v > s->alarm_high_threshold || v < s->alarm_low_threshold) {
-                       if (!s->alarm_raised && s->cb_alarm_raised)
-                               s->cb_alarm_raised(s, s->cb_alarm_raised_data);
-
-                       s->alarm_raised = 1;
-               } else {
-                       s->alarm_raised = 0;
+       if (v > s->alarm_high_threshold || v < s->alarm_low_threshold) {
+               if (!s->alarm_raised && s->cb_alarm_raised) {
+                       s->alarm_raised = true;
+                       s->cb_alarm_raised(s, s->cb_alarm_raised_data);
                }
+       } else {
+               s->alarm_raised = false;
        }
 }
 
@@ -409,36 +390,6 @@ double get_max_temp(struct psensor **sensors)
        return get_max_value(sensors, SENSOR_TYPE_TEMP);
 }
 
-struct psensor **get_all_sensors(int use_libatasmart, int values_max_length)
-{
-       struct psensor **psensors;
-       struct psensor **tmp_psensors;
-
-       psensors = NULL;
-
-       if (!use_libatasmart) {
-               tmp_psensors = hddtemp_psensor_list_add(psensors,
-                                                       values_max_length);
-               if (tmp_psensors != psensors) {
-                       free(psensors);
-                       psensors = tmp_psensors;
-               }
-       }
-#ifdef HAVE_ATASMART
-               else {
-                       atasmart_psensor_list_append(&psensors,
-                                                    values_max_length);
-               }
-#endif
-
-       if (!psensors) {        /* there is no detected sensors */
-               psensors = malloc(sizeof(struct psensor *));
-               *psensors = NULL;
-       }
-
-       return psensors;
-}
-
 const char *psensor_type_to_str(unsigned int type)
 {
        if (type & SENSOR_TYPE_NVCTRL) {
@@ -504,17 +455,6 @@ const char *psensor_type_to_unit_str(unsigned int type, int use_celsius)
        return _("N/A");
 }
 
-void psensor_list_update_measures(struct psensor **sensors)
-{
-       if (psensor_list_contains_type(sensors, SENSOR_TYPE_HDDTEMP))
-               hddtemp_psensor_list_update(sensors);
-
-#ifdef HAVE_ATASMART
-       if (psensor_list_contains_type(sensors, SENSOR_TYPE_ATASMART))
-               atasmart_psensor_list_update(sensors);
-#endif
-}
-
 void psensor_log_measures(struct psensor **sensors)
 {
        if (log_level == LOG_DEBUG)
@@ -527,14 +467,6 @@ void psensor_log_measures(struct psensor **sensors)
                }
 }
 
-void psensor_init()
-{
-}
-
-void psensor_cleanup()
-{
-}
-
 struct psensor **psensor_list_copy(struct psensor **sensors)
 {
        struct psensor **result;