Example #1
0
static struct var *
vcc_Stv_mkvar(struct vcc *tl, const struct token *t, enum var_type fmt)
{
	struct var *v;

	v = TlAlloc(tl, sizeof *v);
	AN(v);

	v->name = TlDupTok(tl, t);
	v->r_methods = 0;
#define VCL_MET_MAC(l,u,t,b)	v->r_methods |= VCL_MET_##u;
#include "tbl/vcl_returns.h"
#undef VCL_MET_MAC
	v->fmt = fmt;

	return (v);
}
Example #2
0
struct symbol *
vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc)
{
	struct symbol *sym;
	struct var *v;
	const struct var *vh;
	int l;
	char buf[258];

	vh = wc->var;

	v = TlAlloc(tl, sizeof *v);
	AN(v);

	v->name = TlDupTok(tl, t);
	v->r_methods = vh->r_methods;
	v->w_methods = vh->w_methods;
	v->fmt = STRING;
	v->http = vh->http;
	l = strlen(v->name + vh->len) + 1;

	bprintf(buf, "\\%03o%s:", (unsigned)l, v->name + vh->len);
	v->hdr = TlDup(tl, buf);
	bprintf(buf, "VRT_GetHdr(sp, %s, \"%s\")", v->http, v->hdr);
	v->rname = TlDup(tl, buf);

	bprintf(buf, "VRT_SetHdr(sp, %s, \"%s\", ", v->http, v->hdr);
	v->lname = TlDup(tl, buf);

	sym = VCC_AddSymbolTok(tl, t, SYM_VAR);
	AN(sym);
	sym->var = v;
	sym->fmt = v->fmt;
	sym->eval = vcc_Eval_Var;
	sym->r_methods = v->r_methods;
	return (sym);
}