Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
ws_getopt.h File Reference
#include <ws_symbol_export.h>

Go to the source code of this file.

Classes

struct  ws_option
 Structure representing a long-form command-line option. More...
 

Macros

#define ws_no_argument   0
 
#define ws_required_argument   1
 
#define ws_optional_argument   2
 

Functions

WS_DLL_PUBLIC int ws_getopt (int argc, char *const argv[], const char *optstring)
 Parse command-line options.
 
WS_DLL_PUBLIC int ws_getopt_long (int argc, char *const *argv, const char *optstring, const struct ws_option *longopts, int *idx)
 Parse command-line options, supporting both short and long forms.
 
WS_DLL_PUBLIC int ws_getopt_long_only (int argc, char *const *argv, const char *optstring, const struct ws_option *longopts, int *idx)
 Parse command-line options, treating all options as long unless prefixed with '+'.
 

Variables

WS_DLL_PUBLIC char * ws_optarg
 
WS_DLL_PUBLIC int ws_optind
 
WS_DLL_PUBLIC int ws_opterr
 
WS_DLL_PUBLIC int ws_optopt
 
WS_DLL_PUBLIC int ws_optpos
 
WS_DLL_PUBLIC int ws_optreset
 

Detailed Description

musl as a whole is licensed under the following standard MIT license:


Copyright © 2005-2020 Rich Felker, et al.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Function Documentation

◆ ws_getopt()

WS_DLL_PUBLIC int ws_getopt ( int  argc,
char *const  argv[],
const char *  optstring 
)

Parse command-line options.

Portable wrapper for parsing command-line arguments using a simplified getopt-style interface. Processes options from the argument vector according to the specified option string.

Parameters
argcArgument count.
argvArgument vector.
optstringString containing the valid option characters.
Returns
The next option character, or -1 when no more options are found.

◆ ws_getopt_long()

WS_DLL_PUBLIC int ws_getopt_long ( int  argc,
char *const *  argv,
const char *  optstring,
const struct ws_option longopts,
int *  idx 
)

Parse command-line options, supporting both short and long forms.

Extended getopt-style parser that handles short options and long options defined in a ws_option array. Supports optional argument flags and returns the matched option value or sets a flag pointer if specified.

Parameters
argcArgument count.
argvArgument vector.
optstringString containing valid short option characters.
longoptsArray of ws_option structures defining long options.
idxOptional pointer to receive index of matched long option.
Returns
The matched option value, or -1 when no more options are found.

◆ ws_getopt_long_only()

WS_DLL_PUBLIC int ws_getopt_long_only ( int  argc,
char *const *  argv,
const char *  optstring,
const struct ws_option longopts,
int *  idx 
)

Parse command-line options, treating all options as long unless prefixed with '+'.

Variant of ws_getopt_long() that interprets all options as long-form unless explicitly marked as short. Useful for applications preferring long option syntax.

Parameters
argcArgument count.
argvArgument vector.
optstringString containing valid short option characters.
longoptsArray of ws_option structures defining long options.
idxOptional pointer to receive index of matched long option.
Returns
The matched option value, or -1 when no more options are found.