]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdparser.c
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"
16 void CmdsHelp(const command_t Commands
[])
18 if (Commands
[0].Name
== NULL
)
21 while (Commands
[i
].Name
)
23 if (!offline
|| Commands
[i
].Offline
)
24 PrintAndLog("%-16s %s", Commands
[i
].Name
, Commands
[i
].Help
);
29 void CmdsParse(const command_t Commands
[], const char *Cmd
)
33 memset(cmd_name
, 0, 32);
34 sscanf(Cmd
, "%31s%n", cmd_name
, &len
);
36 while (Commands
[i
].Name
&& strcmp(Commands
[i
].Name
, cmd_name
))
39 /* try to find exactly one prefix-match */
40 if(!Commands
[i
].Name
) {
44 for(i
=0;Commands
[i
].Name
;i
++) {
45 if( !strncmp(Commands
[i
].Name
, cmd_name
, strlen(cmd_name
)) ) {
50 if(matches
== 1) i
=last_match
;
53 if (Commands
[i
].Name
) {
54 while (Cmd
[len
] == ' ')
56 Commands
[i
].Parse(Cmd
+ len
);
58 // show help for selected hierarchy or if command not recognised