]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdparser.c
48d044d591e1583f5da7f3c932006b6f627aad5c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
14 #include "cmdparser.h"
15 #include "proxmark3.h"
17 void CmdsHelp(const command_t Commands
[])
19 if (Commands
[0].Name
== NULL
)
22 while (Commands
[i
].Name
)
24 if (offline
== 0 || Commands
[i
].Offline
)
25 PrintAndLog("%-16s %s", Commands
[i
].Name
, Commands
[i
].Help
);
26 if (offline
== 2 && !Commands
[i
].Offline
)
27 PrintAndLog("%-14s @ %s", Commands
[i
].Name
, Commands
[i
].Help
);
32 void CmdsParse(const command_t Commands
[], const char *Cmd
)
36 memset(cmd_name
, 0, 32);
37 sscanf(Cmd
, "%31s%n", cmd_name
, &len
);
39 while (Commands
[i
].Name
&& strcmp(Commands
[i
].Name
, cmd_name
))
42 /* try to find exactly one prefix-match */
43 if(!Commands
[i
].Name
) {
47 for(i
=0;Commands
[i
].Name
;i
++) {
48 if( !strncmp(Commands
[i
].Name
, cmd_name
, strlen(cmd_name
)) ) {
53 if(matches
== 1) i
=last_match
;
56 if (Commands
[i
].Name
) {
57 while (Cmd
[len
] == ' ')
59 Commands
[i
].Parse(Cmd
+ len
);
61 // show help for selected hierarchy or if command not recognised