| 20 | help(const char *progname); |
| 21 | |
| 22 | int |
| 23 | main(int argc, char **argv) |
| 24 | { |
| 25 | int c; |
| 26 | |
| 27 | const char *progname; |
| 28 | |
| 29 | const char *pghost = NULL; |
| 30 | const char *pgport = NULL; |
| 31 | const char *pguser = NULL; |
| 32 | const char *pgdbname = NULL; |
| 33 | const char *connect_timeout = DEFAULT_CONNECT_TIMEOUT; |
| 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 | |
| 41 | const char *keywords[PARAMS_ARRAY_SIZE]; |
| 42 | const char *values[PARAMS_ARRAY_SIZE]; |
| 43 | |
| 44 | bool quiet = false; |
| 45 | |
| 46 | PGPing rv; |
| 47 | PQconninfoOption *opts = NULL; |
| 48 | PQconninfoOption *defs = NULL; |
| 49 | PQconninfoOption *opt; |
| 50 | PQconninfoOption *def; |
| 51 | char *errmsg = NULL; |
| 52 | |
| 53 | /* |
| 54 | * We accept user and database as options to avoid useless errors from |
| 55 | * connecting with invalid params |
| 56 | */ |
| 57 | |
| 58 | static struct option long_options[] = { |
| 59 | {"dbname", required_argument, NULL, 'd'}, |
| 60 | {"host", required_argument, NULL, 'h'}, |
| 61 | {"port", required_argument, NULL, 'p'}, |
| 62 | {"quiet", no_argument, NULL, 'q'}, |
| 63 | {"timeout", required_argument, NULL, 't'}, |
| 64 | {"username", required_argument, NULL, 'U'}, |
| 65 | {NULL, 0, NULL, 0} |
| 66 | }; |
| 67 | |
| 68 | pg_logging_init(argv[0]); |
| 69 | progname = get_progname(argv[0]); |
| 70 | set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pgscripts")); |
| 71 | handle_help_version_opts(argc, argv, progname, help); |
| 72 | |
| 73 | while ((c = getopt_long(argc, argv, "d:h:p:qt:U:", long_options, NULL)) != -1) |
| 74 | { |
| 75 | switch (c) |
| 76 | { |
| 77 | case 'd': |
| 78 | pgdbname = pg_strdup(optarg); |
| 79 | break; |
nothing calls this directly
no test coverage detected