chg: 'hf mf csave'

chg: 'mem save'
chg: 'hf 15 dump' - no extra newline after last block in emlfile
This commit is contained in:
iceman1001 2018-05-03 11:02:50 +02:00
parent 53feba2bbe
commit 0e7d8faf59
3 changed files with 12 additions and 9 deletions

View file

@ -2950,7 +2950,9 @@ int CmdHF14AMfCSave(const char *Cmd) {
// eml
for (j = 0; j < 16; j++)
fprintf(feml, "%02x", buf[j]);
fprintf(feml,"\n");
if (i != numBlocks -1)
fprintf(feml,"\n");
// bin
fwrite(buf, 1, sizeof(buf), fbin);

View file

@ -57,9 +57,7 @@ int fileExists(const char *filename) {
int saveFile(const char *preferredName, const char *suffix, const void* data, size_t datalen) {
int size = sizeof(char) * (strlen(preferredName) + strlen(suffix) + 10);
char * fileName = malloc(size);
memset(fileName, 0, size);
char * fileName = calloc(size,sizeof(char));
int num = 1;
sprintf(fileName,"%s.%s", preferredName, suffix);
while (fileExists(fileName)) {
@ -91,11 +89,10 @@ int saveFileEML(const char *preferredName, const char *suffix, uint8_t* data, si
int retval = 0;
int blocks = datalen/blocksize;
uint16_t currblock = 1;
int i,j;
int size = sizeof(char) * (strlen(preferredName) + strlen(suffix) + 10);
char * fileName = malloc(size);
memset(fileName, 0, size);
char * fileName = calloc(size, sizeof(char));
int num = 1;
sprintf(fileName,"%s.%s", preferredName, suffix);
while (fileExists(fileName)) {
@ -115,8 +112,12 @@ int saveFileEML(const char *preferredName, const char *suffix, uint8_t* data, si
for (i = 0; i < datalen; i++) {
fprintf(f, "%02X", data[i] );
if ( (i+1) % blocksize == 0)
// no extra line in the end
if ( (i+1) % blocksize == 0 && currblock != blocks ) {
fprintf(f, "\n");
currblock++;
}
}
// left overs
if ( datalen % blocksize != 0) {

View file

@ -620,7 +620,7 @@ int saveTraceCard(void) {
// no extra line in the end
if ( i < 255 )
fprintf(f,"\n");
fprintf(f, "\n");
}
fflush(f);
fclose(f);