New protocol: PKCS#1 (rfc2313 pplus some extra oid's)
[obnox/wireshark/wip.git] / alert_box.c
1 /* alert_box.c
2  * Routines to put up various "standard" alert boxes used in multiple
3  * places
4  *
5  * $Id$
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 /* With MSVC and a libethereal.dll this file needs to import some variables 
27    in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */   
28 #define _NEED_VAR_IMPORT_
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <string.h>
35
36 #include <glib.h>
37
38 #include <epan/filesystem.h>
39 #include <epan/dfilter/dfilter.h>
40
41 #include "alert_box.h"
42
43 #include "simple_dialog.h"
44
45 /*
46  * Alert box for general errors.
47  */
48 void
49 failure_alert_box(const char *msg_format, va_list ap)
50 {
51   vsimple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, msg_format, ap);
52 }
53
54 /*
55  * Alert box for a failed attempt to open or create a file.
56  * "err" is assumed to be a UNIX-style errno; "for_writing" is TRUE if
57  * the file is being opened for writing and FALSE if it's being opened
58  * for reading.
59  *
60  * XXX - add explanatory secondary text for at least some of the errors;
61  * various HIGs suggest that you should, for example, suggest that the
62  * user remove files if the file system is full.  Perhaps that's because
63  * they're providing guidelines for people less sophisticated than the
64  * typical Ethereal user is, but....
65  */
66 void
67 open_failure_alert_box(const char *filename, int err, gboolean for_writing)
68 {
69   simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
70                 file_open_error_message(err, for_writing), filename);
71 }
72
73 /*
74  * Alert box for a failed attempt to read a file.
75  * "err" is assumed to be a UNIX-style errno.
76  */
77 void
78 read_failure_alert_box(const char *filename, int err)
79 {
80   simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
81                 "An error occurred while reading from the file \"%s\": %s.",
82                 filename, strerror(err));
83 }
84
85 /*
86  * Alert box for a failed attempt to write to a file.
87  * "err" is assumed to be a UNIX-style errno.
88  *
89  * XXX - add explanatory secondary text for at least some of the errors;
90  * various HIGs suggest that you should, for example, suggest that the
91  * user remove files if the file system is full.  Perhaps that's because
92  * they're providing guidelines for people less sophisticated than the
93  * typical Ethereal user is, but....
94  */
95 void
96 write_failure_alert_box(const char *filename, int err)
97 {
98   simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
99                 file_write_error_message(err), filename);
100 }
101
102 /*
103  * Alert box for an invalid display filter expression.
104  * Assumes "dfilter_error_msg" has been set by "dfilter_compile()" to the
105  * error message for the filter.
106  *
107  * XXX - should this have a "Help" button that pops up the display filter
108  * help?
109  */
110 void
111 bad_dfilter_alert_box(const char *dftext)
112 {
113   simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, 
114                 "%s%s%s\n"
115                 "\n"
116                 "The filter expression \"%s\" is not a valid display filter.\n"
117                 "See the help for a description of the display filter syntax.",
118                 simple_dialog_primary_start(), dfilter_error_msg,
119                 simple_dialog_primary_end(), dftext);
120 }