diff options
author | Martin Mares <mj@ucw.cz> | 2000-01-19 16:07:00 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2000-01-19 16:07:00 +0100 |
commit | 9fac310d1a4e46f4bcc70177e59cbf93763ef479 (patch) | |
tree | 7ad25775400768f05abbd8f004fb0ca80a5f60fe /client | |
parent | f50b9e48b93e3f69423a0e6e5fef273ba2022958 (diff) | |
download | bird-9fac310d1a4e46f4bcc70177e59cbf93763ef479.tar bird-9fac310d1a4e46f4bcc70177e59cbf93763ef479.zip |
Put client on a stony ground. The whole client is going to be system-specific
(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.
Diffstat (limited to 'client')
-rw-r--r-- | client/Makefile | 2 | ||||
-rw-r--r-- | client/client.c | 45 | ||||
-rw-r--r-- | client/client.h | 6 | ||||
-rw-r--r-- | client/commands.c | 20 | ||||
-rw-r--r-- | client/util.c | 40 |
5 files changed, 98 insertions, 15 deletions
diff --git a/client/Makefile b/client/Makefile index 0d01724..867476c 100644 --- a/client/Makefile +++ b/client/Makefile @@ -1,4 +1,4 @@ -source=client.c +source=client.c commands.c util.c root-rel=../ dir-name=client diff --git a/client/client.c b/client/client.c index 2a43a8d..e9bc827 100644 --- a/client/client.c +++ b/client/client.c @@ -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!"); } diff --git a/client/client.h b/client/client.h index b5d6ab1..2e1e050 100644 --- a/client/client.h +++ b/client/client.h @@ -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 index 0000000..ea9358d --- /dev/null +++ b/client/commands.c @@ -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 index 0000000..65a1fb2 --- /dev/null +++ b/client/util.c @@ -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); +} |