summaryrefslogtreecommitdiffstats
path: root/heimdall
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2014-11-16 21:02:07 +0100
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2014-11-16 21:02:39 +0100
commit1ddfdc1a880279ce07b2c43f60b7aa138d4ad315 (patch)
tree4ea142d9013a6dfdf84cab401f561d45ff8ccad4 /heimdall
parentMore empty transfer craziness, this time when receving packets (diff)
downloadHeimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.gz
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.bz2
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.lz
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.xz
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.tar.zst
Heimdall-1ddfdc1a880279ce07b2c43f60b7aa138d4ad315.zip
Diffstat (limited to 'heimdall')
-rw-r--r--heimdall/CMakeLists.txt88
-rw-r--r--heimdall/source/BridgeManager.cpp6
-rw-r--r--heimdall/source/Heimdall.h16
3 files changed, 97 insertions, 13 deletions
diff --git a/heimdall/CMakeLists.txt b/heimdall/CMakeLists.txt
new file mode 100644
index 0000000..8887211
--- /dev/null
+++ b/heimdall/CMakeLists.txt
@@ -0,0 +1,88 @@
+cmake_minimum_required(VERSION 2.8.4)
+
+project(heimdall)
+
+if(WIN32)
+ set(LIBUSB_1_INCLUDE_DIRS
+ ../libusb-1.0/include)
+else(WIN32)
+ find_package(libusb-1.0 REQUIRED)
+endif(WIN32)
+
+set(LIBPIT_INCLUDE_DIRS
+ ../libpit/Source)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+
+include_directories(SYSTEM ${LIBUSB_1_INCLUDE_DIRS})
+
+include_directories(${LIBPIT_INCLUDE_DIRS})
+
+set(HEIMDALL_SOURCE_FILES
+ source/Arguments.cpp
+ source/Arguments.h
+ source/BeginDumpPacket.h
+ source/BeginSessionPacket.h
+ source/BridgeManager.cpp
+ source/BridgeManager.h
+ source/ClosePcScreenAction.cpp
+ source/ClosePcScreenAction.h
+ source/ControlPacket.h
+ source/DetectAction.cpp
+ source/DetectAction.h
+ source/DeviceTypePacket.h
+ source/DownloadPitAction.cpp
+ source/DownloadPitAction.h
+ source/DumpPartFileTransferPacket.h
+ source/DumpPartPitFilePacket.h
+ source/DumpResponse.h
+ source/EndFileTransferPacket.h
+ source/EndModemFileTransferPacket.h
+ source/EndPhoneFileTransferPacket.h
+ source/EndPitFileTransferPacket.h
+ source/EndSessionPacket.h
+ source/FilePartSizePacket.h
+ source/FileTransferPacket.h
+ source/FlashAction.cpp
+ source/FlashAction.h
+ source/FlashPartFileTransferPacket.h
+ source/FlashPartPitFilePacket.h
+ source/Heimdall.h
+ source/HelpAction.cpp
+ source/HelpAction.h
+ source/InboundPacket.h
+ source/InfoAction.cpp
+ source/InfoAction.h
+ source/Interface.cpp
+ source/Interface.h
+ source/main.cpp
+ source/OutboundPacket.h
+ source/Packet.h
+ source/PitFilePacket.h
+ source/PitFileResponse.h
+ source/PrintPitAction.cpp
+ source/PrintPitAction.h
+ source/ReceiveFilePartPacket.h
+ source/ResponsePacket.h
+ source/SendFilePartPacket.h
+ source/SendFilePartResponse.h
+ source/SessionSetupPacket.h
+ source/SessionSetupResponse.h
+ source/SetupSessionPacket.h
+ source/SetupSessionResponse.h
+ source/TotalBytesPacket.h
+ source/Utility.cpp
+ source/Utility.h
+ source/VersionAction.cpp
+ source/VersionAction.h)
+
+include(LargeFiles)
+use_large_files(heimdall YES)
+add_executable(heimdall ${HEIMDALL_SOURCE_FILES})
+
+target_link_libraries(heimdall PRIVATE pit)
+
+LINK_DIRECTORIES(../libusb-1.0/lib/mingw)
+if(WIN32)
+ target_link_libraries(heimdall PRIVATE ${CMAKE_SOURCE_DIR}/libusb-1.0/lib/mingw/libusb-1.0.a)
+endif(WIN32)
diff --git a/heimdall/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp
index 9b8fdfa..8fb678c 100644
--- a/heimdall/source/BridgeManager.cpp
+++ b/heimdall/source/BridgeManager.cpp
@@ -19,7 +19,7 @@
THE SOFTWARE.*/
// C Standard Library
-#include <stdio.h>
+#include <cstdio>
// libusb
#include <libusb.h>
@@ -53,7 +53,9 @@
#include "SessionSetupResponse.h"
// Future versions of libusb will use usb_interface instead of interface.
+#ifndef usb_interface
#define usb_interface interface
+#endif
#define USB_CLASS_CDC_DATA 0x0A
@@ -1035,7 +1037,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
{
sequenceCount++;
- int lastSequenceBytes = fileSize % (fileTransferSequenceMaxLength * fileTransferPacketSize);
+ unsigned int lastSequenceBytes = fileSize % (fileTransferSequenceMaxLength * fileTransferPacketSize);
lastSequenceSize = lastSequenceBytes / fileTransferPacketSize;
if (partialPacketByteCount != 0)
diff --git a/heimdall/source/Heimdall.h b/heimdall/source/Heimdall.h
index 3982dd4..c5c11ef 100644
--- a/heimdall/source/Heimdall.h
+++ b/heimdall/source/Heimdall.h
@@ -21,7 +21,7 @@
#ifndef HEIMDALL_H
#define HEIMDALL_H
-#ifdef OS_WINDOWS
+#ifdef _MSC_VER // Microsoft Visual C Standard Library
#include <Windows.h>
#undef GetBinaryType
@@ -36,24 +36,18 @@
#define FileTell(FILE) _ftelli64(FILE)
#define FileRewind(FILE) rewind(FILE)
-#else
+#else // POSIX Standard Library
-#include "../config.h"
-
-#if defined(OS_DARWIN) || defined(OS_LINUX)
#include <unistd.h>
+
#define Sleep(t) usleep(1000*t)
#define FileOpen(FILE, MODE) fopen(FILE, MODE)
#define FileClose(FILE) fclose(FILE)
-#define FileSeek(FILE, OFFSET, ORIGIN) fseeko(FILE, OFFSET, ORIGIN)
-#define FileTell(FILE) ftello(FILE)
+#define FileSeek(FILE, OFFSET, ORIGIN) fseeko64(FILE, OFFSET, ORIGIN)
+#define FileTell(FILE) ftello64(FILE)
#define FileRewind(FILE) rewind(FILE)
-#else
-#error operating system not supported
-#endif
-
#endif
#if (!(defined _MSC_VER) || (_MSC_VER < 1700))