]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
Fix windows compilation issues. But still not final. We should move to pthread and...
authorizsh@fail0verflow.com <izsh@fail0verflow.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 20 Feb 2010 00:36:48 +0000 (00:36 +0000)
committerizsh@fail0verflow.com <izsh@fail0verflow.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 20 Feb 2010 00:36:48 +0000 (00:36 +0000)
client/Makefile
client/cmdmain.c
client/flash.c
client/flash.h
client/prox.c
client/proxusb.h
client/ui.c
client/wingui.c

index 65788beb040190d1e0e430ae5a7fb2cf36792a87..d0978a9891d3a116d635cde1ca18a656ceacf21c 100644 (file)
@@ -1,4 +1,4 @@
-WINCC=c:\mingw\bin\gcc
+CC=gcc
 #COMMON_FLAGS = -m32
 
 VPATH = ../common
@@ -12,8 +12,8 @@ CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall
 QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
 
 CMDSRCS = \
-                       $(VPATH)\crc16.c \
-                       $(VPATH)\iso14443crc.c \
+                       crc16.c \
+                       iso14443crc.c \
                        data.c \
                        graph.c \
                        ui.c \
@@ -64,8 +64,8 @@ all: $(BINS)
 all-static: LDLIBS:=-static $(LDLIBS)
 all-static: snooper cli flasher
 
-prox.exe: prox.c wingui.c $(CMDSRCS) flash.c
-       $(WINCC) $(CFLAGS) $(DEFINES) -o prox.exe prox.c wingui.c $(CMDSRCS) flash.c $(WINLIBS)
+prox.exe: prox.o wingui.o $(CMDOBJS) flash.o
+       $(CC) $(CFLAGS) $(DEFINES) -o prox.exe prox.o wingui.o $(CMDOBJS) flash.c $(WINLIBS)
        
 proxmark3: LDLIBS+=$(QTLDLIBS)
 proxmark3: proxmark3.o $(CMDOBJS) proxusb.o $(QTGUI)
index c6d59e2e1daf421a418848d91ba6b109c72200e8..1e49e6cbcee9eb66b72843c63879dfdcb6d07c77 100644 (file)
@@ -2,9 +2,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#ifdef WIN32
-#include <windows.h>
-#endif
+#include "sleep.h"
 #include "cmdparser.h"
 #include "data.h"
 #include "usb_cmd.h"
@@ -14,7 +12,6 @@
 #include "cmdhw.h"
 #include "cmdlf.h"
 #include "cmdmain.h"
-#include "proxusb.h"
 
 unsigned int current_command = CMD_UNKNOWN;
 unsigned int received_command = CMD_UNKNOWN;
@@ -50,13 +47,16 @@ void WaitForResponse(uint32_t response_type)
 {
   while (received_command != response_type) {
 #ifdef WIN32
+    // FIXME: Do we really need this under windows or is it
+    // just some historical code?
+    // pthread seems to be availabe for win32 nowadays
+    // so we should be able to port the code and get rid
+    // of this part.
     UsbCommand c;
     if (ReceiveCommandPoll(&c))
       UsbCommandReceived(&c);
-    Sleep(0);
-#else
-    usleep(10000); // XXX ugh
 #endif
+    msleep(10); // XXX ugh
   }
   received_command = CMD_UNKNOWN;
 }
index ee66dbe17da1bd5a7e3146fb7bc970aaa3f8403e..b4e4c8918b21e82df6ad8638ff005ae4f685f21d 100644 (file)
@@ -14,7 +14,6 @@ BOOL UsbConnect(void);
 
 static uint32_t ExpectedAddr;
 static uint8_t QueuedToSend[256];
-static bool AllWritten;
 #define PHYSICAL_FLASH_START 0x100000
 #define PHYSICAL_FLASH_END   0x200000
 
@@ -63,8 +62,6 @@ void WriteBlock(unsigned int block_start, unsigned int len, unsigned char *buf)
   memcpy(c.d.asBytes, temp_buf+240, 16);
   SendCommand(&c);
   WaitForAck();
-
-  AllWritten = true;
 }
 
 void LoadFlashFromFile(const char *file, int start_addr, int end_addr)
index ab4fca967a3615a13408679254103565ab332dc4..20090db7c88ae1e008936464ac88f1a827a5b9dc 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __FLASH_H__
 #define __FLASH_H__
 
+#include <stdint.h>
+
 struct partition {
   int start;
   int end;
index 190cfd70999bba0ec0afedd665c70e32aabaadbf..d619c821c2d54a0b3251a76be2aadf5fdc430910 100644 (file)
@@ -3,16 +3,15 @@
 #include <stdio.h>\r
 #include <ctype.h>\r
 #include <stdlib.h>\r
-#include <stdint.h>\r
 //extern "C" {\r
 #include "include/hidusage.h"\r
 #include "include/hidpi.h"\r
 #include "include/hidsdi.h"\r
 //}\r
 \r
-#include "ui.h"\r
 #include "flash.h"\r
-#include "proxusb.h"\r
+#include "usb_cmd.h"\r
+#include "ui.h"\r
 \r
 #define OUR_VID 0x9ac4\r
 #define OUR_PID 0x4b8f\r
index 4ee00750d316dafdafa44a32eba16636e954e33e..32a334c68edec7690796388d288c8e57d10d6b2d 100644 (file)
@@ -1,14 +1,10 @@
 #ifndef PROXUSB_H__
 #define PROXUSB_H__
 
-#ifdef _MSC_VER
-typedef DWORD uint32_t;
-typedef BYTE uint8_t;
-typedef WORD uint16_t;
-#define bool BOOL
-#else
 #include <stdint.h>
 #include <stdbool.h>
+#ifndef WIN32
+#include <usb.h>
 #endif
 #include "usb_cmd.h"
 
index 9f4377c87322966039482b796303aa0c154e9182..99c9f17007240191a7da4f14fd6b6464385a096c 100644 (file)
@@ -10,6 +10,11 @@ int offline;
 
 static char *logfilename = "proxmark3.log";
 
+// FIXME: ifndef not really nice...
+// We should eventually get rid of it once
+// we fully factorize the code between *nix and windows
+// (using pthread and alikes...)
+#ifndef WIN32
 void PrintAndLog(char *fmt, ...)
 {
   va_list argptr, argptr2;
@@ -30,23 +35,13 @@ void PrintAndLog(char *fmt, ...)
   va_end(argptr);
   printf("\n");
   if (logging && logfile) {
-#if 0
-    char zeit[25];
-    time_t jetzt_t;
-    struct tm *jetzt;
-
-    jetzt_t = time(NULL);
-    jetzt = localtime(&jetzt_t);
-    strftime(zeit, 25, "%b %e %T", jetzt);
-
-    fprintf(logfile,"%s ", zeit);
-#endif
     vfprintf(logfile, fmt, argptr2);
     fprintf(logfile,"\n");
     fflush(logfile);
   }
   va_end(argptr2);
 }
+#endif
 
 void SetLogFilename(char *fn)
 {
index 6c7ef52906c90b19aef7728c34aab923f93ffb32..9fcf5ea6758244779c40dbfe0a19eabd1b631644 100644 (file)
 #include <stdlib.h>\r
 #include <stdio.h>\r
 #include <math.h>\r
-#include "graph.h"\r
+\r
 #include "proxusb.h"\r
-#include "cmdmain.h"\r
+#include "graph.h"\r
 #include "ui.h"\r
+#include "cmdmain.h"\r
 \r
 #define oops() do { \\r
        char line[100]; \\r
@@ -354,7 +355,7 @@ nopaint:
        return 1;\r
 }\r
 \r
-void PrintToScrollback(char *fmt, ...)\r
+void PrintAndLog(char *fmt, ...)\r
 {\r
        va_list f;\r
        char str[1024];\r
@@ -450,8 +451,8 @@ void ShowGui()
        ResizeCommandWindow();\r
        SetFocus(CommandEdit);\r
 \r
-       PrintToScrollback(">> Started prox, built " __DATE__ " " __TIME__);\r
-       PrintToScrollback(">> Connected to device");\r
+       PrintAndLog(">> Started prox, built " __DATE__ " " __TIME__);\r
+       PrintAndLog(">> Connected to device");\r
 \r
        GreyPenLite = CreatePen(PS_SOLID, 1, RGB(50, 50, 50));\r
        GreyPen = CreatePen(PS_SOLID, 1, RGB(100, 100, 100));\r
Impressum, Datenschutz