#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 |
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.