getopt_long - Definition More...
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "generic.h"
#include "getopt_long.h"
Go to the source code of this file.
Defines | |
#define | BADARG ':' |
#define | BADCH '?' |
#define | EEND -1 |
#define | EMSG "" |
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 | |
char * | optarg |
int | opterr = 1 |
int | optind = 1 |
int | optopt |
int | optreset |
getopt_long - Definition
Definition in file getopt_long.c.
#define BADARG ':' |
Definition at line 37 of file getopt_long.c.
#define BADCH '?' |
Definition at line 36 of file getopt_long.c.
#define EEND -1 |
Definition at line 38 of file getopt_long.c.
#define EMSG "" |
Definition at line 39 of file getopt_long.c.
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.
char* optarg |
Definition at line 33 of file getopt_long.c.
int opterr = 1 |
Definition at line 30 of file getopt_long.c.
int optind = 1 |
Definition at line 31 of file getopt_long.c.
int optopt |
Definition at line 32 of file getopt_long.c.
int optreset |
Definition at line 34 of file getopt_long.c.