2 * Routines for code that can run in GUI and command-line environments to
3 * use to report errors and warnings to the user (e.g., I/O errors, or
4 * problems with preference settings) if the message should be shown as
5 * a GUI error in a GUI environment.
7 * The application using libwsutil will register error-reporting
8 * routines, and the routines defined here will call the registered
9 * routines. That way, these routines can be called by code that
10 * doesn't itself know whether to pop up a dialog or print something
11 * to the standard error.
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * SPDX-License-Identifier: GPL-2.0-or-later
22 #include "report_message.h"
24 static void (*vreport_failure_func)(const char *, va_list);
25 static void (*vreport_warning_func)(const char *, va_list);
26 static void (*report_open_failure_func)(const char *, int, gboolean);
27 static void (*report_read_failure_func)(const char *, int);
28 static void (*report_write_failure_func)(const char *, int);
30 void init_report_message(void (*vreport_failure_fcn_p)(const char *, va_list),
31 void (*vreport_warning_fcn_p)(const char *, va_list),
32 void (*report_open_failure_fcn_p)(const char *, int, gboolean),
33 void (*report_read_failure_fcn_p)(const char *, int),
34 void (*report_write_failure_fcn_p)(const char *, int))
36 vreport_failure_func = vreport_failure_fcn_p;
37 vreport_warning_func = vreport_warning_fcn_p;
38 report_open_failure_func = report_open_failure_fcn_p;
39 report_read_failure_func = report_read_failure_fcn_p;
40 report_write_failure_func = report_write_failure_fcn_p;
44 * Report a general error.
47 report_failure(const char *msg_format, ...)
51 va_start(ap, msg_format);
52 (*vreport_failure_func)(msg_format, ap);
57 * Report a general warning.
60 report_warning(const char *msg_format, ...)
64 va_start(ap, msg_format);
65 (*vreport_warning_func)(msg_format, ap);
70 * Report an error when trying to open or create a file.
71 * "err" is assumed to be an error code from Wiretap; positive values are
72 * UNIX-style errnos, so this can be used for open failures not from
73 * Wiretap as long as the failure code is just an errno.
76 report_open_failure(const char *filename, int err,
79 (*report_open_failure_func)(filename, err, for_writing);
83 * Report an error when trying to read a file.
84 * "err" is assumed to be a UNIX-style errno.
87 report_read_failure(const char *filename, int err)
89 (*report_read_failure_func)(filename, err);
93 * Report an error when trying to write a file.
94 * "err" is assumed to be a UNIX-style errno.
97 report_write_failure(const char *filename, int err)
99 (*report_write_failure_func)(filename, err);
103 * Editor modelines - http://www.wireshark.org/tools/modelines.html
108 * indent-tabs-mode: t
111 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
112 * :indentSize=8:tabSize=8:noTabs=false: