#include "c.h"
Go to the source code of this file.
Defines | |
#define | BADCH (int)'?' |
#define | BADARG (int)':' |
#define | EMSG "" |
Functions | |
int | getopt (int nargc, char *const *nargv, const char *ostr) |
Variables | |
int | opterr = 1 |
int | optind = 1 |
int | optopt |
char * | optarg |
int getopt | ( | int | nargc, | |
char *const * | nargv, | |||
const char * | ostr | |||
) |
Definition at line 77 of file getopt.c.
References optarg, opterr, optind, and optopt.
Referenced by AuxiliaryProcessMain(), get_opts(), main(), PostmasterMain(), and process_postgres_switches().
{ static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ if (!*place) { /* update scanning pointer */ if (optind >= nargc || *(place = nargv[optind]) != '-') { place = EMSG; return -1; } if (place[1] && *++place == '-' && place[1] == '\0') { /* found "--" */ ++optind; place = EMSG; return -1; } } /* option letter okay? */ if ((optopt = (int) *place++) == (int) ':' || !(oli = strchr(ostr, optopt))) { /* * if the user didn't specify '-' as an option, assume it means -1. */ if (optopt == (int) '-') { place = EMSG; return -1; } if (!*place) ++optind; if (opterr && *ostr != ':') (void) fprintf(stderr, "illegal option -- %c\n", optopt); return BADCH; } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) /* no white space */ optarg = place; else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (*ostr == ':') return BADARG; if (opterr) (void) fprintf(stderr, "option requires an argument -- %c\n", optopt); return BADCH; } else /* white space */ optarg = nargv[optind]; place = EMSG; ++optind; } return optopt; /* dump back option letter */ }
char* optarg |
Definition at line 51 of file getopt.c.
Referenced by AuxiliaryProcessMain(), get_opts(), get_stats_option_name(), getopt(), getopt_long(), handle_args(), main(), parse_psql_options(), parseCommandLine(), PostmasterMain(), process_postgres_switches(), and regression_main().
int opterr = 1 |
Definition at line 48 of file getopt.c.
Referenced by getopt(), getopt_long(), PostmasterMain(), and process_postgres_switches().
int optind = 1 |
Definition at line 49 of file getopt.c.
Referenced by AuxiliaryProcessMain(), getopt(), getopt_long(), handle_args(), main(), parse_psql_options(), PostmasterMain(), process_postgres_switches(), and regression_main().