static int get_word(char *src, char **dst, char *word, int size)
{
int ret = 0;
- while(((*src == ' ') || (*src == '\t')) && *src)
+ while(((*src == ' ') || (*src == '\t') || (*src == '\n')) && *src)
src++;
- while(((*src != ' ') && (*src != '\t')) && *src && (ret < (size - 1))) {
+ while(((*src != ' ') && (*src != '\t') && (*src != '\n')) && *src && (ret < (size - 1))) {
*word = *src;
word++;
src++;
FILE *readf, *writef;
int pid;
char buf[1024], *bptr = buf;
- char t1[16], t2[16], t3[16];
+ float t1, t2, t3;
pid = run_piped_stream(digitemp_cmd, digitemp_args, &readf, &writef);
if (pid < 0) {
fgets(buf, 1024, readf);
+/*
get_word(bptr, &bptr, t1, 16);
*bptr++ = 0;
get_word(bptr, &bptr, t2, 16);
*bptr++ = 0;
get_word(bptr, &bptr, t3, 16);
*bptr++ = 0;
+*/
+ t1 = dec_to_float(bptr, &bptr);
+ t2 = dec_to_float(bptr, &bptr);
+ t3 = dec_to_float(bptr, &bptr);
+
+ t2 += 2.16;
+ t3 += -0.44;
while (fgets(buf, 1024, readf));
harvest_zombies(pid);
- sprintf(data, "%s:%s", t2, t3);
+ sprintf(data, "%.2f:%.2f", t3, t2);
return 0;
}