* 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.
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#ifndef HAVE_GETOPT_LONG
#include "wsutil/wsgetopt.h"
#endif
+#include "ws_attributes.h"
enum extcap_options {
EXTCAP_BASE_OPTIONS_ENUM
extcap->do_list_interfaces = 1;
break;
case EXTCAP_OPT_VERSION:
+ extcap->ws_version = g_strdup(optargument);
extcap->do_version = 1;
break;
case EXTCAP_OPT_LIST_DLTS:
void extcap_base_cleanup(extcap_parameters ** extcap)
{
- /* g_list_free_full() only exists since 2.28. g_list_free_full((*extcap)->interfaces, extcap_iface_free);*/
- g_list_foreach((*extcap)->interfaces, (GFunc)extcap_iface_free, NULL);
- g_list_free((*extcap)->interfaces);
+ g_list_free_full((*extcap)->interfaces, extcap_iface_free);
g_free((*extcap)->exename);
g_free((*extcap)->fifo);
g_free((*extcap)->interface);
g_free((*extcap)->version);
g_free((*extcap)->helppage);
g_free((*extcap)->help_header);
- g_list_foreach((*extcap)->help_options, (GFunc)extcap_help_option_free, NULL);
- g_list_free((*extcap)->help_options);
+ g_free((*extcap)->ws_version);
+ g_list_free_full((*extcap)->help_options, extcap_help_option_free);
g_free(*extcap);
*extcap = NULL;
}
-static void extcap_print_option(gpointer option)
+static void extcap_print_option(gpointer option, gpointer user_data _U_)
{
extcap_option_t* o = (extcap_option_t*)option;
printf("\t%s: %s\n", o->optname, o->optdesc);
printf("%s", extcap->help_header);
printf("\n");
printf("Options:\n");
- g_list_foreach(extcap->help_options, (GFunc)extcap_print_option, NULL);
+ g_list_foreach(extcap->help_options, extcap_print_option, NULL);
printf("\n");
}
void extcap_init_custom_log(const char* filename)
{
+ if (!filename || strlen(filename) == 0)
+ return;
custom_log = fopen(filename, "w");
if (!custom_log)
g_error("Can't open custom log file: %s (%s)", filename, strerror(errno));
void extcap_config_debug(unsigned* count)
{
printf("arg {number=%u}{call=--debug}{display=Run in debug mode}"
- "{type=boolean}{default=false}{tooltip=Print debug messages}\n",
- (*count)++);
+ "{type=boolean}{default=false}{tooltip=Print debug messages}{required=false}"
+ "{group=Debug}\n", (*count)++);
printf("arg {number=%u}{call=--debug-file}{display=Use a file for debug}"
- "{type=string}{tooltip=Set a file where the debug messages are written}\n",
- (*count)++);
+ "{type=string}{tooltip=Set a file where the debug messages are written}{required=false}"
+ "{group=Debug}\n", (*count)++);
}
void extcap_cmdline_debug(char** ar, const unsigned n)