+ strcpy (tmpfile, state->filename);
+ strcat (tmpfile, ".XXXXXX");
+
+ s = mkstemp (tmpfile);
+ if (s == -1) {
+ state->lasterror = "Error writing stream to output. "
+ "Cannot open temporary file.";
+ return -1;
+ }
+
+ out = fdopen (s, "wb");
+ if (!out) {
+ unlink (tmpfile);
+ close (s);
+ state->lasterror = "Error writing stream to output. "
+ "Cannot open temporary file.";
+ return -1;
+ }
+