From 4c06702de69187dfe182a2a6fa9a801e135b64b1 Mon Sep 17 00:00:00 2001 From: Glenn Date: Sat, 15 Jul 2017 17:40:05 -0700 Subject: [PATCH] windows fixes --- test.cpp | 8 ++++---- yojimbo.cpp | 42 +++++++++++++++++++++--------------------- yojimbo.h | 4 ++-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/test.cpp b/test.cpp index 365b590e..dab78285 100644 --- a/test.cpp +++ b/test.cpp @@ -129,7 +129,7 @@ void test_queue() check( queue.GetSize() == QueueSize ); } -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS void test_base64() { @@ -167,7 +167,7 @@ void test_base64() check( memcmp( key, decoded_key, KeyBytes ) == 0 ); } -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS void test_bitpacker() { @@ -2211,9 +2211,9 @@ int main() RUN_TEST( test_endian ); RUN_TEST( test_queue ); -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS RUN_TEST( test_base64 ); -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS RUN_TEST( test_bitpacker ); RUN_TEST( test_stream ); RUN_TEST( test_address ); diff --git a/yojimbo.cpp b/yojimbo.cpp index 5f10923c..f985f491 100644 --- a/yojimbo.cpp +++ b/yojimbo.cpp @@ -67,9 +67,9 @@ void ShutdownYojimbo() #include #include -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS #include -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS extern "C" void netcode_random_bytes( uint8_t*, int ); @@ -143,7 +143,7 @@ namespace yojimbo printf( " (%d bytes)\n", data_bytes ); } -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS int base64_encode_string( const char * input, char * output, int output_size ) { @@ -205,7 +205,7 @@ namespace yojimbo return ( result == 0 ) ? (int) output_length : -1; } -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS } // --------------------------------------------------------------------------------- @@ -872,7 +872,7 @@ double yojimbo_time() // --------------------------------------------------------------------------------- -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS #include #include #include @@ -882,7 +882,7 @@ double yojimbo_time() #include #include #include -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS #include #include #include "netcode.h" @@ -894,33 +894,33 @@ namespace yojimbo { struct MatcherInternal { -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS mbedtls_net_context server_fd; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; mbedtls_x509_crt cacert; -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS }; Matcher::Matcher( Allocator & allocator ) { -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS yojimbo_assert( ConnectTokenBytes == NETCODE_CONNECT_TOKEN_BYTES ); m_allocator = &allocator; m_initialized = false; m_matchStatus = MATCH_IDLE; m_internal = YOJIMBO_NEW( allocator, MatcherInternal ); memset( m_connectToken, 0, sizeof( m_connectToken ) ); -#else // #if YOJIMBO_HAS_MBEDTLS +#else // #if YOJIMBO_WITH_MBEDTLS (void) allocator; -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS } Matcher::~Matcher() { -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS mbedtls_net_free( &m_internal->server_fd ); mbedtls_x509_crt_free( &m_internal->cacert ); mbedtls_ssl_free( &m_internal->ssl ); @@ -928,12 +928,12 @@ namespace yojimbo mbedtls_ctr_drbg_free( &m_internal->ctr_drbg ); mbedtls_entropy_free( &m_internal->entropy ); YOJIMBO_DELETE( *m_allocator, MatcherInternal, m_internal ); -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS } bool Matcher::Initialize() { -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS const char * pers = "yojimbo_client"; @@ -960,7 +960,7 @@ namespace yojimbo memset( m_connectToken, 0, sizeof( m_connectToken ) ); -#endif // // #if YOJIMBO_HAS_MBEDTLS +#endif // // #if YOJIMBO_WITH_MBEDTLS m_initialized = true; @@ -969,7 +969,7 @@ namespace yojimbo void Matcher::RequestMatch( uint64_t protocolId, uint64_t clientId, bool verifyCertificate ) { -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS yojimbo_assert( m_initialized ); @@ -1096,14 +1096,14 @@ namespace yojimbo mbedtls_ssl_close_notify( &m_internal->ssl ); -#else // #if YOJIMBO_HAS_MBEDTLS +#else // #if YOJIMBO_WITH_MBEDTLS (void) protocolId; (void) clientId; (void) verifyCertificate; m_matchStatus = MATCH_FAILED; -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS } MatchStatus Matcher::GetMatchStatus() @@ -1113,17 +1113,17 @@ namespace yojimbo void Matcher::GetConnectToken( uint8_t * connectToken ) { -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS yojimbo_assert( connectToken ); yojimbo_assert( m_matchStatus == MATCH_READY ); if ( m_matchStatus == MATCH_READY ) { memcpy( connectToken, m_connectToken, ConnectTokenBytes ); } -#else // #if YOJIMBO_HAS_MBEDTLS +#else // #if YOJIMBO_WITH_MBEDTLS (void) connectToken; yojimbo_assert( false ); -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS } } diff --git a/yojimbo.h b/yojimbo.h index fa8486ed..2f47f269 100644 --- a/yojimbo.h +++ b/yojimbo.h @@ -5614,10 +5614,10 @@ namespace yojimbo Allocator * m_allocator; ///< The allocator passed into the constructor. bool m_initialized; ///< True if the matcher was successfully initialized. See Matcher::Initialize. MatchStatus m_matchStatus; ///< The current match status. -#if YOJIMBO_HAS_MBEDTLS +#if YOJIMBO_WITH_MBEDTLS struct MatcherInternal * m_internal; ///< Internals are in here to avoid spilling details of mbedtls library outside of yojimbo_matcher.cpp uint8_t m_connectToken[ConnectTokenBytes]; ///< The connect token data from the last call to Matcher::RequestMatch once the match status is MATCH_READY. -#endif // #if YOJIMBO_HAS_MBEDTLS +#endif // #if YOJIMBO_WITH_MBEDTLS }; }