tabularize parameters to be passed to vcc

Parameters are passed to vcc via specific setter functions, presumably
to avoid binary compability issues between the main program (here:
vanishd) and a library (here: libvcc).

This commit does not change that interface in any way, but generates
both sides from a common table include to avoid having to edit five
spots in four different source files and write trivial setter functions
for a simple mgt_vcc parameter change.
parent d0a89676
...@@ -221,10 +221,8 @@ int mgt_has_vcl(void); ...@@ -221,10 +221,8 @@ int mgt_has_vcl(void);
extern char *mgt_cc_cmd; extern char *mgt_cc_cmd;
extern const char *mgt_vcl_path; extern const char *mgt_vcl_path;
extern const char *mgt_vmod_path; extern const char *mgt_vmod_path;
extern unsigned mgt_vcc_err_unref; #define MGT_VCC(t, n, cc) extern t mgt_vcc_ ## n;
extern unsigned mgt_vcc_acl_pedantic; #include <tbl/mgt_vcc.h>
extern unsigned mgt_vcc_allow_inline_c;
extern unsigned mgt_vcc_unsafe_path;
#if defined(PTHREAD_CANCELED) || defined(PTHREAD_MUTEX_DEFAULT) #if defined(PTHREAD_CANCELED) || defined(PTHREAD_MUTEX_DEFAULT)
#error "Keep pthreads out of in manager process" #error "Keep pthreads out of in manager process"
......
...@@ -65,11 +65,8 @@ struct vcc_priv { ...@@ -65,11 +65,8 @@ struct vcc_priv {
char *mgt_cc_cmd; char *mgt_cc_cmd;
const char *mgt_vcl_path; const char *mgt_vcl_path;
const char *mgt_vmod_path; const char *mgt_vmod_path;
unsigned mgt_vcc_err_unref; #define MGT_VCC(t, n, cc) t mgt_vcc_ ## n;
unsigned mgt_vcc_allow_inline_c; #include <tbl/mgt_vcc.h>
unsigned mgt_vcc_unsafe_path;
unsigned mgt_vcc_acl_pedantic;
#define VGC_SRC "vgc.c" #define VGC_SRC "vgc.c"
#define VGC_LIB "vgc.so" #define VGC_LIB "vgc.so"
...@@ -107,10 +104,11 @@ run_vcc(void *priv) ...@@ -107,10 +104,11 @@ run_vcc(void *priv)
VCC_Builtin_VCL(vcc, builtin_vcl); VCC_Builtin_VCL(vcc, builtin_vcl);
VCC_VCL_path(vcc, mgt_vcl_path); VCC_VCL_path(vcc, mgt_vcl_path);
VCC_VMOD_path(vcc, mgt_vmod_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); #define MGT_VCC(type, name, camelcase) \
VCC_Unsafe_Path(vcc, mgt_vcc_unsafe_path); VCC_ ## camelcase (vcc, mgt_vcc_ ## name);
VCC_Acl_Pedantic(vcc, mgt_vcc_acl_pedantic); #include "tbl/mgt_vcc.h"
STV_Foreach(stv) STV_Foreach(stv)
VCC_Predef(vcc, "VCL_STEVEDORE", stv->ident); VCC_Predef(vcc, "VCL_STEVEDORE", stv->ident);
VTAILQ_FOREACH(vpg, &vclhead, list) VTAILQ_FOREACH(vpg, &vclhead, list)
......
...@@ -22,6 +22,7 @@ nobase_pkginclude_HEADERS = \ ...@@ -22,6 +22,7 @@ nobase_pkginclude_HEADERS = \
tbl/http_headers.h \ tbl/http_headers.h \
tbl/http_response.h \ tbl/http_response.h \
tbl/locks.h \ tbl/locks.h \
tbl/mgt_vcc.h \
tbl/obj_attr.h \ tbl/obj_attr.h \
tbl/oc_exp_flags.h \ tbl/oc_exp_flags.h \
tbl/oc_flags.h \ tbl/oc_flags.h \
......
...@@ -33,15 +33,15 @@ ...@@ -33,15 +33,15 @@
struct vcc; struct vcc;
struct vcc *VCC_New(void); struct vcc *VCC_New(void);
void VCC_Allow_InlineC(struct vcc *, unsigned);
void VCC_Builtin_VCL(struct vcc *, const char *); void VCC_Builtin_VCL(struct vcc *, const char *);
void VCC_Err_Unref(struct vcc *, unsigned);
void VCC_Unsafe_Path(struct vcc *, unsigned);
void VCC_Acl_Pedantic(struct vcc *, unsigned);
void VCC_VCL_path(struct vcc *, const char *); void VCC_VCL_path(struct vcc *, const char *);
void VCC_VMOD_path(struct vcc *, const char *); void VCC_VMOD_path(struct vcc *, const char *);
void VCC_Predef(struct vcc *, const char *type, const char *name); void VCC_Predef(struct vcc *, const char *type, const char *name);
void VCC_VCL_Range(unsigned *, unsigned *); void VCC_VCL_Range(unsigned *, unsigned *);
#define MGT_VCC(t, n, cc) \
void VCC_ ## cc (struct vcc *, t);
#include "tbl/mgt_vcc.h"
int VCC_Compile(struct vcc *, struct vsb **, int VCC_Compile(struct vcc *, struct vsb **,
const char *, const char *, const char *, const char *); const char *, const char *, const char *, const char *);
MGT_VCC(unsigned, acl_pedantic, Acl_Pedantic)
MGT_VCC(unsigned, allow_inline_c, Allow_InlineC)
MGT_VCC(unsigned, err_unref, Err_Unref)
MGT_VCC(unsigned, unsafe_path, Unsafe_Path)
#undef MGT_VCC
...@@ -889,37 +889,13 @@ VCC_VMOD_path(struct vcc *vcc, const char *str) ...@@ -889,37 +889,13 @@ VCC_VMOD_path(struct vcc *vcc, const char *str)
* Configure settings * Configure settings
*/ */
void #define MGT_VCC(type, name, camelcase) \
VCC_Err_Unref(struct vcc *vcc, unsigned u) void VCC_ ## camelcase (struct vcc *vcc, type val) \
{ { \
CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); \
CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); vcc->name = val; \
vcc->err_unref = u; }
} #include "tbl/mgt_vcc.h"
void
VCC_Allow_InlineC(struct vcc *vcc, unsigned u)
{
CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC);
vcc->allow_inline_c = u;
}
void
VCC_Unsafe_Path(struct vcc *vcc, unsigned u)
{
CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC);
vcc->unsafe_path = u;
}
void
VCC_Acl_Pedantic(struct vcc *vcc, unsigned u)
{
CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC);
vcc->acl_pedantic = u;
}
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* Configure settings * Configure settings
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment