Commit 7981186e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Work towards making struct sess opaque to the generated code.


git-svn-id: http://www.varnish-cache.org/svn/trunk@210 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent d2db7a16
......@@ -67,3 +67,12 @@ VRT_GetReq(struct sess *sp)
assert(http_GetReq(sp->http, &p));
return (p);
}
/*--------------------------------------------------------------------*/
void
VRT_handling(struct sess *sp, enum handling hand)
{
sp->handling = hand;
}
......@@ -47,8 +47,6 @@ struct sess {
enum handling handling;
char done;
TAILQ_ENTRY(sess) list;
sesscb_f *sesscb;
......@@ -82,7 +80,7 @@ int string_match(const char *, const char *);
#endif
typedef void vcl_init_f(void);
typedef void vcl_func_f(struct sess *sp);
typedef int vcl_func_f(struct sess *sp);
struct VCL_conf {
unsigned magic;
......
......@@ -31,10 +31,10 @@ int VRT_switch_config(const char *);
char *VRT_GetHdr(struct sess *, const char *);
char *VRT_GetReq(struct sess *);
void VRT_handling(struct sess *sp, enum handling hand);
#define VRT_done(sess, hand) \
#define VRT_done(sp, hand) \
do { \
sess->handling = hand; \
sess->done = 1; \
return; \
VRT_handling(sp, hand); \
return (1); \
} while (0)
......@@ -962,12 +962,11 @@ Action(struct tokenlist *tl)
case T_CALL:
ExpectErr(tl, ID);
AddRef(tl, tl->t, R_FUNC);
I(tl);
sbuf_printf(tl->fc, "VGC_function_%*.*s(sp);\n",
I(tl); sbuf_printf(tl->fc,
"if (VGC_function_%*.*s(sp))\n",
tl->t->e - tl->t->b,
tl->t->e - tl->t->b, tl->t->b);
I(tl); sbuf_printf(tl->fc, "if (sp->done)\n");
I(tl); sbuf_printf(tl->fc, "\treturn;\n");
I(tl); sbuf_printf(tl->fc, "\treturn (1);\n");
NextToken(tl);
return;
case T_REWRITE:
......@@ -1291,13 +1290,11 @@ Function(struct tokenlist *tl)
NextToken(tl);
ExpectErr(tl, ID);
AddDef(tl, tl->t, R_FUNC);
sbuf_printf(tl->fh, "static void VGC_function_%*.*s (struct sess *sp);\n",
sbuf_printf(tl->fh, "static int VGC_function_%*.*s (struct sess *sp);\n",
tl->t->e - tl->t->b,
tl->t->e - tl->t->b, tl->t->b);
I(tl);
sbuf_printf(tl->fc, "static void\n");
I(tl);
sbuf_printf(tl->fc, "VGC_function_%*.*s (struct sess *sp)\n",
I(tl); sbuf_printf(tl->fc, "static int\n");
I(tl); sbuf_printf(tl->fc, "VGC_function_%*.*s (struct sess *sp)\n",
tl->t->e - tl->t->b,
tl->t->e - tl->t->b, tl->t->b);
NextToken(tl);
......
......@@ -446,8 +446,6 @@ vcl_output_lang_h(FILE *f)
fputs("\n", f);
fputs(" enum handling handling;\n", f);
fputs("\n", f);
fputs(" char done;\n", f);
fputs("\n", f);
fputs(" TAILQ_ENTRY(sess) list;\n", f);
fputs("\n", f);
fputs(" sesscb_f *sesscb;\n", f);
......@@ -481,7 +479,7 @@ vcl_output_lang_h(FILE *f)
fputs("#endif\n", f);
fputs("\n", f);
fputs("typedef void vcl_init_f(void);\n", f);
fputs("typedef void vcl_func_f(struct sess *sp);\n", f);
fputs("typedef int vcl_func_f(struct sess *sp);\n", f);
fputs("\n", f);
fputs("struct VCL_conf {\n", f);
fputs(" unsigned magic;\n", f);
......@@ -529,11 +527,11 @@ vcl_output_lang_h(FILE *f)
fputs("\n", f);
fputs("char *VRT_GetHdr(struct sess *, const char *);\n", f);
fputs("char *VRT_GetReq(struct sess *);\n", f);
fputs("void VRT_handling(struct sess *sp, enum handling hand);\n", f);
fputs("\n", f);
fputs("#define VRT_done(sess, hand) \\\n", f);
fputs("#define VRT_done(sp, hand) \\\n", f);
fputs(" do { \\\n", f);
fputs(" sess->handling = hand; \\\n", f);
fputs(" sess->done = 1; \\\n", f);
fputs(" return; \\\n", f);
fputs(" VRT_handling(sp, hand); \\\n", f);
fputs(" return (1); \\\n", f);
fputs(" } while (0)\n", f);
}
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