mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-12-29 11:52:59 +08:00
Merge pull request #2139 from jmichelp/quotes
Support double-quoted arguments in CLI
This commit is contained in:
commit
119a4c5efa
2 changed files with 17 additions and 0 deletions
|
@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Add support for quoted arguments in the CLI, allowing spaces in them which
|
||||
are removed automatically (@jmichelp)
|
||||
- Added UDP support on Windows (@wh201906)
|
||||
- Added client communication timeout to preferences (@iceman1001)
|
||||
- Added IPv6 support (@wh201906)
|
||||
|
|
|
@ -147,6 +147,7 @@ enum ParserState {
|
|||
PS_FIRST,
|
||||
PS_ARGUMENT,
|
||||
PS_OPTION,
|
||||
PS_QUOTE,
|
||||
};
|
||||
|
||||
#define isSpace(c)(c == ' ' || c == '\t')
|
||||
|
@ -195,6 +196,10 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab
|
|||
case PS_ARGUMENT:
|
||||
if (state == PS_FIRST)
|
||||
state = PS_ARGUMENT;
|
||||
if (str[i] == '"') {
|
||||
state = PS_QUOTE;
|
||||
break;
|
||||
}
|
||||
if (isSpace(str[i])) {
|
||||
spaceptr = bufptr;
|
||||
state = PS_FIRST;
|
||||
|
@ -215,6 +220,16 @@ int CLIParserParseStringEx(CLIParserContext *ctx, const char *str, void *vargtab
|
|||
*bufptr = str[i];
|
||||
bufptr++;
|
||||
break;
|
||||
case PS_QUOTE:
|
||||
if (str[i] == '"') {
|
||||
*bufptr++ = 0x00;
|
||||
state = PS_FIRST;
|
||||
} else {
|
||||
if (isSpace(str[i]) == false) {
|
||||
*bufptr++ = str[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (bufptr > bufptrend) {
|
||||
PrintAndLogEx(ERR, "ERROR: Line too long\n");
|
||||
|
|
Loading…
Reference in a new issue