void mgt_vcc_init(void) { vcc = VCC_New(); AN(vcc); VCC_Builtin_VCL(vcc, builtin_vcl); }
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); }