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


C++ VSB_finish函数代码示例

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


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

示例1: 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:robguima,项目名称:Varnish-Cache,代码行数:33,代码来源:vtc_log.c

示例2: vsmw_delseg

static void
vsmw_delseg(struct vsmw *vsmw, struct vsmwseg *seg, int fixidx)
{
	char *t = NULL;
	ssize_t s;
	int fd;

	CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC);
	CHECK_OBJ_NOTNULL(seg, VSMWSEG_MAGIC);

	VTAILQ_REMOVE(&vsmw->segs, seg, list);
	REPLACE(seg->class, NULL);
	REPLACE(seg->id, NULL);
	FREE_OBJ(seg);

	if (fixidx) {
		vsmw_mkent(vsmw, vsmw->idx);
		REPLACE(t, VSB_data(vsmw->vsb));
		AN(t);
		fd = openat(vsmw->vdirfd,
		    t, O_WRONLY|O_CREAT|O_EXCL, vsmw->mode);
		assert(fd >= 0);
		vsmw_idx_head(vsmw, fd);
		VSB_clear(vsmw->vsb);
		VTAILQ_FOREACH(seg, &vsmw->segs, list)
			vsmw_fmt_index(vsmw, seg);
		AZ(VSB_finish(vsmw->vsb));
		s = write(fd, VSB_data(vsmw->vsb), VSB_len(vsmw->vsb));
		assert(s == VSB_len(vsmw->vsb));
		AZ(close(fd));
		AZ(renameat(vsmw->vdirfd, t, vsmw->vdirfd, vsmw->idx));
		REPLACE(t, NULL);
	}
}
开发者ID:hermunn,项目名称:varnish-cache,代码行数:34,代码来源:common_vsmw.c

示例3: vtc_hex_to_bin

struct vsb *
vtc_hex_to_bin(struct vtclog *vl, const char *arg)
{
	struct vsb *vsb;
	unsigned sh = 4;
	unsigned c, b = 0;

	vsb = VSB_new_auto();
	AN(vsb);
	for (; *arg != '\0'; arg++) {
		if (vct_issp(*arg) || *arg == '\n')
			continue;
		c = (uint8_t)*arg;
		if (c >= '0' && c <= '9')
			b |= (c - 48U) << sh;
		else if (c >= 'A' && c <= 'F')
			b |= (c - 55U) << sh;
		else if (c >= 'a' && c <= 'f')
			b |= (c - 87U) << sh;
		else
			vtc_fatal(vl,"Illegal hex string");
		sh = 4 - sh;
		if (sh == 4) {
			VSB_putc(vsb, b);
			b = 0;
		}
	}
	if (sh != 4)
		VSB_putc(vsb, b);
	AZ(VSB_finish(vsb));
	return (vsb);
}
开发者ID:hermunn,项目名称:varnish-cache,代码行数:32,代码来源:vtc_subr.c

示例4: VEP_Finish

struct vsb *
VEP_Finish(struct busyobj *bo)
{
	struct vep_state *vep;
	ssize_t l, lcb;

	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
	vep = bo->vep;
	CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
	assert(vep->bo == bo);

	if (vep->o_pending)
		vep_mark_common(vep, vep->ver_p, vep->last_mark);
	if (vep->o_wait > 0) {
		lcb = vep->cb(vep->bo, 0, VGZ_ALIGN);
		vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
	}
	(void)vep->cb(vep->bo, 0, VGZ_FINISH);

	bo->vep = NULL;
	AZ(VSB_finish(vep->vsb));
	l = VSB_len(vep->vsb);
	if (vep->esi_found && l > 0)
		return (vep->vsb);
	VSB_delete(vep->vsb);
	return (NULL);
}
开发者ID:1HLtd,项目名称:Varnish-Cache,代码行数:27,代码来源:cache_esi_parse.c

示例5: vcc_expr_edit

static struct expr *
vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1,
    struct expr *e2)
{
	struct expr *e;
	int nl = 1;

	e = vcc_new_expr();
	while (*p != '\0') {
		if (*p == '\n') {
			if (!nl)
				VSB_putc(e->vsb, *p);
			nl = 1;
			p++;
			continue;
		}
		nl = 0;
		if (*p != '\v') {
			VSB_putc(e->vsb, *p);
			p++;
			continue;
		}
		assert(*p == '\v');
		p++;
		switch(*p) {
		case '+': VSB_cat(e->vsb, "\v+"); break;
		case '-': VSB_cat(e->vsb, "\v-"); break;
		case '1':
		case '2':
			if (*p == '1')
				VSB_cat(e->vsb, VSB_data(e1->vsb));
			else {
				AN(e2);
				VSB_cat(e->vsb, VSB_data(e2->vsb));
			}
			break;
		default:
			assert(__LINE__ == 0);
		}
		p++;
	}
	AZ(VSB_finish(e->vsb));
	if (e1 != NULL)
		e->t1 = e1->t1;
	else if (e2 != NULL)
		e->t1 = e2->t1;
	if (e2 != NULL)
		e->t2 = e2->t1;
	else if (e1 != NULL)
		e->t1 = e1->t1;
	if ((e1 == NULL || e1->constant) && (e2 == NULL || e2->constant))
		e->constant = 1;
	vcc_delete_expr(e1);
	vcc_delete_expr(e2);
	e->fmt = fmt;
	return (e);
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:57,代码来源:vcc_expr.c

示例6: vtc_send_proxy

int
vtc_send_proxy(int fd, int version, const struct suckaddr *sac,
    const struct suckaddr *sas)
{
	struct vsb *vsb;
	char hc[VTCP_ADDRBUFSIZE];
	char pc[VTCP_PORTBUFSIZE];
	char hs[VTCP_ADDRBUFSIZE];
	char ps[VTCP_PORTBUFSIZE];
	int i, len;
	int proto;

	AN(sac);
	AN(sas);

	assert(version == 1 || version == 2);
	vsb = VSB_new_auto();
	AN(vsb);

	proto = VSA_Get_Proto(sas);
	assert(proto == PF_INET6 || proto == PF_INET);

	if (version == 1) {
		VSB_bcat(vsb, vpx1_sig, sizeof(vpx1_sig));
		if (proto == PF_INET6)
			VSB_printf(vsb, " TCP6 ");
		else if (proto == PF_INET)
			VSB_printf(vsb, " TCP4 ");
		VTCP_name(sac, hc, sizeof(hc), pc, sizeof(pc));
		VTCP_name(sas, hs, sizeof(hs), ps, sizeof(ps));
		VSB_printf(vsb, "%s %s %s %s\r\n", hc, hs, pc, ps);
	} else if (version == 2) {
		VSB_bcat(vsb, vpx2_sig, sizeof(vpx2_sig));
		VSB_putc(vsb, 0x21);
		if (proto == PF_INET6) {
			VSB_putc(vsb, 0x21);
			VSB_putc(vsb, 0x00);
			VSB_putc(vsb, 0x24);
		} else if (proto == PF_INET) {
			VSB_putc(vsb, 0x11);
			VSB_putc(vsb, 0x00);
			VSB_putc(vsb, 0x0c);
		}
		vpx_enc_addr(vsb, proto, sac);
		vpx_enc_addr(vsb, proto, sas);
		vpx_enc_port(vsb, sac);
		vpx_enc_port(vsb, sas);
	} else
		WRONG("Wrong proxy version");

	AZ(VSB_finish(vsb));
	len = VSB_len(vsb);
	i = write(fd, VSB_data(vsb), len);
	VSB_delete(vsb);
	return (i != len);
}
开发者ID:daghf,项目名称:varnish-cache,代码行数:56,代码来源:vtc_proxy.c

示例7: h_order_finish

static void
h_order_finish(struct vlog_priv_t *vlog, int fd)
{
	assert(VSB_finish(vlog->ob[fd]) == 0);
	if (VSB_len(vlog->ob[fd]) > 1 && VSL_Matched(vlog->vd, vlog->bitmap[fd])) {
		VSB_printf(vlog->answer,"%s", VSB_data(vlog->ob[fd]));
	}
	vlog->bitmap[fd] = 0;
	VSB_clear(vlog->ob[fd]);
}
开发者ID:cleberjsantos,项目名称:vagent2,代码行数:10,代码来源:vlog.c

示例8: vtc_hexdump

//lint -e{818}
void
vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx,
    const unsigned char *str, int len)
{
	int nl = 1;
	unsigned l;
	double tx;

	CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC);
	tx = VTIM_mono() - t0;
	assert(len >= 0);
	assert(lvl >= 0);
	assert(lvl < NLEAD);
	AZ(pthread_mutex_lock(&vl->mtx));
	vl->act = 1;
	VSB_clear(vl->vsb);
	if (pfx == NULL)
		pfx = "";
	if (str == NULL)
		VSB_printf(vl->vsb, "%s %-4s %4.1f %s| (null)",
		    lead[lvl], vl->id, tx, pfx);
	else {
		for (l = 0; l < len; l++, str++) {
			if (l > 512) {
				VSB_printf(vl->vsb, "...");
				break;
			}
			if (nl) {
				VSB_printf(vl->vsb, "%s %-4s %4.1f %s| ",
				    lead[lvl], vl->id, tx, pfx);
				nl = 0;
			}
			VSB_printf(vl->vsb, " %02x", *str);
			if ((l & 0xf) == 0xf) {
				VSB_printf(vl->vsb, "\n");
				nl = 1;
			}
		}
	}
	if (!nl)
		VSB_printf(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) {
		vtc_error = 1;
		if (pthread_self() != vtc_thread)
			pthread_exit(NULL);
	}
}
开发者ID:ying123,项目名称:Varnish-Cache,代码行数:55,代码来源:vtc_log.c

示例9: http_write

static void
http_write(const struct http *hp, int lvl, const char *pfx)
{
	int l;

	AZ(VSB_finish(hp->vsb));
	vtc_dump(hp->vl, lvl, pfx, VSB_data(hp->vsb), VSB_len(hp->vsb));
	l = write(hp->fd, VSB_data(hp->vsb), VSB_len(hp->vsb));
	if (l != VSB_len(hp->vsb))
		vtc_log(hp->vl, hp->fatal, "Write failed: (%d vs %d) %s",
		    l, VSB_len(hp->vsb), strerror(errno));
}
开发者ID:acdha,项目名称:Varnish-Cache,代码行数:12,代码来源:vtc_http.c

示例10: varnish_vclbackend

static void
varnish_vclbackend(struct varnish *v, const char *vcl)
{
	struct vsb *vsb, *vsb2;
	enum VCLI_status_e u;

	if (v->cli_fd < 0)
		varnish_launch(v);
	if (vtc_error)
		return;
	vsb = VSB_new_auto();
	AN(vsb);

	vsb2 = VSB_new_auto();
	AN(vsb2);

	cmd_server_genvcl(vsb2);
	AZ(VSB_finish(vsb2));

	VSB_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n%s\n",
	    ++v->vcl_nbr, NONSENSE, VSB_data(vsb2), vcl, NONSENSE);
	AZ(VSB_finish(vsb));

	u = varnish_ask_cli(v, VSB_data(vsb), NULL);
	if (u != CLIS_OK) {
		VSB_delete(vsb);
		VSB_delete(vsb2);
		vtc_log(v->vl, 0, "FAIL VCL does not compile");
		return;
	}
	VSB_clear(vsb);
	VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr);
	AZ(VSB_finish(vsb));
	u = varnish_ask_cli(v, VSB_data(vsb), NULL);
	assert(u == CLIS_OK);
	VSB_delete(vsb);
	VSB_delete(vsb2);
}
开发者ID:UsabilityDynamics,项目名称:node-varnish-service,代码行数:38,代码来源:vtc_varnish.c

示例11: vcc_mk_expr

static struct expr *
vcc_mk_expr(enum var_type fmt, const char *str, ...)
{
	va_list ap;
	struct expr *e;

	e = vcc_new_expr();
	e->fmt = fmt;
	va_start(ap, str);
	VSB_vprintf(e->vsb, str, ap);
	va_end(ap);
	AZ(VSB_finish(e->vsb));
	return (e);
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:14,代码来源:vcc_expr.c

示例12: mcf_askchild

static void
mcf_askchild(struct cli *cli, const char * const *av, void *priv)
{
	int i;
	char *q;
	unsigned u;
	struct vsb *vsb;

	(void)priv;
	/*
	 * Command not recognized in master, try cacher if it is
	 * running.
	 */
	if (cli_o <= 0) {
		if (!strcmp(av[1], "help")) {
			if (av[2] == NULL || strcmp(av[2], "-j"))
				VCLI_Out(cli,
				   "No help from child, (not running).\n");
			return;
		}
		VCLI_SetResult(cli, CLIS_UNKNOWN);
		VCLI_Out(cli,
		    "Unknown request in manager process "
		    "(child not running).\n"
		    "Type 'help' for more info.");
		return;
	}
	vsb = VSB_new_auto();
	for (i = 1; av[i] != NULL; i++) {
		VSB_quote(vsb, av[i], strlen(av[i]), 0);
		VSB_putc(vsb, ' ');
	}
	VSB_putc(vsb, '\n');
	AZ(VSB_finish(vsb));
	i = write(cli_o, VSB_data(vsb), VSB_len(vsb));
	if (i != VSB_len(vsb)) {
		VSB_destroy(&vsb);
		VCLI_SetResult(cli, CLIS_COMMS);
		VCLI_Out(cli, "CLI communication error");
		MGT_Child_Cli_Fail();
		return;
	}
	VSB_destroy(&vsb);
	if (VCLI_ReadResult(cli_i, &u, &q, mgt_param.cli_timeout))
		MGT_Child_Cli_Fail();
	VCLI_SetResult(cli, u);
	VCLI_Out(cli, "%s", q);
	free(q);
}
开发者ID:ElijahLynn,项目名称:Varnish-Cache,代码行数:49,代码来源:mgt_cli.c

示例13: varnish_vcl

static void
varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect)
{
	struct vsb *vsb;
	enum VCLI_status_e u;

	if (v->cli_fd < 0)
		varnish_launch(v);
	if (vtc_error)
		return;
	vsb = VSB_new_auto();
	AN(vsb);

	VSB_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n",
	    ++v->vcl_nbr, NONSENSE, vcl, NONSENSE);
	AZ(VSB_finish(vsb));

	u = varnish_ask_cli(v, VSB_data(vsb), NULL);
	if (u != expect) {
		VSB_delete(vsb);
		vtc_log(v->vl, 0,
		    "VCL compilation got %u expected %u",
		    u, expect);
		return;
	}
	if (u == CLIS_OK) {
		VSB_clear(vsb);
		VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr);
		AZ(VSB_finish(vsb));
		u = varnish_ask_cli(v, VSB_data(vsb), NULL);
		assert(u == CLIS_OK);
	} else {
		vtc_log(v->vl, 2, "VCL compilation failed (as expected)");
	}
	VSB_delete(vsb);
}
开发者ID:UsabilityDynamics,项目名称:node-varnish-service,代码行数:36,代码来源:vtc_varnish.c

示例14: run_vcc

run_vcc(void *priv)
{
	struct vsb *csrc;
	struct vsb *sb = NULL;
	struct vcc_priv *vp;
	int fd, i, l;
	struct vcc *vcc;
	struct stevedore *stv;

	VJ_subproc(JAIL_SUBPROC_VCC);
	CAST_OBJ_NOTNULL(vp, priv, VCC_PRIV_MAGIC);

	AZ(chdir(vp->dir));

	vcc = VCC_New();
	AN(vcc);
	VCC_Builtin_VCL(vcc, builtin_vcl);
	VCC_VCL_path(vcc, mgt_vcl_path);
	VCC_VMOD_path(vcc, mgt_vmod_path);
	VCC_Err_Unref(vcc, mgt_vcc_err_unref);
	VCC_Allow_InlineC(vcc, mgt_vcc_allow_inline_c);
	VCC_Unsafe_Path(vcc, mgt_vcc_unsafe_path);
	STV_Foreach(stv)
		VCC_Predef(vcc, "VCL_STEVEDORE", stv->ident);
	mgt_vcl_export_labels(vcc);
	csrc = VCC_Compile(vcc, &sb, vp->vclsrc, vp->vclsrcfile);
	AZ(VSB_finish(sb));
	if (VSB_len(sb))
		printf("%s", VSB_data(sb));
	VSB_destroy(&sb);
	if (csrc == NULL)
		exit(2);

	fd = open(VGC_SRC, O_WRONLY|O_TRUNC|O_CREAT, 0600);
	if (fd < 0) {
		fprintf(stderr, "VCC cannot open %s", vp->csrcfile);
		exit(2);
	}
	l = VSB_len(csrc);
	i = write(fd, VSB_data(csrc), l);
	if (i != l) {
		fprintf(stderr, "VCC cannot write %s", vp->csrcfile);
		exit(2);
	}
	closefd(&fd);
	VSB_destroy(&csrc);
	exit(0);
}
开发者ID:ehocdet,项目名称:varnish-cache,代码行数:48,代码来源:mgt_vcc.c

示例15: mgt_cli_telnet

void
mgt_cli_telnet(const char *T_arg)
{
	struct vss_addr **ta;
	int i, n, sock, good;
	struct telnet *tn;
	char *p;
	struct vsb *vsb;
	char abuf[VTCP_ADDRBUFSIZE];
	char pbuf[VTCP_PORTBUFSIZE];

	n = VSS_resolve(T_arg, NULL, &ta);
	if (n == 0) {
		REPORT(LOG_ERR, "-T %s Could not be resolved\n", T_arg);
		exit(2);
	}
	good = 0;
	vsb = VSB_new_auto();
	XXXAN(vsb);
	for (i = 0; i < n; ++i) {
		sock = VSS_listen(ta[i], 10);
		if (sock < 0)
			continue;
		VTCP_myname(sock, abuf, sizeof abuf, pbuf, sizeof pbuf);
		VSB_printf(vsb, "%s %s\n", abuf, pbuf);
		good++;
		tn = telnet_new(sock);
		tn->ev = vev_new();
		XXXAN(tn->ev);
		tn->ev->fd = sock;
		tn->ev->fd_flags = POLLIN;
		tn->ev->callback = telnet_accept;
		AZ(vev_add(mgt_evb, tn->ev));
		free(ta[i]);
		ta[i] = NULL;
	}
	free(ta);
	if (good == 0) {
		REPORT(LOG_ERR, "-T %s could not be listened on.", T_arg);
		exit(2);
	}
	AZ(VSB_finish(vsb));
	/* Save in shmem */
	p = VSM_Alloc(VSB_len(vsb) + 1, "Arg", "-T", "");
	AN(p);
	strcpy(p, VSB_data(vsb));
	VSB_delete(vsb);
}
开发者ID:BabyOnlineSG,项目名称:pkg-varnish,代码行数:48,代码来源:mgt_cli.c


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