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); }
//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); }
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); }
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))); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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, ""); }
void vcc_ParseBackend(struct vcc *tl) { struct token *t_first, *t_be; struct symbol *sym; char vgcname[MAX_BACKEND_NAME + 20]; t_first = tl->t; vcc_NextToken(tl); /* ID: backend */ vcc_ExpectCid(tl); /* ID: name */ ERRCHK(tl); if (tl->t->e - tl->t->b > MAX_BACKEND_NAME) { VSB_printf(tl->sb, "Name of %.*s too long (max %d, is %zu):\n", PF(t_first), MAX_BACKEND_NAME, (size_t)(tl->t->e - tl->t->b)); vcc_ErrWhere(tl, tl->t); return; } t_be = tl->t; vcc_NextToken(tl); sprintf(vgcname, "vgc_backend_%.*s", PF(t_be)); Fh(tl, 0, "\nstatic struct director *%s;\n", vgcname); sym = VCC_HandleSymbol(tl, t_be, BACKEND, "%s", vgcname); ERRCHK(tl); vcc_ParseHostDef(tl, t_be, vgcname); ERRCHK(tl); if (tl->err) { VSB_printf(tl->sb, "\nIn %.*s specification starting at:\n", PF(t_first)); vcc_ErrWhere(tl, t_first); return; } if (tl->default_director == NULL || vcc_IdIs(t_be, "default")) { tl->default_director = sym->rname; tl->t_default_director = t_be; } }
void STV_Config(const char *spec) { char **av, buf[8]; const char *name; struct stevedore *stv; const struct stevedore *stv2; int ac; static unsigned seq = 0; av = MGT_NamedArg(spec, &name, "-s"); AN(av); if (av[1] == NULL) ARGV_ERR("-s argument lacks strategy {malloc, file, ...}\n"); for (ac = 0; av[ac + 2] != NULL; ac++) continue; stv2 = MGT_Pick(STV_choice, av[1], "storage"); AN(stv2); /* Append strategy to ident string */ VSB_printf(vident, ",-s%s", av[1]); av += 2; CHECK_OBJ_NOTNULL(stv2, STEVEDORE_MAGIC); ALLOC_OBJ(stv, STEVEDORE_MAGIC); AN(stv); *stv = *stv2; AN(stv->name); if (name == NULL) { bprintf(buf, "s%u", seq++); name = buf; } stv->ident = strdup(name); AN(stv->ident); stv_check_ident(spec, stv->ident); if (stv->init != NULL) stv->init(stv, ac, av); else if (ac != 0) ARGV_ERR("(-s %s) too many arguments\n", stv->name); AN(stv->allocobj); AN(stv->methods); if (!strcmp(stv->ident, TRANSIENT_STORAGE)) { AZ(stv_transient); stv_transient = stv; } else VTAILQ_INSERT_TAIL(&stevedores, stv, list); /* NB: Do not free av, stevedore gets to keep it */ }
void vcc_ParseDirector(struct vcc *tl) { struct token *t_first; int isfirst; t_first = tl->t; vcc_NextToken(tl); /* ID: director | backend */ vcc_ExpectCid(tl); /* ID: name */ ERRCHK(tl); if (tl->t->e - tl->t->b > 64) { VSB_printf(tl->sb, "Name of %.*s too long (max 64, is %zu):\n", PF(t_first), (size_t)(tl->t->e - tl->t->b)); vcc_ErrWhere(tl, tl->t); return; } tl->t_dir = tl->t; vcc_NextToken(tl); isfirst = tl->ndirector; if (vcc_IdIs(t_first, "backend")) { vcc_ParseSimpleDirector(tl); } else { VSB_printf(tl->sb, "\ndirectors are now in VMOD.directors\n"); vcc_ErrWhere(tl, t_first); return; } if (tl->err) { VSB_printf(tl->sb, "\nIn %.*s specification starting at:\n", PF(t_first)); vcc_ErrWhere(tl, t_first); return; } if (isfirst == 1 || vcc_IdIs(tl->t_dir, "default")) { tl->defaultdir = tl->ndirector - 1; tl->t_defaultdir = tl->t_dir; } tl->t_dir = NULL; }
static void pan_busyobj(const struct busyobj *bo) { VSB_printf(pan_vsp, " busyobj = %p {\n", bo); if (bo->is_gzip) VSB_printf(pan_vsp, " is_gzip\n"); if (bo->is_gunzip) VSB_printf(pan_vsp, " is_gunzip\n"); if (bo->do_gzip) VSB_printf(pan_vsp, " do_gzip\n"); if (bo->do_gunzip) VSB_printf(pan_vsp, " do_gunzip\n"); if (bo->do_esi) VSB_printf(pan_vsp, " do_esi\n"); if (bo->do_stream) VSB_printf(pan_vsp, " do_stream\n"); if (bo->should_close) VSB_printf(pan_vsp, " should_close\n"); VSB_printf(pan_vsp, " bodystatus = %d,\n", bo->body_status); VSB_printf(pan_vsp, " },\n"); if (VALID_OBJ(bo->vbc, BACKEND_MAGIC)) pan_vbc(bo->vbc); }
static void pan_objcore(const char *typ, const struct objcore *oc) { VSB_printf(pan_vsp, " objcore (%s) = %p {\n", typ, oc); VSB_printf(pan_vsp, " refcnt = %d\n", oc->refcnt); VSB_printf(pan_vsp, " flags = 0x%x\n", oc->flags); VSB_printf(pan_vsp, " objhead = %p\n", oc->objhead); VSB_printf(pan_vsp, " stevedore = %p", oc->stobj->stevedore); if (oc->stobj->stevedore != NULL) { VSB_printf(pan_vsp, " (%s", oc->stobj->stevedore->name); if (strlen(oc->stobj->stevedore->ident)) VSB_printf(pan_vsp, " %s", oc->stobj->stevedore->ident); VSB_printf(pan_vsp, ")"); } VSB_printf(pan_vsp, "\n"); VSB_printf(pan_vsp, " }\n"); }
static void pan_req(const struct req *req) { const char *stp; VSB_printf(pan_vsp, "req = %p {\n", req); VSB_printf(pan_vsp, " sp = %p, vxid = %u,", req->sp, VXID(req->vsl->wid)); switch (req->req_step) { #define REQ_STEP(l, u, arg) case R_STP_##u: stp = "R_STP_" #u; break; #include "tbl/steps.h" #undef REQ_STEP default: stp = NULL; } if (stp != NULL) VSB_printf(pan_vsp, " step = %s,\n", stp); else VSB_printf(pan_vsp, " step = 0x%x,\n", req->req_step); VSB_printf(pan_vsp, " req_body = %s,\n", reqbody_status_2str(req->req_body_status)); if (req->err_code) VSB_printf(pan_vsp, " err_code = %d, err_reason = %s,\n", req->err_code, req->err_reason ? req->err_reason : "(null)"); VSB_printf(pan_vsp, " restarts = %d, esi_level = %d\n", req->restarts, req->esi_level); if (req->sp != NULL) pan_sess(req->sp); if (req->wrk != NULL) pan_wrk(req->wrk); pan_ws(req->ws, 2); pan_http("req", req->http, 2); if (req->resp->ws != NULL) pan_http("resp", req->resp, 2); if (VALID_OBJ(req->vcl, VCL_CONF_MAGIC)) pan_vcl(req->vcl); if (req->objcore != NULL) { pan_objcore("REQ", req->objcore); if (req->objcore->busyobj != NULL) pan_busyobj(req->objcore->busyobj); } VSB_printf(pan_vsp, "},\n"); }
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]); }
void vcc_ParseRoundRobinDirector(struct vcc *tl) { struct token *t_field, *t_be; int nelem; struct fld_spec *fs; const char *first; char *p; fs = vcc_FldSpec(tl, "!backend", NULL); Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin_entry " "vdrre_%.*s[] = {\n", PF(tl->t_dir)); for (nelem = 0; tl->t->tok != '}'; nelem++) { /* List of members */ first = ""; t_be = tl->t; vcc_ResetFldSpec(fs); SkipToken(tl, '{'); Fc(tl, 0, "\t{"); while (tl->t->tok != '}') { /* Member fields */ vcc_IsField(tl, &t_field, fs); ERRCHK(tl); if (vcc_IdIs(t_field, "backend")) { vcc_ParseBackendHost(tl, nelem, &p); ERRCHK(tl); AN(p); Fc(tl, 0, "%s .host = VGC_backend_%s", first, p); } else { ErrInternal(tl); } first = ", "; } vcc_FieldsOk(tl, fs); if (tl->err) { VSB_printf(tl->sb, "\nIn member host specification starting at:\n"); vcc_ErrWhere(tl, t_be); return; } Fc(tl, 0, " },\n"); vcc_NextToken(tl); } Fc(tl, 0, "};\n"); Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin vgc_dir_priv_%.*s = {\n", PF(tl->t_dir)); Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(tl->t_dir)); Fc(tl, 0, "\t.nmember = %d,\n", nelem); Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(tl->t_dir)); Fc(tl, 0, "};\n"); }
static void vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs, int vxid) { char *endptr; AN(prhs); AZ(*prhs); if (vxp->t->tok != VAL) { VSB_printf(vxp->sb, "Expected number got '%.*s' ", PF(vxp->t)); vxp_ErrWhere(vxp, vxp->t, -1); return; } AN(vxp->t->dec); ALLOC_OBJ(*prhs, VEX_RHS_MAGIC); AN(*prhs); if (strchr(vxp->t->dec, '.')) { (*prhs)->type = VEX_FLOAT; (*prhs)->val_float = VNUM(vxp->t->dec); if (isnan((*prhs)->val_float)) { VSB_printf(vxp->sb, "Floating point parse error "); vxp_ErrWhere(vxp, vxp->t, -1); return; } } else { (*prhs)->type = VEX_INT; (*prhs)->val_int = strtoll(vxp->t->dec, &endptr, 0); while (isspace(*endptr)) endptr++; if (*endptr != '\0') { VSB_printf(vxp->sb, "Integer parse error "); vxp_ErrWhere(vxp, vxp->t, -1); return; } } if (vxid && (*prhs)->type != VEX_INT) { VSB_printf(vxp->sb, "Expected integer got '%.*s' ", PF(vxp->t)); vxp_ErrWhere(vxp, vxp->t, 0); return; } vxp_NextToken(vxp); }
static void vsmw_mkent(const struct vsmw *vsmw, const char *pfx) { int fd; uint64_t rn; AN(pfx); while (1) { VSB_clear(vsmw->vsb); VSB_printf(vsmw->vsb, "_.%s", pfx); AZ(VRND_RandomCrypto(&rn, sizeof rn)); VSB_printf(vsmw->vsb, ".%016jx", (uintmax_t)rn); AZ(VSB_finish(vsmw->vsb)); fd = openat(vsmw->vdirfd, VSB_data(vsmw->vsb), O_RDONLY); if (fd < 0 && errno == ENOENT) return; if (fd >= 0) AZ(close(fd)); } }
void vxp__Expect(struct vxp *vxp, unsigned tok) { if (vxp->t->tok == tok) return; VSB_printf(vxp->sb, "Expected %s got ", vxp_tnames[tok]); vxp_ErrToken(vxp, vxp->t); VSB_putc(vxp->sb, ' '); vxp_ErrWhere(vxp, vxp->t, -1); }
static void pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc) { VSB_printf(vsb, "objcore[%s] = %p {\n", typ, oc); VSB_indent(vsb, 2); VSB_printf(vsb, "refcnt = %d,\n", oc->refcnt); VSB_printf(vsb, "flags = 0x%x,\n", oc->flags); VSB_printf(vsb, "objhead = %p,\n", oc->objhead); VSB_printf(vsb, "stevedore = %p", oc->stobj->stevedore); if (oc->stobj->stevedore != NULL) { VSB_printf(vsb, " (%s", oc->stobj->stevedore->name); if (strlen(oc->stobj->stevedore->ident)) VSB_printf(vsb, " %s", oc->stobj->stevedore->ident); VSB_printf(vsb, ")"); } VSB_printf(vsb, ",\n"); VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); }
static void vtc_leadinv(const struct vtclog *vl, int lvl, const char *fmt, va_list ap) { assert(lvl < (int)NLEAD); assert(lvl >= 0); VSB_printf(vl->vsb, "%s %-4s %4.1f ", lead[lvl < 0 ? 1: lvl], vl->id, vl->tx); if (fmt != NULL) (void)VSB_vprintf(vl->vsb, fmt, ap); }
const struct var * vcc_FindVar(struct vcc *tl, const struct token *t, int wr_access, const char *use) { const struct var *v; const struct symbol *sym; AN(tl->vars); sym = VCC_FindSymbol(tl, t, SYM_VAR); if (sym != NULL) { v = sym->var; AN(v); if (wr_access && v->w_methods == 0) { VSB_printf(tl->sb, "Variable "); vcc_ErrToken(tl, t); VSB_printf(tl->sb, " is read only."); VSB_cat(tl->sb, "\nAt: "); vcc_ErrWhere(tl, t); return (NULL); } else if (wr_access) { vcc_AddUses(tl, t, v->w_methods, use); } else if (v->r_methods == 0) { VSB_printf(tl->sb, "Variable "); vcc_ErrToken(tl, t); VSB_printf(tl->sb, " is write only."); VSB_cat(tl->sb, "\nAt: "); vcc_ErrWhere(tl, t); return (NULL); } else { vcc_AddUses(tl, t, v->r_methods, use); } assert(v->fmt != HEADER); return (v); } VSB_printf(tl->sb, "Unknown variable "); vcc_ErrToken(tl, t); VSB_cat(tl->sb, "\nAt: "); vcc_ErrWhere(tl, t); return (NULL); }
static void parse_error(struct vcc *tl) { VSB_printf(tl->sb, "Syntax has changed, use:\n" "\treturn(error(999));\n" "or\n" "\treturn(error(999, \"Response text\"));\n"); vcc_ErrWhere(tl, tl->t); return; }