getopt_long.c File Reference

getopt_long - Definition More...

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "getopt_long.h"

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


Detailed Description

Author:
Andrea Vedaldi

Function Documentation

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

Parameters:
argc 
argv 
optstring abbreviations of
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 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).

Returns:
the code of the next option. Illegal options and mising 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 supporessed and a missing argument causes : to be returned.


Generated on Mon Jan 21 17:43:32 2008 for vlfeat by  doxygen 1.5.4