+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
#include "tools.h"
-char powertochar(int power)
+char powerToChar(int power)
{
switch(power)
{
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);
+}
+
+
+ssize_t fileRead(char *buf, size_t bufsize, char *file)
+{
+ int fd;
+ int readbytes;
+
+ fd = open(file, 0);
+ if (fd < 0)
+ return -1;
+
+ readbytes = read(fd, buf, bufsize - 1);
+ close(fd);
+
+ if (readbytes > 0)
+ buf[readbytes] = '\0';
+ else
+ buf[0] = '\0';
+
+ return readbytes;
+}
\ No newline at end of file