]> err.no Git - varnish/commitdiff
Add a -V option (display version and exit) to all programs.
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 7 Aug 2006 12:35:50 +0000 (12:35 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 7 Aug 2006 12:35:50 +0000 (12:35 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@713 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/varnishd.c
varnish-cache/bin/varnishlog/varnishlog.c
varnish-cache/bin/varnishncsa/Makefile.am
varnish-cache/bin/varnishncsa/varnishncsa.c
varnish-cache/bin/varnishstat/Makefile.am
varnish-cache/bin/varnishstat/varnishstat.c
varnish-cache/bin/varnishtop/varnishtop.c
varnish-cache/include/libvarnish.h
varnish-cache/lib/libvarnish/Makefile.am
varnish-cache/lib/libvarnish/version.c [new file with mode: 0644]

index a39a7db8e87db1b8d00319ee82dbb806db3fc979..27a41ccd73a95fbb817838fcbc2625106b72238e 100644 (file)
@@ -151,6 +151,7 @@ usage(void)
        fprintf(stderr, "    %-28s # %s\n", "",
            "  -s file,<dir_or_file>,<size>");
        fprintf(stderr, "    %-28s # %s\n", "-t", "Default TTL");
+       fprintf(stderr, "    %-28s # %s\n", "-V", "version");
        fprintf(stderr, "    %-28s # %s\n", "-w int[,int[,int]]",
            "Number of worker threads");
        fprintf(stderr, "    %-28s # %s\n", "",
@@ -335,7 +336,7 @@ main(int argc, char *argv[])
        heritage.wthread_timeout = 10;
        heritage.mem_workspace = 4096;
 
-       while ((o = getopt(argc, argv, "b:df:h:p:s:t:w:")) != -1)
+       while ((o = getopt(argc, argv, "b:df:h:p:s:t:Vw:")) != -1)
                switch (o) {
                case 'b':
                        bflag = optarg;
@@ -358,6 +359,9 @@ main(int argc, char *argv[])
                case 't':
                        heritage.default_ttl = strtoul(optarg, NULL, 0);
                        break;
+               case 'V':
+                       varnish_version("varnishd");
+                       exit(0);
                case 'w':
                        tackle_warg(optarg);
                        break;
index 67fa138994c409347498b5c711da19129bbeae45..aaa2ffa43124f643fd8e8e25bfb5ec74bfcfef0f 100644 (file)
@@ -184,10 +184,10 @@ order(unsigned char *p, int h_opt)
 /*--------------------------------------------------------------------*/
 
 static void
-Usage(void)
+usage(void)
 {
-       fprintf(stderr, "Usage: varnishlog [-o] [-w file] [-r file]\n");
-       exit(2);
+       fprintf(stderr, "usage: varnishlog [-oV] [-w file] [-r file]\n");
+       exit(1);
 }
 
 int
@@ -204,7 +204,7 @@ main(int argc, char **argv)
 
        vd = VSL_New();
        
-       while ((c = getopt(argc, argv, VSL_ARGS "how:")) != -1) {
+       while ((c = getopt(argc, argv, VSL_ARGS "hoVw:")) != -1) {
                i = VSL_Arg(vd, c, optarg);
                if (i < 0)
                        exit (1);
@@ -217,11 +217,14 @@ main(int argc, char **argv)
                case 'o':
                        o_flag = 1;
                        break;
+               case 'V':
+                       varnish_version("varnishlog");
+                       exit(0);
                case 'w':
                        w_opt = optarg;
                        break;
                default:
-                       Usage();
+                       usage();
                }
        }
 
@@ -229,7 +232,7 @@ main(int argc, char **argv)
                exit (1);
 
        if (o_flag && w_opt != NULL)
-               Usage();
+               usage();
 
        if (w_opt != NULL) {
                if (!strcmp(w_opt, "-"))
index 707dad110dfaf1866de3e5e0824af9a5214a28fa..f541501fe4bc6882ffdaf94b49aabbc20005b830 100644 (file)
@@ -12,4 +12,5 @@ varnishncsa_CFLAGS = -include config.h
 
 varnishncsa_LDADD = \
        $(top_builddir)/lib/libvarnish/libvarnish.la \
+       $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
        $(top_builddir)/lib/libvarnishapi/libvarnishapi.la
index f52804080ba83c2ee2ad5ee5827742a2d7201f05..66901f851dc5b06c27d1ba35b7ecbdfd4eddfcc8 100644 (file)
@@ -192,10 +192,10 @@ extended_log_format(unsigned char *p, char *w_opt)
 /*--------------------------------------------------------------------*/
 
 static void
-Usage(void)
+usage(void)
 {
-       fprintf(stderr, "Usage: varnishlogfile [-w file] [-r file]\n");
-       exit(2);
+       fprintf(stderr, "usage: varnishncsa [-V] [-w file] [-r file]\n");
+       exit(1);
 }
 
 int
@@ -217,11 +217,14 @@ main(int argc, char **argv)
                if (i > 0)
                        continue;
                switch (c) {
+               case 'V':
+                       varnish_version("varnishncsa");
+                       exit(0);
                case 'w':
                        w_opt = optarg;
                        break;
                default:
-                       Usage();
+                       usage();
                }
        }
 
index 3d8659b5128f951337a43bd01f29dcdceb408ea9..64287da260ee04e697cd71121aaca9c84d631342 100644 (file)
@@ -11,5 +11,6 @@ varnishstat_SOURCES = varnishstat.c
 varnishstat_CFLAGS = -include config.h
 
 varnishstat_LDADD = \
-       -lcurses \
-       $(top_builddir)/lib/libvarnishapi/libvarnishapi.la 
+       $(top_builddir)/lib/libvarnish/libvarnish.la \
+       $(top_builddir)/lib/libvarnishapi/libvarnishapi.la  \
+       -lcurses
index 06119c5f93ebc695f19b14e3f802bb0b559002dc..c8b380b998edde39fed7f7b3c600a6e141948931 100644 (file)
@@ -95,6 +95,13 @@ do_curses(struct varnish_stats *VSL_stats)
        }
 }
 
+static void
+usage(void)
+{
+       fprintf(stderr, "usage: varnishstat [-cV]\n");
+       exit(1);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -104,14 +111,16 @@ main(int argc, char **argv)
 
        VSL_stats = VSL_OpenStats();
 
-       while ((c = getopt(argc, argv, "c")) != -1) {
+       while ((c = getopt(argc, argv, "cV")) != -1) {
                switch (c) {
                case 'c':
                        c_flag = 1;
                        break;
+               case 'V':
+                       varnish_version("varnishstat");
+                       exit(0);
                default:
-                       fprintf(stderr, "Usage:  varnishstat [-c]\n");
-                       exit (2);
+                       usage();
                }
        }
 
index 89d0d147f599606691287157c7c2242162952650..b4a0c2fb5142b346bcd288a87f03b2361a11c2cc 100644 (file)
@@ -34,10 +34,10 @@ static unsigned ntop;
 /*--------------------------------------------------------------------*/
 
 static void
-Usage(void)
+usage(void)
 {
-       fprintf(stderr, "Usage: varnishtop\n");
-       exit(2);
+       fprintf(stderr, "usage: varnishtop [-1V]\n");
+       exit(1);
 }
 
 static void
@@ -89,7 +89,7 @@ main(int argc, char **argv)
 
        vd = VSL_New();
        
-       while ((c = getopt(argc, argv, VSL_ARGS "1")) != -1) {
+       while ((c = getopt(argc, argv, VSL_ARGS "1V")) != -1) {
                i = VSL_Arg(vd, c, optarg);
                if (i < 0)
                        exit (1);
@@ -99,8 +99,11 @@ main(int argc, char **argv)
                case '1':
                        one_flag = 1;
                        break;
+               case 'V':
+                       varnish_version("varnishtop");
+                       exit(0);
                default:
-                       Usage();
+                       usage();
                }
        }
 
index 616290ecf6beed53d133a08467778d47875970a0..3f82ebb552da9bae6b91fe1c6343b6a116865a2d 100644 (file)
@@ -12,5 +12,8 @@ void TIM_format(time_t t, char *p);
 time_t TIM_parse(const char *p);
 #endif
 
+/* from libvarnish/version.c */
+void varnish_version(const char *);
+
 /* Assert zero return value */
 #define AZ(foo)        do { assert((foo) == 0); } while (0)
index 2e331b1d6be6df2675ffa33d11defc3dce91a483..1a3469bced7e2d334afc598cefcecdb4fba14ae5 100644 (file)
@@ -10,6 +10,7 @@ libvarnish_la_SOURCES = \
        cli.c \
        cli_common.c \
        time.c \
+       version.c \
        vsb.c
 
 libvarnish_la_CFLAGS = -include config.h
diff --git a/varnish-cache/lib/libvarnish/version.c b/varnish-cache/lib/libvarnish/version.c
new file mode 100644 (file)
index 0000000..e687a7a
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * $Id$
+ *
+ * Display a standardized version message.
+ */
+
+#include <stdio.h>
+
+#include "libvarnish.h"
+
+void
+varnish_version(const char *progname)
+{
+       fprintf(stderr, "%s (%s-%s)\n", progname,
+           PACKAGE_TARNAME, PACKAGE_VERSION);
+       fprintf(stderr, "Copyright (c) 2006 Linpro AS / Verdens Gang AS\n");
+}