[dpdk-dev] [PATCH 1/3] lib/cmdline: add echo support in batch loading from file

Olivier MATZ olivier.matz at 6wind.com
Tue Dec 19 11:30:59 CET 2017


Hi Xueming,

On Wed, Nov 15, 2017 at 11:45:43PM +0800, Xueming Li wrote:
> Add echo option to echo commandline to screen when running loaded
> scripts from file.
> 
> Signed-off-by: Xueming Li <xuemingl at mellanox.com>
> ---
>  lib/librte_cmdline/cmdline_socket.c | 5 +++--
>  lib/librte_cmdline/cmdline_socket.h | 3 ++-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_cmdline/cmdline_socket.c b/lib/librte_cmdline/cmdline_socket.c
> index 3fc243b70..e57ddeffb 100644
> --- a/lib/librte_cmdline/cmdline_socket.c
> +++ b/lib/librte_cmdline/cmdline_socket.c
> @@ -73,7 +73,8 @@
>  #include "cmdline.h"
>  
>  struct cmdline *
> -cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
> +cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path,
> +		 int echo)
>  {
>  	int fd;
>  
> @@ -86,7 +87,7 @@ cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
>  		dprintf("open() failed\n");
>  		return NULL;
>  	}
> -	return cmdline_new(ctx, prompt, fd, -1);
> +	return cmdline_new(ctx, prompt, fd, echo ? 1 : -1);
>  }
>  
>  struct cmdline *
> diff --git a/lib/librte_cmdline/cmdline_socket.h b/lib/librte_cmdline/cmdline_socket.h
> index aa6068e7e..208134b12 100644
> --- a/lib/librte_cmdline/cmdline_socket.h
> +++ b/lib/librte_cmdline/cmdline_socket.h
> @@ -68,7 +68,8 @@
>  extern "C" {
>  #endif
>  
> -struct cmdline *cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path);
> +struct cmdline *cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt,
> +				 const char *path, int echo);
>  struct cmdline *cmdline_stdin_new(cmdline_parse_ctx_t *ctx, const char *prompt);
>  void cmdline_stdin_exit(struct cmdline *cl);

This breaks the API and ABI.
And it also breaks the compilation, because the modifications of applications
are done in the next commits.

You can send a deprecation notice, and this patch could be added in for 18.05.

But instead, I suggest you to reimplement your own version of cmdline_file_new()
with the echo feature inside testpmd.


More information about the dev mailing list