This patch removes checking for curses/ncurses. It is never used.
It also allows libvirt to be compiled without readline support. If readline support is not available then the only difference is that 'virsh' will be built without it -- in other words, command line editing will not work in virsh.
Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
Index: configure.in =================================================================== RCS file: /data/cvs/libvirt/configure.in,v retrieving revision 1.100 diff -u -r1.100 configure.in --- configure.in 30 Nov 2007 11:10:53 -0000 1.100 +++ configure.in 4 Dec 2007 17:41:25 -0000 @@ -383,16 +383,10 @@ AC_SUBST(AVAHI_LIBS) dnl virsh libraries -AC_CHECK_LIB(curses, initscr, - [VIRSH_LIBS="$VIRSH_LIBS -lcurses"], - [AC_CHECK_LIB(ncurses, initscr, - [VIRSH_LIBS="$VIRSH_LIBS -lncurses"], - [AC_MSG_ERROR([curses/ncurses library not found])], - [$VIRSH_LIBS])], - [$VIRSH_LIBS]) +AC_CHECK_HEADERS([readline/readline.h]) AC_CHECK_LIB(readline, main, [VIRSH_LIBS="$VIRSH_LIBS -lreadline"], - [AC_MSG_ERROR([readline library not found])], + [AC_MSG_WARN([readline library not found])], [$VIRSH_LIBS]) AC_SUBST(VIRSH_LIBS) Index: src/virsh.c =================================================================== RCS file: /data/cvs/libvirt/src/virsh.c,v retrieving revision 1.113 diff -u -r1.113 virsh.c --- src/virsh.c 1 Dec 2007 15:45:25 -0000 1.113 +++ src/virsh.c 4 Dec 2007 17:41:28 -0000 @@ -13,6 +13,8 @@ * $Id: virsh.c,v 1.113 2007/12/01 15:45:25 berrange Exp $ */ +#include "config.h" + #include "libvirt/libvirt.h" #include "libvirt/virterror.h" #include <stdio.h> @@ -39,10 +41,11 @@ #include <libxml/tree.h> #include <libxml/xpath.h> +#ifdef HAVE_READLINE_READLINE_H #include <readline/readline.h> #include <readline/history.h> +#endif -#include "config.h" #include "internal.h" #include "console.h" @@ -4656,6 +4659,8 @@ } } +#ifdef HAVE_READLINE_READLINE_H + /* ----------------- * Readline stuff * ----------------- @@ -4773,6 +4778,41 @@ rl_attempted_completion_function = vshReadlineCompletion; } +static char * +vshReadline (vshControl *ctl ATTRIBUTE_UNUSED, const char *prompt) +{ + return readline (prompt); +} + +#else /* !HAVE_READLINE_READLINE_H */ + +static void +vshReadlineInit (void) +{ + /* empty */ +} + +static char * +vshReadline (vshControl *ctl, const char *prompt) +{ + char line[1024]; + char *r; + int len; + + fputs (prompt, stdout); + r = fgets (line, sizeof line, stdin); + if (r == NULL) return NULL; /* EOF */ + + /* Chomp trailing \n */ + len = strlen (r); + if (len > 0 && r[len-1] == '\n') + r[len-1] = '\0'; + + return vshStrdup (ctl, r); +} + +#endif /* !HAVE_READLINE_READLINE_H */ + /* * Deinitliaze virsh */ @@ -5013,11 +5053,13 @@ vshReadlineInit(); do { ctl->cmdstr = - readline(ctl->uid == 0 ? VSH_PROMPT_RW : VSH_PROMPT_RO); + vshReadline(ctl, ctl->uid == 0 ? VSH_PROMPT_RW : VSH_PROMPT_RO); if (ctl->cmdstr == NULL) break; /* EOF */ if (*ctl->cmdstr) { +#if HAVE_READLINE_READLINE_H add_history(ctl->cmdstr); +#endif if (vshCommandParse(ctl, ctl->cmdstr)) vshCommandRun(ctl, ctl->cmd); }
smime.p7s
Description: S/MIME Cryptographic Signature
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list