Rework Cmd exposed API, use more static and fix [-Wmissing-prototypes], ongoing...

This commit is contained in:
Philippe Teuwen 2019-04-12 01:55:25 +02:00
commit f6a6ec8447
21 changed files with 760 additions and 746 deletions

View file

@ -64,6 +64,7 @@ static int usage_hitag_info(void) {
PrintAndLogEx(NORMAL, " lf hitag info");
return 0;
}
/*
static int usage_hitag_dump(void) {
PrintAndLogEx(NORMAL, "Usage: lf hitag dump [h] p <pwd> f <name>");
PrintAndLogEx(NORMAL, "Options:");
@ -76,6 +77,7 @@ static int usage_hitag_dump(void) {
PrintAndLogEx(NORMAL, " lf hitag dump p 4D494B52 f mydump");
return 0;
}
*/
static int usage_hitag_reader(void) {
PrintAndLogEx(NORMAL, "Hitag reader functions");
PrintAndLogEx(NORMAL, "Usage: lf hitag reader [h] <reader function #>");
@ -120,7 +122,7 @@ static int usage_hitag_checkchallenges(void) {
return 0;
}
int CmdLFHitagList(const char *Cmd) {
static int CmdLFHitagList(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
CmdTraceList("hitag");
return 0;
@ -253,7 +255,7 @@ int CmdLFHitagList(const char *Cmd) {
*/
}
int CmdLFHitagSniff(const char *Cmd) {
static int CmdLFHitagSniff(const char *Cmd) {
char ctmp = tolower(param_getchar(Cmd, 0));
if (ctmp == 'h') return usage_hitag_sniff();
@ -264,7 +266,7 @@ int CmdLFHitagSniff(const char *Cmd) {
return 0;
}
int CmdLFHitagSim(const char *Cmd) {
static int CmdLFHitagSim(const char *Cmd) {
bool errors = false;
bool tag_mem_supplied = false;
@ -476,7 +478,7 @@ static bool getHitagUid(uint32_t *uid) {
return true;
}
int CmdLFHitagInfo(const char *Cmd) {
static int CmdLFHitagInfo(const char *Cmd) {
PrintAndLogEx(INFO, "Hitag2 tag information ");
PrintAndLogEx(INFO, "To be done!");
PrintAndLogEx(INFO, "------------------------------------");
@ -509,7 +511,7 @@ int CmdLFHitagInfo(const char *Cmd) {
// TODO: iceman
// Hitag2 reader, problem is that this command mixes up stuff. So 26 give uid. 21 etc will also give you a memory dump !?
//
int CmdLFHitagReader(const char *Cmd) {
static int CmdLFHitagReader(const char *Cmd) {
UsbCommand c = {CMD_READER_HITAG, {0, 0, 0}, {{0}}};
hitag_data *htd = (hitag_data *)c.d.asBytes;
@ -590,7 +592,7 @@ int CmdLFHitagReader(const char *Cmd) {
return 0;
}
int CmdLFHitagCheckChallenges(const char *Cmd) {
static int CmdLFHitagCheckChallenges(const char *Cmd) {
UsbCommand c = { CMD_TEST_HITAGS_TRACES, {0, 0, 0}, {{0}}};
char filename[FILE_PATH_SIZE] = { 0x00 };
@ -640,7 +642,7 @@ int CmdLFHitagCheckChallenges(const char *Cmd) {
return 0;
}
int CmdLFHitagWriter(const char *Cmd) {
static int CmdLFHitagWriter(const char *Cmd) {
UsbCommand c = { CMD_WR_HITAG_S, {0, 0, 0}, {{0}}};
hitag_data *htd = (hitag_data *)c.d.asBytes;
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
@ -681,7 +683,8 @@ int CmdLFHitagWriter(const char *Cmd) {
return 0;
}
int CmdLFHitagDump(const char *Cmd) {
/*
static int CmdLFHitagDump(const char *Cmd) {
PrintAndLogEx(INFO, "Dumping of tag memory");
PrintAndLogEx(INFO, "To be done!");
@ -689,6 +692,7 @@ int CmdLFHitagDump(const char *Cmd) {
if (ctmp == 'h') return usage_hitag_dump();
return 0;
}
*/
static command_t CommandTable[] = {
{"help", CmdHelp, 1, "This help" },
@ -702,14 +706,18 @@ static command_t CommandTable[] = {
{ NULL, NULL, 0, NULL }
};
static int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
CmdsHelp(CommandTable);
return 0;
}
int CmdLFHitag(const char *Cmd) {
clearCommandBuffer();
CmdsParse(CommandTable, Cmd);
return 0;
}
int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
CmdsHelp(CommandTable);
return 0;
int readHitagUid(void) {
return CmdLFHitagReader("26") == 0;
}