const char *q;
const struct sess *sp;
- if (xxx) {
+ switch(xxx) {
+ case 2:
+ vsb_printf(vsp,
+ "Panic from VCL:\n%s\n", cond);
+ break;
+ case 1:
vsb_printf(vsp,
"Missing errorhandling code in %s(), %s line %d:\n"
" Condition(%s) not true.",
func, file, line, cond);
- } else {
+ break;
+ default:
+ case 0:
vsb_printf(vsp,
"Assert error in %s(), %s line %d:\n"
" Condition(%s) not true.",
func, file, line, cond);
+ break;
}
if (err)
vsb_printf(vsp, " errno = %d (%s)", err, strerror(err));
/*--------------------------------------------------------------------*/
+void
+VRT_panic(struct sess *sp, const char *str, ...)
+{
+ va_list ap;
+ char *b;
+
+ va_start(ap, str);
+ b = vrt_assemble_string(sp->http, "PANIC: ", str, ap);
+ va_end(ap);
+ lbv_assert("VCL", "", 0, b, 0, 2);
+}
+
+/*--------------------------------------------------------------------*/
+
void
VRT_purge(const char *regexp, int hash)
{
int VRT_re_test(struct vsb *, const char *, int sub);
const char *VRT_regsub(const struct sess *sp, int all, const char *, void *, const char *);
+void VRT_panic(struct sess *sp, const char *, ...);
void VRT_purge(const char *, int hash);
void VRT_count(const struct sess *, unsigned);
/*--------------------------------------------------------------------*/
+static void
+parse_panic(struct tokenlist *tl)
+{
+ vcc_NextToken(tl);
+
+ Fb(tl, 1, "VRT_panic(sp, ");
+ if (!vcc_StringVal(tl)) {
+ vcc_ExpectedStringval(tl);
+ return;
+ }
+ do
+ Fb(tl, 0, ", ");
+ while (vcc_StringVal(tl));
+ Fb(tl, 0, " 0);\n");
+}
+
+/*--------------------------------------------------------------------*/
+
typedef void action_f(struct tokenlist *tl);
static struct action_table {
#include "vcl_returns.h"
#undef VCL_RET_MAC
#undef VCL_RET_MAC_E
- { "call", parse_call },
- { "set", parse_set },
- { "unset", parse_unset },
- { "remove", parse_unset }, /* backward compatibility */
- { "purge_url", parse_purge_url },
- { "purge_hash", parse_purge_hash },
- { "esi", parse_esi },
-
- { NULL, NULL }
+
+ /* Keep list sorted from here */
+ { "call", parse_call },
+ { "esi", parse_esi },
+ { "panic", parse_panic },
+ { "purge_hash", parse_purge_hash },
+ { "purge_url", parse_purge_url },
+ { "remove", parse_unset }, /* backward compatibility */
+ { "set", parse_set },
+ { "unset", parse_unset },
+ { NULL, NULL }
};
void
vsb_cat(sb, "int VRT_re_test(struct vsb *, const char *, int sub);\n");
vsb_cat(sb, "const char *VRT_regsub(const struct sess *sp, int all, const char *, void *, const char *);\n");
vsb_cat(sb, "\n");
+ vsb_cat(sb, "void VRT_panic(struct sess *sp, const char *, ...);\n");
vsb_cat(sb, "void VRT_purge(const char *, int hash);\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "void VRT_count(const struct sess *, unsigned);\n");