Hi,
Here is a patch (for head, aka 2.4) that allows a user to use long
options (--help for example), instead of short ones.
Comments? I can apply it if you find it interesting.
--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com
Index: main.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/main.c,v
retrieving revision 1.66
diff -c -p -r1.66 main.c
*** main.c 12 May 2010 04:58:13 -0000 1.66
--- main.c 15 May 2010 14:19:25 -0000
*************** int main(int argc, char **argv)
*** 179,185 ****
--- 179,199 ----
int retrycnt;
int sys_retrycnt;
int debug_level = 0;
+ int optindex;
+ static struct option long_options[] = {
+ {"hba-file", required_argument, NULL, 'a'},
+ {"clear", no_argument, NULL, 'c'},
+ {"debug", no_argument, NULL, 'd'},
+ {"config-file", required_argument, NULL, 'f'},
+ {"pcp-file", required_argument, NULL, 'F'},
+ {"help", no_argument, NULL, 'h'},
+ {"mode", required_argument, NULL, 'm'},
+ {"dont-detach", no_argument, NULL, 'n'},
+ {"version", no_argument, NULL, 'v'},
+ {NULL, 0, NULL, 0}
+ };
+
myargc = argc;
myargv = argv;
*************** int main(int argc, char **argv)
*** 187,193 ****
snprintf(pcp_conf_file, sizeof(pcp_conf_file), "%s/%s", DEFAULT_CONFIGDIR, PCP_PASSWD_FILE_NAME);
snprintf(hba_file, sizeof(hba_file), "%s/%s", DEFAULT_CONFIGDIR, HBA_CONF_FILE_NAME);
! while ((opt = getopt(argc, argv, "a:cdf:F:hm:nv")) != -1)
{
switch (opt)
{
--- 201,207 ----
snprintf(pcp_conf_file, sizeof(pcp_conf_file), "%s/%s", DEFAULT_CONFIGDIR, PCP_PASSWD_FILE_NAME);
snprintf(hba_file, sizeof(hba_file), "%s/%s", DEFAULT_CONFIGDIR, HBA_CONF_FILE_NAME);
! while ((opt = getopt_long(argc, argv, "a:cdf:F:hm:nv", long_options, &optindex)) != -1)
{
switch (opt)
{
*************** static void usage(void)
*** 649,667 ****
fprintf(stderr, " [ -m SHUTDOWN-MODE ] stop\n");
fprintf(stderr, " pgpool [ -f CONFIG_FILE ] [ -F PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ] reload\n\n");
fprintf(stderr, "Common options:\n");
! fprintf(stderr, " -a HBA_CONFIG_FILE Sets the path to the pool_hba.conf configuration file\n");
fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, HBA_CONF_FILE_NAME);
! fprintf(stderr, " -f CONFIG_FILE Sets the path to the pgpool.conf configuration file\n");
fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, POOL_CONF_FILE_NAME);
! fprintf(stderr, " -F PCP_CONFIG_FILE Sets the path to the pcp.conf configuration file\n");
fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, PCP_PASSWD_FILE_NAME);
! fprintf(stderr, " -h Prints this help\n\n");
fprintf(stderr, "Start options:\n");
! fprintf(stderr, " -c Clears query cache (enable_query_cache must be on)\n");
! fprintf(stderr, " -n Don't run in daemon mode, does not detach control tty\n");
! fprintf(stderr, " -d Debug mode\n\n");
fprintf(stderr, "Stop options:\n");
! fprintf(stderr, " -m SHUTDOWN-MODE Can be \"smart\", \"fast\", or \"immediate\"\n\n");
fprintf(stderr, "Shutdown modes are:\n");
fprintf(stderr, " smart quit after all clients have disconnected\n");
fprintf(stderr, " fast quit directly, with proper shutdown\n");
--- 663,685 ----
fprintf(stderr, " [ -m SHUTDOWN-MODE ] stop\n");
fprintf(stderr, " pgpool [ -f CONFIG_FILE ] [ -F PCP_CONFIG_FILE ] [ -a HBA_CONFIG_FILE ] reload\n\n");
fprintf(stderr, "Common options:\n");
! fprintf(stderr, " -a, --hba-file=HBA_CONFIG_FILE\n");
! fprintf(stderr, " Sets the path to the pool_hba.conf configuration file\n");
fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, HBA_CONF_FILE_NAME);
! fprintf(stderr, " -f, --config-file=CONFIG_FILE\n");
! fprintf(stderr, " Sets the path to the pgpool.conf configuration file\n");
fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, POOL_CONF_FILE_NAME);
! fprintf(stderr, " -F, --pcp-file=PCP_CONFIG_FILE\n");
! fprintf(stderr, " Sets the path to the pcp.conf configuration file\n");
fprintf(stderr, " (default: %s/%s)\n",DEFAULT_CONFIGDIR, PCP_PASSWD_FILE_NAME);
! fprintf(stderr, " -h, --help Prints this help\n\n");
fprintf(stderr, "Start options:\n");
! fprintf(stderr, " -c, --clear Clears query cache (enable_query_cache must be on)\n");
! fprintf(stderr, " -n, --dont-detach Don't run in daemon mode, does not detach control tty\n");
! fprintf(stderr, " -d, --debug Debug mode\n\n");
fprintf(stderr, "Stop options:\n");
! fprintf(stderr, " -m, --mode=SHUTDOWN-MODE\n");
! fprintf(stderr, " Can be \"smart\", \"fast\", or \"immediate\"\n\n");
fprintf(stderr, "Shutdown modes are:\n");
fprintf(stderr, " smart quit after all clients have disconnected\n");
fprintf(stderr, " fast quit directly, with proper shutdown\n");
Index: pcp/pcp_attach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_attach_node.c,v
retrieving revision 1.3
diff -c -p -r1.3 pcp_attach_node.c
*** pcp/pcp_attach_node.c 31 Dec 2008 10:25:40 -0000 1.3
--- pcp/pcp_attach_node.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 40,47 ****
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 41,55 ----
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_detach_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_detach_node.c,v
retrieving revision 1.3
diff -c -p -r1.3 pcp_detach_node.c
*** pcp/pcp_detach_node.c 31 Dec 2008 10:25:40 -0000 1.3
--- pcp/pcp_detach_node.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 40,47 ****
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 41,55 ----
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_node_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_count.c,v
retrieving revision 1.3
diff -c -p -r1.3 pcp_node_count.c
*** pcp/pcp_node_count.c 31 Dec 2008 10:25:40 -0000 1.3
--- pcp/pcp_node_count.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 40,47 ****
char pass[MAX_USER_PASSWD_LEN];
int node_count;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 41,55 ----
char pass[MAX_USER_PASSWD_LEN];
int node_count;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_node_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_node_info.c,v
retrieving revision 1.3
diff -c -p -r1.3 pcp_node_info.c
*** pcp/pcp_node_info.c 31 Dec 2008 10:25:40 -0000 1.3
--- pcp/pcp_node_info.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 41,48 ****
int nodeID;
BackendInfo *backend_info;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 42,56 ----
int nodeID;
BackendInfo *backend_info;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_proc_count.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_count.c,v
retrieving revision 1.4
diff -c -p -r1.4 pcp_proc_count.c
*** pcp/pcp_proc_count.c 31 Dec 2008 10:25:40 -0000 1.4
--- pcp/pcp_proc_count.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 41,48 ****
int process_count;
int *process_list = NULL;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 42,56 ----
int process_count;
int *process_list = NULL;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_proc_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_proc_info.c,v
retrieving revision 1.3
diff -c -p -r1.3 pcp_proc_info.c
*** pcp/pcp_proc_info.c 31 Dec 2008 10:25:40 -0000 1.3
--- pcp/pcp_proc_info.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 42,49 ****
ProcessInfo *process_info;
int array_size;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 43,57 ----
ProcessInfo *process_info;
int array_size;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_recovery_node.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_recovery_node.c,v
retrieving revision 1.4
diff -c -p -r1.4 pcp_recovery_node.c
*** pcp/pcp_recovery_node.c 31 Dec 2008 10:25:40 -0000 1.4
--- pcp/pcp_recovery_node.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 40,47 ****
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 41,55 ----
char pass[MAX_USER_PASSWD_LEN];
int nodeID;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_stop_pgpool.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_stop_pgpool.c,v
retrieving revision 1.3
diff -c -p -r1.3 pcp_stop_pgpool.c
*** pcp/pcp_stop_pgpool.c 31 Dec 2008 10:25:40 -0000 1.3
--- pcp/pcp_stop_pgpool.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 40,47 ****
char pass[MAX_USER_PASSWD_LEN];
char mode;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 41,55 ----
char pass[MAX_USER_PASSWD_LEN];
char mode;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
Index: pcp/pcp_systemdb_info.c
===================================================================
RCS file: /cvsroot/pgpool/pgpool-II/pcp/pcp_systemdb_info.c,v
retrieving revision 1.3
diff -c -p -r1.3 pcp_systemdb_info.c
*** pcp/pcp_systemdb_info.c 31 Dec 2008 10:25:40 -0000 1.3
--- pcp/pcp_systemdb_info.c 15 May 2010 14:19:26 -0000
***************
*** 24,29 ****
--- 24,30 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <getopt.h>
#include "pcp.h"
*************** main(int argc, char **argv)
*** 41,48 ****
SystemDBInfo *systemdb_info;
int i, j;
int ch;
! while ((ch = getopt(argc, argv, "hd")) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
--- 42,56 ----
SystemDBInfo *systemdb_info;
int i, j;
int ch;
+ int optindex;
! static struct option long_options[] = {
! {"debug", no_argument, NULL, 'd'},
! {"help", no_argument, NULL, 'h'},
! {NULL, 0, NULL, 0}
! };
!
! while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
switch (ch) {
case 'd':
pcp_enable_debug();
_______________________________________________
Pgpool-hackers mailing list
[email protected]
http://pgfoundry.org/mailman/listinfo/pgpool-hackers