Commit 075e6e64 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Implement -V (version) for vut (varnishlog)

parent b2a04a0a
......@@ -50,11 +50,13 @@
#include "vtim.h"
#include "vut.h"
static const char progname[] = "varnishlog";
static void
usage(void)
{
const char **opt;
fprintf(stderr, "Usage: varnishlog <options>\n\n");
fprintf(stderr, "Usage: %s <options>\n\n", progname);
fprintf(stderr, "Options:\n");
for (opt = vopt_usage; *opt != NULL; opt += 2)
fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1));
......@@ -66,7 +68,7 @@ main(int argc, char * const *argv)
{
char opt;
VUT_Init();
VUT_Init(progname);
while ((opt = getopt(argc, argv, vopt_optstring)) != -1) {
switch (opt) {
......
......@@ -48,6 +48,7 @@ VUT_OPT_r
VSL_OPT_T
VUT_OPT_u
VSL_OPT_v
VUT_OPT_V
VUT_OPT_w
VSL_OPT_x
VSL_OPT_X
......@@ -43,12 +43,6 @@ The following options are available:
XXX: Not yet implemented
-V
Display the version number and exit.
XXX: Not yet implemented
SIGNALS
=======
......
......@@ -32,6 +32,8 @@
#include "vdef.h"
struct VUT {
const char *progname;
/* Options */
int a_opt;
int d_opt;
......@@ -65,7 +67,7 @@ int VUT_Arg(int opt, const char *arg);
void VUT_Setup(void);
void VUT_Init(void);
void VUT_Init(const char *progname);
void VUT_Fini(void);
......
......@@ -84,6 +84,11 @@
"Unbuffered binary file output mode." \
)
#define VUT_OPT_V \
VOPT("V", "[-V]", "Version", \
"Print version information and exit." \
)
#define VUT_OPT_w \
VOPT("w:", "[-w filename]", "Binary output filename", \
"Write log entries to this file instead of displaying" \
......
......@@ -48,6 +48,7 @@
#include "vtim.h"
#include "vas.h"
#include "miniobj.h"
#include "vcs.h"
#include "vut.h"
......@@ -164,6 +165,10 @@ VUT_Arg(int opt, const char *arg)
/* Unbuffered binary output */
VUT.u_opt = 1;
return (1);
case 'V':
/* Print version number and exit */
VCS_Message(VUT.progname);
exit(1);
case 'w':
/* Binary file output */
REPLACE(VUT.w_arg, arg);
......@@ -178,8 +183,9 @@ VUT_Arg(int opt, const char *arg)
}
void
VUT_Init(void)
VUT_Init(const char *progname)
{
VUT.progname = progname;
VUT.g_arg = VSL_g_vxid;
AZ(VUT.vsl);
VUT.vsl = VSL_New();
......
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