> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Also, `lldpcli` will be linked to GNU Readline (which is GPL licensed)
+if available. To avoid this, use `--without-readline` as a configure
+option.
# Libevent
lldp_CHECK_LIBEVENT
-# readline (or something similar)
-AX_LIB_READLINE
-
#######################
### Options
+# Readline
+AC_ARG_WITH([readline],
+ AS_HELP_STRING(
+ [--with-readline],
+ [Enable the use of readline-like library @<:@default=check@:>@]),
+ [],
+ [with_readline=check])
+if test x"$with_readline" != x"no"; then
+ AX_LIB_READLINE
+ if test x"$with_readline" != x"check"; then
+ if test x"$ax_cv_lib_readline" = x"no"; then
+ AC_MSG_FAILURE([*** no readline support found])
+ fi
+ fi
+else
+ ax_cv_lib_readline="no"
+fi
+
# SNMP
AC_ARG_WITH([snmp],
AS_HELP_STRING(
C Compiler.....: $CC $CFLAGS $CPPFLAGS
Linker.........: $LD $LDFLAGS $LIBS
Libevent.......: $libevent
+ Readline.......: ${ax_cv_lib_readline}
Optional features:
SNMP support...: ${with_snmp-no}
CDP............: $enable_cdp
# # include <readline.h>
# # else /* !defined(HAVE_READLINE_H) */
# extern char *readline ();
+# extern int rl_insert_text(const char*);
+# extern int rl_delete_text(int, int);
+# extern void rl_forced_update_display(void);
+# extern int rl_bind_key(int, int(*f)(int, int));
# # endif /* !defined(HAVE_READLINE_H) */
# char *cmdline = NULL;
# #else /* !defined(HAVE_READLINE_READLINE_H) */
# and this notice are preserved. This file is offered as-is, without any
# warranty.
+# Modified version. Original version is available here:
+# http://www.gnu.org/software/autoconf-archive/ax_lib_readline.html
+
#serial 6
AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE])
TRY_LIB="-l$readline_lib -l$termcap_lib"
fi
LIBS="$ORIG_LIBS $TRY_LIB"
- AC_TRY_LINK_FUNC(readline, ax_cv_lib_readline="$TRY_LIB")
+ for readline_func in readline rl_insert_text rl_delete_text rl_forced_update_display; do
+ AC_TRY_LINK_FUNC($readline_func, ax_cv_lib_readline="$TRY_LIB", ax_cv_lib_readline="")
+ if test -z "$ax_cv_lib_readline"; then
+ break
+ fi
+ done
if test -n "$ax_cv_lib_readline"; then
break
fi
# include <readline.h>
# else
extern char *readline();
-extern char *rl_line_buffer
+extern char *rl_line_buffer;
extern int rl_point;
extern int rl_insert_text(const char*);
extern int rl_delete_text(int, int);
-extern int rl_ding(void);
-extern int rl_crlf(void);
-extern int rl_on_new_line(void);
+extern void rl_forced_update_display(void);
extern int rl_bind_key(int, int(*f)(int, int));
# endif
#endif
return 1;
}
+#ifdef HAVE_LIBREADLINE
static int
_cmd_complete(int all)
{
goto end;
}
/* No completion or several completion available. */
- if (!all) rl_ding();
- rl_crlf();
- rl_on_new_line();
+ fprintf(stderr, "\n");
+ rl_forced_update_display();
rc = 0;
end:
free(line);
{
return _cmd_complete(1);
}
+#else
+static char*
+readline()
+{
+ static char line[2048];
+ fprintf(stderr, "%s", prompt());
+ fflush(stderr);
+ if (fgets(line, sizeof(line) - 2, stdin) == NULL)
+ return NULL;
+ return line;
+}
+#endif
static struct cmd_node*
register_commands()
/* More arguments! */
must_exit = 1;
} else {
+#ifdef HAVE_LIBREADLINE
/* Shell session */
rl_bind_key('?', cmd_help);
rl_bind_key('\t', cmd_complete);
+#endif
}
/* Make a connection */
continue;
}
if (cargc == 0) continue;
+#ifdef HAVE_READLINE_HISTORY
add_history(line);
+#endif
}
/* Init output formatter */