| 22 | static void help(const char *progname); |
| 23 | |
| 24 | int |
| 25 | main(int argc, char *argv[]) |
| 26 | { |
| 27 | static struct option long_options[] = { |
| 28 | {"host", required_argument, NULL, 'h'}, |
| 29 | {"port", required_argument, NULL, 'p'}, |
| 30 | {"username", required_argument, NULL, 'U'}, |
| 31 | {"role", required_argument, NULL, 'g'}, |
| 32 | {"no-password", no_argument, NULL, 'w'}, |
| 33 | {"password", no_argument, NULL, 'W'}, |
| 34 | {"echo", no_argument, NULL, 'e'}, |
| 35 | {"createdb", no_argument, NULL, 'd'}, |
| 36 | {"no-createdb", no_argument, NULL, 'D'}, |
| 37 | {"superuser", no_argument, NULL, 's'}, |
| 38 | {"no-superuser", no_argument, NULL, 'S'}, |
| 39 | {"createrole", no_argument, NULL, 'r'}, |
| 40 | {"no-createrole", no_argument, NULL, 'R'}, |
| 41 | {"inherit", no_argument, NULL, 'i'}, |
| 42 | {"no-inherit", no_argument, NULL, 'I'}, |
| 43 | {"login", no_argument, NULL, 'l'}, |
| 44 | {"no-login", no_argument, NULL, 'L'}, |
| 45 | {"replication", no_argument, NULL, 1}, |
| 46 | {"no-replication", no_argument, NULL, 2}, |
| 47 | {"interactive", no_argument, NULL, 3}, |
| 48 | {"connection-limit", required_argument, NULL, 'c'}, |
| 49 | {"pwprompt", no_argument, NULL, 'P'}, |
| 50 | {"encrypted", no_argument, NULL, 'E'}, |
| 51 | {NULL, 0, NULL, 0} |
| 52 | }; |
| 53 | |
| 54 | const char *progname; |
| 55 | int optindex; |
| 56 | int c; |
| 57 | const char *newuser = NULL; |
| 58 | char *host = NULL; |
| 59 | char *port = NULL; |
| 60 | char *username = NULL; |
| 61 | SimpleStringList roles = {NULL, NULL}; |
| 62 | enum trivalue prompt_password = TRI_DEFAULT; |
| 63 | ConnParams cparams; |
| 64 | bool echo = false; |
| 65 | bool interactive = false; |
| 66 | int conn_limit = -2; /* less than minimum valid value */ |
| 67 | bool pwprompt = false; |
| 68 | char *newpassword = NULL; |
| 69 | |
| 70 | /* Tri-valued variables. */ |
| 71 | enum trivalue createdb = TRI_DEFAULT, |
| 72 | superuser = TRI_DEFAULT, |
| 73 | createrole = TRI_DEFAULT, |
| 74 | inherit = TRI_DEFAULT, |
| 75 | login = TRI_DEFAULT, |
| 76 | replication = TRI_DEFAULT; |
| 77 | |
| 78 | PQExpBufferData sql; |
| 79 | |
| 80 | PGconn *conn; |
| 81 | PGresult *result; |
nothing calls this directly
no test coverage detected