The main part is just this:
int
app_delete(FreefareTag tag, MifareDESFireAID aid) {
int res;
res = mifare_desfire_select_application(tag, NULL);
res = mifare_desfire_delete_application(tag, aid);
if (res < 0) {
warn ("Couldn't delete the application");
} else {
printf ("Success!\n");
}
return res;
}
The init/open/connect sequence is ripped right from another example, and the following works fine:
int
apps_list(FreefareTag tag)
{
MifareDESFireAID *aids = NULL;
size_t count;
int res;
res = mifare_desfire_get_application_ids(tag, &aids, &count);
if (res < 0) {
warn ("Can't retrieve tag AIDs");
return res;
}
printf("Applications: %d\n", count);
for(int i = 0; aids[i]; i++) {
printf("[%d] %#08x\n", i, mifare_desfire_aid_get_aid(aids[i]));
}
mifare_desfire_free_application_ids(aids);
return 0;
}