refactor fido2 commands to use load and save fcts from fileutils.c. They will now load from /client/resources and save a new file in working dir

This commit is contained in:
iceman1001 2021-05-08 14:59:40 +02:00
parent 25cdc321cd
commit cbf045dddb
4 changed files with 192 additions and 245 deletions

View file

@ -639,6 +639,9 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data,
}
break;
}
case jsfFido: {
break;
}
case jsfCustom: {
(*callback)(root);
break;
@ -663,6 +666,28 @@ out:
free(fileName);
return retval;
}
int saveFileJSONroot(const char *preferredName, void *root, size_t flags, bool verbose) {
if (root == NULL)
return PM3_EINVARG;
char *filename = newfilenamemcopy(preferredName, ".json");
if (filename == NULL)
return PM3_EMALLOC;
int res = json_dump_file(root, filename, flags);
free(filename);
if ( res == 0 ) {
if (verbose) {
PrintAndLogEx(SUCCESS, "saved to json file " _YELLOW_("%s"), filename);
}
return PM3_SUCCESS;
} else {
PrintAndLogEx(FAILED, "error: can't save the file: " _YELLOW_("%s"), filename);
}
return PM3_EFILE;
}
int saveFileWAVE(const char *preferredName, int *data, size_t datalen) {