Commit 2f3fcf59 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Add a -V option (display version and exit) to all programs.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@713 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 431af3a3
...@@ -151,6 +151,7 @@ usage(void) ...@@ -151,6 +151,7 @@ usage(void)
fprintf(stderr, " %-28s # %s\n", "", fprintf(stderr, " %-28s # %s\n", "",
" -s file,<dir_or_file>,<size>"); " -s file,<dir_or_file>,<size>");
fprintf(stderr, " %-28s # %s\n", "-t", "Default TTL"); fprintf(stderr, " %-28s # %s\n", "-t", "Default TTL");
fprintf(stderr, " %-28s # %s\n", "-V", "version");
fprintf(stderr, " %-28s # %s\n", "-w int[,int[,int]]", fprintf(stderr, " %-28s # %s\n", "-w int[,int[,int]]",
"Number of worker threads"); "Number of worker threads");
fprintf(stderr, " %-28s # %s\n", "", fprintf(stderr, " %-28s # %s\n", "",
...@@ -335,7 +336,7 @@ main(int argc, char *argv[]) ...@@ -335,7 +336,7 @@ main(int argc, char *argv[])
heritage.wthread_timeout = 10; heritage.wthread_timeout = 10;
heritage.mem_workspace = 4096; 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) { switch (o) {
case 'b': case 'b':
bflag = optarg; bflag = optarg;
...@@ -358,6 +359,9 @@ main(int argc, char *argv[]) ...@@ -358,6 +359,9 @@ main(int argc, char *argv[])
case 't': case 't':
heritage.default_ttl = strtoul(optarg, NULL, 0); heritage.default_ttl = strtoul(optarg, NULL, 0);
break; break;
case 'V':
varnish_version("varnishd");
exit(0);
case 'w': case 'w':
tackle_warg(optarg); tackle_warg(optarg);
break; break;
......
...@@ -184,10 +184,10 @@ order(unsigned char *p, int h_opt) ...@@ -184,10 +184,10 @@ order(unsigned char *p, int h_opt)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
Usage(void) usage(void)
{ {
fprintf(stderr, "Usage: varnishlog [-o] [-w file] [-r file]\n"); fprintf(stderr, "usage: varnishlog [-oV] [-w file] [-r file]\n");
exit(2); exit(1);
} }
int int
...@@ -204,7 +204,7 @@ main(int argc, char **argv) ...@@ -204,7 +204,7 @@ main(int argc, char **argv)
vd = VSL_New(); 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); i = VSL_Arg(vd, c, optarg);
if (i < 0) if (i < 0)
exit (1); exit (1);
...@@ -217,11 +217,14 @@ main(int argc, char **argv) ...@@ -217,11 +217,14 @@ main(int argc, char **argv)
case 'o': case 'o':
o_flag = 1; o_flag = 1;
break; break;
case 'V':
varnish_version("varnishlog");
exit(0);
case 'w': case 'w':
w_opt = optarg; w_opt = optarg;
break; break;
default: default:
Usage(); usage();
} }
} }
...@@ -229,7 +232,7 @@ main(int argc, char **argv) ...@@ -229,7 +232,7 @@ main(int argc, char **argv)
exit (1); exit (1);
if (o_flag && w_opt != NULL) if (o_flag && w_opt != NULL)
Usage(); usage();
if (w_opt != NULL) { if (w_opt != NULL) {
if (!strcmp(w_opt, "-")) if (!strcmp(w_opt, "-"))
......
...@@ -12,4 +12,5 @@ varnishncsa_CFLAGS = -include config.h ...@@ -12,4 +12,5 @@ varnishncsa_CFLAGS = -include config.h
varnishncsa_LDADD = \ varnishncsa_LDADD = \
$(top_builddir)/lib/libvarnish/libvarnish.la \ $(top_builddir)/lib/libvarnish/libvarnish.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la $(top_builddir)/lib/libvarnishapi/libvarnishapi.la
...@@ -192,10 +192,10 @@ extended_log_format(unsigned char *p, char *w_opt) ...@@ -192,10 +192,10 @@ extended_log_format(unsigned char *p, char *w_opt)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
Usage(void) usage(void)
{ {
fprintf(stderr, "Usage: varnishlogfile [-w file] [-r file]\n"); fprintf(stderr, "usage: varnishncsa [-V] [-w file] [-r file]\n");
exit(2); exit(1);
} }
int int
...@@ -217,11 +217,14 @@ main(int argc, char **argv) ...@@ -217,11 +217,14 @@ main(int argc, char **argv)
if (i > 0) if (i > 0)
continue; continue;
switch (c) { switch (c) {
case 'V':
varnish_version("varnishncsa");
exit(0);
case 'w': case 'w':
w_opt = optarg; w_opt = optarg;
break; break;
default: default:
Usage(); usage();
} }
} }
......
...@@ -11,5 +11,6 @@ varnishstat_SOURCES = varnishstat.c ...@@ -11,5 +11,6 @@ varnishstat_SOURCES = varnishstat.c
varnishstat_CFLAGS = -include config.h varnishstat_CFLAGS = -include config.h
varnishstat_LDADD = \ varnishstat_LDADD = \
-lcurses \ $(top_builddir)/lib/libvarnish/libvarnish.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
-lcurses
...@@ -95,6 +95,13 @@ do_curses(struct varnish_stats *VSL_stats) ...@@ -95,6 +95,13 @@ do_curses(struct varnish_stats *VSL_stats)
} }
} }
static void
usage(void)
{
fprintf(stderr, "usage: varnishstat [-cV]\n");
exit(1);
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
...@@ -104,14 +111,16 @@ main(int argc, char **argv) ...@@ -104,14 +111,16 @@ main(int argc, char **argv)
VSL_stats = VSL_OpenStats(); VSL_stats = VSL_OpenStats();
while ((c = getopt(argc, argv, "c")) != -1) { while ((c = getopt(argc, argv, "cV")) != -1) {
switch (c) { switch (c) {
case 'c': case 'c':
c_flag = 1; c_flag = 1;
break; break;
case 'V':
varnish_version("varnishstat");
exit(0);
default: default:
fprintf(stderr, "Usage: varnishstat [-c]\n"); usage();
exit (2);
} }
} }
......
...@@ -34,10 +34,10 @@ static unsigned ntop; ...@@ -34,10 +34,10 @@ static unsigned ntop;
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
Usage(void) usage(void)
{ {
fprintf(stderr, "Usage: varnishtop\n"); fprintf(stderr, "usage: varnishtop [-1V]\n");
exit(2); exit(1);
} }
static void static void
...@@ -89,7 +89,7 @@ main(int argc, char **argv) ...@@ -89,7 +89,7 @@ main(int argc, char **argv)
vd = VSL_New(); 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); i = VSL_Arg(vd, c, optarg);
if (i < 0) if (i < 0)
exit (1); exit (1);
...@@ -99,8 +99,11 @@ main(int argc, char **argv) ...@@ -99,8 +99,11 @@ main(int argc, char **argv)
case '1': case '1':
one_flag = 1; one_flag = 1;
break; break;
case 'V':
varnish_version("varnishtop");
exit(0);
default: default:
Usage(); usage();
} }
} }
......
...@@ -12,5 +12,8 @@ void TIM_format(time_t t, char *p); ...@@ -12,5 +12,8 @@ void TIM_format(time_t t, char *p);
time_t TIM_parse(const char *p); time_t TIM_parse(const char *p);
#endif #endif
/* from libvarnish/version.c */
void varnish_version(const char *);
/* Assert zero return value */ /* Assert zero return value */
#define AZ(foo) do { assert((foo) == 0); } while (0) #define AZ(foo) do { assert((foo) == 0); } while (0)
...@@ -10,6 +10,7 @@ libvarnish_la_SOURCES = \ ...@@ -10,6 +10,7 @@ libvarnish_la_SOURCES = \
cli.c \ cli.c \
cli_common.c \ cli_common.c \
time.c \ time.c \
version.c \
vsb.c vsb.c
libvarnish_la_CFLAGS = -include config.h libvarnish_la_CFLAGS = -include config.h
/*
* $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");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment