From c671f10c07f59b7e2dfda332c99a3182c32cb689 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 13 Jan 2014 15:40:40 +0100 Subject: [PATCH] preliminary cmake support. linking still broken. --- CMakeLists.txt | 17 +++++++++++++++-- src/client.h | 6 +++--- src/crypt.h | 8 ++++---- src/ssl.h | 4 ++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b09b26..9b2b5ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,23 @@ add_definitions() include(FindPkgConfig) include(CheckFunctionExists) include(CheckLibraryExists) +include(CheckSymbolExists) pkg_check_modules(BASELIBS libconfig) -check_function_exists(clock_gettime GAVE_CLOCK_GETTIME) -check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT) + +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) + +if(NOT HAVE_CLOCK_GETTIME) + check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT) + if(NOT HAVE_CLOCK_GETTIME_RT) + check_library_exists(c clock_get_time "mach/time.h" HAVE_CLOCK_GET_TIME) + if(NOT HAVE_CLOCK_GET_TIME) + message(FATAL_ERROR "Didn't find clock_gettime() or clock_get_time!") + endif() + else() + set(LIBRARIES ${LIBRARIES} rt) + endif() +endif() set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") diff --git a/src/client.h b/src/client.h index 95f6172..13ea427 100644 --- a/src/client.h +++ b/src/client.h @@ -31,7 +31,7 @@ #ifndef CLIENT_H_45786678 #define CLIENT_H_45786678 -#include +//#include #include #include /* close() */ #include @@ -65,9 +65,9 @@ typedef struct { bool_t shutdown_wait; cryptState_t cryptState; bool_t readBlockedOnWrite, writeBlockedOnRead; - + struct sockaddr_in remote_tcp; - struct sockaddr_in remote_udp; + struct sockaddr_in remote_udp; uint8_t rxbuf[BUFSIZE], txbuf[BUFSIZE]; uint32_t rxcount, msgsize, drainleft, txcount, txsize; int sessionId; diff --git a/src/crypt.h b/src/crypt.h index e190093..7e549b1 100644 --- a/src/crypt.h +++ b/src/crypt.h @@ -32,7 +32,7 @@ #define CRYPTSTATE_H_34564356 #ifdef HAVE_CONFIG_H -#include +//#include #endif #ifdef USE_POLARSSL @@ -53,12 +53,12 @@ typedef struct CryptState { uint8_t encrypt_iv[AES_BLOCK_SIZE]; uint8_t decrypt_iv[AES_BLOCK_SIZE]; uint8_t decrypt_history[0x100]; - + unsigned int uiGood; unsigned int uiLate; unsigned int uiLost; unsigned int uiResync; - + unsigned int uiRemoteGood; unsigned int uiRemoteLate; unsigned int uiRemoteLost; @@ -72,7 +72,7 @@ typedef struct CryptState { #endif etimer_t tLastGood; etimer_t tLastRequest; - bool_t bInit; + bool_t bInit; } cryptState_t; void CryptState_init(cryptState_t *cs); diff --git a/src/ssl.h b/src/ssl.h index ce9e480..1b2d015 100644 --- a/src/ssl.h +++ b/src/ssl.h @@ -33,7 +33,7 @@ #define SSL_H_987698 #ifdef HAVE_CONFIG_H -#include +//#include #endif #ifdef USE_POLARSSL @@ -130,7 +130,7 @@ static inline void SSLi_hex2hash(char *in, uint8_t *hash) int i, offset = 0; char byte[3]; int scanned; - + byte[2] = '\0'; for (i = 0; i < 20; i++) { memcpy(byte, &in[i * 2], 2); -- 2.30.2