mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
fix: rem - now handles cliparse and strings correct
This commit is contained in:
parent
859f0b4d84
commit
9db2a04449
1 changed files with 20 additions and 4 deletions
|
@ -165,19 +165,35 @@ int CmdRem(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "rem",
|
CLIParserInit(&ctx, "rem",
|
||||||
"Add a text line in log file",
|
"Add a text line in log file",
|
||||||
"rem"
|
"rem my message -> adds a timestamp with `my message`"
|
||||||
);
|
);
|
||||||
|
|
||||||
void *argtable[] = {
|
void *argtable[] = {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
|
arg_strx1(NULL, NULL, NULL, "message line you want inserted"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
CLIParserFree(ctx);
|
|
||||||
|
|
||||||
|
struct arg_str* foo = arg_get_str(ctx, 1);
|
||||||
|
size_t count = 0;
|
||||||
|
size_t len = 0;
|
||||||
|
do {
|
||||||
|
count += strlen(foo->sval[len]);
|
||||||
|
} while (len++ < (foo->count - 1));
|
||||||
|
|
||||||
|
char s[count + foo->count];
|
||||||
|
memset(s, 0, sizeof(s));
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
do {
|
||||||
|
snprintf(s + strlen(s), sizeof(s) - strlen(s), "%s ", foo->sval[len]);
|
||||||
|
} while (len++ < (foo->count - 1));
|
||||||
|
|
||||||
|
CLIParserFree(ctx);
|
||||||
char buf[22] = {0};
|
char buf[22] = {0};
|
||||||
AppendDate(buf, sizeof(buf), NULL);
|
AppendDate(buf, sizeof(buf), NULL);
|
||||||
PrintAndLogEx(NORMAL, "%s remark: %s", buf, Cmd);
|
PrintAndLogEx(SUCCESS, "%s remark: %s", buf, s);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue