]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Put client on a stony ground. The whole client is going to be system-specific
authorMartin Mares <mj@ucw.cz>
Wed, 19 Jan 2000 15:07:00 +0000 (15:07 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 19 Jan 2000 15:07:00 +0000 (15:07 +0000)
(the current version UNIX-specific) anyway, so it's useless to try splitting it
to sysdep and generic part. Instead of this, configure script decides (based on
system type and user's wish) what (if any) client should be built and what
autoconfiguration it requires. Also, the client provides its own die/bug/...
functions.

client/Makefile
client/client.c
client/client.h
client/commands.c [new file with mode: 0644]
client/util.c [new file with mode: 0644]
configure.in
sysdep/unix/Modules
sysdep/unix/client-main.c [deleted file]
tools/Makefile.in

index 0d01724fa45fb6e8518719949043d11063e6031d..867476cc895c1f713c0152f26c906dac01ea87ec 100644 (file)
@@ -1,4 +1,4 @@
-source=client.c
+source=client.c commands.c util.c
 root-rel=../
 dir-name=client
 
index 2a43a8de2d5aebc48aac91726992f98cca2780e3..e9bc827d98698604fa970c8c801f0406a44369ed 100644 (file)
@@ -6,21 +6,48 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
 #include "nest/bird.h"
+#include "lib/resource.h"
 #include "client/client.h"
 
-struct cmd_info {
-  char *command;
-  char *args;
-  char *help;
-};
+static char *opt_list = "";
 
-static struct cmd_info command_table[] = {
-#include "conf/commands.h"
-};
+static void
+usage(void)
+{
+  fprintf(stderr, "Usage: birdc\n");
+  exit(1);
+}
+
+static void
+parse_args(int argc, char **argv)
+{
+  int c;
+
+  while ((c = getopt(argc, argv, opt_list)) >= 0)
+    switch (c)
+      {
+      default:
+       usage();
+      }
+  if (optind < argc)
+    usage();
+}
 
 int
 main(int argc, char **argv)
 {
-  return client_main(argc, argv);      /* Call sysdep code */
+#ifdef HAVE_LIBDMALLOC
+  if (!getenv("DMALLOC_OPTIONS"))
+    dmalloc_debug(0x2f03d00);
+#endif
+
+  parse_args(argc, argv);
+
+  bug("Not implemented yet!");
 }
index b5d6ab163f443afcd653978134badd076db3b2d8..2e1e050f06663d90212058f09af99d181553985c 100644 (file)
@@ -1,11 +1,7 @@
 /*
  *     BIRD Client
  *
- *     (c) 1999 Martin Mares <mj@ucw.cz>
+ *     (c) 1999--2000 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
-
-/* sysdep code */
-
-int client_main(int argc, char **argv);
diff --git a/client/commands.c b/client/commands.c
new file mode 100644 (file)
index 0000000..ea9358d
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ *     BIRD Client -- Command Handling
+ *
+ *     (c) 1999--2000 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include "nest/bird.h"
+#include "client/client.h"
+
+struct cmd_info {
+  char *command;
+  char *args;
+  char *help;
+};
+
+struct cmd_info command_table[] = {
+#include "conf/commands.h"
+};
diff --git a/client/util.c b/client/util.c
new file mode 100644 (file)
index 0000000..65a1fb2
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ *     BIRD Client -- Utility Functions
+ *
+ *     (c) 1999--2000 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "nest/bird.h"
+#include "client/client.h"
+
+/* Client versions of logging functions */
+
+void
+bug(char *msg, ...)
+{
+  va_list args;
+
+  va_start(args, msg);
+  fputs("Internal error: ", stderr);
+  vfprintf(stderr, msg, args);
+  fputc('\n', stderr);
+  exit(1);
+}
+
+void
+die(char *msg, ...)
+{
+  va_list args;
+
+  va_start(args, msg);
+  vfprintf(stderr, msg, args);
+  fputc('\n', stderr);
+  exit(1);
+}
index 5ef8212322b8fcce9b81c2b8499065851ec07b61..1e1fdba726c8c1fc9702bb96352a8e806de97d37 100644 (file)
@@ -1,12 +1,13 @@
 dnl ** This is a configure script template for BIRD
 dnl ** Process it with autoconf to get ./configure
-dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
+dnl ** (c) 1999--2000 Martin Mares <mj@ucw.cz>
 
 AC_REVISION($Id$)
 AC_INIT(conf/confbase.Y)
 AC_CONFIG_AUX_DIR(tools)
 
 AC_ARG_ENABLE(debug,[  --enable-debug          enable internal debugging routines (default: enabled)],,enable_debug=yes)
+AC_ARG_ENABLE(client,[  --enable-client         enable building of BIRD client (default: enabled)],,enable_client=yes)
 AC_ARG_WITH(sysconfig,[  --with-sysconfig=FILE   use specified BIRD system configuration file])
 AC_ARG_WITH(protocols,[  --with-protocols=LIST   include specified routing protocols (default: rip,static,pipe)],,[with_protocols="rip,static,pipe"])
 AC_ARG_WITH(sysinclude,[  --with-sysinclude=PATH  search for system includes on specified place])
@@ -133,6 +134,13 @@ else
        AC_DEFINE_UNQUOTED(PATH_CONTROL_SOCKET_DIR, "$localstatedir")
 fi
 
+if test "$enable_client" = yes ; then
+       CLIENT=client
+else
+       CLIENT=
+fi
+AC_SUBST(CLIENT)
+
 mkdir -p $objdir/sysdep
 AC_CONFIG_HEADER($objdir/sysdep/autoconf.h:sysdep/autoconf.h.in)
 AC_OUTPUT_COMMANDS(,[CPP="$CPP" $srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs])
@@ -146,5 +154,6 @@ BIRD was configured with the following options:
        System configuration:   $sysdesc
        Debugging:              $enable_debug
        Routing protocols:      $protocols
+       Client:                 $enable_client
 EOF
 rm -f $objdir/.*-stamp
index aca79319b787b8a50d996f6f99283e1c2fa2999b..017623e73076fb7f8abdbfade48b1991c48ae603 100644 (file)
@@ -19,5 +19,3 @@ krt-iface.h
 krt-set.c
 krt-set.h
 #endif
-
-client-main.c
diff --git a/sysdep/unix/client-main.c b/sysdep/unix/client-main.c
deleted file mode 100644 (file)
index 4fc2433..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *     BIRD Client -- Unix Entry Point
- *
- *     (c) 1999 Martin Mares <mj@ucw.cz>
- *
- *     Can be freely distributed and used under the terms of the GNU GPL.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "nest/bird.h"
-#include "lib/resource.h"      /* For dmalloc */
-#include "client/client.h"
-#include "nest/cli.h"
-
-#include "unix.h"
-
-static char *opt_list = "";
-
-static void
-usage(void)
-{
-  fprintf(stderr, "Usage: birdc\n");
-  exit(1);
-}
-
-static void
-parse_args(int argc, char **argv)
-{
-  int c;
-
-  while ((c = getopt(argc, argv, opt_list)) >= 0)
-    switch (c)
-      {
-      default:
-       usage();
-      }
-  if (optind < argc)
-    usage();
-}
-
-void
-cli_echo(unsigned int class, byte *buf)
-{
-}
-
-int
-client_main(int argc, char **argv)
-{
-#ifdef HAVE_LIBDMALLOC
-  if (!getenv("DMALLOC_OPTIONS"))
-    dmalloc_debug(0x2f03d00);
-#endif
-
-  parse_args(argc, argv);
-
-  bug("Not implemented yet!");
-}
index bbf4db07beac06e6c0b2cf7453813b237105bd9a..56d65140056476daa97715c4e0b28b352e1831ab 100644 (file)
@@ -1,13 +1,17 @@
 # Makefile for the BIRD Internet Routing Daemon
-# (c) 1999 Martin Mares <mj@ucw.cz>
+# (c) 1999--2000 Martin Mares <mj@ucw.cz>
 
 include Rules
 
 srcdir_abs := $(shell cd $(srcdir) ; pwd)
 
-.PHONY: all subdir depend clean distclean tags
+.PHONY: all daemon client subdir depend clean distclean tags
 
-all: .dep-stamp subdir $(exedir)/bird $(exedir)/birdc
+all: .dep-stamp subdir daemon @CLIENT@
+
+daemon: $(exedir)/bird
+
+client: $(exedir)/birdc
 
 subdir depend: .dir-stamp
        set -e ; for a in $(dynamic-dirs) ; do $(MAKE) -C $$a $@ ; done