nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* report_err.c |
2 | * Routines for code that can run in GUI and command-line environments to |
||
3 | * use to report errors to the user (e.g., I/O errors, or problems with |
||
4 | * preference settings). |
||
5 | * |
||
6 | * The application using libwireshark will register error-reporting |
||
7 | * routines, and the routines defined here will call the registered |
||
8 | * routines. That way, these routines can be called by code that |
||
9 | * doesn't itself know whether to pop up a dialog or print something |
||
10 | * to the standard error. |
||
11 | * |
||
12 | * Wireshark - Network traffic analyzer |
||
13 | * By Gerald Combs <gerald@wireshark.org> |
||
14 | * Copyright 1998 Gerald Combs |
||
15 | * |
||
16 | * This program is free software; you can redistribute it and/or |
||
17 | * modify it under the terms of the GNU General Public License |
||
18 | * as published by the Free Software Foundation; either version 2 |
||
19 | * of the License, or (at your option) any later version. |
||
20 | * |
||
21 | * This program is distributed in the hope that it will be useful, |
||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
24 | * GNU General Public License for more details. |
||
25 | * |
||
26 | * You should have received a copy of the GNU General Public License |
||
27 | * along with this program; if not, write to the Free Software |
||
28 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
29 | */ |
||
30 | #include "config.h" |
||
31 | |||
32 | #include <glib.h> |
||
33 | #include "report_err.h" |
||
34 | |||
35 | static void (*vreport_failure_func)(const char *, va_list); |
||
36 | static void (*report_open_failure_func)(const char *, int, gboolean); |
||
37 | static void (*report_read_failure_func)(const char *, int); |
||
38 | static void (*report_write_failure_func)(const char *, int); |
||
39 | |||
40 | void init_report_err(void (*vreport_failure_fcn_p)(const char *, va_list), |
||
41 | void (*report_open_failure_fcn_p)(const char *, int, gboolean), |
||
42 | void (*report_read_failure_fcn_p)(const char *, int), |
||
43 | void (*report_write_failure_fcn_p)(const char *, int)) |
||
44 | { |
||
45 | vreport_failure_func = vreport_failure_fcn_p; |
||
46 | report_open_failure_func = report_open_failure_fcn_p; |
||
47 | report_read_failure_func = report_read_failure_fcn_p; |
||
48 | report_write_failure_func = report_write_failure_fcn_p; |
||
49 | } |
||
50 | |||
51 | /* |
||
52 | * Report a general error. |
||
53 | */ |
||
54 | void |
||
55 | report_failure(const char *msg_format, ...) |
||
56 | { |
||
57 | va_list ap; |
||
58 | |||
59 | va_start(ap, msg_format); |
||
60 | (*vreport_failure_func)(msg_format, ap); |
||
61 | va_end(ap); |
||
62 | } |
||
63 | |||
64 | /* |
||
65 | * Report an error when trying to open or create a file. |
||
66 | * "err" is assumed to be an error code from Wiretap; positive values are |
||
67 | * UNIX-style errnos, so this can be used for open failures not from |
||
68 | * Wiretap as long as the failure code is just an errno. |
||
69 | */ |
||
70 | void |
||
71 | report_open_failure(const char *filename, int err, |
||
72 | gboolean for_writing) |
||
73 | { |
||
74 | (*report_open_failure_func)(filename, err, for_writing); |
||
75 | } |
||
76 | |||
77 | /* |
||
78 | * Report an error when trying to read a file. |
||
79 | * "err" is assumed to be a UNIX-style errno. |
||
80 | */ |
||
81 | void |
||
82 | report_read_failure(const char *filename, int err) |
||
83 | { |
||
84 | (*report_read_failure_func)(filename, err); |
||
85 | } |
||
86 | |||
87 | /* |
||
88 | * Report an error when trying to write a file. |
||
89 | * "err" is assumed to be a UNIX-style errno. |
||
90 | */ |
||
91 | void |
||
92 | report_write_failure(const char *filename, int err) |
||
93 | { |
||
94 | (*report_write_failure_func)(filename, err); |
||
95 | } |
||
96 | |||
97 | /* |
||
98 | * Editor modelines - http://www.wireshark.org/tools/modelines.html |
||
99 | * |
||
100 | * Local variables: |
||
101 | * c-basic-offset: 8 |
||
102 | * tab-width: 8 |
||
103 | * indent-tabs-mode: t |
||
104 | * End: |
||
105 | * |
||
106 | * vi: set shiftwidth=8 tabstop=8 noexpandtab: |
||
107 | * :indentSize=8:tabSize=8:noTabs=false: |
||
108 | */ |