PostgreSQL Source Code git master
Loading...
Searching...
No Matches
getopt.c File Reference
#include "c.h"
#include "pg_getopt.h"
#include "port/pg_getopt_ctx.h"
Include dependency graph for getopt.c:

Go to the source code of this file.

Functions

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

Variables

int opterr = 1
 
int optind = 1
 
int optopt
 
charoptarg
 

Function Documentation

◆ getopt()

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

Definition at line 67 of file getopt.c.

68{
69 static bool active = false;
70 static pg_getopt_ctx ctx;
71 int result;
72
73 if (!active)
74 {
75 pg_getopt_start(&ctx, nargc, nargv, ostr);
76 ctx.opterr = opterr;
77 active = true;
78 }
79
80 result = pg_getopt_next(&ctx);
81 opterr = ctx.opterr;
82 optind = ctx.optind;
83 optopt = ctx.optopt;
84 optarg = ctx.optarg;
85 if (result == -1)
86 active = false;
87 return result;
88}
uint32 result
int optopt
Definition getopt.c:48
int optind
Definition getopt.c:47
char * optarg
Definition getopt.c:49
int opterr
Definition getopt.c:46
int pg_getopt_next(pg_getopt_ctx *ctx)
void pg_getopt_start(pg_getopt_ctx *ctx, int nargc, char *const *nargv, const char *ostr)

References pg_getopt_ctx::optarg, optarg, pg_getopt_ctx::opterr, opterr, pg_getopt_ctx::optind, optind, pg_getopt_ctx::optopt, optopt, pg_getopt_next(), pg_getopt_start(), and result.

Referenced by main().

Variable Documentation

◆ optarg

◆ opterr

int opterr = 1

Definition at line 46 of file getopt.c.

Referenced by getopt(), and getopt_long().

◆ optind

◆ optopt

int optopt

Definition at line 48 of file getopt.c.

Referenced by getopt(), and getopt_long().