libcli icon indicating copy to clipboard operation
libcli copied to clipboard

Get all strings entered in a submode

Open dinuraj opened this issue 6 years ago • 1 comments

I want to create a submode for the user to enter a sequence of strings. They are arbitrary strings and not predetermined keywords. The strings should be processed by a supplied function line by line. Can I do this with libcli ?

dinuraj avatar Feb 14 '19 00:02 dinuraj

Yes, we do this all the time. The 'command' argument of the callback shows what libcli has parsed based on what you've registered. If you have any libcli filters in place those are handled differently. You can use 'cli->filters' to see if there are any filters (if no filters then cli->filters is NULL). The argc/argv pair of arguments show what is left. Note that 'argv[argc]' will be NULL at the end of any user entered 'words'. The following code snippet (warning, typed w/o testing) should show all user entered data after libcli has process the command itself, and will include any filters.

int myArgc;
cli_print(cli, "Libcli processed command is -> %s", command);
for (myArgc=argc; argv[myArgc]; myArgc++)
{
  cli_print(cli, "Argument %s is -> %d", myArgc, argv[myArgc]);
}

RobSanders avatar Apr 22 '19 15:04 RobSanders