Exemple #1
0
char *
VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
{
	char *b, *e;
	unsigned u, x;

	u = WS_Reserve(ws, 0);
	e = b = ws->f;
	e += u;
	if (h != NULL) {
		x = strlen(h);
		if (b + x < e)
			memcpy(b, h, x);
		b += x;
		if (b < e)
			*b = ' ';
		b++;
	}
	b = VRT_StringList(b, e > b ? e - b : 0, p, ap);
	if (b == NULL || b == e) {
		WS_Release(ws, 0);
		return (NULL);
	}
	e = b;
	b = ws->f;
	WS_Release(ws, e - b);
	return (b);
}
Exemple #2
0
vmod_log(struct sess *sp, const char *fmt, ...)
{
	char buf[8192], *p;
	va_list ap;

	va_start(ap, fmt);
	p = VRT_StringList(buf, sizeof buf, fmt, ap);
	va_end(ap);
	if (p != NULL)
		WSP(sp, SLT_VCL_Log, "%s", buf);
}
Exemple #3
0
void
vmod_syslog(struct sess *sp, int fac, const char *fmt, ...)
{
	char buf[8192], *p;
	va_list ap;

	(void)sp;
	va_start(ap, fmt);
	p = VRT_StringList(buf, sizeof buf, fmt, ap);
	va_end(ap);
	if (p != NULL)
		syslog(fac, "%s", buf);
}
vmod_syslog(const struct vrt_ctx *ctx, VCL_INT fac, const char *fmt, ...)
{
	char *p;
	unsigned u;
	va_list ap;

	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
	u = WS_Reserve(ctx->ws, 0);
	p = ctx->ws->f;
	va_start(ap, fmt);
	p = VRT_StringList(p, u, fmt, ap);
	va_end(ap);
	if (p != NULL)
		syslog((int)fac, "%s", p);
	WS_Release(ctx->ws, 0);
}
vmod_log(const struct vrt_ctx *ctx, const char *fmt, ...)
{
	unsigned u;
	va_list ap;
	txt t;

	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
	u = WS_Reserve(ctx->ws, 0);
	t.b = ctx->ws->f;
	va_start(ap, fmt);
	t.e = VRT_StringList(t.b, u, fmt, ap);
	va_end(ap);
	if (t.e != NULL) {
		assert(t.e > t.b);
		t.e--;
		VSLbt(ctx->vsl, SLT_VCL_Log, t);
	}
	WS_Release(ctx->ws, 0);
}
Exemple #6
0
vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...)
{
	unsigned u;
	va_list ap;
	txt t;

	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
	va_start(ap, fmt);
	if (ctx->ws != NULL) {
		u = WS_Reserve(ctx->ws, 0);
		t.b = ctx->ws->f;
		t.e = VRT_StringList(ctx->ws->f, u, fmt, ap);
		if (t.e != NULL)
			syslog((int)fac, "%s", t.b);
		WS_Release(ctx->ws, 0);
	} else
		vsyslog((int)fac, fmt, ap);
	va_end(ap);
}