r1309 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Mon Apr 9 22:50:12 CEST 2007
Author: phk
Date: 2007-04-09 22:50:12 +0200 (Mon, 09 Apr 2007)
New Revision: 1309
Modified:
trunk/varnish-cache/bin/varnishd/mgt.h
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Add a -C argument, which compiles the VCL (either default with -b
or user specified with -f) and outputs the C source on the stdout.
Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h 2007-04-09 20:34:14 UTC (rev 1308)
+++ trunk/varnish-cache/bin/varnishd/mgt.h 2007-04-09 20:50:12 UTC (rev 1309)
@@ -57,7 +57,7 @@
/* mgt_vcc.c */
void mgt_vcc_init(void);
-int mgt_vcc_default(const char *bflag, const char *fflag);
+int mgt_vcc_default(const char *bflag, const char *fflag, int Cflag);
int mgt_push_vcls_and_start(unsigned *status, char **p);
#include "stevedore.h"
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-04-09 20:34:14 UTC (rev 1308)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2007-04-09 20:50:12 UTC (rev 1309)
@@ -280,9 +280,9 @@
/*--------------------------------------------------------------------*/
int
-mgt_vcc_default(const char *b_arg, const char *f_arg)
+mgt_vcc_default(const char *b_arg, const char *f_arg, int C_flag)
{
- char *addr, *port;
+ char *addr, *port, *csrc;
char *buf, *vf;
struct vsb *sb;
struct vclprog *vp;
@@ -312,8 +312,17 @@
free(addr);
free(port);
AN(buf);
+ if (C_flag) {
+ csrc = VCC_Compile(sb, buf, NULL);
+ fputs(csrc, stdout);
+ exit (0);
+ }
vf = mgt_VccCompile(sb, buf, NULL);
free(buf);
+ } else if (C_flag) {
+ csrc = VCC_CompileFile(sb, f_arg);
+ fputs(csrc, stdout);
+ exit (0);
} else {
vf = mgt_VccCompileFile(sb, f_arg);
}
Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2007-04-09 20:34:14 UTC (rev 1308)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2007-04-09 20:50:12 UTC (rev 1309)
@@ -398,6 +398,7 @@
const char *h_flag = "classic";
const char *s_arg = "file";
const char *T_arg = NULL;
+ unsigned C_flag;
char *p;
struct params param;
struct cli cli[1];
@@ -432,7 +433,7 @@
MCF_ParamInit(cli);
cli_check(cli);
- while ((o = getopt(argc, argv, "a:b:df:h:p:s:T:t:Vw:")) != -1)
+ while ((o = getopt(argc, argv, "a:b:Cdf:h:p:s:T:t:Vw:")) != -1)
switch (o) {
case 'a':
MCF_ParamSet(cli, "listen_address", optarg);
@@ -441,6 +442,9 @@
case 'b':
b_arg = optarg;
break;
+ case 'C':
+ C_flag = 1;
+ break;
case 'd':
d_flag++;
break;
@@ -495,7 +499,7 @@
usage();
}
- if (mgt_vcc_default(b_arg, f_arg))
+ if (mgt_vcc_default(b_arg, f_arg, C_flag))
exit (2);
setup_storage(s_arg);
More information about the varnish-commit
mailing list