From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 39F78CF9E for ; Tue, 17 Apr 2018 17:59:34 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2018 08:59:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,464,1517904000"; d="scan'208";a="46886513" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.237.220.128]) ([10.237.220.128]) by fmsmga004.fm.intel.com with ESMTP; 17 Apr 2018 08:59:30 -0700 To: Adrien Mazarguil , Olivier Matz Cc: dev@dpdk.org, Keith Wiles , Jingjing Wu , Thomas Monjalon , Ferruh Yigit , Jim Thompson References: <1510234868-31053-1-git-send-email-adrien.mazarguil@6wind.com> <20180417152016.5163-1-adrien.mazarguil@6wind.com> From: "Burakov, Anatoly" Message-ID: Date: Tue, 17 Apr 2018 16:59:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180417152016.5163-1-adrien.mazarguil@6wind.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v1] cmdline: rework as a wrapper to libedit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Apr 2018 15:59:34 -0000 On 17-Apr-18 4:21 PM, Adrien Mazarguil wrote: > Disclaimer: this patch must not be confused with the CLI library [1] > (work in progress) that will eventually supersede librte_cmdline itself > with a different API. > > Rather, it modifies librte_cmdline to delegate all the heavy lifting > (terminal and history handling), strips unused features and re-implements > what remains of its public API as a wrapper to the editline library (also > known as libedit) [2], a well-known, BSD-licensed and widely available > library used by many projects which does everything needed and more [3]. > > This approach was chosen because converting librte_cmdline as a wrapper to > a more capable library was easier and faster than addressing its > shortcomings and results in much less code to maintain in DPDK. > > It also provides a drop-in solution for applications that rely on > librte_cmdline. They benefit from greatly improved command line handling > without a meaningful impact on their code base. > > The main motivation behind this patch is testpmd's flow (rte_flow) command, > which requires support for dynamic tokens and very long lines that must be > broken down when displayed. This is not supported by librte_cmdline's > limited terminal handling capabilities, resulting in a rather frustrating > user experience. > > It had to be addressed given the importance of testpmd as one of the > primary tool used by PMD developers. > > This rework results in the following changes: > > - Removed circular buffer management interface for command history > (cmdline_cirbuf.c), command history being handled by libedit. > - Removed raw command-line interpreter (cmdline_rdline.c). > - Removed raw terminal handler (cmdline_vt100.c). > - Removed all test/example code for the above. > - Re-implemented high level interactive and non-interactive command-line > handlers (cmdline.c and cmdline_socket.c) on top of libedit using its > native interface, not its readline compatibility layer. > - Made struct cmdline opaque so that applications relying on librte_cmdline > do not need to include any libedit headers. > - Applications do not need to include cmdline_rdline.h anymore. > - Terminal resizing is now automatically handled. > - New external dependency for applications relying on librte_cmdline. > - Major version bump due to the ABI impact of these changes. > > [1] http://dpdk.org/browse/draft/dpdk-draft-cli/ > [2] http://thrysoee.dk/editline/ > [3] http://netbsd.gw.com/cgi-bin/man-cgi?editline++NetBSD-current > > Signed-off-by: Adrien Mazarguil > Cc: Olivier Matz > Cc: Keith Wiles > Cc: Jingjing Wu > Cc: Thomas Monjalon > Cc: Ferruh Yigit > Cc: Jim Thompson > > -- > > No fundamental change since the original RFC [4], except it's been rebased > several times and Meson build support was added in the meantime. Commit log > was also shortened a bit. > > I'm re-sending this because I think it's useful, at least to me (duh). As > the maintainer of rte_flow, I spend most of my time typing flow commands in > testpmd and libedit makes that a pleasant experience. > > Try it out! And don't hesitate to send your acked-by line to get this in > time for 18.05 :) > > [4] http://dpdk.org/ml/archives/dev/2017-November/081605.html > --- <...> > + uint32_t error:1; > + char prompt[RDLINE_PROMPT_SIZE]; > +}; > + > +void > +cmdline_set_prompt(struct cmdline *cl, const char *prompt) > { > - struct cmdline *cl = rdl->opaque; > - int ret; > - ret = cmdline_parse(cl, buf); > - if (ret == CMDLINE_PARSE_AMBIGUOUS) > - cmdline_printf(cl, "Ambiguous command\n"); > - else if (ret == CMDLINE_PARSE_NOMATCH) > - cmdline_printf(cl, "Command not found\n"); > - else if (ret == CMDLINE_PARSE_BAD_ARGS) > - cmdline_printf(cl, "Bad arguments\n"); > + if (!cl || !prompt) > + return; > + snprintf(cl->prompt, sizeof(cl->prompt), "%s", prompt); Didn't look through the entire patch yet, but this stood out - please use strlcpy() :) -- Thanks, Anatoly