diff options
-rw-r--r-- | client/client.c | 23 | ||||
-rw-r--r-- | configure.in | 11 | ||||
-rw-r--r-- | tools/Makefile.in | 2 | ||||
-rw-r--r-- | tools/Rules.in | 1 |
4 files changed, 33 insertions, 4 deletions
diff --git a/client/client.c b/client/client.c index e9bc827..260e043 100644 --- a/client/client.c +++ b/client/client.c @@ -10,6 +10,8 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <readline/readline.h> +#include <readline/history.h> #include "nest/bird.h" #include "lib/resource.h" @@ -39,6 +41,21 @@ parse_args(int argc, char **argv) usage(); } +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; +} + int main(int argc, char **argv) { @@ -49,5 +66,9 @@ main(int argc, char **argv) parse_args(argc, argv); - bug("Not implemented yet!"); + for(;;) + { + char *c = get_command(); + puts(c); + } } diff --git a/configure.in b/configure.in index 1e1fdba..579c6bd 100644 --- a/configure.in +++ b/configure.in @@ -134,12 +134,19 @@ else AC_DEFINE_UNQUOTED(PATH_CONTROL_SOCKET_DIR, "$localstatedir") fi +CLIENT= +CLIENT_LIBS= if test "$enable_client" = yes ; then CLIENT=client -else - CLIENT= + AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory") + AC_CHECK_LIB(ncurses, tgetent, USE_TERMCAP_LIB=-lncurses, + AC_CHECK_LIB(curses, tgetent, USE_TERMCAP_LIB=-lcurses, + AC_CHECK_LIB(termcap, tgetent, USE_TERMCAP_LIB=-ltermcap))) + AC_CHECK_LIB(readline, readline, CLIENT_LIBS="-lreadline $CLIENT_LIBS $USE_TERMCAP_LIB", + AC_MSG_ERROR([[The client requires GNU readline library. Either install the library or use --disable-client to compile without the client.]]), $USE_TERMCAP_LIB) fi AC_SUBST(CLIENT) +AC_SUBST(CLIENT_LIBS) mkdir -p $objdir/sysdep AC_CONFIG_HEADER($objdir/sysdep/autoconf.h:sysdep/autoconf.h.in) diff --git a/tools/Makefile.in b/tools/Makefile.in index 56d6514..1dcb9bc 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -21,7 +21,7 @@ $(exedir)/bird: $(addsuffix /all.o, $(static-dirs)) conf/all.o lib/birdlib.a $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(exedir)/birdc: client/all.o lib/birdlib.a - $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(CLIENT_LIBS) .dir-stamp: mkdir -p $(static-dirs) $(client-dirs) diff --git a/tools/Rules.in b/tools/Rules.in index fc3d2b1..4820182 100644 --- a/tools/Rules.in +++ b/tools/Rules.in @@ -20,6 +20,7 @@ CPPFLAGS=-I$(root-rel) -I$(srcdir) @CPPFLAGS@ CFLAGS=$(CPPFLAGS) @CFLAGS@ LDFLAGS= LIBS=@LIBS@ +CLIENT_LIBS=@CLIENT_LIBS@ CC=@CC@ M4=@M4@ BISON=@BISON@ |