Commit 5a48d2b1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make vcl_dir work for vcl.load and include filenames.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4994 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 533be287
......@@ -153,6 +153,7 @@ run_vcc(void *priv)
vp = priv;
sb = vsb_newauto();
XXXAN(sb);
VCC_VCL_dir(vcc, mgt_vcl_dir);
csrc = VCC_Compile(vcc, sb, vp->vcl);
vsb_finish(sb);
AZ(vsb_overflowed(sb));
......@@ -212,7 +213,7 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag)
}
if (C_flag) {
csrc = vreadfile(sf);
csrc = vreadfile(NULL, sf);
XXXAN(csrc);
(void)fputs(csrc, stdout);
free(csrc);
......@@ -513,7 +514,7 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv)
return;
}
vcl = vreadfile(av[3]);
vcl = vreadfile(mgt_vcl_dir, av[3]);
if (vcl == NULL) {
cli_out(cli, "Cannot open '%s'", av[3]);
cli_result(cli, CLIS_PARAM);
......
......@@ -541,7 +541,7 @@ main(int argc, char * const *argv)
}
if (f_arg != NULL) {
vcl = vreadfile(f_arg);
vcl = vreadfile(NULL, f_arg);
if (vcl == NULL) {
fprintf(stderr, "Cannot read '%s': %s\n",
f_arg, strerror(errno));
......
......@@ -97,7 +97,7 @@ void varnish_version(const char *);
/* from libvarnish/vtmpfile.c */
int vtmpfile(char *);
char *vreadfile(const char *fn);
char *vreadfile(const char *pfx, const char *fn);
const char* svn_version(void);
......
......@@ -34,6 +34,7 @@ SVNID("$Id$")
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
......@@ -98,12 +99,19 @@ vreadfd(int fd)
}
char *
vreadfile(const char *fn)
vreadfile(const char *pfx, const char *fn)
{
int fd, err;
char *r;
char fnb[PATH_MAX + 1];
fd = open(fn, O_RDONLY);
if (fn[0] == '/')
fd = open(fn, O_RDONLY);
else if (pfx != NULL) {
bprintf(fnb, "/%s/%s", pfx, fn); /* XXX: graceful length check */
fd = open(fnb, O_RDONLY);
} else
fd = open(fn, O_RDONLY);
if (fd < 0)
return (NULL);
r = vreadfd(fd);
......
......@@ -382,12 +382,12 @@ vcc_destroy_source(struct source *sp)
/*--------------------------------------------------------------------*/
static struct source *
vcc_file_source(struct vsb *sb, const char *fn)
vcc_file_source(struct vcc *tl, struct vsb *sb, const char *fn)
{
char *f;
struct source *sp;
f = vreadfile(fn);
f = vreadfile(tl->vcl_dir, fn);
if (f == NULL) {
vsb_printf(sb, "Cannot read file '%s': %s\n",
fn, strerror(errno));
......@@ -428,7 +428,7 @@ vcc_resolve_includes(struct vcc *tl)
}
assert(t2 != NULL);
sp = vcc_file_source(tl->sb, t1->dec);
sp = vcc_file_source(tl, tl->sb, t1->dec);
if (sp == NULL) {
vcc_ErrWhere(tl, t1);
return;
......
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