Re: [vpp-dev] Regarding CLI command parsing

2018-08-14 Thread Prashant Upadhyaya
Thanks Dave !
Your trick worked for me exactly as I needed.

Regards
-Prashant


On Mon, Aug 13, 2018 at 11:39 PM, Dave Barach (dbarach)
 wrote:
> Try this in mycmd:
>
> u8 * line;
> if (unformat (input, "%U", unformat_line, &line))
>process_line;
>
> Note that line will be a true u8 * vector: no null-termination. If you need 
> null termination: vec_add1 (line, 0);
>
> Remember to vec_free(...) it unless you're planning to keep it.
>
> HTH... Dave
>
> -Original Message-
> From: vpp-dev@lists.fd.io  On Behalf Of Prashant 
> Upadhyaya
> Sent: Monday, August 13, 2018 1:53 PM
> To: vpp-dev@lists.fd.io
> Subject: [vpp-dev] Regarding CLI command parsing
>
> Hi,
>
> I am relatively new to this and trying to learn the art of using 
> format/unformat.
> My requirement is that if my command is "mycmd" followed by some string 
> (which may have spaces in it), then I should be able to read the entire 
> string up to the \n character typed by the user.
>
> Eg. if the command is typed like
>
> mycmd foo1 foo2 foo3
>
> (the "path" of the VLIB_CLI_COMMAND  is "mycmd") Then in my CLI callback 
> function, I want to be able to get the string
> "foo1 foo2 foo3" setup in a u8* variable. If the leading and trailing spaces 
> are trimmed, I am fine by that. I am looking for the correct way to call the 
> unformat functions in my command callback function to achieve this.
>
> Regards
> -Prashant
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#10139): https://lists.fd.io/g/vpp-dev/message/10139
Mute This Topic: https://lists.fd.io/mt/24505388/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [vpp-dev] Regarding CLI command parsing

2018-08-13 Thread Dave Barach via Lists.Fd.Io
Try this in mycmd:

u8 * line;
if (unformat (input, "%U", unformat_line, &line))
   process_line;

Note that line will be a true u8 * vector: no null-termination. If you need 
null termination: vec_add1 (line, 0); 

Remember to vec_free(...) it unless you're planning to keep it.

HTH... Dave

-Original Message-
From: vpp-dev@lists.fd.io  On Behalf Of Prashant Upadhyaya
Sent: Monday, August 13, 2018 1:53 PM
To: vpp-dev@lists.fd.io
Subject: [vpp-dev] Regarding CLI command parsing

Hi,

I am relatively new to this and trying to learn the art of using 
format/unformat.
My requirement is that if my command is "mycmd" followed by some string (which 
may have spaces in it), then I should be able to read the entire string up to 
the \n character typed by the user.

Eg. if the command is typed like

mycmd foo1 foo2 foo3

(the "path" of the VLIB_CLI_COMMAND  is "mycmd") Then in my CLI callback 
function, I want to be able to get the string
"foo1 foo2 foo3" setup in a u8* variable. If the leading and trailing spaces 
are trimmed, I am fine by that. I am looking for the correct way to call the 
unformat functions in my command callback function to achieve this.

Regards
-Prashant
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#10132): https://lists.fd.io/g/vpp-dev/message/10132
Mute This Topic: https://lists.fd.io/mt/24505388/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-