mirror of
				https://gitlab.labs.nic.cz/labs/bird.git
				synced 2024-05-11 16:54:54 +00:00 
			
		
		
		
	Configure, link and use the readline library.
This commit is contained in:
		| @@ -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); | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										11
									
								
								configure.in
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								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) | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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@ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user