MeteoIODoc 2.11.0
getopt.c File Reference
#include <err.h>
#include <errno.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>

Macros

#define PRINT_ERROR   ((opterr) && (*options != ':'))
 
#define FLAG_PERMUTE   0x01 /* permute non-options to the end of argv */
 
#define FLAG_ALLARGS   0x02 /* treat non-options as args to option "-1" */
 
#define FLAG_LONGONLY   0x04 /* operate as getopt_long_only */
 
#define BADCH   (int)'?'
 
#define BADARG   ((*options == ':') ? (int)':' : (int)'?')
 
#define INORDER   (int)1
 
#define EMSG   ""
 

Functions

static int getopt_internal (int, char *const *, const char *, const struct option *, int *, int)
 
static int parse_long_options (char *const *, const char *, const struct option *, int *, int, int)
 
static int gcd (int, int)
 
static void permute_args (int, int, int, char *const *)
 
int getopt (int nargc, char *const *nargv, const char *options)
 
int getopt_long (int nargc, char *const *nargv, const char *options, const struct option *long_options, int *idx)
 
int getopt_long_only (int nargc, char *const *nargv, const char *options, const struct option *long_options, int *idx)
 

Variables

int opterr = 1
 
int optind = 1
 
int optopt = '?'
 
int optreset
 
char * optarg
 
static char * place = EMSG
 
static int nonopt_start = -1
 
static int nonopt_end = -1
 
static const char recargchar [] = "option requires an argument -- %c"
 
static const char recargstring [] = "option requires an argument -- %s"
 
static const char ambig [] = "ambiguous option -- %.*s"
 
static const char noarg [] = "option doesn't take an argument -- %.*s"
 
static const char illoptchar [] = "unknown option -- %c"
 
static const char illoptstring [] = "unknown option -- %s"
 

Macro Definition Documentation

◆ BADARG

#define BADARG   ((*options == ':') ? (int)':' : (int)'?')

◆ BADCH

#define BADCH   (int)'?'

◆ EMSG

#define EMSG   ""

◆ FLAG_ALLARGS

#define FLAG_ALLARGS   0x02 /* treat non-options as args to option "-1" */

◆ FLAG_LONGONLY

#define FLAG_LONGONLY   0x04 /* operate as getopt_long_only */

◆ FLAG_PERMUTE

#define FLAG_PERMUTE   0x01 /* permute non-options to the end of argv */

◆ INORDER

#define INORDER   (int)1

◆ PRINT_ERROR

#define PRINT_ERROR   ((opterr) && (*options != ':'))

Function Documentation

◆ gcd()

static int gcd ( int  a,
int  b 
)
static

◆ getopt()

int getopt ( int  nargc,
char *const *  nargv,
const char *  options 
)

◆ getopt_internal()

static int getopt_internal ( int  nargc,
char *const *  nargv,
const char *  options,
const struct option long_options,
int *  idx,
int  flags 
)
static

◆ getopt_long()

int getopt_long ( int  nargc,
char *const *  nargv,
const char *  options,
const struct option long_options,
int *  idx 
)

◆ getopt_long_only()

int getopt_long_only ( int  nargc,
char *const *  nargv,
const char *  options,
const struct option long_options,
int *  idx 
)

◆ parse_long_options()

static int parse_long_options ( char *const *  nargv,
const char *  options,
const struct option long_options,
int *  idx,
int  short_too,
int  flags 
)
static

◆ permute_args()

static void permute_args ( int  panonopt_start,
int  panonopt_end,
int  opt_end,
char *const *  nargv 
)
static

Variable Documentation

◆ ambig

const char ambig[] = "ambiguous option -- %.*s"
static

◆ illoptchar

const char illoptchar[] = "unknown option -- %c"
static

◆ illoptstring

const char illoptstring[] = "unknown option -- %s"
static

◆ noarg

const char noarg[] = "option doesn't take an argument -- %.*s"
static

◆ nonopt_end

int nonopt_end = -1
static

◆ nonopt_start

int nonopt_start = -1
static

◆ optarg

char* optarg

◆ opterr

int opterr = 1

◆ optind

int optind = 1

◆ optopt

int optopt = '?'

◆ optreset

int optreset

◆ place

char* place = EMSG
static

◆ recargchar

const char recargchar[] = "option requires an argument -- %c"
static

◆ recargstring

const char recargstring[] = "option requires an argument -- %s"
static