]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Compile and use the new configuration code by default.
authorMartin Mares <mj@ucw.cz>
Fri, 27 Nov 1998 19:37:07 +0000 (19:37 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 27 Nov 1998 19:37:07 +0000 (19:37 +0000)
Makefile
conf/Makefile [new file with mode: 0644]
sysdep/unix/main.c

index eec90c7b7bdd8fefbb3c5808d7dc4bf2bde09e87..c7dd7025e1252bfccb3b6d7266a111b382618b99 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,8 @@ CFLAGS=$(OPT) $(DEBUG) -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses
 
 PROTOCOLS=rip
 LIBDIRS=sysdep/linux sysdep/unix lib
-STDDIRS=nest $(addprefix proto/,$(PROTOCOLS))
+BASEDIRS=nest $(addprefix proto/,$(PROTOCOLS))
+STDDIRS=$(BASEDIRS) $(OBJDIR)/conf
 DIRS=$(STDDIRS) $(OBJDIR)/lib
 PARTOBJS=$(join $(addsuffix /,$(STDDIRS)),$(subst /,_,$(addsuffix .o,$(STDDIRS))))
 LIBS=$(OBJDIR)/lib/birdlib.a
diff --git a/conf/Makefile b/conf/Makefile
new file mode 100644 (file)
index 0000000..e448189
--- /dev/null
@@ -0,0 +1,24 @@
+CONFS=$(TOPDIR)/conf/confbase.Y @CONFS@$(addprefix $(TOPDIR)/,$(addsuffix /config.Y,$(BASEDIRS)))
+OBJS=cf-parse.tab.o cf-lex.o
+CONF=$(TOPDIR)/conf
+
+ifdef DEBUG
+BISON_DEBUG=-t
+#FLEX_DEBUG=-d
+endif
+
+include $(TOPDIR)/Rules
+
+cf-parse.tab.c cf-parse-tab.h: cf-parse.y
+       bison -bcf-parse -dv -pcf_ $(BISON_DEBUG) cf-parse.y
+
+cf-parse.y: $(CONFS) $(CONF)/gen_parser.m4
+       m4 -P $(CONF)/gen_parser.m4 $(CONFS) >cf-parse.y
+
+keywords.h: $(CONFS) $(CONF)/gen_keywords.m4
+       m4 -P $(CONF)/gen_keywords.m4 $(CONFS) >keywords.h
+
+cf-lex.c: cf-lex.l
+       flex $(FLEX_DEBUG) -sB8 -ocf-lex.c -Pcf_ cf-lex.l
+
+dep: keywords.h
index 3d927cb79206c1fc7faedd49a314245e2948ebcf..c649cb27d36b0d172205a98d58e1c6721d4506ce 100644 (file)
@@ -7,6 +7,8 @@
  */
 
 #include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
 #include <sys/signal.h>
 
 #include "nest/bird.h"
@@ -16,7 +18,7 @@
 #include "nest/route.h"
 #include "nest/protocol.h"
 #include "nest/iface.h"
-#include "nest/confile.h"
+#include "conf/conf.h"
 
 #include "unix.h"
 #include "krt.h"
@@ -54,11 +56,32 @@ signal_init(void)
 }
 
 /*
- *     Config Pool
+ *     Reading the Configuration
  */
 
-pool *cfg_pool;
-mempool *cfg_mem;
+static int conf_fd;
+
+static int
+cf_read(byte *dest, unsigned int len)
+{
+  int l = read(conf_fd, dest, len);
+  if (l < 0)
+    cf_error("Read error");
+  return l;
+}
+
+static void
+read_config(void)
+{
+  cf_lex_init_tables();
+  cf_allocate();
+  conf_fd = open(PATH_CONFIG, O_RDONLY);
+  if (conf_fd < 0)
+    die("Unable to open configuration file " PATH_CONFIG ": %m");
+  cf_read_hook = cf_read;
+  cf_lex_init(1);
+  cf_parse();
+}
 
 /*
  *     Hic Est main()
@@ -71,9 +94,11 @@ main(void)
 
   log_init_debug(NULL);
   resource_init();
-  cfg_pool = rp_new(&root_pool, "Config");
-  cfg_mem = mp_new(cfg_pool, 1024);
 
+  debug("Reading configuration file.\n");
+  read_config();
+
+  debug("Initializing.\n");
   io_init();
   rt_init();
   if_init();
@@ -88,7 +113,9 @@ main(void)
   scan_if_init();
   auto_router_id();
 
+#if 0
   protos_start();
+#endif
 
   handle_sigusr(0);