Add routines to return "Please report this as a bug" message strings.

(Routines, so that if we internationalize strings not in the Qt code,
this can return the appropriately translated version.)

Change-Id: I1c169d79acde2f0545af7af2a737883d58f52509
Reviewed-on: https://code.wireshark.org/review/32549
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-03-23 21:02:47 -07:00
parent 2cb4d315ad
commit 4ad6f2a813
5 changed files with 81 additions and 24 deletions

View File

@ -67,6 +67,7 @@
#include "log.h"
#include <wsutil/file_util.h>
#include <wsutil/please_report_bug.h>
#ifndef _WIN32
#include <netinet/in.h>
@ -85,14 +86,6 @@
#include <sys/sockio.h>
#endif
/*
* Standard secondary message for unexpected errors.
*/
static const char please_report[] =
"Please report this to the Wireshark developers.\n"
"https://bugs.wireshark.org/\n"
"(This is not a crash; please do not report it as such.)";
/*
* Given an interface name, find the "friendly name" and interface
* type for the interface.
@ -977,7 +970,8 @@ set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name,
* tell the user to tell the Wireshark developers about it.
*/
if (strstr(set_datalink_err_str, "is not one of the DLTs supported by this device") == NULL)
g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, please_report);
g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len,
"%s", please_report_bug());
else
secondary_errmsg[0] = '\0';
return FALSE;

View File

@ -86,6 +86,7 @@
#include "wsutil/str_util.h"
#include "wsutil/inet_addr.h"
#include "wsutil/time_util.h"
#include "wsutil/please_report_bug.h"
#include "caputils/ws80211_utils.h"
@ -326,14 +327,6 @@ typedef struct _pcap_queue_element {
u_char *pd;
} pcap_queue_element;
/*
* Standard secondary message for unexpected errors.
*/
static const char please_report[] =
"Please report this to the Wireshark developers.\n"
"https://bugs.wireshark.org/\n"
"(This is not a crash; please do not report it as such.)";
/*
* This needs to be static, so that the SIGINT handler can clear the "go"
* flag and for saved_shb_idb_lock.
@ -2774,7 +2767,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
"Couldn't initialize Windows Sockets: error %d", err);
break;
}
g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, please_report);
g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, please_report_bug());
return FALSE;
}
#endif
@ -3342,7 +3335,7 @@ capture_loop_dispatch(loop_data *ld,
if (sel_ret < 0 && errno != EINTR) {
g_snprintf(errmsg, errmsg_len,
"Unexpected error from select: %s", g_strerror(errno));
report_capture_error(errmsg, please_report);
report_capture_error(errmsg, please_report_bug());
ld->go = FALSE;
}
}
@ -3415,7 +3408,7 @@ capture_loop_dispatch(loop_data *ld,
if (sel_ret < 0 && errno != EINTR) {
g_snprintf(errmsg, errmsg_len,
"Unexpected error from select: %s", g_strerror(errno));
report_capture_error(errmsg, please_report);
report_capture_error(errmsg, please_report_bug());
ld->go = FALSE;
}
}
@ -3912,7 +3905,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
case INITFILTER_OTHER_ERROR:
g_snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).",
pcap_geterr(pcap_src->pcap_h));
g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report);
g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report_bug());
goto error;
}
}
@ -4164,7 +4157,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
} else {
g_snprintf(errmsg, sizeof(errmsg), "Error while capturing packets: %s",
cap_err_str);
report_capture_error(errmsg, please_report);
report_capture_error(errmsg, please_report_bug());
}
break;
} else if (pcap_src->from_cap_pipe && pcap_src->cap_pipe_err == PIPERR) {
@ -4236,7 +4229,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
g_snprintf(errmsg, sizeof(errmsg),
"Can't get packet-drop statistics: %s",
pcap_geterr(pcap_src->pcap_h));
report_capture_error(errmsg, please_report);
report_capture_error(errmsg, please_report_bug());
}
}
report_packet_drops(received, pcap_dropped, pcap_src->dropped, pcap_src->flushed, stats->ps_ifdrop, interface_opts->display_name);
@ -4348,7 +4341,7 @@ capture_loop_get_errmsg(char *errmsg, size_t errmsglen, char *secondary_errmsg,
fname, g_strerror(err));
}
g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen,
"%s", please_report);
"%s", please_report_bug());
break;
}
}

View File

@ -48,6 +48,7 @@ set(WSUTIL_PUBLIC_HEADERS
nstime.h
os_version_info.h
pint.h
please_report_bug.h
plugins.h
pow2.h
privileges.h
@ -102,6 +103,7 @@ set(WSUTIL_COMMON_FILES
nstime.c
cpu_info.c
os_version_info.c
please_report_bug.c
privileges.c
rsa.c
sober128.c

View File

@ -0,0 +1,33 @@
/* please_report_bug.c
* Routines returning strings to use when reporting a bug.
* They ask the user to report a bug to the Wireshark developers.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "please_report_bug.h"
/*
* Long message, to use in alert boxes and printed messages.
*/
const char *
please_report_bug(void)
{
return
"Please report this to the Wireshark developers.\n"
"https://bugs.wireshark.org/\n"
"(This is not a crash; please do not report it as such.)";
}
/*
* Short message, to use in status bar messages.
*/
const char *
please_report_bug_short(void)
{
return "Please report this to the Wireshark developers.";
}

View File

@ -0,0 +1,35 @@
/* please_report_bug.h
* Declarations of routines returning strings to use when reporting a bug.
* They ask the user to report a bug to the Wireshark developers.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PLEASE_REPORT_BUG_H__
#define __PLEASE_REPORT_BUG_H__
#include "ws_symbol_export.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Long message, to use in alert boxes and printed messages.
*/
WS_DLL_PUBLIC const char *please_report_bug(void);
/*
* Short message, to use in status bar messages.
*/
WS_DLL_PUBLIC const char *please_report_bug_short(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __PLEASE_REPORT_BUG_H__ */