diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2005-11-26 01:56:22 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2005-11-26 01:56:22 +0000 |
commit | b847af543dd4f319e97e240ca00b48d151d31a2b (patch) | |
tree | 94a39f825c27b9ddca402d8a216993af0878c048 /gtk/print_dlg.c | |
parent | d149d98fc375e8d0ad44aa9983e6c79968cc68d7 (diff) |
fix #358: instead of simply using tpmnam() for the Win32 print function, use the "official" function to create a temporary file
Well, we actually only need the filename here, so create a temp file with the "official" create_tempfile function, keep that tempfile name and then delete this file again, leaving only the name.
I know that's a bit uncommon, but should work and uses the same mechanisms as with other temporary files. So if there are still problems with the official function, we only have one place to fix :-)
svn path=/trunk/; revision=16597
Diffstat (limited to 'gtk/print_dlg.c')
-rw-r--r-- | gtk/print_dlg.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gtk/print_dlg.c b/gtk/print_dlg.c index 0478bbc525..fd63f4b8fe 100644 --- a/gtk/print_dlg.c +++ b/gtk/print_dlg.c @@ -49,6 +49,7 @@ #include "range_utils.h" #include "help_dlg.h" #include "file_util.h" +#include "util.h" /* dialog output action */ @@ -823,6 +824,8 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w) gboolean export_as_csv = FALSE; #ifdef _WIN32 gboolean win_printer = FALSE; + int tmp_fd; + char tmp_namebuf[128+1]; /* XXX - length was used elsewhere too, why? */ #endif cf_print_status_t status; @@ -857,9 +860,22 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w) } else { #ifdef _WIN32 win_printer = TRUE; - /*XXX should use temp file stuff in util routines */ + /* We currently don't have a function in util.h to create just a tempfile */ + /* name, so simply create a tempfile using the "official" function, */ + /* then delete this file again. After this, the name MUST be available. */ + /* */ + /* Don't use tmpnam() or such, as this will fail under some ACL */ + /* circumstances: http://bugs.ethereal.com/bugzilla/show_bug.cgi?id=358 */ + + tmp_fd = create_tempfile(tmp_namebuf, sizeof(tmp_namebuf), "ethprint"); + if(tmp_fd == -1) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Couldn't create a temporary file for printing."); + return; + } g_free(args->file); - args->file = g_strdup(tmpnam(NULL)); + args->file = g_strdup(tmp_namebuf); + eth_unlink(args->file); args->to_file = TRUE; #else g_free(args->cmd); |