Totally untested and probably insanely wrong patch attached.

Andrew


On 7/19/07, Jan Wieck <[EMAIL PROTECTED]> wrote:
On 7/18/2007 1:48 PM, Christopher Browne wrote:
> Andrew Hammond wrote:
>> Our binaries (slon and slonik) don't currently support the --version
>> convention. Would it make sense to add -v or --version or -V which
>> returns the version?
> Jan added the "-v" switch almost three years ago; looking at CVS:

I don't mind if it gets aliased to --version though.


Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== [EMAIL PROTECTED] #

Index: src/slon/slon.c
===================================================================
RCS file: /slony1/slony1-engine/src/slon/slon.c,v
retrieving revision 1.74
diff -u -3 -r1.74 slon.c
--- src/slon/slon.c	27 Jun 2007 16:20:24 -0000	1.74
+++ src/slon/slon.c	19 Jul 2007 22:17:42 -0000
@@ -95,6 +95,8 @@
 	fprintf(stderr, "\n");
 	fprintf(stderr, "Options:\n");
 
+    fprintf(stderr, "    -h, --help            print usage message and exit\n")
+    fprintf(stedrr, "    -v, --version         print version and exit\n");
 	fprintf(stderr, "    -d <debuglevel>       verbosity of logging (1..4)\n");
 	fprintf(stderr, "    -s <milliseconds>     SYNC check interval (default 10000)\n");
 	fprintf(stderr, "    -t <milliseconds>     SYNC interval timeout (default 60000)\n");
@@ -134,6 +136,11 @@
 	extern int	optind;
 	extern char *optarg;
 
+    static struct option longopts[] = {
+        { "help",       no_argument,    NULL,   "h"},
+        { "version",    no_argument,    NULL,   "v"}
+    };
+
 #ifdef WIN32
 	WSADATA		wsaData;
 	int			err;
@@ -165,7 +172,7 @@
 
 	InitializeConfOptions();
 
-	while ((c = getopt(argc, argv, "f:a:d:s:t:g:c:p:o:q:r:l:x:hv?")) != EOF)
+	while ((c = getopt_long(argc, argv, "f:a:d:s:t:g:c:p:o:q:r:l:x:hv?", longopts, NULL)) != -1)
 	{
 		switch (c)
 		{
Index: src/slonik/slonik.c
===================================================================
RCS file: /slony1/slony1-engine/src/slonik/slonik.c,v
retrieving revision 1.79
diff -u -3 -r1.79 slonik.c
--- src/slonik/slonik.c	5 Jul 2007 18:19:04 -0000	1.79
+++ src/slonik/slonik.c	19 Jul 2007 22:17:43 -0000
@@ -82,7 +82,12 @@
 	extern int	optind;
 	int			opt;
 
-	while ((opt = getopt(argc, (char **)argv, "hv")) != EOF)
+    static struct option longopts[] = {
+        { "help",       no_argument,    NULL,   "h"},
+        { "version",    no_argument,    NULL,   "v"}
+    };
+
+	while ((opt = getopt_long(argc, (char **)argv, "hv", longopts, NULL)) != -1)
 	{
 		switch (opt)
 		{
_______________________________________________
Slony1-general mailing list
[email protected]
http://lists.slony.info/mailman/listinfo/slony1-general

Reply via email to