]>
Commit | Line | Data |
---|---|---|
7fe9b0b7 | 1 | #include <stdio.h> |
2 | #include <string.h> | |
3 | #include "ui.h" | |
4 | #include "cmdparser.h" | |
5 | ||
6 | void CmdsHelp(const command_t Commands[]) | |
7 | { | |
8 | if (Commands[0].Name == NULL) | |
9 | return; | |
10 | int i = 0; | |
11 | while (Commands[i].Name) | |
12 | { | |
13 | if (!offline || Commands[i].Offline) | |
14 | PrintAndLog("%-16s %s", Commands[i].Name, Commands[i].Help); | |
15 | ++i; | |
16 | } | |
17 | } | |
18 | ||
19 | void CmdsParse(const command_t Commands[], const char *Cmd) | |
20 | { | |
21 | char cmd_name[32]; | |
22 | int len = 0; | |
23 | memset(cmd_name, 0, 32); | |
24 | sscanf(Cmd, "%31s%n", cmd_name, &len); | |
25 | int i = 0; | |
26 | while (Commands[i].Name && strcmp(Commands[i].Name, cmd_name)) | |
27 | ++i; | |
28 | if (Commands[i].Name) | |
29 | Commands[i].Parse(Cmd + len); | |
30 | else | |
31 | PrintAndLog("Command not found"); | |
32 | } |