From 49799912c52ee42b27b1bf87bf672c5d5a1387ff Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Fri, 29 Apr 2016 20:21:53 +0200 Subject: [PATCH] webservices: Implement WsFileTimeToDateTime. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/reader.c | 20 ++++++++++++++ dlls/webservices/tests/reader.c | 45 +++++++++++++++++++++++++++++++ dlls/webservices/webservices.spec | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index 454f4e9c007..4f2262eab84 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -2044,6 +2044,26 @@ HRESULT WINAPI WsDateTimeToFileTime( const WS_DATETIME *dt, FILETIME *ft, WS_ERR return S_OK; } +/************************************************************************** + * WsFileTimeToDateTime [webservices.@] + */ +HRESULT WINAPI WsFileTimeToDateTime( const FILETIME *ft, WS_DATETIME *dt, WS_ERROR *error ) +{ + unsigned __int64 ticks; + + TRACE( "%p %p %p\n", ft, dt, error ); + if (error) FIXME( "ignoring error parameter\n" ); + + if (!dt || !ft) return E_INVALIDARG; + + ticks = ((unsigned __int64)ft->dwHighDateTime << 32) | ft->dwLowDateTime; + if (ticks > MAX_UINT64 - TICKS_1601_01_01) return WS_E_NUMERIC_OVERFLOW; + if (ticks + TICKS_1601_01_01 > TICKS_MAX) return WS_E_INVALID_FORMAT; + dt->ticks = ticks + TICKS_1601_01_01; + dt->format = WS_DATETIME_FORMAT_UTC; + return S_OK; +} + static HRESULT read_get_node_text( struct reader *reader, WS_XML_UTF8_TEXT **ret ) { WS_XML_TEXT_NODE *text; diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c index ac25084869d..81b762e35e4 100644 --- a/dlls/webservices/tests/reader.c +++ b/dlls/webservices/tests/reader.c @@ -3056,6 +3056,50 @@ static void test_WsDateTimeToFileTime(void) } } +static void test_WsFileTimeToDateTime(void) +{ + WS_DATETIME dt; + FILETIME ft; + HRESULT hr; + + hr = WsFileTimeToDateTime( NULL, NULL, NULL ); + ok( hr == E_INVALIDARG, "got %08x\n", hr ); + + ft.dwLowDateTime = ft.dwHighDateTime = 0; + hr = WsFileTimeToDateTime( &ft, NULL, NULL ); + ok( hr == E_INVALIDARG, "got %08x\n", hr ); + + hr = WsFileTimeToDateTime( NULL, &dt, NULL ); + ok( hr == E_INVALIDARG, "got %08x\n", hr ); + + dt.ticks = 0xdeadbeef; + dt.format = 0xdeadbeef; + hr = WsFileTimeToDateTime( &ft, &dt, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( dt.ticks == 0x701ce1722770000, "got %x%08x\n", (ULONG)(dt.ticks >> 32), (ULONG)dt.ticks ); + ok( dt.format == WS_DATETIME_FORMAT_UTC, "got %u\n", dt.format ); + + ft.dwLowDateTime = 0xd1c03fff; + ft.dwHighDateTime = 0x24c85a5e; + hr = WsFileTimeToDateTime( &ft, &dt, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( dt.ticks == 0x2bca2875f4373fff, "got %x%08x\n", (ULONG)(dt.ticks >> 32), (ULONG)dt.ticks ); + ok( dt.format == WS_DATETIME_FORMAT_UTC, "got %u\n", dt.format ); + + ft.dwLowDateTime++; + hr = WsFileTimeToDateTime( &ft, &dt, NULL ); + ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); + + ft.dwLowDateTime = 0xdd88ffff; + ft.dwHighDateTime = 0xf8fe31e8; + hr = WsFileTimeToDateTime( &ft, &dt, NULL ); + ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); + + ft.dwLowDateTime++; + hr = WsFileTimeToDateTime( &ft, &dt, NULL ); + ok( hr == WS_E_NUMERIC_OVERFLOW, "got %08x\n", hr ); +} + START_TEST(reader) { test_WsCreateError(); @@ -3083,4 +3127,5 @@ START_TEST(reader) test_WsResetHeap(); test_datetime(); test_WsDateTimeToFileTime(); + test_WsFileTimeToDateTime(); } diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec index da8adbe850a..6ff4718c1f3 100644 --- a/dlls/webservices/webservices.spec +++ b/dlls/webservices/webservices.spec @@ -42,7 +42,7 @@ @ stub WsEncodeUrl @ stub WsEndReaderCanonicalization @ stub WsEndWriterCanonicalization -@ stub WsFileTimeToDateTime +@ stdcall WsFileTimeToDateTime(ptr ptr ptr) @ stub WsFillBody @ stdcall WsFillReader(ptr long ptr ptr) @ stdcall WsFindAttribute(ptr ptr ptr long ptr ptr)