trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject svn commit: r1236973 - in /trafficserver/traffic/trunk: configure.ac lib/ts/ink_config.h.in mgmt/cli/Makefile.am mgmt/cli/cliAppInit.cc mgmt/cli/cliMain.cc
Date Sat, 28 Jan 2012 04:04:45 GMT
Author: jpeach
Date: Sat Jan 28 04:04:45 2012
New Revision: 1236973

URL: http://svn.apache.org/viewvc?rev=1236973&view=rev
Log:
TS-1096: libreadline support for traffic_shell

Modified:
    trafficserver/traffic/trunk/configure.ac
    trafficserver/traffic/trunk/lib/ts/ink_config.h.in
    trafficserver/traffic/trunk/mgmt/cli/Makefile.am
    trafficserver/traffic/trunk/mgmt/cli/cliAppInit.cc
    trafficserver/traffic/trunk/mgmt/cli/cliMain.cc

Modified: trafficserver/traffic/trunk/configure.ac
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/configure.ac?rev=1236973&r1=1236972&r2=1236973&view=diff
==============================================================================
--- trafficserver/traffic/trunk/configure.ac (original)
+++ trafficserver/traffic/trunk/configure.ac Sat Jan 28 04:04:45 2012
@@ -1017,6 +1017,18 @@ AC_SUBST(use_hwloc)
 TS_CHECK_JEMALLOC
 TS_CHECK_TCMALLOC
 
+#
+# Check for libreadline/libedit
+
+AC_CHECK_LIB([edit], [readline], [
+    AC_SUBST([LIBREADLINE], [-ledit])
+    AC_DEFINE([HAVE_LIBREADLINE], [1], [Define if you have libedit])],
+    [], [])
+
+AC_CHECK_LIB([readline], [readline], [
+    AC_SUBST([LIBREADLINE], [-lreadline])
+    AC_DEFINE([HAVE_LIBREADLINE], [1], [Define if you have libreadline])],
+    [], [])
 
 # -----------------------------------------------------------------------------
 # 5. CHECK FOR HEADER FILES
@@ -1053,7 +1065,9 @@ TS_FLAG_HEADERS([sys/epoll.h \
                   math.h \
                   stdint.h \
                   net/ppp_defs.h \
-                  ifaddrs.h])
+                  ifaddrs.h\
+		  readline/readline.h \
+		  editline/readline.h ])
 
 AC_SUBST(sys_epollh)
 AC_SUBST(sys_eventh)
@@ -1090,6 +1104,7 @@ AC_SUBST(sys_sysmacrosh)
 AC_SUBST(mathh)
 AC_SUBST(net_ppp_defsh)
 AC_SUBST(ifaddrsh)
+AC_SUBST(readline_readlineh)
 
 TS_FLAG_HEADERS([sys/sysctl.h], [], [],
                  [[#ifdef HAVE_SYS_PARAM_H

Modified: trafficserver/traffic/trunk/lib/ts/ink_config.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_config.h.in?rev=1236973&r1=1236972&r2=1236973&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_config.h.in (original)
+++ trafficserver/traffic/trunk/lib/ts/ink_config.h.in Sat Jan 28 04:04:45 2012
@@ -79,7 +79,8 @@
 #define TS_HAVE_NETINET_IP_H           @netinet_iph@
 #define TS_HAVE_NETINET_IP_ICMP_H      @netinet_ip_icmph@
 #define TS_HAVE_EXECINFO_H             @execinfoh@
-#define TS_HAVE_IFADDRS_H               @ifaddrsh@
+#define TS_HAVE_IFADDRS_H              @ifaddrsh@
+#define TS_HAVE_READLINE_READLINE_H    @readline_readlineh@
 
 /* Libraries */
 #define TS_HAS_LIBZ                    @zlibh@

Modified: trafficserver/traffic/trunk/mgmt/cli/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli/Makefile.am?rev=1236973&r1=1236972&r2=1236973&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli/Makefile.am (original)
+++ trafficserver/traffic/trunk/mgmt/cli/Makefile.am Sat Jan 28 04:04:45 2012
@@ -78,7 +78,8 @@ traffic_shell_LDADD = \
   $(top_builddir)/mgmt/tools/libinkconfigapi.a \
   $(top_builddir)/mgmt/utils/libutils_lm.a \
   $(top_builddir)/lib/ts/libtsutil.la \
-  $(LIBTCL) @LIBDL@ -lm @LIBICONV@ @LIBEXPAT@ @LIBSSL@ \
+  $(LIBTCL) $(LIBREADLINE) \
+  @LIBDL@ -lm @LIBICONV@ @LIBEXPAT@ @LIBSSL@ \
   @LIBTHREAD@ @LIBSOCKET@ @LIBNSL@ @LIBRESOLV@ \
   @LIBRT@ @LIBEXECINFO@ @LIBPCRE@
 

Modified: trafficserver/traffic/trunk/mgmt/cli/cliAppInit.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli/cliAppInit.cc?rev=1236973&r1=1236972&r2=1236973&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli/cliAppInit.cc (original)
+++ trafficserver/traffic/trunk/mgmt/cli/cliAppInit.cc Sat Jan 28 04:04:45 2012
@@ -53,6 +53,12 @@
 #include "ConfigCmd.h"
 #include "CliCreateCommands.h"
 
+#if HAVE_EDITLINE_READLINE_H
+#include <editline/readline.h>
+#elif HAVE_READLINE_READLINE_H
+#include <readline/readline.h>
+#endif
+
 Tcl_Interp *interp;
 extern Tcl_HashTable CommandHashtable;
 
@@ -124,3 +130,34 @@ Tcl_AppInit(Tcl_Interp * app_interp)
 
   return TCL_OK;
 }
+
+#if HAVE_LIBREADLINE
+
+// TCL main read, eval, print loop. We don't use Tcl_Main because we want to
+// use readline to get line editing and command history.
+void Tcl_ReadlineMain(void)
+{
+  char * line;
+
+  for (;;) {
+    line = readline("trafficserver> ");
+    if (line == NULL) {
+      // Received EOF. Bound this into a TCL exit command just like Tcl_Main
+      // does.
+      Tcl_Eval(interp, "exit;");
+    }
+
+    if (*line) {
+      add_history(line);
+      Tcl_Eval(interp, line);
+    }
+
+    free(line);
+  }
+
+  exit(0);
+}
+
+#endif // HAVE_LIBREADLINE
+
+// vim: set ts=2 sw=2 et :

Modified: trafficserver/traffic/trunk/mgmt/cli/cliMain.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/cli/cliMain.cc?rev=1236973&r1=1236972&r2=1236973&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/cli/cliMain.cc (original)
+++ trafficserver/traffic/trunk/mgmt/cli/cliMain.cc Sat Jan 28 04:04:45 2012
@@ -33,6 +33,7 @@
 #include "mgmtapi.h"
 
 extern int Tcl_AppInit(Tcl_Interp * interp);
+extern void Tcl_ReadlineMain(void);
 extern int CliDisplayPrintf;
 void eventCallbackFn(char *name, char *msg, int pri, void *data);
 
@@ -87,6 +88,10 @@ main(int argc, char *argv[])
 
   register_event_callback();
 
+#if HAVE_LIBREADLINE
+  Tcl_SetMainLoop(Tcl_ReadlineMain);
+#endif
+
   Tcl_Main(argc, argv, Tcl_AppInit);
   exit(0);
 }



Mime
View raw message