-/* Create a temporary file in $TMPDIR, or /tmp if TMPDIR is not set.
- * Caller must free temp_filename and fclose temp_file. Succeeds or terminates
- * the process. */
-static void make_temporary_file(char** temp_filename, FILE** temp_file) {
- char* TMPDIR = getenv("TMPDIR");
- if (TMPDIR == NULL) {
- TMPDIR = "/tmp";
- }
- if (asprintf(temp_filename, "%s/reverse.XXXXXX", TMPDIR) == -1) {
- errx(EX_OSERR, "Could not assemble temporary filename");
- }
- int fd = mkstemp(*temp_filename);
- if (fd == -1) err(EX_IOERR, "Could not make a temporary file");
- *temp_file = fdopen(fd, "w");
- if (*temp_file == NULL) err(EX_IOERR, "Could not open temporary file");
-}
-