diff options
author | Dario Lombardo <lomato@gmail.com> | 2016-08-02 22:39:28 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2016-08-04 11:26:26 +0000 |
commit | 5adde36520cf71a87c51c3bde49068623eb4d3d4 (patch) | |
tree | 8f12c8752edc4a2b352f9f215bc8b49a1b8b260e /extcap/randpktdump.c | |
parent | 06464b7db1999b95a9b4166ceb636e4f46fcc7df (diff) |
extcap: restyle the output subsystem.
Change-Id: I3e0674751eb97bf30ae6d70c4e51f347d63b1697
Reviewed-on: https://code.wireshark.org/review/16849
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'extcap/randpktdump.c')
-rw-r--r-- | extcap/randpktdump.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/extcap/randpktdump.c b/extcap/randpktdump.c index 016bcf6768..ae3dcbd19c 100644 --- a/extcap/randpktdump.c +++ b/extcap/randpktdump.c @@ -33,15 +33,10 @@ #define RANDPKTDUMP_VERSION_MINOR "1" #define RANDPKTDUMP_VERSION_RELEASE "0" -#define verbose_print(...) { if (verbose) printf(__VA_ARGS__); } - -static gboolean verbose = TRUE; - enum { EXTCAP_BASE_OPTIONS_ENUM, OPT_HELP, OPT_VERSION, - OPT_VERBOSE, OPT_MAXBYTES, OPT_COUNT, OPT_RANDOM_TYPE, @@ -53,7 +48,6 @@ static struct option longopts[] = { EXTCAP_BASE_OPTIONS, { "help", no_argument, NULL, OPT_HELP}, { "version", no_argument, NULL, OPT_VERSION}, - { "verbose", optional_argument, NULL, OPT_VERBOSE}, { "maxbytes", required_argument, NULL, OPT_MAXBYTES}, { "count", required_argument, NULL, OPT_COUNT}, { "random-type", required_argument, NULL, OPT_RANDOM_TYPE}, @@ -112,12 +106,12 @@ static int list_config(char *interface) char** longname_list; if (!interface) { - errmsg_print("ERROR: No interface specified."); + g_warning("No interface specified."); return EXIT_FAILURE; } if (g_strcmp0(interface, RANDPKT_EXTCAP_INTERFACE)) { - errmsg_print("ERROR: interface must be %s", RANDPKT_EXTCAP_INTERFACE); + g_warning("Interface must be %s", RANDPKT_EXTCAP_INTERFACE); return EXIT_FAILURE; } @@ -183,10 +177,8 @@ int main(int argc, char *argv[]) attach_parent_console(); #endif /* _WIN32 */ - for (i = 0; i < argc; i++) { - verbose_print("%s ", argv[i]); - } - verbose_print("\n"); + for (i = 0; i < argc; i++) + g_debug("%s ", argv[i]); while ((result = getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) { switch (result) { @@ -195,10 +187,6 @@ int main(int argc, char *argv[]) ret = EXIT_SUCCESS; goto end; - case OPT_VERBOSE: - verbose = TRUE; - break; - case OPT_HELP: help(argv[0]); ret = EXIT_SUCCESS; @@ -207,7 +195,7 @@ int main(int argc, char *argv[]) case OPT_MAXBYTES: maxbytes = atoi(optarg); if (maxbytes > MAXBYTES_LIMIT) { - errmsg_print("randpktdump: Max bytes is %d", MAXBYTES_LIMIT); + g_warning("randpktdump: Max bytes is %d", MAXBYTES_LIMIT); goto end; } break; @@ -235,21 +223,21 @@ int main(int argc, char *argv[]) case ':': /* missing option argument */ - errmsg_print("Option '%s' requires an argument", argv[optind - 1]); + g_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: /* Handle extcap specific options */ if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - errmsg_print("Invalid option: %s", argv[optind - 1]); + g_warning("Invalid option: %s", argv[optind - 1]); goto end; } } } if (optind != argc) { - errmsg_print("Invalid option: %s", argv[optind]); + g_warning("Invalid option: %s", argv[optind]); goto end; } @@ -265,7 +253,7 @@ int main(int argc, char *argv[]) /* Some sanity checks */ if ((random_type) && (all_random)) { - errmsg_print("You can specify only one between: --random-type, --all-random"); + g_warning("You can specify only one between: --random-type, --all-random"); goto end; } @@ -278,8 +266,7 @@ int main(int argc, char *argv[]) #ifdef _WIN32 result = WSAStartup(MAKEWORD(1,1), &wsaData); if (result != 0) { - if (verbose) - errmsg_print("ERROR: WSAStartup failed with error: %d", result); + g_warning("ERROR: WSAStartup failed with error: %d", result); goto end; } #endif /* _WIN32 */ @@ -287,7 +274,7 @@ int main(int argc, char *argv[]) if (extcap_conf->capture) { if (g_strcmp0(extcap_conf->interface, RANDPKT_EXTCAP_INTERFACE)) { - errmsg_print("ERROR: invalid interface"); + g_warning("ERROR: invalid interface"); goto end; } @@ -298,7 +285,7 @@ int main(int argc, char *argv[]) if (!example) goto end; - verbose_print("Generating packets: %s\n", example->abbrev); + g_debug("Generating packets: %s", example->abbrev); randpkt_example_init(example, extcap_conf->fifo, maxbytes); randpkt_loop(example, count); |