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)
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;
......
......@@ -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, "-"))
......
......@@ -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
......@@ -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();
}
}
......
......@@ -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
......@@ -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();
}
}
......
......@@ -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();
}
}
......
......@@ -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)
......@@ -10,6 +10,7 @@ libvarnish_la_SOURCES = \
cli.c \
cli_common.c \
time.c \
version.c \
vsb.c
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