17 #define DEFAULT_CONNECT_TIMEOUT "3"
23 main(
int argc,
char **argv)
31 const char *pguser = NULL;
32 const char *pgdbname = NULL;
35 const char *pghost_str = NULL;
36 const char *pghostaddr_str = NULL;
37 const char *pgport_str = NULL;
39 #define PARAMS_ARRAY_SIZE 7
58 static struct option long_options[] = {
73 while ((
c =
getopt_long(argc, argv,
"d:h:p:qt:U:", long_options, NULL)) != -1)
109 pg_log_error(
"too many command-line arguments (first is \"%s\")",
120 keywords[0] =
"host";
122 keywords[1] =
"port";
124 keywords[2] =
"user";
126 keywords[3] =
"dbname";
128 keywords[4] =
"connect_timeout";
129 values[4] = connect_timeout;
130 keywords[5] =
"fallback_application_name";
139 (strncmp(pgdbname,
"postgresql://", 13) == 0 ||
140 strncmp(pgdbname,
"postgres://", 11) == 0 ||
141 strchr(pgdbname,
'=') != NULL))
160 if (strcmp(def->
keyword,
"host") == 0)
163 pghost_str = opt->
val;
167 pghost_str = def->
val;
171 else if (strcmp(def->
keyword,
"hostaddr") == 0)
174 pghostaddr_str = opt->
val;
176 pghostaddr_str = def->
val;
178 else if (strcmp(def->
keyword,
"port") == 0)
181 pgport_str = opt->
val;
185 pgport_str = def->
val;
197 pghostaddr_str != NULL ? pghostaddr_str : pghost_str,
203 printf(
_(
"accepting connections\n"));
206 printf(
_(
"rejecting connections\n"));
225 printf(
_(
"%s issues a connection check to a PostgreSQL database.\n\n"),
progname);
230 printf(
_(
" -d, --dbname=DBNAME database name\n"));
231 printf(
_(
" -q, --quiet run quietly\n"));
232 printf(
_(
" -V, --version output version information, then exit\n"));
233 printf(
_(
" -?, --help show this help, then exit\n"));
235 printf(
_(
"\nConnection options:\n"));
236 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
237 printf(
_(
" -p, --port=PORT database server port\n"));
239 printf(
_(
" -U, --username=USERNAME user name to connect as\n"));
240 printf(
_(
"\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
241 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
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
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)
int main(int argc, char **argv)
#define PARAMS_ARRAY_SIZE
#define DEFAULT_CONNECT_TIMEOUT
static const char * pghost
static const char * pgport
const char * get_progname(const char *argv0)