diff options
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/CMakeLists.txt | 2 | ||||
-rw-r--r-- | wsutil/Makefile.am | 4 | ||||
-rw-r--r-- | wsutil/filesystem.c | 2 | ||||
-rw-r--r-- | wsutil/plugins.c | 2 | ||||
-rw-r--r-- | wsutil/report_err.c | 108 | ||||
-rw-r--r-- | wsutil/report_message.c | 125 | ||||
-rw-r--r-- | wsutil/report_message.h (renamed from wsutil/report_err.h) | 25 |
7 files changed, 146 insertions, 122 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index e9a4ed100d..ab9bb7ba82 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -58,7 +58,7 @@ set(WSUTIL_COMMON_FILES strnatcmp.c str_util.c strtoi.c - report_err.c + report_message.c tempfile.c time_util.c type_util.c diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am index 08af239524..680cf0ea75 100644 --- a/wsutil/Makefile.am +++ b/wsutil/Makefile.am @@ -74,7 +74,7 @@ libwsutil_nonrepl_INCLUDES = \ plugins.h \ privileges.h \ processes.h \ - report_err.h \ + report_message.h \ sign_ext.h \ sober128.h \ socket.h \ @@ -143,7 +143,7 @@ libwsutil_la_SOURCES = \ os_version_info.c \ plugins.c \ privileges.c \ - report_err.c \ + report_message.c \ sober128.c \ str_util.c \ strtoi.c \ diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index aa8a5bcafd..afaf1d673f 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -59,7 +59,7 @@ #endif /* _WIN32 */ #include "filesystem.h" -#include <wsutil/report_err.h> +#include <wsutil/report_message.h> #include <wsutil/privileges.h> #include <wsutil/file_util.h> #include <wsutil/utf8_entities.h> diff --git a/wsutil/plugins.c b/wsutil/plugins.c index d726e80c1e..76bb59d770 100644 --- a/wsutil/plugins.c +++ b/wsutil/plugins.c @@ -37,7 +37,7 @@ #include <wsutil/filesystem.h> #include <wsutil/privileges.h> #include <wsutil/file_util.h> -#include <wsutil/report_err.h> +#include <wsutil/report_message.h> #include <wsutil/plugins.h> #include <wsutil/ws_printf.h> /* ws_debug_printf */ diff --git a/wsutil/report_err.c b/wsutil/report_err.c deleted file mode 100644 index 557b200c90..0000000000 --- a/wsutil/report_err.c +++ /dev/null @@ -1,108 +0,0 @@ -/* report_err.c -* Routines for code that can run in GUI and command-line environments to -* use to report errors to the user (e.g., I/O errors, or problems with -* preference settings). -* -* The application using libwireshark will register error-reporting -* routines, and the routines defined here will call the registered -* routines. That way, these routines can be called by code that -* doesn't itself know whether to pop up a dialog or print something -* to the standard error. -* -* Wireshark - Network traffic analyzer -* By Gerald Combs <gerald@wireshark.org> -* Copyright 1998 Gerald Combs -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#include "config.h" - -#include <glib.h> -#include "report_err.h" - -static void (*vreport_failure_func)(const char *, va_list); -static void (*report_open_failure_func)(const char *, int, gboolean); -static void (*report_read_failure_func)(const char *, int); -static void (*report_write_failure_func)(const char *, int); - -void init_report_err(void (*vreport_failure_fcn_p)(const char *, va_list), - void (*report_open_failure_fcn_p)(const char *, int, gboolean), - void (*report_read_failure_fcn_p)(const char *, int), - void (*report_write_failure_fcn_p)(const char *, int)) -{ - vreport_failure_func = vreport_failure_fcn_p; - report_open_failure_func = report_open_failure_fcn_p; - report_read_failure_func = report_read_failure_fcn_p; - report_write_failure_func = report_write_failure_fcn_p; -} - -/* - * Report a general error. - */ -void -report_failure(const char *msg_format, ...) -{ - va_list ap; - - va_start(ap, msg_format); - (*vreport_failure_func)(msg_format, ap); - va_end(ap); -} - -/* - * Report an error when trying to open or create a file. - * "err" is assumed to be an error code from Wiretap; positive values are - * UNIX-style errnos, so this can be used for open failures not from - * Wiretap as long as the failure code is just an errno. - */ -void -report_open_failure(const char *filename, int err, - gboolean for_writing) -{ - (*report_open_failure_func)(filename, err, for_writing); -} - -/* - * Report an error when trying to read a file. - * "err" is assumed to be a UNIX-style errno. - */ -void -report_read_failure(const char *filename, int err) -{ - (*report_read_failure_func)(filename, err); -} - -/* - * Report an error when trying to write a file. - * "err" is assumed to be a UNIX-style errno. - */ -void -report_write_failure(const char *filename, int err) -{ - (*report_write_failure_func)(filename, err); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/wsutil/report_message.c b/wsutil/report_message.c new file mode 100644 index 0000000000..7889549422 --- /dev/null +++ b/wsutil/report_message.c @@ -0,0 +1,125 @@ +/* report_message.c + * Routines for code that can run in GUI and command-line environments to + * use to report errors and warnings to the user (e.g., I/O errors, or + * problems with preference settings) if the message should be shown as + * a GUI error in a GUI environment. + * + * The application using libwsutil will register error-reporting + * routines, and the routines defined here will call the registered + * routines. That way, these routines can be called by code that + * doesn't itself know whether to pop up a dialog or print something + * to the standard error. + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#include "config.h" + +#include <glib.h> +#include "report_message.h" + +static void (*vreport_failure_func)(const char *, va_list); +static void (*vreport_warning_func)(const char *, va_list); +static void (*report_open_failure_func)(const char *, int, gboolean); +static void (*report_read_failure_func)(const char *, int); +static void (*report_write_failure_func)(const char *, int); + +void init_report_message(void (*vreport_failure_fcn_p)(const char *, va_list), + void (*vreport_warning_fcn_p)(const char *, va_list), + void (*report_open_failure_fcn_p)(const char *, int, gboolean), + void (*report_read_failure_fcn_p)(const char *, int), + void (*report_write_failure_fcn_p)(const char *, int)) +{ + vreport_failure_func = vreport_failure_fcn_p; + vreport_warning_func = vreport_warning_fcn_p; + report_open_failure_func = report_open_failure_fcn_p; + report_read_failure_func = report_read_failure_fcn_p; + report_write_failure_func = report_write_failure_fcn_p; +} + +/* + * Report a general error. + */ +void +report_failure(const char *msg_format, ...) +{ + va_list ap; + + va_start(ap, msg_format); + (*vreport_failure_func)(msg_format, ap); + va_end(ap); +} + +/* + * Report a general warning. + */ +void +report_warning(const char *msg_format, ...) +{ + va_list ap; + + va_start(ap, msg_format); + (*vreport_warning_func)(msg_format, ap); + va_end(ap); +} + +/* + * Report an error when trying to open or create a file. + * "err" is assumed to be an error code from Wiretap; positive values are + * UNIX-style errnos, so this can be used for open failures not from + * Wiretap as long as the failure code is just an errno. + */ +void +report_open_failure(const char *filename, int err, + gboolean for_writing) +{ + (*report_open_failure_func)(filename, err, for_writing); +} + +/* + * Report an error when trying to read a file. + * "err" is assumed to be a UNIX-style errno. + */ +void +report_read_failure(const char *filename, int err) +{ + (*report_read_failure_func)(filename, err); +} + +/* + * Report an error when trying to write a file. + * "err" is assumed to be a UNIX-style errno. + */ +void +report_write_failure(const char *filename, int err) +{ + (*report_write_failure_func)(filename, err); +} + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=8 tabstop=8 noexpandtab: + * :indentSize=8:tabSize=8:noTabs=false: + */ diff --git a/wsutil/report_err.h b/wsutil/report_message.h index fcef2e2e4b..63cbc0d1b4 100644 --- a/wsutil/report_err.h +++ b/wsutil/report_message.h @@ -1,9 +1,10 @@ -/* report_err.h +/* report_message.h * Declarations of routines for code that can run in GUI and command-line - * environments to use to report errors to the user (e.g., I/O errors, or - * problems with preference settings). + * environments to use to report errors and warnings to the user (e.g., + * I/O errors, or problems with preference settings) if the message should + * be shown as a GUI error in a GUI environment. * - * The application using libwireshark will register error-reporting + * The application using libwsutil will register message-reporting * routines, and the routines declared here will call the registered * routines. That way, these routines can be called by code that * doesn't itself know whether to pop up a dialog or print something @@ -28,8 +29,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __REPORT_ERR_H__ -#define __REPORT_ERR_H__ +#ifndef __REPORT_MESSAGE_H__ +#define __REPORT_MESSAGE_H__ #include "ws_symbol_export.h" @@ -38,10 +39,11 @@ extern "C" { #endif /* __cplusplus */ /* - * Initialize the report err routines + * Initialize the report message routines */ -WS_DLL_PUBLIC void init_report_err( +WS_DLL_PUBLIC void init_report_message( void (*vreport_failure)(const char *, va_list), + void (*vreport_warning)(const char *, va_list), void (*report_open_failure)(const char *, int, gboolean), void (*report_read_failure)(const char *, int), void (*report_write_failure)(const char *, int)); @@ -52,6 +54,11 @@ WS_DLL_PUBLIC void init_report_err( WS_DLL_PUBLIC void report_failure(const char *msg_format, ...) G_GNUC_PRINTF(1, 2); /* + * Report a general warning. + */ +WS_DLL_PUBLIC void report_warning(const char *msg_format, ...) G_GNUC_PRINTF(1, 2); + +/* * Report an error when trying to open a file. * "err" is assumed to be an error code from Wiretap; positive values are * UNIX-style errnos, so this can be used for open failures not from @@ -76,4 +83,4 @@ WS_DLL_PUBLIC void report_write_failure(const char *filename, int err); } #endif /* __cplusplus */ -#endif /* __REPORT_ERR_H__ */ +#endif /* __REPORT_MESSAGE_H__ */ |