From d3c282f9179de48d66b850444ea688bfd02c40d7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 16 Aug 2010 13:09:04 +0800 Subject: actually call functions to modify the dump file --- easytool/easytool.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'easytool') diff --git a/easytool/easytool.c b/easytool/easytool.c index 75cec83..2e7ada3 100644 --- a/easytool/easytool.c +++ b/easytool/easytool.c @@ -42,16 +42,24 @@ /* Easycard specific includes */ #include "easycard.h" -#define VERSION "0.03" +#define VERSION "0.04" #define COPYRIGHT \ "EasyTool "VERSION" (C) 2010 by Harald Welte \n" \ "This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n" \ "Use of this software is authorized for RESEARCH PURPOSE ONLY!\n\n" +enum mode { + MODE_DUMP_MFACC, + MODE_DUMP, + MODE_RECHARGE, + MODE_PURCHASE, +}; + struct { int fd; unsigned long size; mifare_tag *mft; + enum mode mode; } global; static void dump_acc_bits(const struct acc_bits_parsed *abp) @@ -126,19 +134,14 @@ static void print_help(void) { } -enum mode { - MODE_DUMP_MFACC, - MODE_DUMP, - MODE_RECHARGE, - MODE_PURCHASE, -}; - int main(int argc, char **argv) { - enum mode mode = MODE_DUMP; + struct stat st; int delta = 0; int option_index = 0; - struct stat st; + int rc; + + global.mode = MODE_DUMP; printf(COPYRIGHT); @@ -159,14 +162,14 @@ int main(int argc, char **argv) switch (c) { case 'a': - mode = MODE_DUMP_MFACC; + global.mode = MODE_DUMP_MFACC; break; case 'r': - mode = MODE_RECHARGE; + global.mode = MODE_RECHARGE; delta = atoi(optarg); break; case 'p': - mode = MODE_PURCHASE; + global.mode = MODE_PURCHASE; delta = atoi(optarg); break; case 'h': @@ -200,7 +203,7 @@ int main(int argc, char **argv) exit(1); } - switch (mode) { + switch (global.mode) { case MODE_DUMP_MFACC: dump_mfcl(global.mft); break; @@ -208,8 +211,10 @@ int main(int argc, char **argv) dump_easycard(global.mft); break; case MODE_RECHARGE: + rc = easy_alter_last_recharge(global.mft, delta); break; case MODE_PURCHASE: + rc = easy_alter_last_purchase(global.mft, delta); break; } -- cgit v1.2.3