PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_getopt_ctx.h
Go to the documentation of this file.
1/*
2 * Re-entrant version of the standard getopt(3) function.
3 *
4 * Portions Copyright (c) 2026, PostgreSQL Global Development Group
5 *
6 * src/include/port/pg_getopt_ctx.h
7 */
8#ifndef PG_GETOPT_CTX_H
9#define PG_GETOPT_CTX_H
10
11typedef struct
12{
13 int nargc;
14 char *const *nargv;
15 const char *ostr;
16
17 /*
18 * Caller can modify 'opterr' between pg_getopt_start() and the first call
19 * to pg_getopt_next(). Equivalent to the global variable of the same
20 * name in standard getopt(3).
21 */
22 int opterr;
23
24 /*
25 * Output variables set by pg_getopt_next(). These are equivalent to the
26 * global variables with same names in standard getopt(3).
27 */
28 char *optarg;
29 int optind;
30 int optopt;
31
32 /* internal state */
33 char *place;
35
36extern void pg_getopt_start(pg_getopt_ctx *ctx, int nargc, char *const *nargv, const char *ostr);
37extern int pg_getopt_next(pg_getopt_ctx *ctx);
38
39#endif /* PG_GETOPT_CTX_H */
int pg_getopt_next(pg_getopt_ctx *ctx)
void pg_getopt_start(pg_getopt_ctx *ctx, int nargc, char *const *nargv, const char *ostr)
char *const * nargv
const char * ostr