0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-09 12:48:43 +00:00

Configure, link and use the readline library.

This commit is contained in:
Martin Mares 2000-01-20 13:13:30 +00:00
parent 9fac310d1a
commit 7211be1cff
4 changed files with 33 additions and 4 deletions

View File

@ -10,6 +10,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "nest/bird.h" #include "nest/bird.h"
#include "lib/resource.h" #include "lib/resource.h"
@ -39,6 +41,21 @@ parse_args(int argc, char **argv)
usage(); 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 int
main(int argc, char **argv) main(int argc, char **argv)
{ {
@ -49,5 +66,9 @@ main(int argc, char **argv)
parse_args(argc, argv); parse_args(argc, argv);
bug("Not implemented yet!"); for(;;)
{
char *c = get_command();
puts(c);
}
} }

View File

@ -134,12 +134,19 @@ else
AC_DEFINE_UNQUOTED(PATH_CONTROL_SOCKET_DIR, "$localstatedir") AC_DEFINE_UNQUOTED(PATH_CONTROL_SOCKET_DIR, "$localstatedir")
fi fi
CLIENT=
CLIENT_LIBS=
if test "$enable_client" = yes ; then if test "$enable_client" = yes ; then
CLIENT=client CLIENT=client
else AC_CHECK_LIB(history, add_history, CLIENT_LIBS="-lhistory")
CLIENT= 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 fi
AC_SUBST(CLIENT) AC_SUBST(CLIENT)
AC_SUBST(CLIENT_LIBS)
mkdir -p $objdir/sysdep mkdir -p $objdir/sysdep
AC_CONFIG_HEADER($objdir/sysdep/autoconf.h:sysdep/autoconf.h.in) AC_CONFIG_HEADER($objdir/sysdep/autoconf.h:sysdep/autoconf.h.in)

View File

@ -21,7 +21,7 @@ $(exedir)/bird: $(addsuffix /all.o, $(static-dirs)) conf/all.o lib/birdlib.a
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(exedir)/birdc: client/all.o lib/birdlib.a $(exedir)/birdc: client/all.o lib/birdlib.a
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(CLIENT_LIBS)
.dir-stamp: .dir-stamp:
mkdir -p $(static-dirs) $(client-dirs) mkdir -p $(static-dirs) $(client-dirs)

View File

@ -20,6 +20,7 @@ CPPFLAGS=-I$(root-rel) -I$(srcdir) @CPPFLAGS@
CFLAGS=$(CPPFLAGS) @CFLAGS@ CFLAGS=$(CPPFLAGS) @CFLAGS@
LDFLAGS= LDFLAGS=
LIBS=@LIBS@ LIBS=@LIBS@
CLIENT_LIBS=@CLIENT_LIBS@
CC=@CC@ CC=@CC@
M4=@M4@ M4=@M4@
BISON=@BISON@ BISON=@BISON@