Go to the source code of this file.
Data Structures | |
struct | option |
getopt_long option More... | |
Defines | |
#define | no_argument 0 |
#define | required_argument 1 |
#define | optional_argument 2 |
Functions | |
int | getopt_long (int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) |
Parse long options - BSD style. | |
Variables | |
int | optind |
option parsing last error | |
int | optopt |
index of option to process in argv | |
char * | optarg |
current option | |
int | optreset |
argument of current option |
#define no_argument 0 |
option with no argument
#define optional_argument 2 |
option with optional argument
#define required_argument 1 |
option with required argument
int getopt_long | ( | int | argc, | |
char *const | argv[], | |||
const char * | optstring, | |||
const struct option * | longopts, | |||
int * | longindex | |||
) |
argc | ||
argv | ||
optstring | abbreviations of | |
longopts | list of long options. | |
longindex | index of current option in longopts. |
A short options sequence is introduced by a singe dash -
. Each short option is described by a signle character int the optstring, possiblily followed by a : character to denote a (mandatory) argument of the short option. A short option with an argument cannot appear in the middle of a short option sequence, but only at the end.
A long option is introduced by a double dash --
. Each long option is described by an instace of the option structure in the longopts table (the last entry must be filled with zeroes to denote the end).
:, then error messages are supporessed and a missing argument causes : to be returned.