updated copyright end date to 2013
[psensor.git] / src / lib / psensor.c
index 05fe03e..8b92c01 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2013 jeanfi@gmail.com
+ * Copyright (C) 2010-2014 jeanfi@gmail.com
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -37,8 +37,9 @@ struct psensor *psensor_create(char *id,
                               unsigned int type,
                               int values_max_length)
 {
-       struct psensor *psensor
-           = (struct psensor *)malloc(sizeof(struct psensor));
+       struct psensor *psensor;
+
+       psensor = (struct psensor *)malloc(sizeof(struct psensor));
 
        psensor->id = id;
        psensor->name = name;
@@ -307,7 +308,7 @@ static double get_min_value(struct psensor **sensors, int type)
        while (*s) {
                struct psensor *sensor = *s;
 
-               if (sensor->graph_enabled && (sensor->type & type)) {
+               if (sensor->type & type) {
                        int i;
                        double t;
 
@@ -339,7 +340,7 @@ double get_max_value(struct psensor **sensors, int type)
        while (*s) {
                struct psensor *sensor = *s;
 
-               if (sensor->graph_enabled && (sensor->type & type)) {
+               if (sensor->type & type) {
                        int i;
                        double t;
                        for (i = 0; i < sensor->values_max_length; i++) {
@@ -546,3 +547,26 @@ psensor_current_value_to_str(const struct psensor *s, unsigned int celcius)
                                    psensor_get_current_value(s),
                                    celcius);
 }
+
+struct psensor **psensor_list_filter_graph_enabled(struct psensor **sensors)
+{
+       int n, i;
+       struct psensor **result, **cur, *s;
+
+       if (!sensors)
+               return NULL;
+
+       n = psensor_list_size(sensors);
+       result = malloc((n+1) * sizeof(struct psensor *));
+
+       for (cur = sensors, i = 0; *cur; cur++) {
+               s = *cur;
+
+               if (s->graph_enabled)
+                       result[i++] = s;
+       }
+
+       result[i] = NULL;
+
+       return result;
+}