当前位置: 首页>>代码示例>>C++>>正文


C++ VSB_printf函数代码示例

本文整理汇总了C++中VSB_printf函数的典型用法代码示例。如果您正苦于以下问题:C++ VSB_printf函数的具体用法?C++ VSB_printf怎么用?C++ VSB_printf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VSB_printf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: VEP_Init

struct vep_state *
VEP_Init(struct vfp_ctx *vc, const struct http *req, vep_callback_t *cb,
    void *cb_priv)
{
	struct vep_state *vep;

	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
	CHECK_OBJ_NOTNULL(req, HTTP_MAGIC);
	vep = WS_Alloc(vc->http->ws, sizeof *vep);
	AN(vep);

	INIT_OBJ(vep, VEP_MAGIC);
	vep->url = req->hd[HTTP_HDR_URL].b;
	vep->vc = vc;
	vep->vsb = VSB_new_auto();
	AN(vep->vsb);

	if (cb != NULL) {
		vep->dogzip = 1;
		/* XXX */
		VSB_printf(vep->vsb, "%c", VEC_GZ);
		vep->cb = cb;
		vep->cb_priv = cb_priv;
	} else {
		vep->cb = vep_default_cb;
		vep->cb_priv = &vep->cb_x;
	}

	vep->state = VEP_START;
	vep->crc = crc32(0L, Z_NULL, 0);
	vep->crcp = crc32(0L, Z_NULL, 0);

	vep->startup = 1;
	return (vep);
}
开发者ID:ShadySQL,项目名称:Varnish-Cache,代码行数:35,代码来源:cache_esi_parse.c

示例2: vtc_log

//lint -e{818}
void
vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...)
{
	double tx;

	CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC);
	tx = VTIM_mono() - t0;
	AZ(pthread_mutex_lock(&vl->mtx));
	vl->act = 1;
	assert(lvl < (int)NLEAD);
	VSB_clear(vl->vsb);
	VSB_printf(vl->vsb, "%s %-4s %4.1f ",
	    lead[lvl < 0 ? 1: lvl], vl->id, tx);
	va_list ap;
	va_start(ap, fmt);
	(void)VSB_vprintf(vl->vsb, fmt, ap);
	va_end(ap);
	VSB_putc(vl->vsb, '\n');
	AZ(VSB_finish(vl->vsb));

	vtc_log_emit(vl, lvl);

	VSB_clear(vl->vsb);
	vl->act = 0;
	AZ(pthread_mutex_unlock(&vl->mtx));
	if (lvl > 0)
		return;
	if (lvl == 0)
		vtc_error = 1;
	if (pthread_self() != vtc_thread)
		pthread_exit(NULL);
}
开发者ID:ying123,项目名称:Varnish-Cache,代码行数:33,代码来源:vtc_log.c

示例3: parse_return

static void
parse_return(struct vcc *tl)
{
	int retval = 0;

	vcc_NextToken(tl);
	ExpectErr(tl, '(');
	vcc_NextToken(tl);
	ExpectErr(tl, ID);

#define VCL_RET_MAC(l, U, B)						\
	do {								\
		if (vcc_IdIs(tl->t, #l)) {				\
			Fb(tl, 1, "VRT_done(sp, VCL_RET_" #U ");\n");	\
			vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\
			retval = 1;					\
		}							\
	} while (0);
#include "vcl_returns.h"
#undef VCL_RET_MAC
	if (!retval) {
		VSB_printf(tl->sb, "Expected return action name.\n");
		vcc_ErrWhere(tl, tl->t);
		ERRCHK(tl);
	}
	vcc_NextToken(tl);
	ExpectErr(tl, ')');
	vcc_NextToken(tl);
}
开发者ID:tpn,项目名称:Varnish-Cache,代码行数:29,代码来源:vcc_action.c

示例4: vbp_write_proxy_v1

static int
vbp_write_proxy_v1(struct vbp_target *vt, int *sock)
{
	char buf[105]; /* maximum size for a TCP6 PROXY line with null char */
	char addr[VTCP_ADDRBUFSIZE];
	char port[VTCP_PORTBUFSIZE];
	struct sockaddr_storage ss;
	struct vsb vsb;
	socklen_t l;

	VTCP_myname(*sock, addr, sizeof addr, port, sizeof port);
	AN(VSB_new(&vsb, buf, sizeof buf, VSB_FIXEDLEN));

	l = sizeof ss;
	AZ(getsockname(*sock, (void *)&ss, &l));
	if (ss.ss_family == AF_INET || ss.ss_family == AF_INET6) {
		VSB_printf(&vsb, "PROXY %s %s %s %s %s\r\n",
		    ss.ss_family == AF_INET ? "TCP4" : "TCP6",
		    addr, addr, port, port);
	} else
		VSB_cat(&vsb, "PROXY UNKNOWN\r\n");
	AZ(VSB_finish(&vsb));

	return (vbp_write(vt, sock, VSB_data(&vsb), VSB_len(&vsb)));
}
开发者ID:hermunn,项目名称:varnish-cache,代码行数:25,代码来源:cache_backend_probe.c

示例5: vbp_bitmap

static void
vbp_bitmap(struct vsb *vsb, char c, uint64_t map, const char *lbl)
{
	int i;
	uint64_t u = (1ULL << 63);

	VSB_printf(vsb, "  ");
	for (i = 0; i < 64; i++) {
		if (map & u)
			VSB_putc(vsb, c);
		else
			VSB_putc(vsb, '-');
		map <<= 1;
	}
	VSB_printf(vsb, " %s\n", lbl);
}
开发者ID:hermunn,项目名称:varnish-cache,代码行数:16,代码来源:cache_backend_probe.c

示例6: pan_already

static int
pan_already(struct vsb *vsb, const void *ptr)
{
	int i;

	for (i = 0; i < already_idx; i++) {
		if (already_list[i] == ptr) {
			VSB_printf(vsb, "  [Already dumped, see above]\n");
			VSB_printf(vsb, "},\n");
			return (1);
		}
	}
	if (already_idx < N_ALREADY)
		already_list[already_idx++] = ptr;
	return (0);
}
开发者ID:ElijahLynn,项目名称:Varnish-Cache,代码行数:16,代码来源:cache_panic.c

示例7: mct_callback

mct_callback(void *priv, const struct suckaddr *sa)
{
	int sock;
	struct vsb *vsb = priv;
	const char *err;
	char abuf[VTCP_ADDRBUFSIZE];
	char pbuf[VTCP_PORTBUFSIZE];
	struct telnet *tn;

	VJ_master(JAIL_MASTER_PRIVPORT);
	sock = VTCP_listen(sa, 10, &err);
	VJ_master(JAIL_MASTER_LOW);
	assert(sock != 0);		// We know where stdin is
	if (sock > 0) {
		VTCP_myname(sock, abuf, sizeof abuf, pbuf, sizeof pbuf);
		VSB_printf(vsb, "%s %s\n", abuf, pbuf);
		tn = telnet_new(sock);
		tn->ev = vev_new();
		AN(tn->ev);
		tn->ev->fd = sock;
		tn->ev->fd_flags = POLLIN;
		tn->ev->callback = telnet_accept;
		tn->ev->priv = tn;
		AZ(vev_add(mgt_evb, tn->ev));
	}
	return (0);
}
开发者ID:ElijahLynn,项目名称:Varnish-Cache,代码行数:27,代码来源:mgt_cli.c

示例8: VJ_Init

void
VJ_Init(const char *j_arg)
{
	char **av;
	int i;

	if (j_arg != NULL) {
		av = VAV_Parse(j_arg, NULL, ARGV_COMMA);
		AN(av);
		if (av[0] != NULL)
			ARGV_ERR("-j argument: %s\n", av[0]);
		if (av[1] == NULL)
			ARGV_ERR("-j argument is emtpy\n");
		vjt = pick(vj_choice, av[1], "jail");
		CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC);
		(void)vjt->init(av + 2);
		VAV_Free(av);
	} else {
		/*
		 * Go through list of jail technologies until one
		 * succeeds, falling back to "none".
		 */
		for (i = 0; vj_choice[i].name != NULL; i++) {
			vjt = vj_choice[i].ptr;
			CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC);
			if (!vjt->init(NULL))
				break;
		}
	}
	VSB_printf(vident, ",-j%s", vjt->name);
}
开发者ID:biddyweb,项目名称:Varnish-Cache,代码行数:31,代码来源:mgt_jail.c

示例9: vcc_regexp

char *
vcc_regexp(struct vcc *tl)
{
	char buf[BUFSIZ], *p;
	vre_t *t;
	const char *error;
	int erroroffset;

	Expect(tl, CSTR);
	if (tl->err)
		return (NULL);
	memset(&t, 0, sizeof t);
	t = VRE_compile(tl->t->dec, 0, &error, &erroroffset);
	if (t == NULL) {
		VSB_printf(tl->sb,
		    "Regexp compilation error:\n\n%s\n\n", error);
		vcc_ErrWhere(tl, tl->t);
		return (NULL);
	}
	VRE_free(&t);
	sprintf(buf, "VGC_re_%u", tl->unique++);
	p = TlAlloc(tl, strlen(buf) + 1);
	strcpy(p, buf);

	Fh(tl, 0, "static void *%s;\n", buf);
	Fi(tl, 0, "\tVRT_re_init(&%s, ",buf);
	EncToken(tl->fi, tl->t);
	Fi(tl, 0, ");\n");
	Ff(tl, 0, "\tVRT_re_fini(%s);\n", buf);
	return (p);
}
开发者ID:KlausBrunner,项目名称:Varnish-Cache,代码行数:31,代码来源:vcc_string.c

示例10: vcc_Expr

void
vcc_Expr(struct vcc *tl, enum var_type fmt)
{
	struct expr *e;
	struct token *t1;

	assert(fmt != VOID);

	t1 = tl->t;
	vcc_expr0(tl, &e, fmt);
	ERRCHK(tl);
	if (fmt == STRING || fmt == STRING_LIST)
		vcc_expr_tostring(&e, fmt);
	if (!tl->err && fmt != e->fmt)  {
		VSB_printf(tl->sb, "Expression has type %s, expected %s\n",
		    vcc_Type(e->fmt), vcc_Type(fmt));
		tl->err = 1;
	}
	if (!tl->err) {
		if (e->fmt == STRING_LIST) {
			e = vcc_expr_edit(STRING_LIST,
			    "\v+\n\v1,\nvrt_magic_string_end\v-", e, NULL);
		}
		vcc_expr_fmt(tl->fb, tl->indent, e);
		VSB_putc(tl->fb, '\n');
	} else {
		if (t1 != tl->t)
			vcc_ErrWhere2(tl, t1, tl->t);
	}
	vcc_delete_expr(e);
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:31,代码来源:vcc_expr.c

示例11: h_order

static int
h_order(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len,
    unsigned spec, const char *ptr, uint64_t bm)
{
	char type;
	struct vlog_priv_t *vlog = priv;

	/* XXX: Just ignore any fd not inside the bitmap */
	if (fd >= sizeof vlog->bitmap / sizeof vlog->bitmap[0])
		return (0);

	vlog->bitmap[fd] |= bm;

	type = (spec & VSL_S_CLIENT) ? 'c' :
	    (spec & VSL_S_BACKEND) ? 'b' : '-';

	if (!(spec & (VSL_S_CLIENT|VSL_S_BACKEND))) {
			(void)local_print(vlog, tag, fd, len, spec, ptr, bm);
		return (0);
	}
	if (vlog->ob[fd] == NULL) {
		vlog->ob[fd] = VSB_new_auto();
		assert(vlog->ob[fd] != NULL);
	}
	if ((tag == SLT_BackendOpen || tag == SLT_SessionOpen ||
		(tag == SLT_ReqStart &&
		    vlog->last[fd] != SLT_SessionOpen &&
		    vlog->last[fd] != SLT_VCL_acl) ||
		(tag == SLT_BackendXID &&
		    vlog->last[fd] != SLT_BackendOpen)) &&
	    VSB_len(vlog->ob[fd]) != 0) {
		/*
		 * This is the start of a new request, yet we haven't seen
		 * the end of the previous one.  Spit it out anyway before
		 * starting on the new one.
		 */
		if (vlog->last[fd] != SLT_SessionClose)
			VSB_printf(vlog->ob[fd], "{ \"fd\": \"%d\","
				"\"tag\": \"%s\", \"type\":\"%c\","
				"\"value\":\"%s\"},\n",
			    fd, "Interrupted", type, VSL_tags[tag]);
		h_order_finish(vlog, fd);
	}

	vlog->last[fd] = tag;

	print_entry(vlog, fd, tag, type, ptr, len);
	switch (tag) {
	case SLT_ReqEnd:
	case SLT_BackendClose:
	case SLT_BackendReuse:
	case SLT_StatSess:
		h_order_finish(vlog, fd);
		break;
	default:
		break;
	}
	return (0);
}
开发者ID:cleberjsantos,项目名称:vagent2,代码行数:59,代码来源:vlog.c

示例12: mgt_vcc_touchfile

static int
mgt_vcc_touchfile(const char *fn, struct vsb *sb)
{
	int i;

	i = open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0600);
	if (i < 0) {
		VSB_printf(sb, "Failed to create %s: %s", fn, strerror(errno));
		return (2);
	}
	if (fchown(i, mgt_param.uid, mgt_param.gid) != 0)
		if (geteuid() == 0)
			VSB_printf(sb, "Failed to change owner on %s: %s\n",
			    fn, strerror(errno));
	AZ(close(i));
	return (0);
}
开发者ID:flano-yuki,项目名称:Varnish-Cache,代码行数:17,代码来源:mgt_vcc.c

示例13: tweak_generic_bytes

static int
tweak_generic_bytes(struct vsb *vsb, volatile ssize_t *dest, const char *arg,
    const char *min, const char *max)
{
	uintmax_t r, rmin = 0, rmax = 0;
	const char *p;

	if (arg != NULL) {
		if (min != NULL) {
			p = VNUM_2bytes(min, &rmin, 0);
			if (p != NULL) {
				VSB_printf(vsb, "Invalid min-val: %s\n", min);
				return (-1);
			}
		}
		if (max != NULL) {
			p = VNUM_2bytes(max, &rmax, 0);
			if (p != NULL) {
				VSB_printf(vsb, "Invalid max-val: %s\n", max);
				return (-1);
			}
		}
		p = VNUM_2bytes(arg, &r, 0);
		if (p != NULL) {
			VSB_printf(vsb, "Could not convert to bytes.\n");
			VSB_printf(vsb, "%s\n", p);
			VSB_printf(vsb,
			    "  Try something like '80k' or '120M'\n");
			return (-1);
		}
		if ((uintmax_t)((ssize_t)r) != r) {
			fmt_bytes(vsb, r);
			VSB_printf(vsb,
			    " is too large for this architecture.\n");
			return (-1);
		}
		if (max != NULL && r > rmax) {
			VSB_printf(vsb, "Must be no more than %s\n", max);
			VSB_printf(vsb, "\n");
			return (-1);
		}
		if (min != NULL && r < rmin) {
			VSB_printf(vsb, "Must be at least %s\n", min);
			return (-1);
		}
		*dest = r;
	} else {
		fmt_bytes(vsb, *dest);
	}
	return (0);
}
开发者ID:ElijahLynn,项目名称:Varnish-Cache,代码行数:51,代码来源:mgt_param_tweak.c

示例14: parse_new_syntax

static void
parse_new_syntax(struct vcc *tl)
{

	VSB_printf(tl->sb, "Please change \"%.*s\" to \"return(%.*s)\".\n",
	    PF(tl->t), PF(tl->t));
	vcc_ErrWhere(tl, tl->t);
}
开发者ID:tpn,项目名称:Varnish-Cache,代码行数:8,代码来源:vcc_action.c

示例15: pan_http

static void
pan_http(const char *id, const struct http *h, int indent)
{
	int i;

	VSB_printf(pan_vsp, "%*shttp[%s] = {\n", indent, "", id);
	VSB_printf(pan_vsp, "%*sws = %p[%s]\n", indent + 2, "",
	    h->ws, h->ws ? h->ws->id : "");
	for (i = 0; i < h->nhd; ++i) {
		if (h->hd[i].b == NULL && h->hd[i].e == NULL)
			continue;
		VSB_printf(pan_vsp, "%*s\"%.*s\",\n", indent + 4, "",
		    (int)(h->hd[i].e - h->hd[i].b),
		    h->hd[i].b);
	}
	VSB_printf(pan_vsp, "%*s},\n", indent, "");
}
开发者ID:Open-Party,项目名称:Varnish-Cache,代码行数:17,代码来源:cache_panic.c


注:本文中的VSB_printf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。