xdbe replaced with more generic pixmap based buffering but there are 3 major bugs:
[monky] / src / hddtemp.c
index 57001d4..b1ba81e 100644 (file)
@@ -1,4 +1,5 @@
 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=c
  *
  * Conky, a system monitor, based on torsmo
  *
@@ -9,7 +10,7 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
  *     (see AUTHORS)
  * All rights reserved.
  *
@@ -25,8 +26,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- * vim: ts=4 sw=4 noet ai cindent syntax=c
- *
  */
 
 #include "conky.h"
@@ -131,7 +130,7 @@ static char *fetch_hddtemp_output(void)
                close(sockfd);
        }
        if (!rp) {
-               NORM_ERR("could not connect to mpd host");
+               NORM_ERR("could not connect to hddtemp host");
                goto GET_OUT;
        }
 
@@ -172,6 +171,9 @@ static int read_hdd_val(const char *line, char **dev, short *val, char *unit,
        }
        line_s = *saveptr;
 
+again:
+       if(!*p)
+               goto out_fail;
        /* read the device */
        *dev = ++p;
        if (!(p = strchr(p, line_s[0])))
@@ -187,8 +189,13 @@ static int read_hdd_val(const char *line, char **dev, short *val, char *unit,
        *(p++) = '\0';
        *unit = *(p++);
        *val = strtol(cval, &endptr, 10);
-       if (*endptr)
-               goto out_fail;
+       if (*endptr) {
+               if (!(p = strchr(p, line_s[0])))
+                       goto out_fail;
+
+               p++;
+               goto again;
+       }
        
        /* preset p for next call */
        p++;
@@ -199,29 +206,30 @@ out_fail:
        return 1;
 }
 
-void update_hddtemp(void) {
+int update_hddtemp(void) {
        char *data, *dev, unit, *saveptr;
        short val;
        static double last_hddtemp_update = 0.0;
 
        /* limit tcp connection overhead */
        if (current_update_time - last_hddtemp_update < 5)
-               return;
+               return 0;
        last_hddtemp_update = current_update_time;
 
        free_hddtemp_info();
 
        if (!(data = fetch_hddtemp_output()))
-               return;
+               return 0;
 
        if (read_hdd_val(data, &dev, &val, &unit, &saveptr)) {
                free(data);
-               return;
+               return 0;
        }
        do {
                add_hddtemp_info(dev, val, unit);
        } while (!read_hdd_val(NULL, &dev, &val, &unit, &saveptr));
        free(data);
+       return 0;
 }
 
 void free_hddtemp(void)