diff --git a/src/apdu.c b/src/apdu.c index 7e546cf..e4022a3 100644 --- a/src/apdu.c +++ b/src/apdu.c @@ -30,7 +30,7 @@ int process_apdu() { { if (INS(apdu) == 0xA4 && P1(apdu) == 0x04 && (P2(apdu) == 0x00 || P2(apdu) == 0x4)) { //select by AID for (int a = 0; a < num_apps; a++) { - if ((current_app = apps[a].select_aid(&apps[a]))) { + if ((current_app = apps[a].select_aid(&apps[a], apdu.data, apdu.nc))) { return set_res_sw(0x90,0x00); } } @@ -169,6 +169,7 @@ void apdu_thread() { //printf("EXIT !!!!!!\r\n"); if (current_app && current_app->unload) { current_app->unload(); + current_app = NULL; } } diff --git a/src/apdu.h b/src/apdu.h index c2a0bee..4bcabe9 100644 --- a/src/apdu.h +++ b/src/apdu.h @@ -25,11 +25,18 @@ typedef struct app { const uint8_t *aid; int (*process_apdu)(); - struct app* (*select_aid)(); + struct app* (*select_aid)(struct app *, const uint8_t *, uint8_t); int (*unload)(); } app_t; -extern int register_app(app_t * (*)()); +extern int register_app(app_t * (*)(app_t *, const uint8_t *, uint8_t)); + +typedef struct cmd +{ + uint8_t ins; + int (*cmd_handler)(); +} cmd_t; + #if defined(DEBUG_APDU) && DEBUG_APDU == 1 #define DEBUG_PAYLOAD(_p,_s) { \ diff --git a/src/main.c b/src/main.c index f3dc2af..ca77d51 100644 --- a/src/main.c +++ b/src/main.c @@ -50,7 +50,7 @@ uint8_t num_apps = 0; app_t *current_app = NULL; -int register_app(app_t * (*select_aid)()) { +int register_app(app_t * (*select_aid)(app_t *, const uint8_t *, uint8_t)) { if (num_apps < sizeof(apps)/sizeof(app_t)) { apps[num_apps].select_aid = select_aid; num_apps++;