+ if (rlen < 0)
+ perror("recv");
+
+ buf[offset] = '\0';
+
+ close(sockfd);
+GET_OUT:
+ freeaddrinfo(result);
+ return buf;
+}
+
+/* this is an iterator:
+ * set line to NULL in consecutive calls to get the next field
+ * note that exhausing iteration is assumed - otherwise *saveptr
+ * is not being freed!
+ */
+static int read_hdd_val(const char *line, char **dev, short *val, char *unit,
+ char **saveptr)
+{
+ char *line_s, *cval, *endptr;
+ static char *p = 0;
+
+ if (line) {
+ *saveptr = strdup(line);
+ p = *saveptr;
+ }
+ line_s = *saveptr;
+
+again:
+ if(!*p)
+ goto out_fail;
+ /* read the device */
+ *dev = ++p;
+ if (!(p = strchr(p, line_s[0])))
+ goto out_fail;
+ *(p++) = '\0';
+ /* jump over the devname */
+ if (!(p = strchr(p, line_s[0])))
+ goto out_fail;
+ /* read the value */
+ cval = ++p;
+ if (!(p = strchr(p, line_s[0])))
+ goto out_fail;
+ *(p++) = '\0';
+ *unit = *(p++);
+ *val = strtol(cval, &endptr, 10);
+ if (*endptr) {
+ if (!(p = strchr(p, line_s[0])))
+ goto out_fail;