aboutsummaryrefslogtreecommitdiffstats
path: root/prefs.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-01-03 06:29:39 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-01-03 06:29:39 +0000
commit32063976966788167a9c0672985e101e7b4a0d2c (patch)
treee4574fea9d9f020a19787b715c774abd43b31570 /prefs.c
parentac62c670c3b2c37f4b1ebdd7c6b98592f028612a (diff)
Don't have "write_prefs()" display a dialog box if the attempt to open
the preferences file fails, have it return an error indication and the path of the preferences file, and have its caller display the dialog box. That way you don't have to drag in the dialog box code if you're going to use the preferences code in, say, a "line-mode" Ethereal. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1413 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'prefs.c')
-rw-r--r--prefs.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/prefs.c b/prefs.c
index bf2e90c433..46d7ba40a1 100644
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
- * $Id: prefs.c,v 1.28 1999/12/30 23:02:38 gram Exp $
+ * $Id: prefs.c,v 1.29 2000/01/03 06:29:32 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -51,7 +51,6 @@
#include "prefs.h"
#include "column.h"
#include "print.h"
-#include "ui_util.h"
/* Internal functions */
static int set_pref(gchar*, gchar*);
@@ -454,8 +453,8 @@ set_pref(gchar *pref, gchar *value) {
return 1;
}
-void
-write_prefs(void) {
+int
+write_prefs(char **pf_path_return) {
FILE *pf;
struct stat s_buf;
@@ -480,10 +479,9 @@ write_prefs(void) {
sprintf(pf_path, "%s/%s/%s", getenv("HOME"), PF_DIR, PF_NAME);
if ((pf = fopen(pf_path, "w")) == NULL) {
- simple_dialog(ESD_TYPE_WARN, NULL,
- "Can't open preferences file\n\"%s\".", pf_path);
- return;
- }
+ *pf_path_return = pf_path;
+ return errno;
+ }
fputs("# Configuration file for Ethereal " VERSION ".\n"
"#\n"
@@ -551,4 +549,10 @@ write_prefs(void) {
gui_ptree_expander_style_text[prefs.gui_ptree_expander_style]);
fclose(pf);
+
+ /* XXX - catch I/O errors (e.g. "ran out of disk space") and return
+ an error indication, or maybe write to a new preferences file and
+ rename that file on top of the old one only if there are not I/O
+ errors. */
+ return 0;
}