X-Git-Url: https://git.enpas.org/?p=sysstatus.git;a=blobdiff_plain;f=statuses%2Ftools.c;h=abb8a0db943f1693bf01492ff5bc5d1a3f0b2b71;hp=83fe2b1ab86aa8ebae45cef7a996360fb3ceeae8;hb=2ddbfa53a31360e50565345a1ac08c0799c8243e;hpb=9102c7c65421f2ef3e415c7e76a741657e34663b diff --git a/statuses/tools.c b/statuses/tools.c index 83fe2b1..abb8a0d 100644 --- a/statuses/tools.c +++ b/statuses/tools.c @@ -5,53 +5,56 @@ char powerToChar(int power) { - switch(power) - { - case 0: - return 'b'; - case 1: - return 'k'; - case 2: - return 'M'; - case 3: - return 'G'; - case 4: - return 'T'; - case 5: - return 'P'; - case 6: - return 'E'; - } - - return '?'; + switch(power) + { + case 0: + return 'b'; + case 1: + return 'k'; + case 2: + return 'M'; + case 3: + return 'G'; + case 4: + return 'T'; + case 5: + return 'P'; + case 6: + return 'E'; + } + + return '?'; } void statusError(char *where, char *what, char *extra) { - fprintf(stderr, "%s: %s", where, what); - if (extra) - fprintf(stderr, " -- %s", extra); - fputs("\n", stderr); + fprintf(stderr, "%s: %s", where, what); + if (extra) { + fprintf(stderr, " -- %s", extra); + } + fputs("\n", stderr); } ssize_t fileRead(char *buf, size_t bufsize, char *file) { - int fd; - int readbytes; + int fd; + int readbytes; - fd = open(file, 0); - if (fd < 0) - return -1; + fd = open(file, 0); + if (fd < 0) { + return -1; + } - readbytes = read(fd, buf, bufsize - 1); - close(fd); + readbytes = read(fd, buf, bufsize - 1); + close(fd); - if (readbytes > 0) - buf[readbytes] = '\0'; - else - buf[0] = '\0'; + if (readbytes > 0) { + buf[readbytes] = '\0'; + } else { + buf[0] = '\0'; + } - return readbytes; + return readbytes; }