getopt_long.h File Reference


Detailed Description

Author:
Andrea Vedaldi This is a re-implementation of GNU getopt_long meant to be used on platforms that do not support such functionality.

Definition in file getopt_long.h.

#include "generic.h"

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

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 int optind
 option parsing last error
VL_EXPORT int optopt
 index of option to process in argv
VL_EXPORT char * optarg
 current option
VL_EXPORT int optreset
 argument of current option

Define Documentation

#define no_argument   0

option with no argument

Definition at line 36 of file getopt_long.h.

#define optional_argument   2

option with optional argument

Definition at line 38 of file getopt_long.h.

Referenced by getopt_long().

#define required_argument   1

option with required argument

Definition at line 37 of file getopt_long.h.

Referenced by getopt_long().


Function Documentation

VL_EXPORT int getopt_long ( int  argc,
char *const   argv[],
const char *  optstring,
const struct option longopts,
int *  longindex 
)

Parameters:
argc 
argv 
optstring 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 singe dash -. Each short option is described by a single character in the 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).

Returns:
the code of the next option. 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 66 of file getopt_long.c.

References option::flag, option::name, optarg, optind, optional_argument, optopt, optreset, required_argument, and option::val.