本文整理汇总了C++中VSB_len函数的典型用法代码示例。如果您正苦于以下问题:C++ VSB_len函数的具体用法?C++ VSB_len怎么用?C++ VSB_len使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VSB_len函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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));
}
示例3: 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);
}
示例4: 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);
}
示例5: vsmw_addseg
static void
vsmw_addseg(struct vsmw *vsmw, struct vsmwseg *seg)
{
int fd;
ssize_t s;
VTAILQ_INSERT_TAIL(&vsmw->segs, seg, list);
fd = openat(vsmw->vdirfd, vsmw->idx, O_APPEND | O_WRONLY);
assert(fd >= 0);
VSB_clear(vsmw->vsb);
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));
}
示例6: VEP_Finish
struct vsb *
VEP_Finish(struct vep_state *vep)
{
ssize_t l, lcb;
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
AZ(vep->include_src);
AZ(vep->attr_vsb);
if (vep->o_pending)
vep_mark_common(vep, vep->ver_p, vep->last_mark);
if (vep->o_wait > 0) {
lcb = vep->cb(vep->vc, vep->cb_priv, 0, VGZ_ALIGN);
vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
}
// NB: We don't account for PAD+SUM+LEN in gzip'ed objects
(void)vep->cb(vep->vc, vep->cb_priv, 0, VGZ_FINISH);
AZ(VSB_finish(vep->vsb));
l = VSB_len(vep->vsb);
if (vep->esi_found && l > 0)
return (vep->vsb);
VSB_destroy(&vep->vsb);
return (NULL);
}
示例7: VEP_Finish
struct vsb *
VEP_Finish(const struct sess *sp)
{
struct vep_state *vep;
ssize_t l, lcb;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
vep = sp->wrk->vep;
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
if (vep->o_pending)
vep_mark_common(vep, vep->ver_p, vep->last_mark);
if (vep->o_wait > 0) {
lcb = vep->cb(vep->sp, 0, VGZ_ALIGN);
vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
}
(void)vep->cb(vep->sp, 0, VGZ_FINISH);
sp->wrk->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);
}
示例8: vfp_esi_end
vfp_esi_end(struct sess *sp)
{
struct vsb *vsb;
struct vef_priv *vef;
ssize_t l;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AN(sp->wrk->vep);
vsb = VEP_Finish(sp);
if (vsb != NULL) {
l = VSB_len(vsb);
assert(l > 0);
/* XXX: This is a huge waste of storage... */
sp->obj->esidata = STV_alloc(sp, l);
XXXAN(sp->obj->esidata);
memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l);
sp->obj->esidata->len = l;
VSB_delete(vsb);
}
if (sp->wrk->vgz_rx != NULL)
VGZ_Destroy(&sp->wrk->vgz_rx);
if (sp->wrk->vef_priv != NULL) {
vef = sp->wrk->vef_priv;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
sp->wrk->vef_priv = NULL;
VGZ_UpdateObj(vef->vgz, sp->obj);
VGZ_Destroy(&vef->vgz);
XXXAZ(vef->error);
FREE_OBJ(vef);
}
return (0);
}
示例9: 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)));
}
示例10: vbp_build_req
static void
vbp_build_req(struct vbp_target *vt, const struct vrt_backend_probe *vbp,
const struct backend *be)
{
struct vsb *vsb;
vsb = VSB_new_auto();
AN(vsb);
VSB_clear(vsb);
if (vbp->request != NULL) {
VSB_cat(vsb, vbp->request);
} else {
VSB_printf(vsb, "GET %s HTTP/1.1\r\n",
vbp->url != NULL ? vbp->url : "/");
if (be->hosthdr != NULL)
VSB_printf(vsb, "Host: %s\r\n", be->hosthdr);
VSB_printf(vsb, "Connection: close\r\n");
VSB_printf(vsb, "\r\n");
}
AZ(VSB_finish(vsb));
vt->req = strdup(VSB_data(vsb));
AN(vt->req);
vt->req_len = VSB_len(vsb);
VSB_destroy(&vsb);
}
示例11: vstat_reply
static unsigned int
vstat_reply(struct http_request *request, const char *arg, void *data)
{
struct vstat_priv_t *vstat;
struct agent_core_t *core = data;
struct http_response *resp;
(void)arg;
GET_PRIV(core, vstat);
if (check_reopen(&vstat->http)) {
http_reply(request->connection, 500, "Couldn't open shmlog");
return 0;
}
do_json(vstat->http.vd, vstat->http.vsb);
resp = http_mkresp(request->connection, 200, NULL);
resp->data = VSB_data(vstat->http.vsb);
resp->ndata = VSB_len(vstat->http.vsb);
http_add_header(resp,"Content-Type","application/json");
send_response(resp);
http_free_resp(resp);
VSB_clear(vstat->http.vsb);
return 0;
}
示例12: VEP_Finish
struct vsb *
VEP_Finish(const struct worker *wrk)
{
struct vep_state *vep;
ssize_t l, lcb;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
vep = wrk->busyobj->vep;
CHECK_OBJ_NOTNULL(vep, VEP_MAGIC);
if (vep->o_pending)
vep_mark_common(vep, vep->ver_p, vep->last_mark);
if (vep->o_wait > 0) {
lcb = vep->cb(vep->wrk, 0, VGZ_ALIGN);
vep_emit_common(vep, lcb - vep->o_last, vep->last_mark);
}
(void)vep->cb(vep->wrk, 0, VGZ_FINISH);
wrk->busyobj->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);
}
示例13: 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);
}
示例14: 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);
}
示例15: cli_cb_after
static void
cli_cb_after(const struct cli *cli)
{
ASSERT_CLI();
Lck_Unlock(&cli_mtx);
VSL(SLT_CLI, 0, "Wr %03u %zd %s",
cli->result, VSB_len(cli->sb), VSB_data(cli->sb));
}