24{
26
28
31 const char *pguser = NULL;
32 const char *pgdbname = NULL;
34
35 const char *pghost_str = NULL;
36 const char *pghostaddr_str = NULL;
37 const char *pgport_str = NULL;
38
39#define PARAMS_ARRAY_SIZE 7
40
43
44 bool quiet = false;
45
52
53
54
55
56
57
58 static struct option long_options[] = {
65 {NULL, 0, NULL, 0}
66 };
67
72
73 while ((
c =
getopt_long(argc, argv,
"d:h:p:qt:U:", long_options, NULL)) != -1)
74 {
76 {
77 case 'd':
79 break;
80 case 'h':
82 break;
83 case 'p':
85 break;
86 case 'q':
87 quiet = true;
88 break;
89 case 't':
91 break;
92 case 'U':
94 break;
95 default:
96
98
99
100
101
102
104 }
105 }
106
108 {
109 pg_log_error(
"too many command-line arguments (first is \"%s\")",
112
113
114
115
116
118 }
119
129 values[4] = connect_timeout;
130 keywords[5] =
"fallback_application_name";
134
135
136
137
138 if (pgdbname &&
139 (strncmp(pgdbname, "postgresql://", 13) == 0 ||
140 strncmp(pgdbname, "postgres://", 11) == 0 ||
141 strchr(pgdbname, '=') != NULL))
142 {
145 {
148 }
149 }
150
152 if (defs == NULL)
153 {
156 }
157
159 {
160 if (strcmp(def->
keyword,
"host") == 0)
161 {
163 pghost_str = opt->
val;
167 pghost_str = def->
val;
168 else
170 }
171 else if (strcmp(def->
keyword,
"hostaddr") == 0)
172 {
174 pghostaddr_str = opt->
val;
176 pghostaddr_str = def->
val;
177 }
178 else if (strcmp(def->
keyword,
"port") == 0)
179 {
181 pgport_str = opt->
val;
185 pgport_str = def->
val;
186 }
187
188 if (opt)
189 opt++;
190 }
191
193
194 if (!quiet)
195 {
197 pghostaddr_str != NULL ? pghostaddr_str : pghost_str,
198 pgport_str);
199
200 switch (rv)
201 {
203 printf(
_(
"accepting connections\n"));
204 break;
206 printf(
_(
"rejecting connections\n"));
207 break;
210 break;
213 break;
214 default:
216 }
217 }
218
220}
static Datum values[MAXATTR]
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
int errmsg(const char *fmt,...)
PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)
PQconninfoOption * PQconndefaults(void)
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
char * pg_strdup(const char *in)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
static const JsonPathKeyword keywords[]
void pg_logging_init(const char *argv0)
#define pg_log_error(...)
#define pg_log_error_hint(...)
void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp)
static AmcheckOptions opts
#define DEFAULT_PGSOCKET_DIR
PGDLLIMPORT char * optarg
static void help(const char *progname)
#define PARAMS_ARRAY_SIZE
static const char * pghost
static const char * pgport
const char * get_progname(const char *argv0)