summaryrefslogtreecommitdiff
path: root/sysdep/unix/main.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-06-13 10:51:03 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-09-12 15:36:46 +0200
commit51f2e7afaf069508685281e8c1b8bb1ceda79d8f (patch)
tree1e6c2fbb1bfa49b543033193adca354c04247e21 /sysdep/unix/main.c
parent5951dfbd5ed21d973e7627740c069d6612d7b899 (diff)
Conf: Symbol manipulation gets its context explicitly
Diffstat (limited to 'sysdep/unix/main.c')
-rw-r--r--sysdep/unix/main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index 0d3ec0c0..23cadb14 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -111,21 +111,21 @@ get_hostname(linpool *lp)
#ifdef PATH_IPROUTE_DIR
static inline void
-add_num_const(char *name, int val, const char *file, const uint line)
+add_num_const(struct config *conf, char *name, int val, const char *file, const uint line)
{
struct f_val *v = cfg_alloc(sizeof(struct f_val));
*v = (struct f_val) { .type = T_INT, .val.i = val };
- struct symbol *sym = cf_get_symbol(name);
- if (sym->class && cf_symbol_is_local(sym))
+ struct symbol *sym = cf_get_symbol(conf, name);
+ if (sym->class && cf_symbol_is_local(conf, sym))
cf_error("Error reading value for %s from %s:%d: already defined", name, file, line);
- cf_define_symbol(sym, SYM_CONSTANT | T_INT, val, v);
+ cf_define_symbol(conf, sym, SYM_CONSTANT | T_INT, val, v);
}
/* the code of read_iproute_table() is based on
rtnl_tab_initialize() from iproute2 package */
static void
-read_iproute_table(char *file, char *prefix, uint max)
+read_iproute_table(struct config *conf, char *file, char *prefix, uint max)
{
char buf[512], namebuf[512];
char *name;
@@ -162,7 +162,7 @@ read_iproute_table(char *file, char *prefix, uint max)
if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9') && (*p != '_'))
*p = '_';
- add_num_const(namebuf, val, file, line);
+ add_num_const(conf, namebuf, val, file, line);
}
fclose(fp);
@@ -191,10 +191,10 @@ sysdep_preconfig(struct config *c)
c->watchdog_warning = UNIX_DEFAULT_WATCHDOG_WARNING;
#ifdef PATH_IPROUTE_DIR
- read_iproute_table(PATH_IPROUTE_DIR "/rt_protos", "ipp_", 255);
- read_iproute_table(PATH_IPROUTE_DIR "/rt_realms", "ipr_", 0xffffffff);
- read_iproute_table(PATH_IPROUTE_DIR "/rt_scopes", "ips_", 255);
- read_iproute_table(PATH_IPROUTE_DIR "/rt_tables", "ipt_", 0xffffffff);
+ read_iproute_table(c, PATH_IPROUTE_DIR "/rt_protos", "ipp_", 255);
+ read_iproute_table(c, PATH_IPROUTE_DIR "/rt_realms", "ipr_", 0xffffffff);
+ read_iproute_table(c, PATH_IPROUTE_DIR "/rt_scopes", "ips_", 255);
+ read_iproute_table(c, PATH_IPROUTE_DIR "/rt_tables", "ipt_", 0xffffffff);
#endif
}