+/* write full file */
+
+int writefile (char *filename, char *buffer, int size)
+{
+
+ /* open file */
+
+ VERBOSE (DEBUG, PRINT ("Opening file %s for writing\n", filename));
+ FILE *fd = fopen (filename, "wb");
+ if (fd == NULL) {
+ VERBOSE (WARNING, PRINT ("Can't open file (%s) for writing\n", filename));
+ return -1;
+ }
+
+ /* write full file */
+
+ VERBOSE (DEBUG, PRINT ("Writing %d bytes\n", size));
+ int len = fwrite (buffer, size, 1, fd);
+ if (len != size) {
+ VERBOSE (WARNING, PRINT ("Can't write full file (%s)\n", filename));
+ }
+ fclose (fd);
+
+ return len;
+}
+