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 = MGT_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); }
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 Wait_config(const char *arg) { ASSERT_MGT(); if (arg != NULL) waiter = MGT_Pick(waiter_choice, arg, "waiter"); else waiter = waiter_choice[0].ptr; }