ws_getopt: Rename struct and macros

This is part of the API and should also be renamed to avoid conflicts.
This commit is contained in:
João Valverde 2021-09-29 18:32:28 +01:00 committed by Wireshark GitLab Utility
parent 0173ea0ec1
commit 5362d0c31b
31 changed files with 204 additions and 204 deletions

View File

@ -1547,9 +1547,9 @@ main(int argc, char *argv[])
gboolean need_separator = FALSE; gboolean need_separator = FALSE;
int opt; int opt;
int overall_error_status = EXIT_SUCCESS; int overall_error_status = EXIT_SUCCESS;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -59,7 +59,7 @@ extern "C" {
#ifdef CAN_SET_CAPTURE_BUFFER_SIZE #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
#define LONGOPT_BUFFER_SIZE \ #define LONGOPT_BUFFER_SIZE \
{"buffer-size", required_argument, NULL, 'B'}, {"buffer-size", ws_required_argument, NULL, 'B'},
#define OPTSTRING_B "B:" #define OPTSTRING_B "B:"
#else #else
#define LONGOPT_BUFFER_SIZE #define LONGOPT_BUFFER_SIZE
@ -67,7 +67,7 @@ extern "C" {
#endif #endif
#ifdef HAVE_PCAP_CREATE #ifdef HAVE_PCAP_CREATE
#define LONGOPT_MONITOR_MODE {"monitor-mode", no_argument, NULL, 'I'}, #define LONGOPT_MONITOR_MODE {"monitor-mode", ws_no_argument, NULL, 'I'},
#define OPTSTRING_I "I" #define OPTSTRING_I "I"
#else #else
#define LONGOPT_MONITOR_MODE #define LONGOPT_MONITOR_MODE
@ -75,19 +75,19 @@ extern "C" {
#endif #endif
#define LONGOPT_CAPTURE_COMMON \ #define LONGOPT_CAPTURE_COMMON \
{"autostop", required_argument, NULL, 'a'}, \ {"autostop", ws_required_argument, NULL, 'a'}, \
{"ring-buffer", required_argument, NULL, 'b'}, \ {"ring-buffer", ws_required_argument, NULL, 'b'}, \
LONGOPT_BUFFER_SIZE \ LONGOPT_BUFFER_SIZE \
{"list-interfaces", no_argument, NULL, 'D'}, \ {"list-interfaces", ws_no_argument, NULL, 'D'}, \
{"interface", required_argument, NULL, 'i'}, \ {"interface", ws_required_argument, NULL, 'i'}, \
LONGOPT_MONITOR_MODE \ LONGOPT_MONITOR_MODE \
{"list-data-link-types", no_argument, NULL, 'L'}, \ {"list-data-link-types", ws_no_argument, NULL, 'L'}, \
{"no-promiscuous-mode", no_argument, NULL, 'p'}, \ {"no-promiscuous-mode", ws_no_argument, NULL, 'p'}, \
{"snapshot-length", required_argument, NULL, 's'}, \ {"snapshot-length", ws_required_argument, NULL, 's'}, \
{"linktype", required_argument, NULL, 'y'}, \ {"linktype", ws_required_argument, NULL, 'y'}, \
{"list-time-stamp-types", no_argument, NULL, LONGOPT_LIST_TSTAMP_TYPES}, \ {"list-time-stamp-types", ws_no_argument, NULL, LONGOPT_LIST_TSTAMP_TYPES}, \
{"time-stamp-type", required_argument, NULL, LONGOPT_SET_TSTAMP_TYPE}, \ {"time-stamp-type", ws_required_argument, NULL, LONGOPT_SET_TSTAMP_TYPE}, \
{"compress-type", required_argument, NULL, LONGOPT_COMPRESS_TYPE}, {"compress-type", ws_required_argument, NULL, LONGOPT_COMPRESS_TYPE},
#define OPTSTRING_CAPTURE_COMMON \ #define OPTSTRING_CAPTURE_COMMON \

View File

@ -93,9 +93,9 @@ main(int argc, char *argv[])
int i; int i;
int opt; int opt;
int overall_error_status; int overall_error_status;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -4822,13 +4822,13 @@ main(int argc, char *argv[])
{ {
char *err_msg; char *err_msg;
int opt; int opt;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
LONGOPT_CAPTURE_COMMON LONGOPT_CAPTURE_COMMON
{"ifname", required_argument, NULL, LONGOPT_IFNAME}, {"ifname", ws_required_argument, NULL, LONGOPT_IFNAME},
{"ifdescr", required_argument, NULL, LONGOPT_IFDESCR}, {"ifdescr", ws_required_argument, NULL, LONGOPT_IFDESCR},
{"capture-comment", required_argument, NULL, LONGOPT_CAPTURE_COMMENT}, {"capture-comment", ws_required_argument, NULL, LONGOPT_CAPTURE_COMMENT},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -1141,16 +1141,16 @@ main(int argc, char *argv[])
#define LONGOPT_CAPTURE_COMMENT LONGOPT_BASE_APPLICATION+6 #define LONGOPT_CAPTURE_COMMENT LONGOPT_BASE_APPLICATION+6
#define LONGOPT_DISCARD_CAPTURE_COMMENT LONGOPT_BASE_APPLICATION+7 #define LONGOPT_DISCARD_CAPTURE_COMMENT LONGOPT_BASE_APPLICATION+7
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"novlan", no_argument, NULL, LONGOPT_NO_VLAN}, {"novlan", ws_no_argument, NULL, LONGOPT_NO_VLAN},
{"skip-radiotap-header", no_argument, NULL, LONGOPT_SKIP_RADIOTAP_HEADER}, {"skip-radiotap-header", ws_no_argument, NULL, LONGOPT_SKIP_RADIOTAP_HEADER},
{"seed", required_argument, NULL, LONGOPT_SEED}, {"seed", ws_required_argument, NULL, LONGOPT_SEED},
{"inject-secrets", required_argument, NULL, LONGOPT_INJECT_SECRETS}, {"inject-secrets", ws_required_argument, NULL, LONGOPT_INJECT_SECRETS},
{"discard-all-secrets", no_argument, NULL, LONGOPT_DISCARD_ALL_SECRETS}, {"discard-all-secrets", ws_no_argument, NULL, LONGOPT_DISCARD_ALL_SECRETS},
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'}, {"version", ws_no_argument, NULL, 'V'},
{"capture-comment", required_argument, NULL, LONGOPT_CAPTURE_COMMENT}, {"capture-comment", ws_required_argument, NULL, LONGOPT_CAPTURE_COMMENT},
{"discard-capture-comment", no_argument, NULL, LONGOPT_DISCARD_CAPTURE_COMMENT}, {"discard-capture-comment", ws_no_argument, NULL, LONGOPT_DISCARD_CAPTURE_COMMENT},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -198,19 +198,19 @@ enum {
OPT_CONFIG_BT_LOCAL_TCP_PORT OPT_CONFIG_BT_LOCAL_TCP_PORT
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
{ "adb-server-ip", required_argument, NULL, OPT_CONFIG_ADB_SERVER_IP}, { "adb-server-ip", ws_required_argument, NULL, OPT_CONFIG_ADB_SERVER_IP},
{ "adb-server-tcp-port", required_argument, NULL, OPT_CONFIG_ADB_SERVER_TCP_PORT}, { "adb-server-tcp-port", ws_required_argument, NULL, OPT_CONFIG_ADB_SERVER_TCP_PORT},
{ "logcat-text", optional_argument, NULL, OPT_CONFIG_LOGCAT_TEXT}, { "logcat-text", ws_optional_argument, NULL, OPT_CONFIG_LOGCAT_TEXT},
{ "logcat-ignore-log-buffer", optional_argument, NULL, OPT_CONFIG_LOGCAT_IGNORE_LOG_BUFFER}, { "logcat-ignore-log-buffer", ws_optional_argument, NULL, OPT_CONFIG_LOGCAT_IGNORE_LOG_BUFFER},
{ "logcat-custom-options", required_argument, NULL, OPT_CONFIG_LOGCAT_CUSTOM_OPTIONS}, { "logcat-custom-options", ws_required_argument, NULL, OPT_CONFIG_LOGCAT_CUSTOM_OPTIONS},
{ "bt-server-tcp-port", required_argument, NULL, OPT_CONFIG_BT_SERVER_TCP_PORT}, { "bt-server-tcp-port", ws_required_argument, NULL, OPT_CONFIG_BT_SERVER_TCP_PORT},
{ "bt-forward-socket", required_argument, NULL, OPT_CONFIG_BT_FORWARD_SOCKET}, { "bt-forward-socket", ws_required_argument, NULL, OPT_CONFIG_BT_FORWARD_SOCKET},
{ "bt-local-ip", required_argument, NULL, OPT_CONFIG_BT_LOCAL_IP}, { "bt-local-ip", ws_required_argument, NULL, OPT_CONFIG_BT_LOCAL_IP},
{ "bt-local-tcp-port", required_argument, NULL, OPT_CONFIG_BT_LOCAL_TCP_PORT}, { "bt-local-tcp-port", ws_required_argument, NULL, OPT_CONFIG_BT_LOCAL_TCP_PORT},
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };

View File

@ -76,10 +76,10 @@ enum {
OPT_REMOTE_COUNT OPT_REMOTE_COUNT
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
SSH_BASE_OPTIONS, SSH_BASE_OPTIONS,
{ 0, 0, 0, 0} { 0, 0, 0, 0}
}; };

View File

@ -51,13 +51,13 @@ enum {
OPT_INTERFACE_ID, OPT_INTERFACE_ID,
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
/* Generic application options */ /* Generic application options */
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
/* Interfaces options */ /* Interfaces options */
{ "interface_id", required_argument, NULL, OPT_INTERFACE_ID}, { "interface_id", ws_required_argument, NULL, OPT_INTERFACE_ID},
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };

View File

@ -54,10 +54,10 @@ enum {
OPT_LEVEL, OPT_LEVEL,
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
{ "p", required_argument, NULL, OPT_PROVIDER}, { "p", ws_required_argument, NULL, OPT_PROVIDER},
{ "k", required_argument, NULL, OPT_KEYWORD}, { "k", ws_required_argument, NULL, OPT_KEYWORD},
{ "l", required_argument, NULL, OPT_LEVEL}, { "l", ws_required_argument, NULL, OPT_LEVEL},
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };

View File

@ -41,13 +41,13 @@ enum {
OPT_PARAMS OPT_PARAMS
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
{ "iue", optional_argument, NULL, OPT_INCLUDE_UNDECIDABLE_EVENT}, { "iue", ws_optional_argument, NULL, OPT_INCLUDE_UNDECIDABLE_EVENT},
{ "etlfile", required_argument, NULL, OPT_ETLFILE}, { "etlfile", ws_required_argument, NULL, OPT_ETLFILE},
{ "params", required_argument, NULL, OPT_PARAMS}, { "params", ws_required_argument, NULL, OPT_PARAMS},
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };

View File

@ -40,16 +40,16 @@
#define EXTCAP_BASE_OPTIONS \ #define EXTCAP_BASE_OPTIONS \
{ "extcap-interfaces", no_argument, NULL, EXTCAP_OPT_LIST_INTERFACES}, \ { "extcap-interfaces", ws_no_argument, NULL, EXTCAP_OPT_LIST_INTERFACES}, \
{ "extcap-version", optional_argument, NULL, EXTCAP_OPT_VERSION}, \ { "extcap-version", ws_optional_argument, NULL, EXTCAP_OPT_VERSION}, \
{ "extcap-dlts", no_argument, NULL, EXTCAP_OPT_LIST_DLTS}, \ { "extcap-dlts", ws_no_argument, NULL, EXTCAP_OPT_LIST_DLTS}, \
{ "extcap-interface", required_argument, NULL, EXTCAP_OPT_INTERFACE}, \ { "extcap-interface", ws_required_argument, NULL, EXTCAP_OPT_INTERFACE}, \
{ "extcap-config", no_argument, NULL, EXTCAP_OPT_CONFIG}, \ { "extcap-config", ws_no_argument, NULL, EXTCAP_OPT_CONFIG}, \
{ "capture", no_argument, NULL, EXTCAP_OPT_CAPTURE}, \ { "capture", ws_no_argument, NULL, EXTCAP_OPT_CAPTURE}, \
{ "extcap-capture-filter", required_argument, NULL, EXTCAP_OPT_CAPTURE_FILTER}, \ { "extcap-capture-filter", ws_required_argument, NULL, EXTCAP_OPT_CAPTURE_FILTER}, \
{ "fifo", required_argument, NULL, EXTCAP_OPT_FIFO}, \ { "fifo", ws_required_argument, NULL, EXTCAP_OPT_FIFO}, \
{ "debug", no_argument, NULL, EXTCAP_OPT_DEBUG}, \ { "debug", ws_no_argument, NULL, EXTCAP_OPT_DEBUG}, \
{ "debug-file", required_argument, NULL, EXTCAP_OPT_DEBUG_FILE} { "debug-file", ws_required_argument, NULL, EXTCAP_OPT_DEBUG_FILE}
typedef struct _extcap_parameters typedef struct _extcap_parameters
{ {

View File

@ -42,16 +42,16 @@ enum {
OPT_TYPE OPT_TYPE
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
{ "maxbytes", required_argument, NULL, OPT_MAXBYTES}, { "maxbytes", ws_required_argument, NULL, OPT_MAXBYTES},
{ "count", required_argument, NULL, OPT_COUNT}, { "count", ws_required_argument, NULL, OPT_COUNT},
{ "delay", required_argument, NULL, OPT_DELAY}, { "delay", ws_required_argument, NULL, OPT_DELAY},
{ "random-type", no_argument, NULL, OPT_RANDOM_TYPE}, { "random-type", ws_no_argument, NULL, OPT_RANDOM_TYPE},
{ "all-random", no_argument, NULL, OPT_ALL_RANDOM}, { "all-random", ws_no_argument, NULL, OPT_ALL_RANDOM},
{ "type", required_argument, NULL, OPT_TYPE}, { "type", ws_required_argument, NULL, OPT_TYPE},
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };

View File

@ -50,11 +50,11 @@ enum {
OPT_START_FROM OPT_START_FROM
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
{ "start-from", required_argument, NULL, OPT_START_FROM}, { "start-from", ws_required_argument, NULL, OPT_START_FROM},
{ 0, 0, 0, 0} { 0, 0, 0, 0}
}; };

View File

@ -28,16 +28,16 @@
#endif #endif
#define SSH_BASE_OPTIONS \ #define SSH_BASE_OPTIONS \
{ "remote-host", required_argument, NULL, OPT_REMOTE_HOST}, \ { "remote-host", ws_required_argument, NULL, OPT_REMOTE_HOST}, \
{ "remote-port", required_argument, NULL, OPT_REMOTE_PORT}, \ { "remote-port", ws_required_argument, NULL, OPT_REMOTE_PORT}, \
{ "remote-username", required_argument, NULL, OPT_REMOTE_USERNAME}, \ { "remote-username", ws_required_argument, NULL, OPT_REMOTE_USERNAME}, \
{ "remote-password", required_argument, NULL, OPT_REMOTE_PASSWORD}, \ { "remote-password", ws_required_argument, NULL, OPT_REMOTE_PASSWORD}, \
{ "remote-interface", required_argument, NULL, OPT_REMOTE_INTERFACE}, \ { "remote-interface", ws_required_argument, NULL, OPT_REMOTE_INTERFACE}, \
{ "remote-filter", required_argument, NULL, OPT_REMOTE_FILTER}, \ { "remote-filter", ws_required_argument, NULL, OPT_REMOTE_FILTER}, \
{ "remote-count", required_argument, NULL, OPT_REMOTE_COUNT}, \ { "remote-count", ws_required_argument, NULL, OPT_REMOTE_COUNT}, \
{ "sshkey", required_argument, NULL, OPT_SSHKEY}, \ { "sshkey", ws_required_argument, NULL, OPT_SSHKEY}, \
{ "sshkey-passphrase", required_argument, NULL, OPT_SSHKEY_PASSPHRASE}, \ { "sshkey-passphrase", ws_required_argument, NULL, OPT_SSHKEY_PASSPHRASE}, \
{ "proxycommand", required_argument, NULL, OPT_PROXYCOMMAND} { "proxycommand", ws_required_argument, NULL, OPT_PROXYCOMMAND}
typedef struct _ssh_params { typedef struct _ssh_params {
gchar* host; gchar* host;

View File

@ -61,14 +61,14 @@ enum {
OPT_REMOTE_NOPROM OPT_REMOTE_NOPROM
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
SSH_BASE_OPTIONS, SSH_BASE_OPTIONS,
{ "remote-capture-command", required_argument, NULL, OPT_REMOTE_CAPTURE_COMMAND}, { "remote-capture-command", ws_required_argument, NULL, OPT_REMOTE_CAPTURE_COMMAND},
{ "remote-sudo", no_argument, NULL, OPT_REMOTE_SUDO }, { "remote-sudo", ws_no_argument, NULL, OPT_REMOTE_SUDO },
{ "remote-noprom", no_argument, NULL, OPT_REMOTE_NOPROM }, { "remote-noprom", ws_no_argument, NULL, OPT_REMOTE_NOPROM },
{ 0, 0, 0, 0} { 0, 0, 0, 0}
}; };

View File

@ -72,14 +72,14 @@ enum {
OPT_PAYLOAD OPT_PAYLOAD
}; };
static struct option longopts[] = { static struct ws_option longopts[] = {
EXTCAP_BASE_OPTIONS, EXTCAP_BASE_OPTIONS,
/* Generic application options */ /* Generic application options */
{ "help", no_argument, NULL, OPT_HELP}, { "help", ws_no_argument, NULL, OPT_HELP},
{ "version", no_argument, NULL, OPT_VERSION}, { "version", ws_no_argument, NULL, OPT_VERSION},
/* Interfaces options */ /* Interfaces options */
{ "port", required_argument, NULL, OPT_PORT}, { "port", ws_required_argument, NULL, OPT_PORT},
{ "payload", required_argument, NULL, OPT_PAYLOAD}, { "payload", ws_required_argument, NULL, OPT_PAYLOAD},
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };

View File

@ -198,9 +198,9 @@ main(int argc, char *argv[])
cfile_close_failure_message cfile_close_failure_message
}; };
int opt; int opt;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'}, {"version", ws_no_argument, NULL, 'V'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
gboolean do_append = FALSE; gboolean do_append = FALSE;

View File

@ -122,8 +122,8 @@ main(int argc, char *argv[])
int allrandom = FALSE; int allrandom = FALSE;
wtap_dumper *savedump; wtap_dumper *savedump;
int ret = EXIT_SUCCESS; int ret = EXIT_SUCCESS;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -406,9 +406,9 @@ main(int argc, char *argv[])
guint fc; guint fc;
gboolean skip_pcap_header = FALSE; gboolean skip_pcap_header = FALSE;
int ret = EXIT_SUCCESS; int ret = EXIT_SUCCESS;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -189,9 +189,9 @@ main(int argc, char *argv[])
FrameRecord_t *prevFrame = NULL; FrameRecord_t *prevFrame = NULL;
int opt; int opt;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
int file_count; int file_count;

View File

@ -222,11 +222,11 @@ sharkd_init(int argc, char **argv)
static const char optstring[] = OPTSTRING; static const char optstring[] = OPTSTRING;
// right now we don't have any long options // right now we don't have any long options
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"api", required_argument, NULL, 'a'}, {"api", ws_required_argument, NULL, 'a'},
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{"config-profile", required_argument, NULL, 'C'}, {"config-profile", ws_required_argument, NULL, 'C'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };

View File

@ -1445,9 +1445,9 @@ parse_options (int argc, char *argv[])
{ {
int c; int c;
char *p; char *p;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
struct tm *now_tm; struct tm *now_tm;

View File

@ -274,9 +274,9 @@ main(int argc, char *argv[])
{ {
char *init_progfile_dir_error; char *init_progfile_dir_error;
int opt; int opt;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
gboolean arg_error = FALSE; gboolean arg_error = FALSE;

View File

@ -688,18 +688,18 @@ main(int argc, char *argv[])
cfile_close_failure_message cfile_close_failure_message
}; };
int opt; int opt;
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
LONGOPT_CAPTURE_COMMON LONGOPT_CAPTURE_COMMON
LONGOPT_DISSECT_COMMON LONGOPT_DISSECT_COMMON
{"print", no_argument, NULL, 'P'}, {"print", ws_no_argument, NULL, 'P'},
{"export-objects", required_argument, NULL, LONGOPT_EXPORT_OBJECTS}, {"export-objects", ws_required_argument, NULL, LONGOPT_EXPORT_OBJECTS},
{"export-tls-session-keys", required_argument, NULL, LONGOPT_EXPORT_TLS_SESSION_KEYS}, {"export-tls-session-keys", ws_required_argument, NULL, LONGOPT_EXPORT_TLS_SESSION_KEYS},
{"color", no_argument, NULL, LONGOPT_COLOR}, {"color", ws_no_argument, NULL, LONGOPT_COLOR},
{"no-duplicate-keys", no_argument, NULL, LONGOPT_NO_DUPLICATE_KEYS}, {"no-duplicate-keys", ws_no_argument, NULL, LONGOPT_NO_DUPLICATE_KEYS},
{"elastic-mapping-filter", required_argument, NULL, LONGOPT_ELASTIC_MAPPING_FILTER}, {"elastic-mapping-filter", ws_required_argument, NULL, LONGOPT_ELASTIC_MAPPING_FILTER},
{"capture-comment", required_argument, NULL, LONGOPT_CAPTURE_COMMENT}, {"capture-comment", ws_required_argument, NULL, LONGOPT_CAPTURE_COMMENT},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
gboolean arg_error = FALSE; gboolean arg_error = FALSE;

View File

@ -191,14 +191,14 @@ commandline_print_usage(gboolean for_help_option) {
#define LONGOPT_CAPTURE_COMMENT LONGOPT_BASE_GUI+2 #define LONGOPT_CAPTURE_COMMENT LONGOPT_BASE_GUI+2
#define OPTSTRING OPTSTRING_CAPTURE_COMMON OPTSTRING_DISSECT_COMMON "C:g:HhjJ:klm:o:P:r:R:Svw:X:Y:z:" #define OPTSTRING OPTSTRING_CAPTURE_COMMON OPTSTRING_DISSECT_COMMON "C:g:HhjJ:klm:o:P:r:R:Svw:X:Y:z:"
static const struct option long_options[] = { static const struct ws_option long_options[] = {
{"help", no_argument, NULL, 'h'}, {"help", ws_no_argument, NULL, 'h'},
{"read-file", required_argument, NULL, 'r' }, {"read-file", ws_required_argument, NULL, 'r' },
{"read-filter", required_argument, NULL, 'R' }, {"read-filter", ws_required_argument, NULL, 'R' },
{"display-filter", required_argument, NULL, 'Y' }, {"display-filter", ws_required_argument, NULL, 'Y' },
{"version", no_argument, NULL, 'v'}, {"version", ws_no_argument, NULL, 'v'},
{"fullscreen", no_argument, NULL, LONGOPT_FULL_SCREEN }, {"fullscreen", ws_no_argument, NULL, LONGOPT_FULL_SCREEN },
{"capture-comment", required_argument, NULL, LONGOPT_CAPTURE_COMMENT}, {"capture-comment", ws_required_argument, NULL, LONGOPT_CAPTURE_COMMENT},
LONGOPT_CAPTURE_COMMON LONGOPT_CAPTURE_COMMON
LONGOPT_DISSECT_COMMON LONGOPT_DISSECT_COMMON
{0, 0, 0, 0 } {0, 0, 0, 0 }

View File

@ -37,10 +37,10 @@ extern "C" {
* Options for dissecting common to all dissecting programs. * Options for dissecting common to all dissecting programs.
*/ */
#define LONGOPT_DISSECT_COMMON \ #define LONGOPT_DISSECT_COMMON \
{"disable-protocol", required_argument, NULL, LONGOPT_DISABLE_PROTOCOL }, \ {"disable-protocol", ws_required_argument, NULL, LONGOPT_DISABLE_PROTOCOL }, \
{"enable-heuristic", required_argument, NULL, LONGOPT_ENABLE_HEURISTIC }, \ {"enable-heuristic", ws_required_argument, NULL, LONGOPT_ENABLE_HEURISTIC }, \
{"disable-heuristic", required_argument, NULL, LONGOPT_DISABLE_HEURISTIC }, \ {"disable-heuristic", ws_required_argument, NULL, LONGOPT_DISABLE_HEURISTIC }, \
{"enable-protocol", required_argument, NULL, LONGOPT_ENABLE_PROTOCOL }, \ {"enable-protocol", ws_required_argument, NULL, LONGOPT_ENABLE_PROTOCOL }, \
#define OPTSTRING_DISSECT_COMMON \ #define OPTSTRING_DISSECT_COMMON \
"d:K:nN:t:u:" "d:K:nN:t:u:"

View File

@ -166,7 +166,7 @@ typedef struct pcapng_option_header_s {
/* ... Padding ... */ /* ... Padding ... */
} pcapng_option_header_t; } pcapng_option_header_t;
struct option { struct pcapng_option {
guint16 type; guint16 type;
guint16 value_length; guint16 value_length;
}; };
@ -4907,7 +4907,7 @@ pcapng_write_sysdig_event_block(wtap_dumper *wdh, const wtap_rec *rec,
guint32 pad_len; guint32 pad_len;
#if 0 #if 0
gboolean have_options = FALSE; gboolean have_options = FALSE;
struct option option_hdr; struct pcapng_option option_hdr;
guint32 comment_len = 0, comment_pad_len = 0; guint32 comment_len = 0, comment_pad_len = 0;
#endif #endif
guint32 options_total_length = 0; guint32 options_total_length = 0;
@ -5375,7 +5375,7 @@ put_nrb_options(wtap_dumper *wdh, guint8 *opt_ptr)
{ {
if (wdh->nrb_hdrs && wdh->nrb_hdrs->len > 0) { if (wdh->nrb_hdrs && wdh->nrb_hdrs->len > 0) {
wtap_block_t nrb_hdr = g_array_index(wdh->nrb_hdrs, wtap_block_t, 0); wtap_block_t nrb_hdr = g_array_index(wdh->nrb_hdrs, wtap_block_t, 0);
struct option option_hdr; struct pcapng_option option_hdr;
wtap_block_foreach_option(nrb_hdr, put_nrb_option, &opt_ptr); wtap_block_foreach_option(nrb_hdr, put_nrb_option, &opt_ptr);

View File

@ -141,7 +141,7 @@ struct epb {
}; };
#define ENHANCED_PACKET_BLOCK_TYPE 0x00000006 #define ENHANCED_PACKET_BLOCK_TYPE 0x00000006
struct option { struct ws_option {
guint16 type; guint16 type;
guint16 value_length; guint16 value_length;
}; };
@ -238,7 +238,7 @@ pcapng_count_string_option(const char *option_value)
{ {
if ((option_value != NULL) && (strlen(option_value) > 0) && (strlen(option_value) < G_MAXUINT16)) { if ((option_value != NULL) && (strlen(option_value) > 0) && (strlen(option_value) < G_MAXUINT16)) {
/* There's a value to write; get its length */ /* There's a value to write; get its length */
return (guint32)(sizeof(struct option) + return (guint32)(sizeof(struct ws_option) +
(guint16)ADD_PADDING(strlen(option_value))); (guint16)ADD_PADDING(strlen(option_value)));
} }
return 0; /* nothing to write */ return 0; /* nothing to write */
@ -250,7 +250,7 @@ pcapng_write_string_option(FILE* pfile,
guint64 *bytes_written, int *err) guint64 *bytes_written, int *err)
{ {
size_t option_value_length; size_t option_value_length;
struct option option; struct ws_option option;
const guint32 padding = 0; const guint32 padding = 0;
if (option_value == NULL) if (option_value == NULL)
@ -261,7 +261,7 @@ pcapng_write_string_option(FILE* pfile,
option.type = option_type; option.type = option_type;
option.value_length = (guint16)option_value_length; option.value_length = (guint16)option_value_length;
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)option_value, (int) option_value_length, bytes_written, err)) if (!write_to_file(pfile, (const guint8*)option_value, (int) option_value_length, bytes_written, err))
@ -316,7 +316,7 @@ pcapng_write_section_header_block(FILE* pfile,
int *err) int *err)
{ {
struct shb shb; struct shb shb;
struct option option; struct ws_option option;
guint32 block_total_length; guint32 block_total_length;
guint32 options_length; guint32 options_length;
@ -334,7 +334,7 @@ pcapng_write_section_header_block(FILE* pfile,
options_length += pcapng_count_string_option(appname); options_length += pcapng_count_string_option(appname);
/* If we have options add size of end-of-options */ /* If we have options add size of end-of-options */
if (options_length != 0) { if (options_length != 0) {
options_length += (guint32)sizeof(struct option); options_length += (guint32)sizeof(struct ws_option);
} }
block_total_length += options_length; block_total_length += options_length;
@ -370,7 +370,7 @@ pcapng_write_section_header_block(FILE* pfile,
/* write end of options */ /* write end of options */
option.type = OPT_ENDOFOPT; option.type = OPT_ENDOFOPT;
option.value_length = 0; option.value_length = 0;
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
} }
@ -394,7 +394,7 @@ pcapng_write_interface_description_block(FILE* pfile,
int *err) int *err)
{ {
struct idb idb; struct idb idb;
struct option option; struct ws_option option;
guint32 block_total_length; guint32 block_total_length;
guint32 options_length; guint32 options_length;
const guint32 padding = 0; const guint32 padding = 0;
@ -412,20 +412,20 @@ pcapng_write_interface_description_block(FILE* pfile,
/* 08 - IDB_IF_SPEED */ /* 08 - IDB_IF_SPEED */
if (if_speed != 0) { if (if_speed != 0) {
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
sizeof(guint64)); sizeof(guint64));
} }
/* 09 - IDB_TSRESOL */ /* 09 - IDB_TSRESOL */
if (tsresol != 0) { if (tsresol != 0) {
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
sizeof(struct option)); sizeof(struct ws_option));
} }
/* 11 - IDB_FILTER */ /* 11 - IDB_FILTER */
if ((filter != NULL) && (strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) { if ((filter != NULL) && (strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16)) {
/* No, this isn't a string, it has an extra type byte */ /* No, this isn't a string, it has an extra type byte */
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
(guint16)(ADD_PADDING(strlen(filter)+ 1))); (guint16)(ADD_PADDING(strlen(filter)+ 1)));
} }
@ -437,7 +437,7 @@ pcapng_write_interface_description_block(FILE* pfile,
/* If we have options add size of end-of-options */ /* If we have options add size of end-of-options */
if (options_length != 0) { if (options_length != 0) {
options_length += (guint32)sizeof(struct option); options_length += (guint32)sizeof(struct ws_option);
} }
block_total_length += options_length; block_total_length += options_length;
@ -471,7 +471,7 @@ pcapng_write_interface_description_block(FILE* pfile,
option.type = IDB_IF_SPEED; option.type = IDB_IF_SPEED;
option.value_length = sizeof(guint64); option.value_length = sizeof(guint64);
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)&if_speed, sizeof(guint64), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&if_speed, sizeof(guint64), bytes_written, err))
@ -483,7 +483,7 @@ pcapng_write_interface_description_block(FILE* pfile,
option.type = IDB_TSRESOL; option.type = IDB_TSRESOL;
option.value_length = sizeof(guint8); option.value_length = sizeof(guint8);
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)&tsresol, sizeof(guint8), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&tsresol, sizeof(guint8), bytes_written, err))
@ -499,7 +499,7 @@ pcapng_write_interface_description_block(FILE* pfile,
if ((filter != NULL) && (strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16 - 1)) { if ((filter != NULL) && (strlen(filter) > 0) && (strlen(filter) < G_MAXUINT16 - 1)) {
option.type = IDB_FILTER; option.type = IDB_FILTER;
option.value_length = (guint16)(strlen(filter) + 1 ); option.value_length = (guint16)(strlen(filter) + 1 );
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
/* The first byte of the Option Data keeps a code of the filter used, 0 = lipbpcap filter string */ /* The first byte of the Option Data keeps a code of the filter used, 0 = lipbpcap filter string */
@ -527,7 +527,7 @@ pcapng_write_interface_description_block(FILE* pfile,
/* write end of options */ /* write end of options */
option.type = OPT_ENDOFOPT; option.type = OPT_ENDOFOPT;
option.value_length = 0; option.value_length = 0;
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
} }
@ -550,7 +550,7 @@ pcapng_write_enhanced_packet_block(FILE* pfile,
int *err) int *err)
{ {
struct epb epb; struct epb epb;
struct option option; struct ws_option option;
guint32 block_total_length; guint32 block_total_length;
guint64 timestamp; guint64 timestamp;
guint32 options_length; guint32 options_length;
@ -565,12 +565,12 @@ pcapng_write_enhanced_packet_block(FILE* pfile,
options_length = 0; options_length = 0;
options_length += pcapng_count_string_option(comment); options_length += pcapng_count_string_option(comment);
if (flags != 0) { if (flags != 0) {
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
sizeof(guint32)); sizeof(guint32));
} }
/* If we have options add size of end-of-options */ /* If we have options add size of end-of-options */
if (options_length != 0) { if (options_length != 0) {
options_length += (guint32)sizeof(struct option); options_length += (guint32)sizeof(struct ws_option);
} }
block_total_length += options_length; block_total_length += options_length;
timestamp = (guint64)sec * ts_mul + (guint64)usec; timestamp = (guint64)sec * ts_mul + (guint64)usec;
@ -613,7 +613,7 @@ pcapng_write_enhanced_packet_block(FILE* pfile,
if (flags != 0) { if (flags != 0) {
option.type = EPB_FLAGS; option.type = EPB_FLAGS;
option.value_length = sizeof(guint32); option.value_length = sizeof(guint32);
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)&flags, sizeof(guint32), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&flags, sizeof(guint32), bytes_written, err))
return FALSE; return FALSE;
@ -622,7 +622,7 @@ pcapng_write_enhanced_packet_block(FILE* pfile,
/* write end of options */ /* write end of options */
option.type = OPT_ENDOFOPT; option.type = OPT_ENDOFOPT;
option.value_length = 0; option.value_length = 0;
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
} }
@ -646,7 +646,7 @@ pcapng_write_interface_statistics_block(FILE* pfile,
#else #else
struct timeval now; struct timeval now;
#endif #endif
struct option option; struct ws_option option;
guint32 block_total_length; guint32 block_total_length;
guint32 options_length; guint32 options_length;
guint64 timestamp; guint64 timestamp;
@ -693,26 +693,26 @@ pcapng_write_interface_statistics_block(FILE* pfile,
block_total_length = (guint32)(sizeof(struct isb) + sizeof(guint32)); block_total_length = (guint32)(sizeof(struct isb) + sizeof(guint32));
options_length = 0; options_length = 0;
if (isb_ifrecv != G_MAXUINT64) { if (isb_ifrecv != G_MAXUINT64) {
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
sizeof(guint64)); sizeof(guint64));
} }
if (isb_ifdrop != G_MAXUINT64) { if (isb_ifdrop != G_MAXUINT64) {
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
sizeof(guint64)); sizeof(guint64));
} }
/* OPT_COMMENT */ /* OPT_COMMENT */
options_length += pcapng_count_string_option(comment); options_length += pcapng_count_string_option(comment);
if (isb_starttime !=0) { if (isb_starttime !=0) {
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
sizeof(guint64)); /* ISB_STARTTIME */ sizeof(guint64)); /* ISB_STARTTIME */
} }
if (isb_endtime !=0) { if (isb_endtime !=0) {
options_length += (guint32)(sizeof(struct option) + options_length += (guint32)(sizeof(struct ws_option) +
sizeof(guint64)); /* ISB_ENDTIME */ sizeof(guint64)); /* ISB_ENDTIME */
} }
/* If we have options add size of end-of-options */ /* If we have options add size of end-of-options */
if (options_length != 0) { if (options_length != 0) {
options_length += (guint32)sizeof(struct option); options_length += (guint32)sizeof(struct ws_option);
} }
block_total_length += options_length; block_total_length += options_length;
@ -736,7 +736,7 @@ pcapng_write_interface_statistics_block(FILE* pfile,
option.value_length = sizeof(guint64); option.value_length = sizeof(guint64);
high = (guint32)((isb_starttime>>32) & 0xffffffff); high = (guint32)((isb_starttime>>32) & 0xffffffff);
low = (guint32)(isb_starttime & 0xffffffff); low = (guint32)(isb_starttime & 0xffffffff);
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)&high, sizeof(guint32), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&high, sizeof(guint32), bytes_written, err))
@ -752,7 +752,7 @@ pcapng_write_interface_statistics_block(FILE* pfile,
option.value_length = sizeof(guint64); option.value_length = sizeof(guint64);
high = (guint32)((isb_endtime>>32) & 0xffffffff); high = (guint32)((isb_endtime>>32) & 0xffffffff);
low = (guint32)(isb_endtime & 0xffffffff); low = (guint32)(isb_endtime & 0xffffffff);
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)&high, sizeof(guint32), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&high, sizeof(guint32), bytes_written, err))
@ -764,7 +764,7 @@ pcapng_write_interface_statistics_block(FILE* pfile,
if (isb_ifrecv != G_MAXUINT64) { if (isb_ifrecv != G_MAXUINT64) {
option.type = ISB_IFRECV; option.type = ISB_IFRECV;
option.value_length = sizeof(guint64); option.value_length = sizeof(guint64);
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)&isb_ifrecv, sizeof(guint64), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&isb_ifrecv, sizeof(guint64), bytes_written, err))
@ -773,7 +773,7 @@ pcapng_write_interface_statistics_block(FILE* pfile,
if (isb_ifdrop != G_MAXUINT64) { if (isb_ifdrop != G_MAXUINT64) {
option.type = ISB_IFDROP; option.type = ISB_IFDROP;
option.value_length = sizeof(guint64); option.value_length = sizeof(guint64);
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
if (!write_to_file(pfile, (const guint8*)&isb_ifdrop, sizeof(guint64), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&isb_ifdrop, sizeof(guint64), bytes_written, err))
@ -783,7 +783,7 @@ pcapng_write_interface_statistics_block(FILE* pfile,
/* write end of options */ /* write end of options */
option.type = OPT_ENDOFOPT; option.type = OPT_ENDOFOPT;
option.value_length = 0; option.value_length = 0;
if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct option), bytes_written, err)) if (!write_to_file(pfile, (const guint8*)&option, sizeof(struct ws_option), bytes_written, err))
return FALSE; return FALSE;
} }

View File

@ -362,10 +362,10 @@ static void test_getopt_long_basic2(void)
char **argv; char **argv;
int argc; int argc;
struct option longopts[] = { struct ws_option longopts[] = {
{ "opt1", no_argument, NULL, '1' }, { "opt1", ws_no_argument, NULL, '1' },
{ "opt2", required_argument, NULL, '2' }, { "opt2", ws_required_argument, NULL, '2' },
{ "opt3", required_argument, NULL, '3' }, { "opt3", ws_required_argument, NULL, '3' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
argv = new_argv(&argc, "/bin/ls", "--opt1", "--opt2", "arg1", "--opt3=arg2", "path", (char *)NULL); argv = new_argv(&argc, "/bin/ls", "--opt1", "--opt2", "arg1", "--opt3=arg2", "path", (char *)NULL);

View File

@ -138,9 +138,9 @@ int ws_getopt(int argc, char * const argv[], const char *optstring)
return c; return c;
} }
static int __getopt_long_core(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly); static int __getopt_long_core(int argc, char *const *argv, const char *optstring, const struct ws_option *longopts, int *idx, int longonly);
static int __getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly) static int __getopt_long(int argc, char *const *argv, const char *optstring, const struct ws_option *longopts, int *idx, int longonly)
{ {
int ret, skipped, resumed; int ret, skipped, resumed;
if (!ws_optind || ws_optreset) { if (!ws_optind || ws_optreset) {
@ -169,7 +169,7 @@ static int __getopt_long(int argc, char *const *argv, const char *optstring, con
return ret; return ret;
} }
static int __getopt_long_core(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly) static int __getopt_long_core(int argc, char *const *argv, const char *optstring, const struct ws_option *longopts, int *idx, int longonly)
{ {
ws_optarg = 0; ws_optarg = 0;
if (longopts && argv[ws_optind][0] == '-' && if (longopts && argv[ws_optind][0] == '-' &&
@ -223,7 +223,7 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
return '?'; return '?';
} }
ws_optarg = opt+1; ws_optarg = opt+1;
} else if (longopts[i].has_arg == required_argument) { } else if (longopts[i].has_arg == ws_required_argument) {
if (!(ws_optarg = argv[ws_optind])) { if (!(ws_optarg = argv[ws_optind])) {
ws_optopt = longopts[i].val; ws_optopt = longopts[i].val;
if (colon) return ':'; if (colon) return ':';
@ -258,12 +258,12 @@ static int __getopt_long_core(int argc, char *const *argv, const char *optstring
return ws_getopt(argc, argv, optstring); return ws_getopt(argc, argv, optstring);
} }
int ws_getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx) int ws_getopt_long(int argc, char *const *argv, const char *optstring, const struct ws_option *longopts, int *idx)
{ {
return __getopt_long(argc, argv, optstring, longopts, idx, 0); return __getopt_long(argc, argv, optstring, longopts, idx, 0);
} }
int ws_getopt_long_only(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx) int ws_getopt_long_only(int argc, char *const *argv, const char *optstring, const struct ws_option *longopts, int *idx)
{ {
return __getopt_long(argc, argv, optstring, longopts, idx, 1); return __getopt_long(argc, argv, optstring, longopts, idx, 1);
} }

View File

@ -38,19 +38,19 @@ WS_DLL_PUBLIC int ws_getopt(int, char * const [], const char *);
WS_DLL_PUBLIC char *ws_optarg; WS_DLL_PUBLIC char *ws_optarg;
WS_DLL_PUBLIC int ws_optind, ws_opterr, ws_optopt, ws_optpos, ws_optreset; WS_DLL_PUBLIC int ws_optind, ws_opterr, ws_optopt, ws_optpos, ws_optreset;
struct option { struct ws_option {
const char *name; const char *name;
int has_arg; int has_arg;
int *flag; int *flag;
int val; int val;
}; };
WS_DLL_PUBLIC int ws_getopt_long(int, char *const *, const char *, const struct option *, int *); WS_DLL_PUBLIC int ws_getopt_long(int, char *const *, const char *, const struct ws_option *, int *);
WS_DLL_PUBLIC int ws_getopt_long_only(int, char *const *, const char *, const struct option *, int *); WS_DLL_PUBLIC int ws_getopt_long_only(int, char *const *, const char *, const struct ws_option *, int *);
#define no_argument 0 #define ws_no_argument 0
#define required_argument 1 #define ws_required_argument 1
#define optional_argument 2 #define ws_optional_argument 2
#ifdef __cplusplus #ifdef __cplusplus
} }