*/
static void
-vcc_EmitBeIdent(struct vsb *v, const struct token *qual, int serial, const struct token *first, const struct token *last)
+vcc_EmitBeIdent(struct vsb *v, const struct token *name, const char *qual, int serial, const struct token *first, const struct token *last)
{
vsb_printf(v, "\t.ident =");
- if (serial != 0 && qual != NULL) {
- vsb_printf(v, "\n\t \"%.*s \"", PF(qual));
- qual = VTAILQ_NEXT(qual, list);
- vsb_printf(v, "\n\t \"%.*s \"", PF(qual));
- vsb_printf(v, "\n\t \":: %d :: \"", serial);
- }
+ AN(qual);
+ vsb_printf(v, "\n\t \"%s %.*s\"", qual, PF(name));
+ if (serial != 0)
+ vsb_printf(v, "\n\t \"[%d]\"", serial);
while (first != last) {
if (first->dec != NULL)
vsb_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"",
*/
static void
-vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, int serial)
+vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *name, const char *qual, int serial)
{
struct token *t_field;
struct token *t_first;
t_host = tl->t;
vcc_NextToken(tl);
} else if (vcc_IdIs(t_field, "port")) {
+ ExpectErr(tl, CSTR);
assert(tl->t->dec != NULL);
t_port = tl->t;
vcc_NextToken(tl);
}
ExpectErr(tl, '}');
- vcc_EmitBeIdent(tl->fh, qual, serial, t_first, tl->t);
- Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(qual));
+ vcc_EmitBeIdent(tl->fh, name, qual, serial, t_first, tl->t);
+ Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(name));
if (serial)
Fh(tl, 0, "[%d]", serial);
Fh(tl, 0, "\"\n};\n");
h->name = tl->t;
vcc_NextToken(tl);
- vcc_ParseBackendHost(tl, &nbh, h->name, 0);
+ vcc_ParseBackendHost(tl, &nbh, h->name, "backend", 0);
ERRCHK(tl);
h->hnum = nbh;
vcc_IsField(tl, &t_field, fs);
ERRCHK(tl);
if (vcc_IdIs(t_field, "backend")) {
- vcc_ParseBackendHost(tl, &nbh, t_dir, nelem);
+ vcc_ParseBackendHost(tl, &nbh,
+ t_dir, "random", nelem);
Fc(tl, 0, " .host = &bh_%d,", nbh);
ERRCHK(tl);
} else if (vcc_IdIs(t_field, "weight")) {
vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
vsb_cat(sb, " */\n");
vsb_cat(sb, "struct vrt_backend {\n");
- vsb_cat(sb, " const char *portname;\n");
- vsb_cat(sb, " const char *hostname;\n");
- vsb_cat(sb, " const char *vcl_name;\n");
- vsb_cat(sb, " const char *ident;\n");
+ vsb_cat(sb, " char *portname;\n");
+ vsb_cat(sb, " char *hostname;\n");
+ vsb_cat(sb, " char *vcl_name;\n");
+ vsb_cat(sb, " char *ident;\n");
vsb_cat(sb, " double connect_timeout;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");