X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/8d0a3e87d7d2350f4a05698a42f57625e460e5d6..395ec4e99ca757472fa962345552e3f01ea0c154:/client/loclass/fileutils.c

diff --git a/client/loclass/fileutils.c b/client/loclass/fileutils.c
index 74c36a4d..e5e5c5b0 100644
--- a/client/loclass/fileutils.c
+++ b/client/loclass/fileutils.c
@@ -35,6 +35,7 @@
  * 
  * 
  ****************************************************************************/
+#ifndef ON_DEVICE
 
 #include <stdio.h>
 #include <string.h>
@@ -51,11 +52,11 @@
 int fileExists(const char *filename) {
 
 #ifdef _WIN32
-	struct _stat fileStat;
-	int result = _stat(filename, &fileStat);
+	struct _stat st;
+	int result = _stat(filename, &st);
 #else
-	struct stat fileStat;
-	int result = stat(filename, &fileStat);
+	struct stat st;
+	int result = stat(filename, &st);
 #endif
 	return result == 0;
 }
@@ -76,30 +77,20 @@ int saveFile(const char *preferredName, const char *suffix, const void* data, si
 	/* We should have a valid filename now, e.g. dumpdata-3.bin */
 
 	/*Opening file for writing in binary mode*/
-	FILE *fh=fopen(fileName,"wb");
-	if(!fh) {
-		PrintAndLog("Failed to write to file '%s'", fileName);
+	FILE *fileHandle=fopen(fileName,"wb");
+	if(!fileHandle) {
+		prnlog("Failed to write to file '%s'", fileName);
+		free(fileName);
 		return 1;
 	}
-	fwrite(data, 1,	datalen, fh);
-	fclose(fh);
-	PrintAndLog("Saved data to '%s'", fileName);
+	fwrite(data, 1,	datalen, fileHandle);
+	fclose(fileHandle);
+	prnlog("Saved data to '%s'", fileName);
 	free(fileName);
 
 	return 0;
 }
 
-int loadFile(const char *fileName, void* data, size_t datalen)
-{
-	FILE *filehandle = fopen(fileName, "rb");
-	if(!filehandle) {
-		PrintAndLog("Failed to read from file '%s'", fileName);
-		return 1;
-	}
-	fread(data,datalen,1,filehandle);
-	fclose(filehandle);
-	return 0;
-}
 /**
  * Utility function to print to console. This is used consistently within the library instead
  * of printf, but it actually only calls printf (and adds a linebreak).
@@ -110,11 +101,18 @@ int loadFile(const char *fileName, void* data, size_t datalen)
  */
 void prnlog(char *fmt, ...)
 {
-
+	char buffer[2048] = {0};
 	va_list args;
 	va_start(args,fmt);
-    PrintAndLog(fmt, args);
-    //vprintf(fmt,args);
+	vsprintf (buffer,fmt, args);
 	va_end(args);
-    //printf("\n");
+	PrintAndLog(buffer);
+
+}
+#else //if we're on ARM
+void prnlog(char *fmt,...)
+{
+	return;
 }
+
+#endif