Better file structure and build system
[sysstatus.git] / src / status / fan.c
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <unistd.h>
4
5 #include "status/fan.h"
6 #include "tools.h"
7
8
9 void status_fan(char *title, char *sysfile)
10 {
11   char stline[16];
12   ssize_t stlen;
13
14   stlen = fileRead(stline, sizeof(stline), sysfile);
15   if (stlen <= 0) {
16     return;
17   }
18
19   // Read a valid value? Sometimes we get garbage from sysfs...
20   if (stlen > 5) {
21     printf(" ^fg(red)%sERROR ", title);
22     return;
23   }
24
25   fputs(" ^fg(#CCCCCC)", stdout);
26   fputs(title, stdout);
27   fwrite(stline, 1, stlen - 1, stdout);
28   fputs(" rpm ", stdout);
29 }