From 174d06e4c64b70c9a276f2bad1ba7a550cec8e7f Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Fri, 24 Feb 2012 05:17:46 +0000 Subject: Revert SVN #40866 (which used g_fprintf() in place of fprintf()). Using g_fprintf() fails (crashes) on Windows because the Windows GLib DLL is linked with (depends upon) MSVCRT while editcap is linked with (depends upon) MSVCR90. IOW: "You can't do that ... (on Windows)" See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6695 (Comment 2) for some additional information. svn path=/trunk/; revision=41168 --- editcap.c | 281 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 141 insertions(+), 140 deletions(-) (limited to 'editcap.c') diff --git a/editcap.c b/editcap.c index 0e64182cef..d643ea45c6 100644 --- a/editcap.c +++ b/editcap.c @@ -12,6 +12,11 @@ #include "config.h" #endif +#include +#include +#include +#include + /* * Just make sure we include the prototype for strptime as well * (needed for glibc 2.2) but make sure we do this only if not @@ -21,13 +26,9 @@ #ifndef __USE_XOPEN # define __USE_XOPEN #endif -#ifndef _XOPEN_SOURCE -# define _XOPEN_SOURCE -#endif #include #include -#include #ifdef HAVE_UNISTD_H #include @@ -195,7 +196,7 @@ fileset_extract_prefix_suffix(const char *fname, gchar **fprefix, gchar **fsuffi save_file = g_strdup(fname); if (save_file == NULL) { - g_fprintf(stderr, "editcap: Out of memory\n"); + fprintf(stderr, "editcap: Out of memory\n"); return FALSE; } @@ -235,32 +236,32 @@ add_selection(char *sel) if (++max_selected >= MAX_SELECTIONS) { /* Let the user know we stopped selecting */ - g_print("Out of room for packet selections!\n"); + printf("Out of room for packet selections!\n"); return(FALSE); } - g_printf("Add_Selected: %s\n", sel); + printf("Add_Selected: %s\n", sel); if ((locn = strchr(sel, '-')) == NULL) { /* No dash, so a single number? */ - g_print("Not inclusive ..."); + printf("Not inclusive ..."); selectfrm[max_selected].inclusive = 0; selectfrm[max_selected].first = atoi(sel); - g_printf(" %i\n", selectfrm[max_selected].first); + printf(" %i\n", selectfrm[max_selected].first); } else { - g_print("Inclusive ..."); + printf("Inclusive ..."); next = locn + 1; selectfrm[max_selected].inclusive = 1; selectfrm[max_selected].first = atoi(sel); selectfrm[max_selected].second = atoi(next); - g_printf(" %i, %i\n", selectfrm[max_selected].first, selectfrm[max_selected].second); + printf(" %i, %i\n", selectfrm[max_selected].first, selectfrm[max_selected].second); } @@ -327,12 +328,12 @@ set_time_adjustment(char *optarg_str_p) } else { val = strtol(optarg_str_p, &frac, 10); if (frac == NULL || frac == optarg_str_p || val == LONG_MIN || val == LONG_MAX) { - g_fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", + fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", optarg_str_p); exit(1); } if (val < 0) { /* implies '--' since we caught '-' above */ - g_fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", + fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", optarg_str_p); exit(1); } @@ -349,7 +350,7 @@ set_time_adjustment(char *optarg_str_p) } if (*frac != '.' || end == NULL || end == frac || val < 0 || val > ONE_MILLION || val == LONG_MIN || val == LONG_MAX) { - g_fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", + fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", optarg_str_p); exit(1); } @@ -402,12 +403,12 @@ set_strict_time_adj(char *optarg_str_p) } else { val = strtol(optarg_str_p, &frac, 10); if (frac == NULL || frac == optarg_str_p || val == LONG_MIN || val == LONG_MAX) { - g_fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", + fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", optarg_str_p); exit(1); } if (val < 0) { /* implies '--' since we caught '-' above */ - g_fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", + fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", optarg_str_p); exit(1); } @@ -424,7 +425,7 @@ set_strict_time_adj(char *optarg_str_p) } if (*frac != '.' || end == NULL || end == frac || val < 0 || val > ONE_MILLION || val == LONG_MIN || val == LONG_MAX) { - g_fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", + fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", optarg_str_p); exit(1); } @@ -472,12 +473,12 @@ set_rel_time(char *optarg_str_p) } else { val = strtol(optarg_str_p, &frac, 10); if (frac == NULL || frac == optarg_str_p || val == LONG_MIN || val == LONG_MAX) { - g_fprintf(stderr, "1: editcap: \"%s\" isn't a valid rel time value\n", + fprintf(stderr, "1: editcap: \"%s\" isn't a valid rel time value\n", optarg_str_p); exit(1); } if (val < 0) { /* implies '--' since we caught '-' above */ - g_fprintf(stderr, "2: editcap: \"%s\" isn't a valid rel time value\n", + fprintf(stderr, "2: editcap: \"%s\" isn't a valid rel time value\n", optarg_str_p); exit(1); } @@ -494,7 +495,7 @@ set_rel_time(char *optarg_str_p) } if (*frac != '.' || end == NULL || end == frac || val < 0 || val > ONE_BILLION || val == LONG_MIN || val == LONG_MAX) { - g_fprintf(stderr, "3: editcap: \"%s\" isn't a valid rel time value\n", + fprintf(stderr, "3: editcap: \"%s\" isn't a valid rel time value\n", optarg_str_p); exit(1); } @@ -666,75 +667,75 @@ usage(gboolean is_error) " (" SVNVERSION " from " SVNPATH ")" #endif "\n", VERSION); - g_fprintf(output, "Edit and/or translate the format of capture files.\n"); - g_fprintf(output, "See http://www.wireshark.org for more information.\n"); - g_fprintf(output, "\n"); - g_fprintf(output, "Usage: editcap [options] ... [ [-] ... ]\n"); - g_fprintf(output, "\n"); - g_fprintf(output, " and must both be present.\n"); - g_fprintf(output, "A single packet or a range of packets can be selected.\n"); - g_fprintf(output, "\n"); - g_fprintf(output, "Packet selection:\n"); - g_fprintf(output, " -r keep the selected packets; default is to delete them.\n"); - g_fprintf(output, " -A only output packets whose timestamp is after (or equal\n"); - g_fprintf(output, " to) the given time (format as YYYY-MM-DD hh:mm:ss).\n"); - g_fprintf(output, " -B only output packets whose timestamp is before the\n"); - g_fprintf(output, " given time (format as YYYY-MM-DD hh:mm:ss).\n"); - g_fprintf(output, "\n"); - g_fprintf(output, "Duplicate packet removal:\n"); - g_fprintf(output, " -d remove packet if duplicate (window == %d).\n", DEFAULT_DUP_DEPTH); - g_fprintf(output, " -D remove packet if duplicate; configurable \n"); - g_fprintf(output, " Valid values are 0 to %d.\n", MAX_DUP_DEPTH); - g_fprintf(output, " NOTE: A of 0 with -v (verbose option) is\n"); - g_fprintf(output, " useful to print MD5 hashes.\n"); - g_fprintf(output, " -w remove packet if duplicate packet is found EQUAL TO OR\n"); - g_fprintf(output, " LESS THAN prior to current packet.\n"); - g_fprintf(output, " A is specified in relative seconds\n"); - g_fprintf(output, " (e.g. 0.000001).\n"); - g_fprintf(output, "\n"); - g_fprintf(output, " NOTE: The use of the 'Duplicate packet removal' options with\n"); - g_fprintf(output, " other editcap options except -v may not always work as expected.\n"); - g_fprintf(output, " Specifically the -r, -t or -S options will very likely NOT have the\n"); - g_fprintf(output, " desired effect if combined with the -d, -D or -w.\n"); - g_fprintf(output, "\n"); - g_fprintf(output, "Packet manipulation:\n"); - g_fprintf(output, " -s truncate each packet to max. bytes of data.\n"); - g_fprintf(output, " -C chop each packet by bytes. Positive values\n"); - g_fprintf(output, " chop at the packet beginning, negative values at the\n"); - g_fprintf(output, " packet end.\n"); - g_fprintf(output, " -t