Clean up initialization of nat_ca[]
Factor it out of ef_init_srv() and put it into new nsc_init(), next to nat_ca[].
This commit is contained in:
parent
55ff4f8e3a
commit
400df7be82
3 changed files with 25 additions and 13 deletions
|
@ -249,7 +249,10 @@ extern int nstr_comp(struct nscstr *np, int len, int type, char *str);
|
||||||
extern char *nstr_comp_val(char *, struct valstr*, int);
|
extern char *nstr_comp_val(char *, struct valstr*, int);
|
||||||
extern int nstr_coerce_val(struct valstr *, nsc_type, char *);
|
extern int nstr_coerce_val(struct valstr *, nsc_type, char *);
|
||||||
extern int nstr_exec(struct nscstr *, int, void *);
|
extern int nstr_exec(struct nscstr *, int, void *);
|
||||||
|
/* src/lib/common/nstreval.c */
|
||||||
extern void nstr_exec_val(struct valstr *, natid, void *, nsc_type);
|
extern void nstr_exec_val(struct valstr *, natid, void *, nsc_type);
|
||||||
extern char *symbol_by_value(int, struct symbol *);
|
extern char *symbol_by_value(int, struct symbol *);
|
||||||
|
/* src/lib/global/nsc.c */
|
||||||
|
extern void nsc_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -532,7 +532,7 @@ struct castr cou_ca[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct castr nat_ca[sizeof(cou_ca) / sizeof(*cou_ca)];
|
struct castr nat_ca[sizeof(cou_ca) / sizeof(*cou_ca)];
|
||||||
/* initialized in ef_init_srv() */
|
/* initialized by nsc_init() */
|
||||||
|
|
||||||
struct castr realm_ca[] = {
|
struct castr realm_ca[] = {
|
||||||
/* uid is encoded in cnum, realm */
|
/* uid is encoded in cnum, realm */
|
||||||
|
@ -599,6 +599,7 @@ struct castr symbol_ca[] = {
|
||||||
{NSC_STRING, NSC_CONST, 0, offsetof(struct symbol, name), "name", EF_BAD},
|
{NSC_STRING, NSC_CONST, 0, offsetof(struct symbol, name), "name", EF_BAD},
|
||||||
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
|
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct castr mdchr_ca[] = {
|
struct castr mdchr_ca[] = {
|
||||||
/* no need for uid */
|
/* no need for uid */
|
||||||
/* name must come first, clients may rely on it */
|
/* name must come first, clients may rely on it */
|
||||||
|
@ -614,3 +615,21 @@ struct castr mdchr_ca[] = {
|
||||||
EF_BAD},
|
EF_BAD},
|
||||||
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
|
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
nsc_init(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
unsigned flags;
|
||||||
|
|
||||||
|
for (i = 0; cou_ca[i].ca_name; i++) {
|
||||||
|
nat_ca[i] = cou_ca[i];
|
||||||
|
flags = nat_ca[i].ca_flags;
|
||||||
|
if (flags & NSC_EXTRA)
|
||||||
|
flags &= ~NSC_EXTRA;
|
||||||
|
else if (i != 0)
|
||||||
|
flags |= NSC_DEITY;
|
||||||
|
nat_ca[i].ca_flags = flags;
|
||||||
|
}
|
||||||
|
nat_ca[i] = cou_ca[i];
|
||||||
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ static void ef_fina_view(int);
|
||||||
void
|
void
|
||||||
ef_init_srv(void)
|
ef_init_srv(void)
|
||||||
{
|
{
|
||||||
unsigned i, flags;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(fileinit) / sizeof(fileinit[0]); i++) {
|
for (i = 0; i < sizeof(fileinit) / sizeof(fileinit[0]); i++) {
|
||||||
empfile[fileinit[i].ef_type].init = fileinit[i].init;
|
empfile[fileinit[i].ef_type].init = fileinit[i].init;
|
||||||
|
@ -70,17 +70,7 @@ ef_init_srv(void)
|
||||||
empfile[fileinit[i].ef_type].prewrite = fileinit[i].prewrite;
|
empfile[fileinit[i].ef_type].prewrite = fileinit[i].prewrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; cou_ca[i].ca_name; i++) {
|
nsc_init();
|
||||||
nat_ca[i] = cou_ca[i];
|
|
||||||
flags = nat_ca[i].ca_flags;
|
|
||||||
if (flags & NSC_EXTRA)
|
|
||||||
flags &= ~NSC_EXTRA;
|
|
||||||
else if (i != 0)
|
|
||||||
flags |= NSC_DEITY;
|
|
||||||
nat_ca[i].ca_flags = flags;
|
|
||||||
}
|
|
||||||
nat_ca[i] = cou_ca[i];
|
|
||||||
|
|
||||||
ef_open_srv();
|
ef_open_srv();
|
||||||
if (ef_verify() < 0)
|
if (ef_verify() < 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue