Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/msspi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ namespace _detail { template< typename T > struct _alignof_trick { char _; T _te
#include "CSP_WinCrypt.h"
#include "CSP_Sspi.h"
#include "CSP_SChannel.h"
#include <time.h>

#ifdef CLOCK_BOOTTIME
#define MSSPI_TICK_CLOCK CLOCK_BOOTTIME
#elif defined( CLOCK_MONOTONIC )
#define MSSPI_TICK_CLOCK CLOCK_MONOTONIC
#endif

#ifdef MSSPI_TICK_CLOCK
static DWORD GetTickCount()
{
struct timespec ts;
if( clock_gettime( MSSPI_TICK_CLOCK, &ts ) != 0 )
return 0;

return (DWORD)ts.tv_sec * 1000 + (DWORD)( ts.tv_nsec / 1000000 );
}
#else // not MSSPI_TICK_CLOCK
#include <sys/time.h>

static DWORD GetTickCount()
Expand All @@ -102,8 +120,9 @@ static DWORD GetTickCount()
if( gettimeofday( &tv, NULL ) != 0 )
return 0;

return (DWORD)( ( tv.tv_sec * 1000 ) + ( tv.tv_usec / 1000 ) );
return (DWORD)tv.tv_sec * 1000 + (DWORD)( tv.tv_usec / 1000 );
}
#endif // MSSPI_TICK_CLOCK
#endif // _WIN32

#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
Expand Down Expand Up @@ -448,6 +467,9 @@ struct MSSPI_CredCache

bool isActive( DWORD dwNow )
{
if( !dwNow && !dwLastActive )
return false;

return dwNow - dwLastActive < SSPI_CREDSCACHE_DEFAULT_TIMEOUT;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/msspi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define MSSPI_VERSION_MAJOR 1
#define MSSPI_VERSION_MINOR 0
#define MSSPI_VERSION_PATCH 8
#define MSSPI_VERSION_PATCH 9

#define MSSPI_VERSION \
( ( MSSPI_VERSION_MAJOR << 16 ) | ( MSSPI_VERSION_MINOR << 8 ) | MSSPI_VERSION_PATCH )
Expand Down
Loading