DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: dev@dpdk.org, Keith Wiles <keith.wiles@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@intel.com>,
	Jim Thompson <jim@netgate.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2] cmdline: rework as a wrapper to libedit
Date: Tue, 26 Jun 2018 15:33:13 +0200	[thread overview]
Message-ID: <20180626133313.5ciboen7of44qlej@platinum> (raw)
In-Reply-To: <20180626132121.6qm3m3mx2ubkxyn3@platinum>

> I noticed a bad behavior change (in addition to many good ones):
> ctrl-c now quits the application, and this was not the case before.
> I often use ctrl-c to delete the line I'm currently editing. Please
> see at the end a proposition to restore this feature.

And now, ladies and gentlemen, the proposition I was talking about :)

 diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c
 index f334d7123..860457dc6 100644
 --- a/examples/vhost_crypto/main.c
 +++ b/examples/vhost_crypto/main.c
 @@ -15,7 +15,6 @@
  #include <rte_cryptodev.h>
  #include <rte_vhost_crypto.h>
  
 -#include <cmdline_rdline.h>
  #include <cmdline_parse.h>
  #include <cmdline_parse_string.h>
  #include <cmdline.h>
 diff --git a/lib/librte_cmdline/Makefile b/lib/librte_cmdline/Makefile
 index feb1f1bca..052934b69 100644
 --- a/lib/librte_cmdline/Makefile
 +++ b/lib/librte_cmdline/Makefile
 @@ -23,6 +23,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_socket.c
  SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_parse_portlist.c
  
  LDLIBS += -lrte_eal
 +LDLIBS += $(shell pkg-config --libs libedit)
  
  # install includes
  INCS := cmdline.h cmdline_parse.h cmdline_parse_num.h cmdline_parse_ipaddr.h
 diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c
 index 1c45cd9ff..af72f394f 100644
 --- a/lib/librte_cmdline/cmdline.c
 +++ b/lib/librte_cmdline/cmdline.c
 @@ -4,8 +4,9 @@
   * All rights reserved.
   */
  
 +#include <sys/types.h>
  #include <ctype.h>
 -#include <histedit.h>
 +#include <signal.h>
  #include <stdint.h>
  #include <stdio.h>
  #include <string.h>
 @@ -16,6 +17,8 @@
  #include <poll.h>
  #include <errno.h>
  
 +#include <histedit.h>
 +
  #include <rte_string_fns.h>
  
  #include "cmdline_parse.h"
 @@ -60,6 +63,32 @@ cmdline_el_prompt(EditLine *el)
  	return cl->prompt;
  }
  
 +static int
 +editline_break(EditLine *el, int c)
 +{
 +	struct cmdline *cl;
 +
 +	(void)c;
 +
 +	if (el_get(el, EL_CLIENTDATA, &cl))
 +		return CC_FATAL;
 +
 +	fprintf(cl->f_out, "\n");
 +
 +	return CC_NEWLINE;
 +}
 +
 +static int
 +editline_suspend(EditLine *editline, int c)
 +{
 +	(void)editline;
 +	(void)c;
 +
 +	kill(getpid(), SIGSTOP);
 +
 +	return CC_NORM;
 +}
 +
  static unsigned char
  cmdline_el_execute(EditLine *el, int c)
  {
 @@ -224,6 +253,20 @@ cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_in, int s_out)
  	if (el_set(cl->el, EL_ADDFN, "ed-execute", "Execute command",
  		   cmdline_el_execute))
  		goto error;
 +	if (el_set(cl->el, EL_SETTY, "-d", "-isig", NULL))
 +		goto error;
 +	if (el_set(cl->el, EL_ADDFN, "ed-break",
 +			"Break and flush the buffer",
 +			editline_break))
 +		goto error;
 +	if (el_set(cl->el, EL_BIND, "^C", "ed-break", NULL))
 +		goto error;
 +	if (el_set(cl->el, EL_ADDFN, "ed-suspend",
 +			"Suspend the terminal",
 +			editline_suspend))
 +		goto error;
 +	if (el_set(cl->el, EL_BIND, "^Z", "ed-suspend", NULL))
 +		goto error;
  	if (el_set(cl->el, EL_BIND, "^J", "ed-execute", NULL))
  		goto error;
  	if (el_set(cl->el, EL_BIND, "^M", "ed-execute", NULL))
 diff --git a/mk/rte.app.mk b/mk/rte.app.mk
 index e5caefb08..f7d9f6f2c 100644
 --- a/mk/rte.app.mk
 +++ b/mk/rte.app.mk
 @@ -81,8 +81,6 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
  _LDLIBS-$(CONFIG_RTE_LIBRTE_PCI)            += -lrte_pci
  _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
  _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 -
 -_LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += $(shell pkg-config --libs libedit)
  _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
  _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
  
 @@ -267,6 +265,7 @@ ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)
  _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)          += -lnuma
  endif
  _LDLIBS-$(CONFIG_RTE_PORT_PCAP)             += -lpcap
 +_LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += $(shell pkg-config --libs libedit)
  endif # !CONFIG_RTE_BUILD_SHARED_LIBS
  
  _LDLIBS-y += $(EXECENV_LDLIBS)

  reply	other threads:[~2018-06-26 13:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 13:43 [dpdk-dev] [RFC] " Adrien Mazarguil
2017-11-15  4:12 ` Wiles, Keith
2017-11-15  8:04   ` Olivier MATZ
2017-11-15 16:31     ` Wiles, Keith
2017-11-16  9:23   ` Adrien Mazarguil
2017-11-16 16:48     ` Wiles, Keith
2017-11-16 18:07       ` Thomas Monjalon
2017-11-16 17:06     ` Ferruh Yigit
2017-11-16 17:27       ` Wiles, Keith
2017-11-16 18:05         ` Thomas Monjalon
2017-11-16 16:53 ` Jim Thompson
2018-04-17 15:21 ` [dpdk-dev] [PATCH v1] " Adrien Mazarguil
2018-04-17 15:59   ` Burakov, Anatoly
2018-04-19 15:13   ` [dpdk-dev] [PATCH v2] " Adrien Mazarguil
2018-06-26 13:21     ` Olivier Matz
2018-06-26 13:33       ` Olivier Matz [this message]
2018-06-27 10:36       ` Bruce Richardson
2018-06-27 11:35         ` Olivier Matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180626133313.5ciboen7of44qlej@platinum \
    --to=olivier.matz@6wind.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jim@netgate.com \
    --cc=jingjing.wu@intel.com \
    --cc=keith.wiles@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).