--- /dev/null
+#include <malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "debug.h"
+
+#include "file.h"
+
+/* read full file */
+
+int readfile (unsigned char **buffer, char *filename)
+{
+
+ /* open file */
+
+ FILE *fd = fopen (filename, "rb");
+ if (fd == NULL) {
+ VERBOSE (WARNING, PRINT ("Can't open file (%s)\n", filename));
+ return -1;
+ }
+
+ fseek (fd, 0, SEEK_END);
+ int size = ftell (fd);
+ fseek (fd, 0, SEEK_SET); /* same as rewind(f); */
+
+ /* read full file */
+
+ *buffer = calloc (size + 1, 1);
+ fread (*buffer, size, 1, fd);
+ fclose (fd);
+
+ *buffer[size] = 0;
+ return size;
+}
+
+/* vim: set ts=4 sw=4 et: */