Replace all strerror() with g_strerror().

Remove our local strerror implementation.
Mark strerror as locale unsafe API.

This fixes bug 5715.

svn path=/trunk/; revision=37812
This commit is contained in:
Stig Bjørlykke 2011-06-28 09:00:11 +00:00
parent 6c094f6775
commit 8443bbbf75
48 changed files with 157 additions and 284 deletions

View File

@ -25,7 +25,6 @@ check_include_file("stdarg.h" HAVE_STDARG_H)
check_include_file("stddef.h" HAVE_STDDEF_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("strerror.h" NEED_STRERROR_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)

View File

@ -75,7 +75,7 @@ read_failure_alert_box(const char *filename, int err)
{
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"An error occurred while reading from the file \"%s\": %s.",
filename, strerror(err));
filename, g_strerror(err));
}
/*

View File

@ -676,7 +676,7 @@ process_cap_file(wtap *wth, const char *filename)
if (size == -1) {
fprintf(stderr,
"capinfos: Can't get size of \"%s\": %s.\n",
filename, strerror(err));
filename, g_strerror(err));
g_free(cf_info.encap_counts);
return 1;
}

View File

@ -127,7 +127,7 @@ get_interface_list(int *err, char **err_str)
if (err_str != NULL) {
*err_str = g_strdup_printf(
"Can't get list of interfaces: error opening socket: %s",
strerror(errno));
g_strerror(errno));
}
return NULL;
}
@ -148,7 +148,7 @@ get_interface_list(int *err, char **err_str)
if (err_str != NULL) {
*err_str = g_strdup_printf(
"Can't get list of interfaces: SIOCGIFCONF ioctl error: %s",
strerror(errno));
g_strerror(errno));
}
goto fail;
}
@ -206,7 +206,7 @@ get_interface_list(int *err, char **err_str)
if (err_str != NULL) {
*err_str = g_strdup_printf(
"Can't get list of interfaces: SIOCGIFFLAGS error getting flags for interface %s: %s",
ifr->ifr_name, strerror(errno));
ifr->ifr_name, g_strerror(errno));
}
goto fail;
}

View File

@ -595,7 +595,7 @@ sync_pipe_start(capture_options *capture_opts) {
#else /* _WIN32 */
if (pipe(sync_pipe) < 0) {
/* Couldn't create the pipe between parent and child. */
report_failure("Couldn't create sync pipe: %s", strerror(errno));
report_failure("Couldn't create sync pipe: %s", g_strerror(errno));
g_free( (gpointer) argv[0]);
g_free(argv);
return FALSE;
@ -610,7 +610,7 @@ sync_pipe_start(capture_options *capture_opts) {
ws_close(sync_pipe[PIPE_READ]);
execv(argv[0], (gpointer)argv);
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
argv[0], strerror(errno));
argv[0], g_strerror(errno));
sync_pipe_errmsg_to_parent(2, errmsg, "");
/* Exit with "_exit()", so that we don't close the connection
@ -644,7 +644,7 @@ sync_pipe_start(capture_options *capture_opts) {
if (capture_opts->fork_child == -1) {
/* We couldn't even create the child process. */
report_failure("Couldn't create child process: %s", strerror(errno));
report_failure("Couldn't create child process: %s", g_strerror(errno));
ws_close(sync_pipe_read_fd);
#ifdef _WIN32
ws_close(capture_opts->signal_pipe_write_fd);
@ -795,7 +795,7 @@ sync_pipe_open_command(const char** argv, int *data_read_fd,
/* Create a pipe for the child process to send us messages */
if (pipe(sync_pipe) < 0) {
/* Couldn't create the message pipe between parent and child. */
*msg = g_strdup_printf("Couldn't create sync pipe: %s", strerror(errno));
*msg = g_strdup_printf("Couldn't create sync pipe: %s", g_strerror(errno));
g_free( (gpointer) argv[0]);
g_free(argv);
return -1;
@ -804,7 +804,7 @@ sync_pipe_open_command(const char** argv, int *data_read_fd,
/* Create a pipe for the child process to send us data */
if (pipe(data_pipe) < 0) {
/* Couldn't create the data pipe between parent and child. */
*msg = g_strdup_printf("Couldn't create data pipe: %s", strerror(errno));
*msg = g_strdup_printf("Couldn't create data pipe: %s", g_strerror(errno));
ws_close(sync_pipe[PIPE_READ]);
ws_close(sync_pipe[PIPE_WRITE]);
g_free( (gpointer) argv[0]);
@ -825,7 +825,7 @@ sync_pipe_open_command(const char** argv, int *data_read_fd,
ws_close(sync_pipe[PIPE_WRITE]);
execv(argv[0], (gpointer)argv);
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
argv[0], strerror(errno));
argv[0], g_strerror(errno));
sync_pipe_errmsg_to_parent(2, errmsg, "");
/* Exit with "_exit()", so that we don't close the connection
@ -862,7 +862,7 @@ sync_pipe_open_command(const char** argv, int *data_read_fd,
if (*fork_child == -1) {
/* We couldn't even create the child process. */
*msg = g_strdup_printf("Couldn't create child process: %s", strerror(errno));
*msg = g_strdup_printf("Couldn't create child process: %s", g_strerror(errno));
ws_close(*data_read_fd);
ws_close(*message_read_fd);
return -1;
@ -1352,9 +1352,9 @@ pipe_read_bytes(int pipe_fd, char *bytes, int required, char **msg)
error = errno;
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
"read from pipe %d: error(%u): %s", pipe_fd, error,
strerror(error));
g_strerror(error));
*msg = g_strdup_printf("Error reading from sync pipe: %s",
strerror(error));
g_strerror(error));
return newly;
}
@ -1413,7 +1413,7 @@ sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max) {
} else if (newly < 0) {
/* error */
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
"read from pipe %d: error(%u): %s", pipe_fd, errno, strerror(errno));
"read from pipe %d: error(%u): %s", pipe_fd, errno, g_strerror(errno));
return newly;
} else if (bytes[offset] == '\n') {
break;
@ -1654,7 +1654,7 @@ sync_pipe_wait_for_child(int fork_child, gchar **msgp)
ret = 0;
#ifdef _WIN32
if (_cwait(&fork_child_status, fork_child, _WAIT_CHILD) == -1) {
*msgp = g_strdup_printf("Error from cwait(): %s", strerror(errno));
*msgp = g_strdup_printf("Error from cwait(): %s", g_strerror(errno));
ret = -1;
} else {
/*
@ -1696,7 +1696,7 @@ sync_pipe_wait_for_child(int fork_child, gchar **msgp)
ret = -1;
}
} else {
*msgp = g_strdup_printf("Error from waitpid(): %s", strerror(errno));
*msgp = g_strdup_printf("Error from waitpid(): %s", g_strerror(errno));
ret = -1;
}
#endif
@ -1820,7 +1820,7 @@ signal_pipe_capquit_to_child(capture_options *capture_opts)
ret = write(capture_opts->signal_pipe_write_fd, quit_msg, sizeof quit_msg);
if(ret == -1) {
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
"signal_pipe_capquit_to_child: %d header: error %s", capture_opts->signal_pipe_write_fd, strerror(errno));
"signal_pipe_capquit_to_child: %d header: error %s", capture_opts->signal_pipe_write_fd, g_strerror(errno));
}
}
#endif
@ -1842,7 +1842,7 @@ sync_pipe_stop(capture_options *capture_opts)
int sts = kill(capture_opts->fork_child, SIGINT);
if (sts != 0) {
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
"Sending SIGINT to child failed: %s\n", strerror(errno));
"Sending SIGINT to child failed: %s\n", g_strerror(errno));
}
#else
#define STOP_SLEEP_TIME 500 /* ms */
@ -1882,7 +1882,7 @@ sync_pipe_kill(int fork_child)
int sts = kill(fork_child, SIGTERM); /* SIGTERM so it can clean up if necessary */
if (sts != 0) {
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
"Sending SIGTERM to child failed: %s\n", strerror(errno));
"Sending SIGTERM to child failed: %s\n", g_strerror(errno));
}
#else
/* Remark: This is not the preferred method of closing a process!

View File

@ -306,9 +306,6 @@
/* Define if inet/v6defs.h needs to be included */
#cmakedefine NEED_INET_V6DEFS_H 1
/* Define if strerror.h needs to be included */
#cmakedefine NEED_STRERROR_H 1
/* Define if strptime.h needs to be included */
#cmakedefine NEED_STRPTIME_H 1

View File

@ -634,7 +634,7 @@ read_users_filters(GSList **cfl)
if (errno != ENOENT) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open filter file\n\"%s\": %s.", path,
strerror(errno));
g_strerror(errno));
}
g_free(path);
return FALSE;
@ -661,7 +661,7 @@ color_filters_read_globals(gpointer user_data)
if (errno != ENOENT) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open global filter file\n\"%s\": %s.", path,
strerror(errno));
g_strerror(errno));
}
g_free(path);
return FALSE;
@ -684,7 +684,7 @@ color_filters_import(gchar *path, gpointer user_data)
if ((f = ws_fopen(path, "r")) == NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open\n%s\nfor reading: %s.",
path, strerror(errno));
path, g_strerror(errno));
return FALSE;
}
@ -749,7 +749,7 @@ color_filters_write(GSList *cfl)
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\"\nfor color files: %s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
return FALSE;
}
@ -758,7 +758,7 @@ color_filters_write(GSList *cfl)
if ((f = ws_fopen(path, "w+")) == NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open\n%s\nfor writing: %s.",
path, strerror(errno));
path, g_strerror(errno));
g_free(path);
return FALSE;
}
@ -777,7 +777,7 @@ color_filters_export(gchar *path, GSList *cfl, gboolean only_marked)
if ((f = ws_fopen(path, "w+")) == NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open\n%s\nfor writing: %s.",
path, strerror(errno));
path, g_strerror(errno));
return FALSE;
}
write_filters_file(cfl, f, only_marked);

View File

@ -43,8 +43,6 @@
/* #undef HAVE_SA_LEN */
/* #undef NEED_STRERROR_H */
/* #undef HAVE_MKSTEMP */
/* #undef HAVE_MKDTEMP */

View File

@ -1754,16 +1754,6 @@ fi
AM_CONDITIONAL(NEED_GETOPT_LO, test "x$ac_cv_func_getopt" = "xno")
AC_SUBST(GETOPT_LO)
AC_CHECK_FUNC(strerror, STRERROR_LO="",
[STRERROR_LO="strerror.lo"
AC_DEFINE(NEED_STRERROR_H, 1, [Define if strerror.h needs to be included])
])
if test "$ac_cv_func_strerror" = no ; then
STRERROR_LO="strerror.lo"
fi
AM_CONDITIONAL(NEED_STRERROR_LO, test "x$ac_cv_func_strerror" = "xno")
AC_SUBST(STRERROR_LO)
AC_CHECK_FUNC(strncasecmp, STRNCASECMP_LO="",
STRNCASECMP_LO="strncasecmp.lo")
if test "$ac_cv_func_strncasecmp" = no ; then

View File

@ -32,10 +32,6 @@
#include <string.h>
#include <errno.h>
#ifdef NEED_STRERROR_H
#include "wsutil/strerror.h"
#endif
#include <glib.h>
#include <epan/epan.h>
@ -103,24 +99,24 @@ main(int argc, char **argv)
if (gpf_open_errno != 0) {
fprintf(stderr,
"can't open global preferences file \"%s\": %s.\n",
pf_path, strerror(gpf_open_errno));
pf_path, g_strerror(gpf_open_errno));
}
if (gpf_read_errno != 0) {
fprintf(stderr,
"I/O error reading global preferences file \"%s\": %s.\n",
pf_path, strerror(gpf_read_errno));
pf_path, g_strerror(gpf_read_errno));
}
}
if (pf_path != NULL) {
if (pf_open_errno != 0) {
fprintf(stderr,
"can't open your preferences file \"%s\": %s.\n",
pf_path, strerror(pf_open_errno));
pf_path, g_strerror(pf_open_errno));
}
if (pf_read_errno != 0) {
fprintf(stderr,
"I/O error reading your preferences file \"%s\": %s.\n",
pf_path, strerror(pf_read_errno));
pf_path, g_strerror(pf_read_errno));
}
}
@ -189,7 +185,7 @@ static void
read_failure_message(const char *filename, int err)
{
fprintf(stderr, "dftest: An error occurred while reading from the file \"%s\": %s.\n",
filename, strerror(err));
filename, g_strerror(err));
}
/*
@ -199,5 +195,5 @@ static void
write_failure_message(const char *filename, int err)
{
fprintf(stderr, "dftest: An error occurred while writing to the file \"%s\": %s.\n",
filename, strerror(err));
filename, g_strerror(err));
}

View File

@ -539,7 +539,7 @@ relinquish_all_capabilities(void)
cap_t caps = cap_init(); /* all capabilities initialized to off */
print_caps("Pre-clear");
if (cap_set_proc(caps)) {
cmdarg_err("cap_set_proc() fail return: %s", strerror(errno));
cmdarg_err("cap_set_proc() fail return: %s", g_strerror(errno));
}
print_caps("Post-clear");
cap_free(caps);
@ -1467,14 +1467,14 @@ relinquish_privs_except_capture(void)
print_caps("Pre drop, pre set");
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) {
cmdarg_err("prctl() fail return: %s", strerror(errno));
cmdarg_err("prctl() fail return: %s", g_strerror(errno));
}
cap_set_flag(caps, CAP_PERMITTED, cl_len, cap_list, CAP_SET);
cap_set_flag(caps, CAP_INHERITABLE, cl_len, cap_list, CAP_SET);
if (cap_set_proc(caps)) {
cmdarg_err("cap_set_proc() fail return: %s", strerror(errno));
cmdarg_err("cap_set_proc() fail return: %s", g_strerror(errno));
}
print_caps("Pre drop, post set");
@ -1483,7 +1483,7 @@ relinquish_privs_except_capture(void)
print_caps("Post drop, pre set");
cap_set_flag(caps, CAP_EFFECTIVE, cl_len, cap_list, CAP_SET);
if (cap_set_proc(caps)) {
cmdarg_err("cap_set_proc() fail return: %s", strerror(errno));
cmdarg_err("cap_set_proc() fail return: %s", g_strerror(errno));
}
print_caps("Post drop, post set");
@ -1688,7 +1688,7 @@ cap_pipe_open_live(char *pipename,
else {
g_snprintf(errmsg, errmsgl,
"The capture session could not be initiated "
"due to error getting information on pipe/socket: %s", strerror(errno));
"due to error getting information on pipe/socket: %s", g_strerror(errno));
pcap_opts->cap_pipe_err = PIPERR;
}
return;
@ -1698,7 +1698,7 @@ cap_pipe_open_live(char *pipename,
if (fd == -1) {
g_snprintf(errmsg, errmsgl,
"The capture session could not be initiated "
"due to error on pipe open: %s", strerror(errno));
"due to error on pipe open: %s", g_strerror(errno));
pcap_opts->cap_pipe_err = PIPERR;
return;
}
@ -1707,7 +1707,7 @@ cap_pipe_open_live(char *pipename,
if (fd == -1) {
g_snprintf(errmsg, errmsgl,
"The capture session could not be initiated "
"due to error on socket create: %s", strerror(errno));
"due to error on socket create: %s", g_strerror(errno));
pcap_opts->cap_pipe_err = PIPERR;
return;
}
@ -1747,7 +1747,7 @@ cap_pipe_open_live(char *pipename,
if (b == -1) {
g_snprintf(errmsg, errmsgl,
"The capture session coud not be initiated "
"due to error on socket connect: %s", strerror(errno));
"due to error on socket connect: %s", g_strerror(errno));
pcap_opts->cap_pipe_err = PIPERR;
return;
}
@ -1833,7 +1833,7 @@ cap_pipe_open_live(char *pipename,
sel_ret = cap_pipe_select(fd);
if (sel_ret < 0) {
g_snprintf(errmsg, errmsgl,
"Unexpected error from select: %s", strerror(errno));
"Unexpected error from select: %s", g_strerror(errno));
goto error;
} else if (sel_ret > 0) {
b = read(fd, ((char *)&magic)+bytes_read, sizeof magic-bytes_read);
@ -1842,7 +1842,7 @@ cap_pipe_open_live(char *pipename,
g_snprintf(errmsg, errmsgl, "End of file on pipe magic during open");
else
g_snprintf(errmsg, errmsgl, "Error on pipe magic during open: %s",
strerror(errno));
g_strerror(errno));
goto error;
}
bytes_read += b;
@ -1862,7 +1862,7 @@ cap_pipe_open_live(char *pipename,
g_snprintf(errmsg, errmsgl, "End of file on pipe magic during open");
else
g_snprintf(errmsg, errmsgl, "Error on pipe magic during open: %s",
strerror(errno));
g_strerror(errno));
goto error;
}
@ -1908,7 +1908,7 @@ cap_pipe_open_live(char *pipename,
sel_ret = cap_pipe_select(fd);
if (sel_ret < 0) {
g_snprintf(errmsg, errmsgl,
"Unexpected error from select: %s", strerror(errno));
"Unexpected error from select: %s", g_strerror(errno));
goto error;
} else if (sel_ret > 0) {
b = read(fd, ((char *)hdr)+bytes_read,
@ -1918,7 +1918,7 @@ cap_pipe_open_live(char *pipename,
g_snprintf(errmsg, errmsgl, "End of file on pipe header during open");
else
g_snprintf(errmsg, errmsgl, "Error on pipe header during open: %s",
strerror(errno));
g_strerror(errno));
goto error;
}
bytes_read += b;
@ -1935,7 +1935,7 @@ cap_pipe_open_live(char *pipename,
g_snprintf(errmsg, errmsgl, "End of file on pipe header during open");
else
g_snprintf(errmsg, errmsgl, "Error on pipe header header during open: %s",
strerror(errno));
g_strerror(errno));
goto error;
}
#endif /* USE_THREADS */
@ -2148,7 +2148,7 @@ cap_pipe_dispatch(loop_data *ld, pcap_options *pcap_opts, guchar *data, char *er
LocalFree(err_str);
#else
g_snprintf(errmsg, errmsgl, "Error reading from pipe: %s",
strerror(errno));
g_strerror(errno));
#endif
/* Fall through */
case PD_ERR:
@ -2554,7 +2554,7 @@ capture_loop_init_output(capture_options *capture_opts, loop_data *ld, char *err
g_snprintf(errmsg, errmsg_len,
"The file to which the capture would be"
" saved (\"%s\") could not be opened: %s.",
capture_opts->save_file, strerror(err));
capture_opts->save_file, g_strerror(err));
}
break;
}
@ -2622,7 +2622,7 @@ capture_loop_dispatch(loop_data *ld,
if (sel_ret <= 0) {
if (sel_ret < 0 && errno != EINTR) {
g_snprintf(errmsg, errmsg_len,
"Unexpected error from select: %s", strerror(errno));
"Unexpected error from select: %s", g_strerror(errno));
report_capture_error(errmsg, please_report);
ld->go = FALSE;
}
@ -2686,7 +2686,7 @@ capture_loop_dispatch(loop_data *ld,
} else {
if (sel_ret < 0 && errno != EINTR) {
g_snprintf(errmsg, errmsg_len,
"Unexpected error from select: %s", strerror(errno));
"Unexpected error from select: %s", g_strerror(errno));
report_capture_error(errmsg, please_report);
ld->go = FALSE;
}
@ -2882,7 +2882,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
if (is_tempfile) {
g_snprintf(errmsg, errmsg_len,
"The temporary file to which the capture would be saved (\"%s\") "
"could not be opened: %s.", capfile_name, strerror(errno));
"could not be opened: %s.", capfile_name, g_strerror(errno));
} else {
if (capture_opts->multi_files_on) {
ringbuf_error_cleanup();
@ -2891,7 +2891,7 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd,
g_snprintf(errmsg, errmsg_len,
"The file to which the capture would be saved (\"%s\") "
"could not be opened: %s.", capfile_name,
strerror(errno));
g_strerror(errno));
}
g_free(capfile_name);
return FALSE;
@ -3337,7 +3337,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
/* On Linux, if an interface goes down while you're capturing on it,
you'll get a "recvfrom: Network is down" or
"The interface went down" error (ENETDOWN).
(At least you will if strerror() doesn't show a local translation
(At least you will if g_strerror() doesn't show a local translation
of the error.)
On FreeBSD and OS X, if a network adapter disappears while
@ -3527,13 +3527,13 @@ capture_loop_get_errmsg(char *errmsg, int errmsglen, const char *fname,
g_snprintf(errmsg, errmsglen,
"The file to which the capture was being saved\n"
"(\"%s\") could not be closed: %s.",
fname, strerror(err));
fname, g_strerror(err));
} else {
g_snprintf(errmsg, errmsglen,
"An error occurred while writing to the file"
" to which the capture was being saved\n"
"(\"%s\"): %s.",
fname, strerror(err));
fname, g_strerror(err));
}
break;
}

View File

@ -115,7 +115,7 @@ void dfilter_macro_save(const gchar* filename, gchar** error) {
FILE* f = ws_fopen(filename,"w");
if (!f) {
*error = ep_strdup_printf("Could not open file: '%s', error: %s\n", filename, strerror(errno) );
*error = ep_strdup_printf("Could not open file: '%s', error: %s\n", filename, g_strerror(errno) );
return;
}

View File

@ -275,7 +275,7 @@ description_attr description=\042
D(("entity: %s filename: %s yyin: %p\n",e->name,e->file,yyin));
if (!yyin) {
if (errno) {
fprintf(stderr, "Could not open file: '%s', error: %s\n", e->file, strerror(errno) );
fprintf(stderr, "Could not open file: '%s', error: %s\n", e->file, g_strerror(errno) );
yyterminate();
}
} else {

View File

@ -288,9 +288,6 @@
#include <ctype.h>
#include <glib.h>
#include <math.h>
#ifdef NEED_STRERROR_H
#include "wsutil/strerror.h"
#endif
#include "isprint.h"
@ -1321,7 +1318,7 @@ static void read_IOR_strings_from_file(const gchar *name, int max_iorlen) {
if (fp == NULL) {
if (errno == EACCES)
fprintf(stderr, "Error opening file %s for reading: %s\n", name, strerror(errno));
fprintf(stderr, "Error opening file %s for reading: %s\n", name, g_strerror(errno));
return;
}

View File

@ -200,7 +200,7 @@ extern GString* dtd_preparse(const gchar* dname,const gchar* fname, GString* er
if (!yyin) {
if (err)
g_string_append_printf(err, "Could not open file: '%s', error: %s",fullname,strerror(errno));
g_string_append_printf(err, "Could not open file: '%s', error: %s",fullname,g_strerror(errno));
return NULL;
}

View File

@ -395,7 +395,7 @@ init_progfile_dir(const char *arg0
* allocate for the current directory.
*/
return g_strdup_printf("pathconf failed: %s\n",
strerror(errno));
g_strerror(errno));
}
curdir = (char *)g_malloc(path_max);
if (getcwd(curdir, path_max) == NULL) {
@ -405,7 +405,7 @@ init_progfile_dir(const char *arg0
*/
g_free(curdir);
return g_strdup_printf("getcwd failed: %s\n",
strerror(errno));
g_strerror(errno));
}
path = g_strdup_printf("%s/%s", curdir, arg0);
g_free(curdir);
@ -1650,7 +1650,7 @@ file_open_error_message(int err, gboolean for_writing)
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"The file \"%%s\" could not be %s: %s.",
for_writing ? "created" : "opened",
strerror(err));
g_strerror(err));
errmsg = errmsg_errno;
break;
}
@ -1686,7 +1686,7 @@ file_write_error_message(int err)
default:
g_snprintf(errmsg_errno, sizeof(errmsg_errno),
"An error occurred while writing to the file \"%%s\": %s.",
strerror(err));
g_strerror(err));
errmsg = errmsg_errno;
break;
}

View File

@ -267,7 +267,7 @@
if (!yyin) {
if (errno) {
g_string_append_printf(error, "Could not open file: '%s', error: %s\n", fullpaths[include_stack_ptr], strerror(errno) );
g_string_append_printf(error, "Could not open file: '%s', error: %s\n", fullpaths[include_stack_ptr], g_strerror(errno) );
yyterminate();
}
} else {
@ -583,7 +583,7 @@ gboolean radius_load_dictionary (radius_dictionary_t* d, gchar* dir, const gchar
yyin = ws_fopen(fullpaths[include_stack_ptr],"r");
if (!yyin) {
g_string_append_printf(error, "Could not open file: '%s', error: %s\n", fullpaths[include_stack_ptr], strerror(errno) );
g_string_append_printf(error, "Could not open file: '%s', error: %s\n", fullpaths[include_stack_ptr], g_strerror(errno) );
g_free(fullpaths[include_stack_ptr]);
*err_str = error->str;
g_string_free(error,FALSE);

View File

@ -262,7 +262,7 @@ gboolean uat_save(uat_t* uat, char** error) {
}
if (!fp) {
*error = ep_strdup_printf("uat_save: error opening '%s': %s",fname,strerror(errno));
*error = ep_strdup_printf("uat_save: error opening '%s': %s",fname,g_strerror(errno));
return FALSE;
}
@ -449,7 +449,7 @@ gboolean uat_fld_chk_num_dec(void* u1 _U_, const char* strptr, unsigned len, con
long i = strtol(str,&str,10);
if ( ( i == 0) && (errno == ERANGE || errno == EINVAL) ) {
*err = strerror(errno);
*err = g_strerror(errno);
return FALSE;
}
}
@ -464,7 +464,7 @@ gboolean uat_fld_chk_num_hex(void* u1 _U_, const char* strptr, unsigned len, con
long i = strtol(str,&str,16);
if ( ( i == 0) && (errno == ERANGE || errno == EINVAL) ) {
*err = strerror(errno);
*err = g_strerror(errno);
return FALSE;
}
}

View File

@ -285,7 +285,7 @@ gboolean uat_load(uat_t* uat_in, char** err) {
if (!(yyin = ws_fopen(fname,"r"))) {
*err = strerror(errno);
*err = g_strerror(errno);
g_free(fname);
return FALSE;
}

View File

@ -84,7 +84,7 @@ write_prefs_to_file(void)
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_dir_path,
strerror(errno));
g_strerror(errno));
g_free(pf_dir_path);
} else {
/* Write the preferencs out. */
@ -92,7 +92,7 @@ write_prefs_to_file(void)
if (err != 0) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't open preferences file\n\"%s\": %s.", pf_path,
strerror(err));
g_strerror(err));
g_free(pf_path);
}
}

View File

@ -1080,7 +1080,7 @@ color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
if (!prefs.gui_use_pref_save) {
if (!color_filters_write(color_filter_edit_list))
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open filter file: %s", strerror(errno));
"Could not open filter file: %s", g_strerror(errno));
}
/* Apply the coloring rules, both the temporary ones in
@ -1100,7 +1100,7 @@ color_save_cb(GtkButton *button _U_, gpointer user_data _U_)
if (!color_filters_write(color_filter_edit_list))
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open filter file: %s", strerror(errno));
"Could not open filter file: %s", g_strerror(errno));
}
/* User pressed "Cancel" button (or "ESC" or the 'X'):

View File

@ -837,7 +837,7 @@ filter_dlg_save(filter_list_type_t list_type)
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\"\nfor filter files: %s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
return;
}
@ -847,7 +847,7 @@ filter_dlg_save(filter_list_type_t list_type)
/* We had an error saving the filter. */
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not save to your %s filter file\n\"%s\": %s.",
filter_type, f_path, strerror(f_save_errno));
filter_type, f_path, g_strerror(f_save_errno));
g_free(f_path);
}
}

View File

@ -503,7 +503,7 @@ follow_print_stream(GtkWidget * w _U_, gpointer data)
} else {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Error writing to print command: %s",
strerror(errno));
g_strerror(errno));
}
/* XXX - cancel printing? */
destroy_print_stream(stream);
@ -941,7 +941,7 @@ follow_destroy_cb(GtkWidget *w, gpointer data _U_)
case FOLLOW_TCP :
i = ws_unlink(follow_info->data_out_filename);
if(i != 0) {
g_warning("Follow: Couldn't remove temporary file: \"%s\", errno: %s (%u)", follow_info->data_out_filename, strerror(errno), errno);
g_warning("Follow: Couldn't remove temporary file: \"%s\", errno: %s (%u)", follow_info->data_out_filename, g_strerror(errno), errno);
}
break;

View File

@ -145,7 +145,7 @@ follow_tcp_stream_cb(GtkWidget * w _U_, gpointer data _U_)
if (tmp_fd == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not create temporary file %s: %s",
follow_info->data_out_filename, strerror(errno));
follow_info->data_out_filename, g_strerror(errno));
g_free(follow_info->data_out_filename);
g_free(follow_info);
g_free(follow_filter);
@ -156,7 +156,7 @@ follow_tcp_stream_cb(GtkWidget * w _U_, gpointer data _U_)
if (data_out_file == NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not create temporary file %s: %s",
follow_info->data_out_filename, strerror(errno));
follow_info->data_out_filename, g_strerror(errno));
ws_close(tmp_fd);
ws_unlink(follow_info->data_out_filename);
g_free(follow_info->data_out_filename);
@ -227,7 +227,7 @@ follow_tcp_stream_cb(GtkWidget * w _U_, gpointer data _U_)
if (ferror(data_out_file)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not read from temporary file %s: %s",
follow_info->data_out_filename, strerror(errno));
follow_info->data_out_filename, g_strerror(errno));
} else {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Short read from temporary file %s: expected %lu, got %lu",
@ -358,7 +358,7 @@ follow_read_tcp_stream(follow_info_t *follow_info,
if (data_out_file == NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not open temporary file %s: %s", follow_info->data_out_filename,
strerror(errno));
g_strerror(errno));
return FRS_OPEN_ERROR;
}
@ -421,7 +421,7 @@ follow_read_tcp_stream(follow_info_t *follow_info,
if (ferror(data_out_file)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Error reading temporary file %s: %s", follow_info->data_out_filename,
strerror(errno));
g_strerror(errno));
fclose(data_out_file);
data_out_file = NULL;
return FRS_READ_ERROR;

View File

@ -510,7 +510,7 @@ static gboolean funnel_open_file(const char* fname, const char* filter, const ch
if (cf_open(&cfile, fname, FALSE, &err) != CF_OK) {
*err_str = strerror(err);
*err_str = g_strerror(err);
if (rfcode != NULL) dfilter_free(rfcode);
return FALSE;
}

View File

@ -45,10 +45,6 @@
#include <unistd.h>
#endif
#ifdef NEED_STRERROR_H
#include "wsutil/strerror.h"
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#else
@ -1871,24 +1867,24 @@ read_configuration_files(char **gdp_path, char **dp_path)
if (gpf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open global preferences file\n\"%s\": %s.", gpf_path,
strerror(gpf_open_errno));
g_strerror(gpf_open_errno));
}
if (gpf_read_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"I/O error reading global preferences file\n\"%s\": %s.", gpf_path,
strerror(gpf_read_errno));
g_strerror(gpf_read_errno));
}
}
if (pf_path != NULL) {
if (pf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open your preferences file\n\"%s\": %s.", pf_path,
strerror(pf_open_errno));
g_strerror(pf_open_errno));
}
if (pf_read_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"I/O error reading your preferences file\n\"%s\": %s.", pf_path,
strerror(pf_read_errno));
g_strerror(pf_read_errno));
}
g_free(pf_path);
pf_path = NULL;
@ -1906,7 +1902,7 @@ read_configuration_files(char **gdp_path, char **dp_path)
if (cf_path != NULL) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open your capture filter file\n\"%s\": %s.", cf_path,
strerror(cf_open_errno));
g_strerror(cf_open_errno));
g_free(cf_path);
}
@ -1915,7 +1911,7 @@ read_configuration_files(char **gdp_path, char **dp_path)
if (df_path != NULL) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open your display filter file\n\"%s\": %s.", df_path,
strerror(df_open_errno));
g_strerror(df_open_errno));
g_free(df_path);
}
@ -1926,12 +1922,12 @@ read_configuration_files(char **gdp_path, char **dp_path)
if (gdp_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open global disabled protocols file\n\"%s\": %s.",
*gdp_path, strerror(gdp_open_errno));
*gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"I/O error reading global disabled protocols file\n\"%s\": %s.",
*gdp_path, strerror(gdp_read_errno));
*gdp_path, g_strerror(gdp_read_errno));
}
g_free(*gdp_path);
*gdp_path = NULL;
@ -1940,12 +1936,12 @@ read_configuration_files(char **gdp_path, char **dp_path)
if (dp_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open your disabled protocols file\n\"%s\": %s.", *dp_path,
strerror(dp_open_errno));
g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"I/O error reading your disabled protocols file\n\"%s\": %s.", *dp_path,
strerror(dp_read_errno));
g_strerror(dp_read_errno));
}
g_free(*dp_path);
*dp_path = NULL;
@ -2159,7 +2155,7 @@ main(int argc, char *argv[])
if (rf_path != NULL && rf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open common recent file\n\"%s\": %s.",
rf_path, strerror(rf_open_errno));
rf_path, g_strerror(rf_open_errno));
}
/* "pre-scan" the command line parameters, if we have "console only"
@ -2254,7 +2250,7 @@ main(int argc, char *argv[])
if (rf_path != NULL && rf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open recent file\n\"%s\": %s.",
rf_path, strerror(rf_open_errno));
rf_path, g_strerror(rf_open_errno));
}
if (recent.gui_fileopen_remembered_dir &&
@ -2789,7 +2785,7 @@ main(int argc, char *argv[])
if (rf_path != NULL && rf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open recent file\n\"%s\": %s.",
rf_path, strerror(rf_open_errno));
rf_path, g_strerror(rf_open_errno));
}
color_filters_enable(recent.packet_list_colorize);
@ -3656,7 +3652,7 @@ static void copy_global_profile (const gchar *profile_name)
if (create_persconffile_profile(profile_name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\":\n%s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
}
@ -3665,7 +3661,7 @@ static void copy_global_profile (const gchar *profile_name)
&pf_dir_path, &pf_dir_path2) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.",
pf_filename, pf_dir_path2, pf_dir_path, strerror(errno));
pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno));
g_free(pf_filename);
g_free(pf_dir_path);
@ -3718,7 +3714,7 @@ void change_configuration_profile (const gchar *profile_name)
if (rf_path != NULL && rf_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"Could not open common recent file\n\"%s\": %s.",
rf_path, strerror(rf_open_errno));
rf_path, g_strerror(rf_open_errno));
}
if (recent.gui_fileopen_remembered_dir &&
test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) {

View File

@ -1431,7 +1431,7 @@ prefs_main_write(void)
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_dir_path,
strerror(errno));
g_strerror(errno));
g_free(pf_dir_path);
} else {
/* Write the preferencs out. */
@ -1439,7 +1439,7 @@ prefs_main_write(void)
if (err != 0) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't open preferences file\n\"%s\": %s.", pf_path,
strerror(err));
g_strerror(err));
g_free(pf_path);
}
}

View File

@ -1107,7 +1107,7 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
write_failure_alert_box(args->file, errno);
else
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Error writing to print command: %s", strerror(errno));
"Error writing to print command: %s", g_strerror(errno));
break;
}

View File

@ -383,7 +383,7 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy)
if (create_persconffile_profile(profile1->name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\":\n%s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
}
@ -394,7 +394,7 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy)
&pf_filename, &pf_dir_path, &pf_dir_path2) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.",
pf_filename, pf_dir_path2, pf_dir_path, strerror(errno));
pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno));
g_free(pf_filename);
g_free(pf_dir_path);
@ -420,7 +420,7 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy)
if (create_persconffile_profile(profile1->name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\":\n%s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
}
@ -436,7 +436,7 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy)
&pf_dir_path, &pf_dir_path2) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't rename directory\n\"%s\" to\n\"%s\":\n%s.",
pf_dir_path, pf_dir_path2, strerror(errno));
pf_dir_path, pf_dir_path2, g_strerror(errno));
g_free(pf_dir_path);
g_free(pf_dir_path2);
@ -473,7 +473,7 @@ profile_apply(GtkWidget *main_w, GtkTreeView *profile_l, gboolean destroy)
if (delete_persconffile_profile(profile1->name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't delete profile directory\n\"%s\":\n%s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
}
@ -1143,7 +1143,7 @@ profile_name_edit_ok (GtkWidget *w _U_, gpointer parent_w)
if (create_persconffile_profile(new_name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\":\n%s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
} else if (strlen (profile_name) &&
@ -1152,7 +1152,7 @@ profile_name_edit_ok (GtkWidget *w _U_, gpointer parent_w)
{
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.",
pf_filename, pf_dir_path2, pf_dir_path, strerror(errno));
pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno));
g_free(pf_filename);
g_free(pf_dir_path);
@ -1166,7 +1166,7 @@ profile_name_edit_ok (GtkWidget *w _U_, gpointer parent_w)
&pf_dir_path, &pf_dir_path2) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't rename directory\n\"%s\" to\n\"%s\":\n%s.",
pf_dir_path, pf_dir_path2, strerror(errno));
pf_dir_path, pf_dir_path2, g_strerror(errno));
g_free(pf_dir_path);
g_free(pf_dir_path2);
@ -1347,7 +1347,7 @@ profile_delete_cb (GtkWidget *w _U_, gpointer data _U_)
if (delete_persconffile_profile(name, &pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't delete profile directory\n\"%s\":\n%s.",
pf_dir_path, strerror(errno));
pf_dir_path, g_strerror(errno));
g_free(pf_dir_path);
}

View File

@ -372,14 +372,14 @@ proto_write(gpointer parent_w _U_)
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\"\nfor disabled protocols file: %s.", pf_dir_path,
strerror(errno));
g_strerror(errno));
g_free(pf_dir_path);
} else {
save_disabled_protos_list(&pf_path, &pf_save_errno);
if (pf_path != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Could not save to your disabled protocols file\n\"%s\": %s.",
pf_path, strerror(pf_save_errno));
pf_path, g_strerror(pf_save_errno));
g_free(pf_path);
}
}

View File

@ -154,7 +154,7 @@ write_recent(void)
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
strerror(errno));
g_strerror(errno));
g_free(pf_dir_path);
return FALSE;
}
@ -163,7 +163,7 @@ write_recent(void)
if ((rf = ws_fopen(rf_path, "w")) == NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't open recent file\n\"%s\": %s.", rf_path,
strerror(errno));
g_strerror(errno));
g_free(rf_path);
return FALSE;
}
@ -277,7 +277,7 @@ write_profile_recent(void)
if (create_persconffile_dir(&pf_dir_path) == -1) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
strerror(errno));
g_strerror(errno));
g_free(pf_dir_path);
return FALSE;
}
@ -286,7 +286,7 @@ write_profile_recent(void)
if ((rf = ws_fopen(rf_path, "w")) == NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Can't open recent file\n\"%s\": %s.", rf_path,
strerror(errno));
g_strerror(errno));
g_free(rf_path);
return FALSE;
}

View File

@ -299,18 +299,13 @@ display_queued_messages(void)
gpointer
vsimple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, va_list ap)
{
gchar *vmessage;
gchar *message;
queued_message_t *queued_message;
GtkWidget *win;
GdkWindowState state = 0;
/* Format the message. */
vmessage = g_strdup_vprintf(msg_format, ap);
/* convert character encoding from locale to UTF8 (using iconv) */
message = g_locale_to_utf8(vmessage, -1, NULL, NULL, NULL);
g_free(vmessage);
message = g_strdup_vprintf(msg_format, ap);
if (top_level != NULL) {
state = gdk_window_get_state(top_level->window);

View File

@ -120,12 +120,12 @@ static void text_page_set_text(GtkWidget *page, const char *absolute_path)
}
if(ferror(text_file)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Error reading file \"%s\": %s",
absolute_path, strerror(errno));
absolute_path, g_strerror(errno));
}
fclose(text_file);
} else {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open file \"%s\": %s",
absolute_path, strerror(errno));
absolute_path, g_strerror(errno));
}
}

View File

@ -329,7 +329,7 @@ main(int argc, char *argv[])
out_fd = ws_open(out_filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (out_fd == -1) {
fprintf(stderr, "mergecap: Couldn't open output file %s: %s\n",
out_filename, strerror(errno));
out_filename, g_strerror(errno));
exit(1);
}
}

View File

@ -292,9 +292,6 @@
/* Define to 1 if you have the `stpcpy' function. */
#define HAVE_STPCPY 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

View File

@ -2906,7 +2906,7 @@ read_asn1_type_table(const char *filename)
data = g_malloc(size);
if (fread(data, size, 1, f) < 1) {
g_warning("error reading %s, %s", filename, strerror(errno));
g_warning("error reading %s, %s", filename, g_strerror(errno));
}
fclose(f);

View File

@ -182,7 +182,7 @@ blk_cmnt_stop "*/"
yy_switch_to_buffer(include_stack[--include_stack_ptr] );
if (errno)
g_string_append_printf(mc->config_error, "Mate parser: Could not open file: '%s': %s", yytext, strerror(errno) );
g_string_append_printf(mc->config_error, "Mate parser: Could not open file: '%s': %s", yytext, g_strerror(errno) );
} else {
@ -292,7 +292,7 @@ extern gboolean mate_load_config(const gchar* filename, mate_config* matecfg) {
yyin = ws_fopen(filename,"r");
if (!yyin) {
g_string_append_printf(mc->config_error,"Mate parser: Could not open file: '%s', error: %s", filename, strerror(errno) );
g_string_append_printf(mc->config_error,"Mate parser: Could not open file: '%s', error: %s", filename, g_strerror(errno) );
return FALSE;
}

View File

@ -711,7 +711,7 @@ seed(void)
if (errno != ENOENT) {
fprintf(stderr,
"randpkt: Could not open " RANDOM_DEV " for reading: %s\n",
strerror(errno));
g_strerror(errno));
exit(2);
}
goto fallback;
@ -721,7 +721,7 @@ seed(void)
if (ret == -1) {
fprintf(stderr,
"randpkt: Could not read from " RANDOM_DEV ": %s\n",
strerror(errno));
g_strerror(errno));
exit(2);
}
if ((size_t)ret != sizeof randomness) {

View File

@ -61,10 +61,6 @@
# include <sys/stat.h>
#endif
#ifdef NEED_STRERROR_H
#include "wsutil/strerror.h"
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#else
@ -274,7 +270,7 @@ raw_pipe_open(const char *pipe_name)
#ifndef _WIN32
if (ws_stat64(pipe_name, &pipe_stat) < 0) {
fprintf(stderr, "rawshark: The pipe %s could not be checked: %s\n",
pipe_name, strerror(errno));
pipe_name, g_strerror(errno));
return -1;
}
if (! S_ISFIFO(pipe_stat.st_mode)) {
@ -293,7 +289,7 @@ raw_pipe_open(const char *pipe_name)
rfd = ws_open(pipe_name, O_RDONLY | O_NONBLOCK, 0000 /* no creation so don't matter */);
if (rfd == -1) {
fprintf(stderr, "rawshark: \"%s\" could not be opened: %s\n",
pipe_name, strerror(errno));
pipe_name, g_strerror(errno));
return -1;
}
#else /* _WIN32 */
@ -348,7 +344,7 @@ raw_pipe_open(const char *pipe_name)
rfd = _open_osfhandle((long) hPipe, _O_RDONLY);
if (rfd == -1) {
fprintf(stderr, "rawshark: \"%s\" could not be opened: %s\n",
pipe_name, strerror(errno));
pipe_name, g_strerror(errno));
return -1;
}
#endif /* _WIN32 */
@ -531,21 +527,21 @@ main(int argc, char *argv[])
if (gpf_path != NULL) {
if (gpf_open_errno != 0) {
cmdarg_err("Can't open global preferences file \"%s\": %s.",
pf_path, strerror(gpf_open_errno));
pf_path, g_strerror(gpf_open_errno));
}
if (gpf_read_errno != 0) {
cmdarg_err("I/O error reading global preferences file \"%s\": %s.",
pf_path, strerror(gpf_read_errno));
pf_path, g_strerror(gpf_read_errno));
}
}
if (pf_path != NULL) {
if (pf_open_errno != 0) {
cmdarg_err("Can't open your preferences file \"%s\": %s.", pf_path,
strerror(pf_open_errno));
g_strerror(pf_open_errno));
}
if (pf_read_errno != 0) {
cmdarg_err("I/O error reading your preferences file \"%s\": %s.",
pf_path, strerror(pf_read_errno));
pf_path, g_strerror(pf_read_errno));
}
g_free(pf_path);
pf_path = NULL;
@ -560,11 +556,11 @@ main(int argc, char *argv[])
if (gdp_path != NULL) {
if (gdp_open_errno != 0) {
cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.",
gdp_path, strerror(gdp_open_errno));
gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.",
gdp_path, strerror(gdp_read_errno));
gdp_path, g_strerror(gdp_read_errno));
}
g_free(gdp_path);
}
@ -572,12 +568,12 @@ main(int argc, char *argv[])
if (dp_open_errno != 0) {
cmdarg_err(
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
strerror(dp_open_errno));
g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
cmdarg_err(
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
strerror(dp_read_errno));
g_strerror(dp_read_errno));
}
g_free(dp_path);
}
@ -1546,7 +1542,7 @@ show_print_file_io_error(int err)
default:
cmdarg_err("An error occurred while printing packets: %s.",
strerror(err));
g_strerror(err));
break;
}
}
@ -1622,7 +1618,7 @@ static void
read_failure_message(const char *filename, int err)
{
cmdarg_err("An error occurred while reading from the file \"%s\": %s.",
filename, strerror(err));
filename, g_strerror(err));
}
/*
@ -1632,7 +1628,7 @@ static void
write_failure_message(const char *filename, int err)
{
cmdarg_err("An error occurred while writing to the file \"%s\": %s.",
filename, strerror(err));
filename, g_strerror(err));
}
/*

View File

@ -1316,7 +1316,7 @@ parse_options (int argc, char *argv[])
input_file = ws_fopen(input_filename, "rb");
if (!input_file) {
fprintf(stderr, "Cannot open file [%s] for reading: %s\n",
input_filename, strerror(errno));
input_filename, g_strerror(errno));
exit(-1);
}
} else {
@ -1329,7 +1329,7 @@ parse_options (int argc, char *argv[])
output_file = ws_fopen(output_filename, "wb");
if (!output_file) {
fprintf(stderr, "Cannot open file [%s] for writing: %s\n",
output_filename, strerror(errno));
output_filename, g_strerror(errno));
exit(-1);
}
} else {

View File

@ -96,6 +96,7 @@ my %APIs = (
'g_strdown',
'g_string_up',
'g_string_down',
'strerror', # use g_strerror
# Use the ws_* version of these:
# (Necessary because on Windows we use UTF8 for throughout the code
# so we must tweak that to UTF16 before operating on the file. Code
@ -115,7 +116,7 @@ my %APIs = (
# APIs that SHOULD NOT be used in Wireshark (any more)
'deprecated' => { 'count_errors' => 1, 'functions' => [
'perror', # Use strerror() and report messages in whatever
'perror', # Use g_strerror() and report messages in whatever
# fashion is appropriate for the code in question.
'ctime', # Use abs_time_secs_to_str()
'dissector_add', # Use dissector_add_uint()

View File

@ -51,10 +51,6 @@
# include <sys/stat.h>
#endif
#ifdef NEED_STRERROR_H
#include "wsutil/strerror.h"
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#else
@ -1019,21 +1015,21 @@ main(int argc, char *argv[])
if (gpf_path != NULL) {
if (gpf_open_errno != 0) {
cmdarg_err("Can't open global preferences file \"%s\": %s.",
pf_path, strerror(gpf_open_errno));
pf_path, g_strerror(gpf_open_errno));
}
if (gpf_read_errno != 0) {
cmdarg_err("I/O error reading global preferences file \"%s\": %s.",
pf_path, strerror(gpf_read_errno));
pf_path, g_strerror(gpf_read_errno));
}
}
if (pf_path != NULL) {
if (pf_open_errno != 0) {
cmdarg_err("Can't open your preferences file \"%s\": %s.", pf_path,
strerror(pf_open_errno));
g_strerror(pf_open_errno));
}
if (pf_read_errno != 0) {
cmdarg_err("I/O error reading your preferences file \"%s\": %s.",
pf_path, strerror(pf_read_errno));
pf_path, g_strerror(pf_read_errno));
}
g_free(pf_path);
pf_path = NULL;
@ -1048,11 +1044,11 @@ main(int argc, char *argv[])
if (gdp_path != NULL) {
if (gdp_open_errno != 0) {
cmdarg_err("Could not open global disabled protocols file\n\"%s\": %s.",
gdp_path, strerror(gdp_open_errno));
gdp_path, g_strerror(gdp_open_errno));
}
if (gdp_read_errno != 0) {
cmdarg_err("I/O error reading global disabled protocols file\n\"%s\": %s.",
gdp_path, strerror(gdp_read_errno));
gdp_path, g_strerror(gdp_read_errno));
}
g_free(gdp_path);
}
@ -1060,12 +1056,12 @@ main(int argc, char *argv[])
if (dp_open_errno != 0) {
cmdarg_err(
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
strerror(dp_open_errno));
g_strerror(dp_open_errno));
}
if (dp_read_errno != 0) {
cmdarg_err(
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
strerror(dp_read_errno));
g_strerror(dp_read_errno));
}
g_free(dp_path);
}
@ -3522,7 +3518,7 @@ show_print_file_io_error(int err)
default:
cmdarg_err("An error occurred while printing packets: %s.",
strerror(err));
g_strerror(err));
break;
}
}
@ -3665,7 +3661,7 @@ static void
read_failure_message(const char *filename, int err)
{
cmdarg_err("An error occurred while reading from the file \"%s\": %s.",
filename, strerror(err));
filename, g_strerror(err));
}
/*
@ -3675,7 +3671,7 @@ static void
write_failure_message(const char *filename, int err)
{
cmdarg_err("An error occurred while writing to the file \"%s\": %s.",
filename, strerror(err));
filename, g_strerror(err));
}
/*

View File

@ -363,7 +363,7 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *))
*/
if (uname(&name) < 0) {
g_string_append_printf(str, "unknown OS version (uname failed - %s)",
strerror(errno));
g_strerror(errno));
return;
}

View File

@ -622,7 +622,7 @@ const char
return "Unknown reason";
return wtap_errlist[wtap_errlist_index];
} else
return strerror(err);
return g_strerror(err);
}
/* Close only the sequential side, freeing up memory it uses.

View File

@ -33,7 +33,6 @@ set(WSUTIL_FILES
# @INET_ATON_LO@ # inet_aton.c
# @INET_NTOP_LO@ # inet_ntop.c
# @INET_PTON_LO@ # inet_pton.c
# @STRERROR_LO@ # strerror.c
# @STRNCASECMP_LO@ # strncasecmp.c
# @STRPTIME_LO@ # strptime.c
mpeg-audio.c

View File

@ -54,12 +54,6 @@ else
def_sym_filter_symbols += || /^ws_inet_pton/
endif
if NEED_STRERROR_LO
wsutil_optional_objects += @STRERROR_LO@
else
def_sym_filter_symbols += || /^strerror/
endif
if NEED_STRNCASECMP_LO
wsutil_optional_objects += @STRNCASECMP_LO@
else
@ -98,8 +92,6 @@ EXTRA_libwsutil_la_SOURCES= \
inet_ntop.c \
inet_pton.c \
inet_v6defs.h \
strerror.c \
strerror.h \
strncasecmp.c \
strptime.c \
strptime.h \

View File

@ -1,43 +0,0 @@
/* strerror.c
*
* $Id$
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "strerror.h"
#include <glib.h>
/*
* Version of "strerror()", for the benefit of OSes that don't have it
* (e.g., SunOS 4.x).
*/
char *
strerror(int errnum)
{
extern int sys_nerr;
extern char *sys_errlist[];
static char errbuf[5+1+11+1]; /* "Error %d" */
if (errnum < 0 || errnum >= sys_nerr) {
g_snprintf(errbuf, 18, "Error %d", errnum);
return errbuf;
} else
return sys_errlist[errnum];
}

View File

@ -1,33 +0,0 @@
/* strerror.h
*
* $Id$
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __STRERROR_H__
#define __STRERROR_H__
/*
* Version of "strerror()", for the benefit of OSes that don't have it
* (e.g., SunOS 4.x).
*/
extern char *strerror(int);
#endif