1999-10-29 17:44:44 +08:00
|
|
|
/*
|
|
|
|
* BIRD Client
|
|
|
|
*
|
2000-01-19 22:37:56 +08:00
|
|
|
* (c) 1999--2000 Martin Mares <mj@ucw.cz>
|
1999-10-29 17:44:44 +08:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
2000-01-19 23:07:00 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
2000-01-20 21:13:30 +08:00
|
|
|
#include <readline/readline.h>
|
|
|
|
#include <readline/history.h>
|
2000-01-19 23:07:00 +08:00
|
|
|
|
1999-10-29 17:44:44 +08:00
|
|
|
#include "nest/bird.h"
|
2000-01-19 23:07:00 +08:00
|
|
|
#include "lib/resource.h"
|
1999-10-29 17:44:44 +08:00
|
|
|
#include "client/client.h"
|
|
|
|
|
2000-01-19 23:07:00 +08:00
|
|
|
static char *opt_list = "";
|
2000-01-19 22:37:56 +08:00
|
|
|
|
2000-01-19 23:07:00 +08:00
|
|
|
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();
|
|
|
|
}
|
2000-01-19 22:37:56 +08:00
|
|
|
|
2000-01-20 21:13:30 +08:00
|
|
|
static char *
|
|
|
|
get_command(void)
|
|
|
|
{
|
|
|
|
static char *cmd_buffer;
|
|
|
|
|
|
|
|
if (cmd_buffer)
|
|
|
|
free(cmd_buffer);
|
|
|
|
cmd_buffer = readline("bird> ");
|
|
|
|
if (!cmd_buffer)
|
|
|
|
exit(0);
|
|
|
|
if (cmd_buffer[0])
|
|
|
|
add_history(cmd_buffer);
|
|
|
|
return cmd_buffer;
|
|
|
|
}
|
|
|
|
|
1999-10-29 17:44:44 +08:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2000-01-19 23:07:00 +08:00
|
|
|
#ifdef HAVE_LIBDMALLOC
|
|
|
|
if (!getenv("DMALLOC_OPTIONS"))
|
|
|
|
dmalloc_debug(0x2f03d00);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
parse_args(argc, argv);
|
|
|
|
|
2000-01-20 21:13:30 +08:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
char *c = get_command();
|
|
|
|
puts(c);
|
|
|
|
}
|
1999-10-29 17:44:44 +08:00
|
|
|
}
|