getopt_long More...
#include "generic.h"
Go to the source code of this file.
Classes | |
struct | option |
getopt_long option More... | |
Defines | |
#define | no_argument 0 |
#define | optional_argument 2 |
#define | required_argument 1 |
Functions | |
VL_EXPORT int | getopt_long (int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) |
Parse long options (BSD style) | |
Variables | |
VL_EXPORT char * | optarg |
VL_EXPORT int | opterr |
VL_EXPORT int | optind |
VL_EXPORT int | optopt |
VL_EXPORT int | optreset |
getopt_long
This is a drop-in replacament of GNU getopt_long meant to be used on platforms that do not support such functionality.
Definition in file getopt_long.h.
#define no_argument 0 |
option with no argument
Definition at line 34 of file getopt_long.h.
#define optional_argument 2 |
option with optional argument
Definition at line 36 of file getopt_long.h.
#define required_argument 1 |
option with required argument
Definition at line 35 of file getopt_long.h.
VL_EXPORT int getopt_long | ( | int | argc, |
char *const | argv[], | ||
const char * | optstring, | ||
const struct option * | longopts, | ||
int * | longindex | ||
) |
Parse long options (BSD style)
argc | number of arguments. |
argv | pointer to the vector of arguments. |
optstring | list of abbreviated options |
longopts | list of long options. |
longindex | index of current option in longopts. |
This function extract long and short options from the argument list argv of argc entries.
A short options sequence is introduced by a single dash character -
. Each short option is described by a single character in the string optstring, possibly 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 instance of the option structure in the longopts table (the last entry must be filled with zeroes to denote the end).
Illegal options and missing arguments cause the function to skip the option and return '?'. If opterr is true
(default), the function prints an error message to stderr. Finally, if optstring has a leading :, then error messages are suppressed and a missing argument causes : to be returned.
Definition at line 74 of file getopt_long.c.
VL_EXPORT char* optarg |
argument of the current option
Definition at line 22 of file getopt_long.h.
VL_EXPORT int opterr |
code of the last error occured while parsing an option
Definition at line 19 of file getopt_long.h.
VL_EXPORT int optind |
index of the next option to process in argv
Definition at line 20 of file getopt_long.h.
VL_EXPORT int optopt |
current option
Definition at line 21 of file getopt_long.h.
VL_EXPORT int optreset |
reset flag
Definition at line 23 of file getopt_long.h.