- char dest_filename[MAX_FILENAME_SIZE] = "";
- FILE *source_handle = fopen(source_file, "r");
- int destination_fd = mkstemp(template);
- FILE *destination_handle = fdopen(destination_fd, "w");
- if (!source_handle || !(destination_handle)) {
- // handle open error
- pb_log("%s: failed: unable to open source file '%s'\n",
+ FILE *destination_handle, *source_handle;
+ int destination_fd, result = 0;
+ unsigned char *buffer;
+ ssize_t r;
+ size_t l1;
+
+ source_handle = fopen(source_file, "r");
+ if (!source_handle) {
+ pb_log("%s: unable to open source file '%s': %m\n",