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).
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.
14 * Wireshark - Network traffic analyzer
15 * By Gerald Combs <gerald@wireshark.org>
16 * Copyright 1998 Gerald Combs
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 #include "report_err.h"
38 static void (*report_failure_func
)(const char *, va_list);
39 static void (*report_open_failure_func
)(const char *, int, gboolean
);
40 static void (*report_read_failure_func
)(const char *, int);
41 static void (*report_write_failure_func
)(const char *, int);
43 void init_report_err(void (*report_failure_fcn_p
)(const char *, va_list),
44 void (*report_open_failure_fcn_p
)(const char *, int, gboolean
),
45 void (*report_read_failure_fcn_p
)(const char *, int),
46 void (*report_write_failure_fcn_p
)(const char *, int))
48 report_failure_func
= report_failure_fcn_p
;
49 report_open_failure_func
= report_open_failure_fcn_p
;
50 report_read_failure_func
= report_read_failure_fcn_p
;
51 report_write_failure_func
= report_write_failure_fcn_p
;
55 * Report a general error.
58 report_failure(const char *msg_format
, ...)
62 va_start(ap
, msg_format
);
63 (*report_failure_func
)(msg_format
, ap
);
68 * Report an error when trying to open or create a file.
69 * "err" is assumed to be an error code from Wiretap; positive values are
70 * UNIX-style errnos, so this can be used for open failures not from
71 * Wiretap as long as the failure code is just an errno.
74 report_open_failure(const char *filename
, int err
,
77 (*report_open_failure_func
)(filename
, err
, for_writing
);
81 * Report an error when trying to read a file.
82 * "err" is assumed to be a UNIX-style errno.
85 report_read_failure(const char *filename
, int err
)
87 (*report_read_failure_func
)(filename
, err
);
91 * Report an error when trying to write a file.
92 * "err" is assumed to be a UNIX-style errno.
95 report_write_failure(const char *filename
, int err
)
97 (*report_write_failure_func
)(filename
, err
);