r4809 - trunk/varnish-cache/bin/varnishadm
phk at varnish-cache.org
phk at varnish-cache.org
Mon May 17 22:11:59 CEST 2010
Author: phk
Date: 2010-05-17 22:11:59 +0200 (Mon, 17 May 2010)
New Revision: 4809
Modified:
trunk/varnish-cache/bin/varnishadm/Makefile.am
trunk/varnish-cache/bin/varnishadm/varnishadm.c
Log:
Give varnishadm the ability to find -T and possibly -S arguments if given
a -n argument.
Modified: trunk/varnish-cache/bin/varnishadm/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishadm/Makefile.am 2010-05-17 20:11:01 UTC (rev 4808)
+++ trunk/varnish-cache/bin/varnishadm/Makefile.am 2010-05-17 20:11:59 UTC (rev 4809)
@@ -11,5 +11,6 @@
varnishadm_LDADD = \
$(top_builddir)/lib/libvarnish/libvarnish.la \
+ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
${PTHREAD_LIBS} ${NET_LIBS}
Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c
===================================================================
--- trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-05-17 20:11:01 UTC (rev 4808)
+++ trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-05-17 20:11:59 UTC (rev 4809)
@@ -44,6 +44,7 @@
#include "cli.h"
#include "cli_common.h"
#include "libvarnish.h"
+#include "varnishapi.h"
#include "vss.h"
static double timeout = 5;
@@ -214,10 +215,16 @@
{
const char *T_arg = NULL;
const char *S_arg = NULL;
+ const char *n_arg = NULL;
+ struct VSL_data *vsd;
+ char *p;
int opt, sock;
- while ((opt = getopt(argc, argv, "S:T:t:")) != -1) {
+ while ((opt = getopt(argc, argv, "n:S:T:t:")) != -1) {
switch (opt) {
+ case 'n':
+ n_arg = optarg;
+ break;
case 'S':
S_arg = optarg;
break;
@@ -235,6 +242,25 @@
argc -= optind;
argv += optind;
+ if (n_arg != NULL) {
+ vsd = VSL_New();
+ assert(VSL_Arg(vsd, 'n', n_arg));
+ if (!VSL_Open(vsd)) {
+ if (T_arg == NULL) {
+ p = VSL_Find_Alloc(vsd, "Arg", "-T", NULL);
+ if (p != NULL) {
+ T_arg = strdup(p);
+ }
+ }
+ if (S_arg == NULL) {
+ p = VSL_Find_Alloc(vsd, "Arg", "-S", NULL);
+ if (p != NULL) {
+ S_arg = strdup(p);
+ }
+ }
+ }
+ }
+
if (T_arg == NULL)
usage();
More information about the varnish-commit
mailing list