From af3b8c34cc8b46275de5b4d254a2569df0fcb072 Mon Sep 17 00:00:00 2001 From: des Date: Sun, 19 Aug 2007 17:26:45 +0000 Subject: [PATCH] Improve style. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1854 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishadm/varnishadm.1 | 37 +++++++++------------- varnish-cache/bin/varnishadm/varnishadm.c | 38 +++++++++++------------ 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/varnish-cache/bin/varnishadm/varnishadm.1 b/varnish-cache/bin/varnishadm/varnishadm.1 index 711d9f4e..dd471e10 100644 --- a/varnish-cache/bin/varnishadm/varnishadm.1 +++ b/varnish-cache/bin/varnishadm/varnishadm.1 @@ -28,45 +28,36 @@ .\" .\" $Id$ .\" -.Dd June 06, 2007 +.Dd August 19, 2007 .Dt VARNISHADM 1 .Os .Sh NAME .Nm varnishadm .Sh SYNOPSIS .Nm -.Fl T Ar address:port +.Fl T Ar address:port +.Cm Ar command +.Op Ar ... .Sh DESCRIPTION The .Nm -utility sends the given command to the +utility sends the given command and arguments to the .Xr varnishd 1 -instance at address:port and prints the results. 0 is returned on success, 1 -on failure. +instance at address:port and prints the results. .Pp The following options are available: .Bl -tag -width Fl .It Fl T Ar address:port -Connect via telnet to this address and port. -.Sh EXAMPLES -The following command lists all available commands provided by the -management interface of -.Ed -.Xr varnishd 1 -.Bd -literal -offset 4n -$ varnishadm -T 127.0.0.1:23 help -.Ed +Connect to the management interface at the specified address and port. +.El +.Sh EXIT STATUS +The exit status of the +.Nm +utility is zero if the command succeeded, and non-zero otherwise. .Sh SEE ALSO -.Xr varnishd 1 , -.Xr varnishhist 1 , -.Xr varnishncsa 1 , -.Xr varnishstat 1 , -.Xr varnishtop 1 +.Xr varnishd 1 .Sh HISTORY The .Nm -utility was developed by -.An Cecilie Fritzvold Aq cecilihf@linpro.no . - -This manual page was written by +utility and this manual page were written by .An Cecilie Fritzvold Aq cecilihf@linpro.no . diff --git a/varnish-cache/bin/varnishadm/varnishadm.c b/varnish-cache/bin/varnishadm/varnishadm.c index 5db9eff2..e3f11239 100644 --- a/varnish-cache/bin/varnishadm/varnishadm.c +++ b/varnish-cache/bin/varnishadm/varnishadm.c @@ -46,12 +46,12 @@ * returned */ static void -telnet_mgt(const char* T_arg, int argc, char* argv[]) +telnet_mgt(const char *T_arg, int argc, char *argv[]) { struct vss_addr **ta; char *addr, *port; int i, n; - int sock; + int sock; long status, bytes; char *answer = NULL; char buf[13]; @@ -62,11 +62,11 @@ telnet_mgt(const char* T_arg, int argc, char* argv[]) free(addr); free(port); if (n == 0) { - fprintf(stderr, "Could not open TELNET port\n"); + fprintf(stderr, "Could not resolve '%s'\n", T_arg); exit(2); } - sock = VSS_connect(ta[0]); + sock = VSS_connect(ta[0]); for (i = 0; i < n; ++i) { free(ta[i]); @@ -121,36 +121,34 @@ telnet_mgt(const char* T_arg, int argc, char* argv[]) static void usage(void) { - fprintf(stderr, "usage: varnishadm -T address:port \n"); + fprintf(stderr, + "usage: varnishadm -T [address]:port command [...]\n"); exit(1); } int main(int argc, char *argv[]) { - int c; - const char *address = NULL; - int T_arg = 0; + const char *T_arg = NULL; + int opt; - if (argc < 2) - usage(); - - while ((c = getopt(argc, argv, "T:")) != -1) { - switch (c) { + while ((opt = getopt(argc, argv, "T:")) != -1) { + switch (opt) { case 'T': - T_arg = 1; - address = optarg; + T_arg = optarg; break; default: usage(); } } - if (T_arg) { - if (optind == argc) - usage(); - telnet_mgt(address, argc - optind, &argv[optind]); - } + argc -= optind; + argv += optind; + + if (T_arg == NULL || argc < 1) + usage(); + + telnet_mgt(T_arg, argc, argv); exit(0); } -- 2.39.5