ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2017
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
17 participants
284 discussions
Start a n
N
ew thread
[akhaldi] 75960: [WS2_32_WINETEST] Sync with Wine Staging 2.16. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:36:21 2017 New Revision: 75960 URL:
http://svn.reactos.org/svn/reactos?rev=75960&view=rev
Log: [WS2_32_WINETEST] Sync with Wine Staging 2.16. CORE-13762 Modified: trunk/rostests/winetests/ws2_32/sock.c Modified: trunk/rostests/winetests/ws2_32/sock.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/ws2_32/sock.c?r…
============================================================================== --- trunk/rostests/winetests/ws2_32/sock.c [iso-8859-1] (original) +++ trunk/rostests/winetests/ws2_32/sock.c [iso-8859-1] Sun Sep 24 11:36:21 2017 @@ -72,7 +72,13 @@ static void (WINAPI *pfreeaddrinfo)(struct addrinfo *); static int (WINAPI *pgetaddrinfo)(LPCSTR,LPCSTR,const struct addrinfo *,struct addrinfo **); static void (WINAPI *pFreeAddrInfoW)(PADDRINFOW); +static void (WINAPI *pFreeAddrInfoExW)(ADDRINFOEXW *ai); static int (WINAPI *pGetAddrInfoW)(LPCWSTR,LPCWSTR,const ADDRINFOW *,PADDRINFOW *); +static int (WINAPI *pGetAddrInfoExW)(const WCHAR *name, const WCHAR *servname, DWORD namespace, + GUID *namespace_id, const ADDRINFOEXW *hints, ADDRINFOEXW **result, + struct timeval *timeout, OVERLAPPED *overlapped, + LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine, HANDLE *handle); +static int (WINAPI *pGetAddrInfoExOverlappedResult)(OVERLAPPED *overlapped); static PCSTR (WINAPI *pInetNtop)(INT,LPVOID,LPSTR,ULONG); static PCWSTR(WINAPI *pInetNtopW)(INT,LPVOID,LPWSTR,ULONG); static int (WINAPI *pInetPtonA)(INT,LPCSTR,LPVOID); @@ -1234,7 +1240,10 @@ pfreeaddrinfo = (void *)GetProcAddress(hws2_32, "freeaddrinfo"); pgetaddrinfo = (void *)GetProcAddress(hws2_32, "getaddrinfo"); pFreeAddrInfoW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoW"); + pFreeAddrInfoExW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoExW"); pGetAddrInfoW = (void *)GetProcAddress(hws2_32, "GetAddrInfoW"); + pGetAddrInfoExW = (void *)GetProcAddress(hws2_32, "GetAddrInfoExW"); + pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(hws2_32, "GetAddrInfoExOverlappedResult"); pInetNtop = (void *)GetProcAddress(hws2_32, "inet_ntop"); pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW"); pInetPtonA = (void *)GetProcAddress(hws2_32, "inet_pton"); @@ -1654,7 +1663,7 @@ ok(k == 99, "Expected 99, got %d\n", k); } } - else /* <= 2003 the tests differ between TCP and UDP, UDP silenty accepts */ + else /* <= 2003 the tests differ between TCP and UDP, UDP silently accepts */ { SetLastError(0xdeadbeef); k = 99; @@ -3613,6 +3622,7 @@ struct sockaddr_in addr; struct timeval select_timeout; + memset(&readfds, 0, sizeof(readfds)); FD_ZERO(&readfds); FD_SET(par->s, &readfds); select_timeout.tv_sec=5; @@ -4785,7 +4795,7 @@ } ok(memcmp(he->h_addr_list[0], loopback, he->h_length) == 0, - "gethostbyname(\"localhost\") returned %d.%d.%d.%d\n", + "gethostbyname(\"localhost\") returned %u.%u.%u.%u\n", he->h_addr_list[0][0], he->h_addr_list[0][1], he->h_addr_list[0][2], he->h_addr_list[0][3]); } @@ -4809,7 +4819,7 @@ if (he->h_addr_list[0][0] == 127) { ok(memcmp(he->h_addr_list[0], magic_loopback, he->h_length) == 0, - "gethostbyname(\"%s\") returned %d.%d.%d.%d not 127.12.34.56\n", + "gethostbyname(\"%s\") returned %u.%u.%u.%u not 127.12.34.56\n", name, he->h_addr_list[0][0], he->h_addr_list[0][1], he->h_addr_list[0][2], he->h_addr_list[0][3]); } @@ -6871,7 +6881,6 @@ memset(&ov, 0, sizeof(ov)); completion_called = 0; iret = WSARecv(dest, bufs, 1, NULL, &flags, &ov, io_completion); - todo_wine ok(iret == SOCKET_ERROR && GetLastError() == WSAEINVAL, "WSARecv failed - %d error %d\n", iret, GetLastError()); ok(!completion_called, "completion called\n"); @@ -7382,11 +7391,124 @@ ok(result2 == NULL, "got %p\n", result2); } +static void test_GetAddrInfoExW(void) +{ + static const WCHAR empty[] = {0}; + static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0}; + static const WCHAR winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0}; + ADDRINFOEXW *result; + OVERLAPPED overlapped; + HANDLE event; + int ret; + + if (!pGetAddrInfoExW || !pGetAddrInfoExOverlappedResult) + { + win_skip("GetAddrInfoExW and/or GetAddrInfoExOverlappedResult not present\n"); + return; + } + + event = WSACreateEvent(); + + result = (ADDRINFOEXW *)0xdeadbeef; + WSASetLastError(0xdeadbeef); + ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL); + ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret); + ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError()); + ok(result == NULL, "got %p\n", result); + + result = NULL; + WSASetLastError(0xdeadbeef); + ret = pGetAddrInfoExW(empty, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL); + ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError()); + ok(result != NULL, "GetAddrInfoW failed\n"); + ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError()); + pFreeAddrInfoExW(result); + + result = NULL; + ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL, NULL); + ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError()); + pFreeAddrInfoExW(result); + + result = (void*)0xdeadbeef; + memset(&overlapped, 0xcc, sizeof(overlapped)); + overlapped.hEvent = event; + ResetEvent(event); + ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL); + ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError()); + ok(!result, "result != NULL\n"); + ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n"); + ret = pGetAddrInfoExOverlappedResult(&overlapped); + ok(!ret, "overlapped result is %d\n", ret); + pFreeAddrInfoExW(result); + + result = (void*)0xdeadbeef; + memset(&overlapped, 0xcc, sizeof(overlapped)); + ResetEvent(event); + overlapped.hEvent = event; + WSASetLastError(0xdeadbeef); + ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL); + ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n", WSAGetLastError()); + ok(WSAGetLastError() == ERROR_IO_PENDING, "expected 11001, got %d\n", WSAGetLastError()); + ret = overlapped.Internal; + ok(ret == WSAEINPROGRESS || ret == ERROR_SUCCESS, "overlapped.Internal = %u\n", ret); + ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n"); + ret = pGetAddrInfoExOverlappedResult(&overlapped); + ok(!ret, "overlapped result is %d\n", ret); + ok(overlapped.hEvent == event, "hEvent changed %p\n", overlapped.hEvent); + ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n", overlapped.Internal); + ok(overlapped.Pointer == &result, "overlapped.Pointer != &result\n"); + ok(result != NULL, "result == NULL\n"); + ok(!result->ai_blob, "ai_blob != NULL\n"); + ok(!result->ai_bloblen, "ai_bloblen != 0\n"); + ok(!result->ai_provider, "ai_provider = %s\n", wine_dbgstr_guid(result->ai_provider)); + pFreeAddrInfoExW(result); + + result = (void*)0xdeadbeef; + memset(&overlapped, 0xcc, sizeof(overlapped)); + ResetEvent(event); + overlapped.hEvent = event; + ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, &overlapped, NULL, NULL); + todo_wine + ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret); + todo_wine + ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError()); + ok(result == NULL, "got %p\n", result); + ret = WaitForSingleObject(event, 0); + todo_wine_if(ret != WAIT_TIMEOUT) /* Remove when abowe todo_wines are fixed */ + ok(ret == WAIT_TIMEOUT, "wait failed\n"); + + WSACloseEvent(event); +} + +static void verify_ipv6_addrinfo(ADDRINFOA *result, const char *expectedIp) +{ + SOCKADDR_IN6 *sockaddr6; + char ipBuffer[256]; + const char *ret; + + ok(result->ai_family == AF_INET6, "ai_family == %d\n", result->ai_family); + ok(result->ai_addrlen >= sizeof(struct sockaddr_in6), "ai_addrlen == %d\n", (int)result->ai_addrlen); + ok(result->ai_addr != NULL, "ai_addr == NULL\n"); + + if (result->ai_addr != NULL) + { + sockaddr6 = (SOCKADDR_IN6 *)result->ai_addr; + ok(sockaddr6->sin6_family == AF_INET6, "ai_addr->sin6_family == %d\n", sockaddr6->sin6_family); + ok(sockaddr6->sin6_port == 0, "ai_addr->sin6_port == %d\n", sockaddr6->sin6_port); + + ZeroMemory(ipBuffer, sizeof(ipBuffer)); + ret = pInetNtop(AF_INET6, &sockaddr6->sin6_addr, ipBuffer, sizeof(ipBuffer)); + ok(ret != NULL, "inet_ntop failed (%d)\n", WSAGetLastError()); + ok(strcmp(ipBuffer, expectedIp) == 0, "ai_addr->sin6_addr == '%s' (expected '%s')\n", ipBuffer, expectedIp); + } +} + static void test_getaddrinfo(void) { int i, ret; ADDRINFOA *result, *result2, *p, hint; - CHAR name[256]; + SOCKADDR_IN *sockaddr; + CHAR name[256], *ip; DWORD size = sizeof(name); if (!pgetaddrinfo || !pfreeaddrinfo) @@ -7515,6 +7637,88 @@ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret); ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError()); ok(result == NULL, "got %p\n", result); + + /* Test IPv4 address conversion */ + result = NULL; + ret = pgetaddrinfo("192.168.1.253", NULL, NULL, &result); + ok(!ret, "getaddrinfo failed with %d\n", ret); + ok(result->ai_family == AF_INET, "ai_family == %d\n", result->ai_family); + ok(result->ai_addrlen >= sizeof(struct sockaddr_in), "ai_addrlen == %d\n", (int)result->ai_addrlen); + ok(result->ai_addr != NULL, "ai_addr == NULL\n"); + sockaddr = (SOCKADDR_IN *)result->ai_addr; + ok(sockaddr->sin_family == AF_INET, "ai_addr->sin_family == %d\n", sockaddr->sin_family); + ok(sockaddr->sin_port == 0, "ai_addr->sin_port == %d\n", sockaddr->sin_port); + + ip = inet_ntoa(sockaddr->sin_addr); + ok(strcmp(ip, "192.168.1.253") == 0, "sockaddr->ai_addr == '%s'\n", ip); + pfreeaddrinfo(result); + + /* Test IPv4 address conversion with port */ + result = NULL; + hint.ai_flags = AI_NUMERICHOST; + ret = pgetaddrinfo("192.168.1.253:1024", NULL, &hint, &result); + hint.ai_flags = 0; + ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo returned unexpected result: %d\n", ret); + ok(result == NULL, "expected NULL, got %p\n", result); + + /* Test IPv6 address conversion */ + result = NULL; + SetLastError(0xdeadbeef); + ret = pgetaddrinfo("2a00:2039:dead:beef:cafe::6666", NULL, NULL, &result); + + if (result != NULL) + { + ok(!ret, "getaddrinfo failed with %d\n", ret); + verify_ipv6_addrinfo(result, "2a00:2039:dead:beef:cafe::6666"); + pfreeaddrinfo(result); + + /* Test IPv6 address conversion with brackets */ + result = NULL; + ret = pgetaddrinfo("[beef::cafe]", NULL, NULL, &result); + ok(!ret, "getaddrinfo failed with %d\n", ret); + verify_ipv6_addrinfo(result, "beef::cafe"); + pfreeaddrinfo(result); + + /* Test IPv6 address conversion with brackets and hints */ + memset(&hint, 0, sizeof(ADDRINFOA)); + hint.ai_flags = AI_NUMERICHOST; + hint.ai_family = AF_INET6; + result = NULL; + ret = pgetaddrinfo("[beef::cafe]", NULL, &hint, &result); + ok(!ret, "getaddrinfo failed with %d\n", ret); + verify_ipv6_addrinfo(result, "beef::cafe"); + pfreeaddrinfo(result); + + memset(&hint, 0, sizeof(ADDRINFOA)); + hint.ai_flags = AI_NUMERICHOST; + hint.ai_family = AF_INET; + result = NULL; + ret = pgetaddrinfo("[beef::cafe]", NULL, &hint, &result); + ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret); + + /* Test IPv6 address conversion with brackets and port */ + result = NULL; + ret = pgetaddrinfo("[beef::cafe]:10239", NULL, NULL, &result); + ok(!ret, "getaddrinfo failed with %d\n", ret); + verify_ipv6_addrinfo(result, "beef::cafe"); + pfreeaddrinfo(result); + + /* Test IPv6 address conversion with unmatched brackets */ + result = NULL; + hint.ai_flags = AI_NUMERICHOST; + ret = pgetaddrinfo("[beef::cafe", NULL, &hint, &result); + ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret); + + ret = pgetaddrinfo("beef::cafe]", NULL, &hint, &result); + ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret); + } + else + { + ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret); + win_skip("getaddrinfo does not support IPV6\n"); + } + + hint.ai_flags = 0; for (i = 0;i < (sizeof(hinttests) / sizeof(hinttests[0]));i++) { @@ -7619,12 +7823,15 @@ goto end; } + bytesReturned = 0xdeadbeef; iret = WSAIoctl(connector, SIO_GET_EXTENSION_FUNCTION_POINTER, &connectExGuid, sizeof(connectExGuid), &pConnectEx, sizeof(pConnectEx), &bytesReturned, NULL, NULL); if (iret) { win_skip("WSAIoctl failed to get ConnectEx with ret %d + errno %d\n", iret, WSAGetLastError()); goto end; } + + ok(bytesReturned == sizeof(pConnectEx), "expected sizeof(pConnectEx), got %u\n", bytesReturned); bret = pConnectEx(INVALID_SOCKET, (struct sockaddr*)&address, addrlen, NULL, 0, &bytesReturned, &overlapped); ok(bret == FALSE && WSAGetLastError() == WSAENOTSOCK, "ConnectEx on invalid socket " @@ -7756,22 +7963,14 @@ address.sin_port = htons(1); bret = pConnectEx(connector, (struct sockaddr*)&address, addrlen, NULL, 0, &bytesReturned, &overlapped); - ok(bret == FALSE && GetLastError(), "ConnectEx to bad destination failed: " + ok(bret == FALSE && GetLastError() == ERROR_IO_PENDING, "ConnectEx to bad destination failed: " "returned %d + errno %d\n", bret, GetLastError()); - - if (GetLastError() == ERROR_IO_PENDING) - { - dwret = WaitForSingleObject(overlapped.hEvent, 15000); - ok(dwret == WAIT_OBJECT_0, "Waiting for connect event failed with %d + errno %d\n", dwret, GetLastError()); - - bret = GetOverlappedResult((HANDLE)connector, &overlapped, &bytesReturned, FALSE); - ok(bret == FALSE && GetLastError() == ERROR_CONNECTION_REFUSED, - "Connecting to a disconnected host returned error %d - %d\n", bret, WSAGetLastError()); - } - else { - ok(GetLastError() == WSAECONNREFUSED, - "Connecting to a disconnected host returned error %d - %d\n", bret, WSAGetLastError()); - } + dwret = WaitForSingleObject(overlapped.hEvent, 15000); + ok(dwret == WAIT_OBJECT_0, "Waiting for connect event failed with %d + errno %d\n", dwret, GetLastError()); + + bret = GetOverlappedResult((HANDLE)connector, &overlapped, &bytesReturned, FALSE); + ok(bret == FALSE && GetLastError() == ERROR_CONNECTION_REFUSED, + "Connecting to a disconnected host returned error %d - %d\n", bret, WSAGetLastError()); end: if (overlapped.hEvent) @@ -9852,6 +10051,11 @@ io_port = CreateIoCompletionPort((HANDLE)dest, previous_port, 236, 0); ok(io_port != NULL, "failed to create completion port %u\n", GetLastError()); + + io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; + status = pNtSetInformationFile((HANDLE)src, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); + ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */, + "expected STATUS_SUCCESS, got %08x\n", status); io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; status = pNtSetInformationFile((HANDLE)dest, &io, &io_info, sizeof(io_info), FileIoCompletionNotificationInformation); @@ -10559,6 +10763,7 @@ test_ipv6only(); test_TransmitFile(); test_GetAddrInfoW(); + test_GetAddrInfoExW(); test_getaddrinfo(); test_AcceptEx(); test_ConnectEx();
7 years, 3 months
1
0
0
0
[akhaldi] 75959: [REG_WINETEST] Sync with Wine Staging 2.16. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:33:35 2017 New Revision: 75959 URL:
http://svn.reactos.org/svn/reactos?rev=75959&view=rev
Log: [REG_WINETEST] Sync with Wine Staging 2.16. CORE-13762 Modified: trunk/rostests/winetests/reg/reg.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/rostests/winetests/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/reg/reg.c?rev=7…
7 years, 3 months
1
0
0
0
[akhaldi] 75958: [REG] Sync with Wine Staging 2.16. CORE-13762 39e0e81 reg: Null-terminate incomplete REG_EXPAND_SZ and REG_MULTI_SZ Unicode data. 82fc4c8 reg: Close any open registry keys before s...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:33:04 2017 New Revision: 75958 URL:
http://svn.reactos.org/svn/reactos?rev=75958&view=rev
Log: [REG] Sync with Wine Staging 2.16. CORE-13762 39e0e81 reg: Null-terminate incomplete REG_EXPAND_SZ and REG_MULTI_SZ Unicode data. 82fc4c8 reg: Close any open registry keys before starting the key deletion process. 5de883c reg: Use the correct return codes during the import operation. 56e58e4 reg: Delete registry keys via the state machine. d90f2a5 reg: Delete registry values via the state machine. db98cc4 reg: Handle unknown registry data types in the state machine. 32d5368 reg: Import hex data via the state machine. f1874c1 reg: Import REG_DWORD data via the state machine. 038f1c6 reg: Parse data types and import REG_SZ data via the state machine. 0565934 reg: Parse key names and value names in the state machine. 3e87a70 reg: Introduce a partial state machine for importing Windows 3.1 registry data. aa386af reg: Add initial support for the import operation. f2fbbec reg: Rename reg.h to resource.h. c6c95a0 reg: Compile with msvcrt. 8c253c4 reg: Make some variables 'static const'. 337e0f4 reg: Avoid an uninitialized variable warning. 8abec73 reg: Dynamically allocate memory for the value name buffer when deleting all registry values in a specified key. e7ea838 reg: Use a helper function to resize a memory buffer. a1bc33a reg: Use a helper function to free allocated memory. a6e28cc reg: Use a helper function to allocate memory and die on failure. 90da210 reg: Account for sizeof(WCHAR) when resizing the value name buffer during the query operation. fb22f6c reg: Avoid using RegQueryInfoKey() to enumerate subkeys and values in the query operation. Added: trunk/reactos/base/applications/cmdutils/reg/import.c (with props) trunk/reactos/base/applications/cmdutils/reg/resource.h (with props) Modified: trunk/reactos/base/applications/cmdutils/reg/CMakeLists.txt trunk/reactos/base/applications/cmdutils/reg/lang/bg-BG.rc trunk/reactos/base/applications/cmdutils/reg/lang/cs-CZ.rc trunk/reactos/base/applications/cmdutils/reg/lang/da-DK.rc trunk/reactos/base/applications/cmdutils/reg/lang/de-DE.rc trunk/reactos/base/applications/cmdutils/reg/lang/en-US.rc trunk/reactos/base/applications/cmdutils/reg/lang/es-ES.rc trunk/reactos/base/applications/cmdutils/reg/lang/fr-FR.rc trunk/reactos/base/applications/cmdutils/reg/lang/it-IT.rc trunk/reactos/base/applications/cmdutils/reg/lang/ja-JP.rc trunk/reactos/base/applications/cmdutils/reg/lang/ko-KR.rc trunk/reactos/base/applications/cmdutils/reg/lang/lt-LT.rc trunk/reactos/base/applications/cmdutils/reg/lang/nl-NL.rc trunk/reactos/base/applications/cmdutils/reg/lang/no-NO.rc trunk/reactos/base/applications/cmdutils/reg/lang/pl-PL.rc trunk/reactos/base/applications/cmdutils/reg/lang/pt-PT.rc trunk/reactos/base/applications/cmdutils/reg/lang/ro-RO.rc trunk/reactos/base/applications/cmdutils/reg/lang/ru-RU.rc trunk/reactos/base/applications/cmdutils/reg/lang/sl-SI.rc trunk/reactos/base/applications/cmdutils/reg/lang/sq-AL.rc trunk/reactos/base/applications/cmdutils/reg/lang/sv-SE.rc trunk/reactos/base/applications/cmdutils/reg/lang/tr-TR.rc trunk/reactos/base/applications/cmdutils/reg/lang/uk-UA.rc trunk/reactos/base/applications/cmdutils/reg/lang/zh-CN.rc trunk/reactos/base/applications/cmdutils/reg/lang/zh-TW.rc trunk/reactos/base/applications/cmdutils/reg/reg.c trunk/reactos/base/applications/cmdutils/reg/reg.h trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/base/applications/cmdutils/reg/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/CMakeLists.txt [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -2,7 +2,7 @@ remove_definitions(-D_WIN32_WINNT=0x502) add_definitions(-D_WIN32_WINNT=0x600) -add_executable(reg reg.c reg.rc) +add_executable(reg import.c reg.c reg.rc) set_module_type(reg win32cui UNICODE) target_link_libraries(reg wine) add_importlibs(reg advapi32 advapi32_vista user32 msvcrt kernel32 ntdll) Added: trunk/reactos/base/applications/cmdutils/reg/import.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/import.c (added) +++ trunk/reactos/base/applications/cmdutils/reg/import.c [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -0,0 +1,1042 @@ +/* + * Copyright 2017 Hugh McMaster + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <windef.h> +#include <winbase.h> +#include <winreg.h> +#include <stdio.h> + +#include <wine/unicode.h> +#include <wine/debug.h> + +#include "reg.h" + +WINE_DEFAULT_DEBUG_CHANNEL(reg); + +static WCHAR *GetWideString(const char *strA) +{ + if (strA) + { + WCHAR *strW; + int len = MultiByteToWideChar(CP_ACP, 0, strA, -1, NULL, 0); + + strW = heap_xalloc(len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, strA, -1, strW, len); + return strW; + } + return NULL; +} + +static WCHAR *GetWideStringN(const char *strA, int size, DWORD *len) +{ + if (strA) + { + WCHAR *strW; + *len = MultiByteToWideChar(CP_ACP, 0, strA, size, NULL, 0); + + strW = heap_xalloc(*len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, strA, size, strW, *len); + return strW; + } + *len = 0; + return NULL; +} + +static WCHAR *(*get_line)(FILE *); + +/* parser definitions */ +enum parser_state +{ + HEADER, /* parsing the registry file version header */ + PARSE_WIN31_LINE, /* parsing a Windows 3.1 registry line */ + LINE_START, /* at the beginning of a registry line */ + KEY_NAME, /* parsing a key name */ + DELETE_KEY, /* deleting a registry key */ + DEFAULT_VALUE_NAME, /* parsing a default value name */ + QUOTED_VALUE_NAME, /* parsing a double-quoted value name */ + DATA_START, /* preparing for data parsing operations */ + DELETE_VALUE, /* deleting a registry value */ + DATA_TYPE, /* parsing the registry data type */ + STRING_DATA, /* parsing REG_SZ data */ + DWORD_DATA, /* parsing DWORD data */ + HEX_DATA, /* parsing REG_BINARY, REG_NONE, REG_EXPAND_SZ or REG_MULTI_SZ data */ + EOL_BACKSLASH, /* preparing to parse multiple lines of hex data */ + HEX_MULTILINE, /* parsing multiple lines of hex data */ + UNKNOWN_DATA, /* parsing an unhandled or invalid data type */ + SET_VALUE, /* adding a value to the registry */ + NB_PARSER_STATES +}; + +struct parser +{ + FILE *file; /* pointer to a registry file */ + WCHAR two_wchars[2]; /* first two characters from the encoding check */ + BOOL is_unicode; /* parsing Unicode or ASCII data */ + short int reg_version; /* registry file version */ + HKEY hkey; /* current registry key */ + WCHAR *key_name; /* current key name */ + WCHAR *value_name; /* value name */ + DWORD parse_type; /* generic data type for parsing */ + DWORD data_type; /* data type */ + void *data; /* value data */ + DWORD data_size; /* size of the data (in bytes) */ + BOOL backslash; /* TRUE if the current line contains a backslash */ + enum parser_state state; /* current parser state */ +}; + +typedef WCHAR *(*parser_state_func)(struct parser *parser, WCHAR *pos); + +/* parser state machine functions */ +static WCHAR *header_state(struct parser *parser, WCHAR *pos); +static WCHAR *parse_win31_line_state(struct parser *parser, WCHAR *pos); +static WCHAR *line_start_state(struct parser *parser, WCHAR *pos); +static WCHAR *key_name_state(struct parser *parser, WCHAR *pos); +static WCHAR *delete_key_state(struct parser *parser, WCHAR *pos); +static WCHAR *default_value_name_state(struct parser *parser, WCHAR *pos); +static WCHAR *quoted_value_name_state(struct parser *parser, WCHAR *pos); +static WCHAR *data_start_state(struct parser *parser, WCHAR *pos); +static WCHAR *delete_value_state(struct parser *parser, WCHAR *pos); +static WCHAR *data_type_state(struct parser *parser, WCHAR *pos); +static WCHAR *string_data_state(struct parser *parser, WCHAR *pos); +static WCHAR *dword_data_state(struct parser *parser, WCHAR *pos); +static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos); +static WCHAR *eol_backslash_state(struct parser *parser, WCHAR *pos); +static WCHAR *hex_multiline_state(struct parser *parser, WCHAR *pos); +static WCHAR *unknown_data_state(struct parser *parser, WCHAR *pos); +static WCHAR *set_value_state(struct parser *parser, WCHAR *pos); + +static const parser_state_func parser_funcs[NB_PARSER_STATES] = +{ + header_state, /* HEADER */ + parse_win31_line_state, /* PARSE_WIN31_LINE */ + line_start_state, /* LINE_START */ + key_name_state, /* KEY_NAME */ + delete_key_state, /* DELETE_KEY */ + default_value_name_state, /* DEFAULT_VALUE_NAME */ + quoted_value_name_state, /* QUOTED_VALUE_NAME */ + data_start_state, /* DATA_START */ + delete_value_state, /* DELETE_VALUE */ + data_type_state, /* DATA_TYPE */ + string_data_state, /* STRING_DATA */ + dword_data_state, /* DWORD_DATA */ + hex_data_state, /* HEX_DATA */ + eol_backslash_state, /* EOL_BACKSLASH */ + hex_multiline_state, /* HEX_MULTILINE */ + unknown_data_state, /* UNKNOWN_DATA */ + set_value_state, /* SET_VALUE */ +}; + +/* set the new parser state and return the previous one */ +static inline enum parser_state set_state(struct parser *parser, enum parser_state state) +{ + enum parser_state ret = parser->state; + parser->state = state; + return ret; +} + +/****************************************************************************** + * Converts a hex representation of a DWORD into a DWORD. + */ +static BOOL convert_hex_to_dword(WCHAR *str, DWORD *dw) +{ + WCHAR *p, *end; + int count = 0; + + while (*str == ' ' || *str == '\t') str++; + if (!*str) goto error; + + p = str; + while (isxdigitW(*p)) + { + count++; + p++; + } + if (count > 8) goto error; + + end = p; + while (*p == ' ' || *p == '\t') p++; + if (*p && *p != ';') goto error; + + *end = 0; + *dw = strtoulW(str, &end, 16); + return TRUE; + +error: + return FALSE; +} + +/****************************************************************************** + * Converts comma-separated hex data into a binary string and modifies + * the input parameter to skip the concatenating backslash, if found. + * + * Returns TRUE or FALSE to indicate whether parsing was successful. + */ +static BOOL convert_hex_csv_to_hex(struct parser *parser, WCHAR **str) +{ + size_t size; + BYTE *d; + WCHAR *s; + + parser->backslash = FALSE; + + /* The worst case is 1 digit + 1 comma per byte */ + size = ((lstrlenW(*str) + 1) / 2) + parser->data_size; + parser->data = heap_xrealloc(parser->data, size); + + s = *str; + d = (BYTE *)parser->data + parser->data_size; + + while (*s) + { + WCHAR *end; + unsigned long wc; + + wc = strtoulW(s, &end, 16); + if (wc > 0xff) return FALSE; + + if (s == end && wc == 0) + { + while (*end == ' ' || *end == '\t') end++; + if (*end == '\\') + { + parser->backslash = TRUE; + *str = end + 1; + return TRUE; + } + else if (*end == ';') + return TRUE; + return FALSE; + } + + *d++ = wc; + parser->data_size++; + + if (*end && *end != ',') + { + while (*end == ' ' || *end == '\t') end++; + if (*end && *end != ';') return FALSE; + return TRUE; + } + + if (*end) end++; + s = end; + } + + return TRUE; +} + +/****************************************************************************** + * Parses the data type of the registry value being imported and modifies + * the input parameter to skip the string representation of the data type. + * + * Returns TRUE or FALSE to indicate whether a data type was found. + */ +static BOOL parse_data_type(struct parser *parser, WCHAR **line) +{ + struct data_type { const WCHAR *tag; int len; int type; int parse_type; }; + + static const WCHAR quote[] = {'"'}; + static const WCHAR hex[] = {'h','e','x',':'}; + static const WCHAR dword[] = {'d','w','o','r','d',':'}; + static const WCHAR hexp[] = {'h','e','x','('}; + + static const struct data_type data_types[] = { + /* tag len type parse type */ + { quote, 1, REG_SZ, REG_SZ }, + { hex, 4, REG_BINARY, REG_BINARY }, + { dword, 6, REG_DWORD, REG_DWORD }, + { hexp, 4, -1, REG_BINARY }, /* REG_NONE, REG_EXPAND_SZ, REG_MULTI_SZ */ + { NULL, 0, 0, 0 } + }; + + const struct data_type *ptr; + + for (ptr = data_types; ptr->tag; ptr++) + { + if (strncmpW(ptr->tag, *line, ptr->len)) + continue; + + parser->parse_type = ptr->parse_type; + parser->data_type = ptr->parse_type; + *line += ptr->len; + + if (ptr->type == -1) + { + WCHAR *end; + DWORD val; + + if (!**line || tolowerW((*line)[1]) == 'x') + return FALSE; + + /* "hex(xx):" is special */ + val = wcstoul(*line, &end, 16); + if (*end != ')' || *(end + 1) != ':' || (val == ~0u && errno == ERANGE)) + return FALSE; + + parser->data_type = val; + *line = end + 2; + } + return TRUE; + } + return FALSE; +} + +/****************************************************************************** + * Replaces escape sequences with their character equivalents and + * null-terminates the string on the first non-escaped double quote. + * + * Assigns a pointer to the remaining unparsed data in the line. + * Returns TRUE or FALSE to indicate whether a closing double quote was found. + */ +static BOOL unescape_string(WCHAR *str, WCHAR **unparsed) +{ + int str_idx = 0; /* current character under analysis */ + int val_idx = 0; /* the last character of the unescaped string */ + int len = lstrlenW(str); + BOOL ret; + + for (str_idx = 0; str_idx < len; str_idx++, val_idx++) + { + if (str[str_idx] == '\\') + { + str_idx++; + switch (str[str_idx]) + { + case 'n': + str[val_idx] = '\n'; + break; + case 'r': + str[val_idx] = '\r'; + break; + case '0': + str[val_idx] = '\0'; + break; + case '\\': + case '"': + str[val_idx] = str[str_idx]; + break; + default: + if (!str[str_idx]) return FALSE; + output_message(STRING_ESCAPE_SEQUENCE, str[str_idx]); + str[val_idx] = str[str_idx]; + break; + } + } + else if (str[str_idx] == '"') + break; + else + str[val_idx] = str[str_idx]; + } + + ret = (str[str_idx] == '"'); + *unparsed = str + str_idx + 1; + str[val_idx] = '\0'; + return ret; +} + +static HKEY parse_key_name(WCHAR *key_name, WCHAR **key_path) +{ + if (!key_name) return 0; + + *key_path = strchrW(key_name, '\\'); + if (*key_path) (*key_path)++; + + return path_get_rootkey(key_name); +} + +static void close_key(struct parser *parser) +{ + if (parser->hkey) + { + heap_free(parser->key_name); + parser->key_name = NULL; + + RegCloseKey(parser->hkey); + parser->hkey = NULL; + } +} + +static LONG open_key(struct parser *parser, WCHAR *path) +{ + HKEY key_class; + WCHAR *key_path; + LONG res; + + close_key(parser); + + /* Get the registry class */ + if (!path || !(key_class = parse_key_name(path, &key_path))) + return ERROR_INVALID_PARAMETER; + + res = RegCreateKeyExW(key_class, key_path, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &parser->hkey, NULL); + + if (res == ERROR_SUCCESS) + { + parser->key_name = heap_xalloc((lstrlenW(path) + 1) * sizeof(WCHAR)); + lstrcpyW(parser->key_name, path); + } + else + parser->hkey = NULL; + + return res; +} + +static void free_parser_data(struct parser *parser) +{ + if (parser->parse_type == REG_DWORD || parser->parse_type == REG_BINARY) + heap_free(parser->data); + + parser->data = NULL; + parser->data_size = 0; +} + +static void prepare_hex_string_data(struct parser *parser) +{ + if (parser->data_type == REG_EXPAND_SZ || parser->data_type == REG_MULTI_SZ) + { + if (parser->is_unicode) + { + WCHAR *data = parser->data; + DWORD len = parser->data_size / sizeof(WCHAR); + + if (data[len - 1] != 0) + { + data[len] = 0; + parser->data_size += sizeof(WCHAR); + } + } + else + { + BYTE *data = parser->data; + + if (data[parser->data_size - 1] != 0) + { + data[parser->data_size] = 0; + parser->data_size++; + } + + parser->data = GetWideStringN(parser->data, parser->data_size, &parser->data_size); + parser->data_size *= sizeof(WCHAR); + heap_free(data); + } + } +} + +enum reg_versions { + REG_VERSION_31, + REG_VERSION_40, + REG_VERSION_50, + REG_VERSION_FUZZY, + REG_VERSION_INVALID +}; + +static enum reg_versions parse_file_header(const WCHAR *s) +{ + static const WCHAR header_31[] = {'R','E','G','E','D','I','T',0}; + static const WCHAR header_40[] = {'R','E','G','E','D','I','T','4',0}; + static const WCHAR header_50[] = {'W','i','n','d','o','w','s',' ', + 'R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ', + 'V','e','r','s','i','o','n',' ','5','.','0','0',0}; + + while (*s == ' ' || *s == '\t') s++; + + if (!strcmpW(s, header_31)) + return REG_VERSION_31; + + if (!strcmpW(s, header_40)) + return REG_VERSION_40; + + if (!strcmpW(s, header_50)) + return REG_VERSION_50; + + /* The Windows version accepts registry file headers beginning with "REGEDIT" and ending + * with other characters, as long as "REGEDIT" appears at the start of the line. For example, + * "REGEDIT 4", "REGEDIT9" and "REGEDIT4FOO" are all treated as valid file headers. + * In all such cases, however, the contents of the registry file are not imported. + */ + if (!strncmpW(s, header_31, 7)) /* "REGEDIT" without NUL */ + return REG_VERSION_FUZZY; + + return REG_VERSION_INVALID; +} + +/* handler for parser HEADER state */ +static WCHAR *header_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line, *header; + + if (!(line = get_line(parser->file))) + return NULL; + + if (!parser->is_unicode) + { + header = heap_xalloc((lstrlenW(line) + 3) * sizeof(WCHAR)); + header[0] = parser->two_wchars[0]; + header[1] = parser->two_wchars[1]; + lstrcpyW(header + 2, line); + parser->reg_version = parse_file_header(header); + heap_free(header); + } + else parser->reg_version = parse_file_header(line); + + switch (parser->reg_version) + { + case REG_VERSION_31: + set_state(parser, PARSE_WIN31_LINE); + break; + case REG_VERSION_40: + case REG_VERSION_50: + set_state(parser, LINE_START); + break; + default: + get_line(NULL); /* Reset static variables */ + return NULL; + } + + return line; +} + +/* handler for parser PARSE_WIN31_LINE state */ +static WCHAR *parse_win31_line_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line, *value; + static WCHAR hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T'}; + unsigned int key_end = 0; + + if (!(line = get_line(parser->file))) + return NULL; + + if (strncmpW(line, hkcr, ARRAY_SIZE(hkcr))) + return line; + + /* get key name */ + while (line[key_end] && !isspaceW(line[key_end])) key_end++; + + value = line + key_end; + while (*value == ' ' || *value == '\t') value++; + + if (*value == '=') value++; + if (*value == ' ') value++; /* at most one space is skipped */ + + line[key_end] = 0; + + if (open_key(parser, line) != ERROR_SUCCESS) + { + output_message(STRING_OPEN_KEY_FAILED, line); + return line; + } + + parser->value_name = NULL; + parser->data_type = REG_SZ; + parser->data = value; + parser->data_size = (lstrlenW(value) + 1) * sizeof(WCHAR); + + set_state(parser, SET_VALUE); + return value; +} + +/* handler for parser LINE_START state */ +static WCHAR *line_start_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line, *p; + + if (!(line = get_line(parser->file))) + return NULL; + + for (p = line; *p; p++) + { + switch (*p) + { + case '[': + set_state(parser, KEY_NAME); + return p + 1; + case '@': + set_state(parser, DEFAULT_VALUE_NAME); + return p; + case '"': + set_state(parser, QUOTED_VALUE_NAME); + return p + 1; + case ' ': + case '\t': + break; + default: + return p; + } + } + + return p; +} + +/* handler for parser KEY_NAME state */ +static WCHAR *key_name_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *p = pos, *key_end; + + if (*p == ' ' || *p == '\t' || !(key_end = strrchrW(p, ']'))) + goto done; + + *key_end = 0; + + if (*p == '-') + { + set_state(parser, DELETE_KEY); + return p + 1; + } + else if (open_key(parser, p) != ERROR_SUCCESS) + output_message(STRING_OPEN_KEY_FAILED, p); + +done: + set_state(parser, LINE_START); + return p; +} + +/* handler for parser DELETE_KEY state */ +static WCHAR *delete_key_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *p = pos; + + close_key(parser); + + if (*p == 'H' || *p == 'h') + { + HKEY root; + WCHAR *path; + + root = parse_key_name(p, &path); + + if (root && path && *path) + RegDeleteTreeW(root, path); + } + + set_state(parser, LINE_START); + return p; +} + +/* handler for parser DEFAULT_VALUE_NAME state */ +static WCHAR *default_value_name_state(struct parser *parser, WCHAR *pos) +{ + heap_free(parser->value_name); + parser->value_name = NULL; + + set_state(parser, DATA_START); + return pos + 1; +} + +/* handler for parser QUOTED_VALUE_NAME state */ +static WCHAR *quoted_value_name_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *val_name = pos, *p; + + if (parser->value_name) + { + heap_free(parser->value_name); + parser->value_name = NULL; + } + + if (!unescape_string(val_name, &p)) + goto invalid; + + /* copy the value name in case we need to parse multiple lines and the buffer is overwritten */ + parser->value_name = heap_xalloc((lstrlenW(val_name) + 1) * sizeof(WCHAR)); + lstrcpyW(parser->value_name, val_name); + + set_state(parser, DATA_START); + return p; + +invalid: + set_state(parser, LINE_START); + return val_name; +} + +/* handler for parser DATA_START state */ +static WCHAR *data_start_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *p = pos; + unsigned int len; + + while (*p == ' ' || *p == '\t') p++; + if (*p != '=') goto invalid; + p++; + while (*p == ' ' || *p == '\t') p++; + + /* trim trailing whitespace */ + len = strlenW(p); + while (len > 0 && (p[len - 1] == ' ' || p[len - 1] == '\t')) len--; + p[len] = 0; + + if (*p == '-') + set_state(parser, DELETE_VALUE); + else + set_state(parser, DATA_TYPE); + return p; + +invalid: + set_state(parser, LINE_START); + return p; +} + +/* handler for parser DELETE_VALUE state */ +static WCHAR *delete_value_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *p = pos + 1; + + while (*p == ' ' || *p == '\t') p++; + if (*p && *p != ';') goto done; + + RegDeleteValueW(parser->hkey, parser->value_name); + +done: + set_state(parser, LINE_START); + return p; +} + +/* handler for parser DATA_TYPE state */ +static WCHAR *data_type_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line = pos; + + if (!parse_data_type(parser, &line)) + { + set_state(parser, LINE_START); + return line; + } + + switch (parser->parse_type) + { + case REG_SZ: + set_state(parser, STRING_DATA); + break; + case REG_DWORD: + set_state(parser, DWORD_DATA); + break; + case REG_BINARY: /* all hex data types, including undefined */ + set_state(parser, HEX_DATA); + break; + default: + set_state(parser, UNKNOWN_DATA); + } + + return line; +} + +/* handler for parser STRING_DATA state */ +static WCHAR *string_data_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line; + + parser->data = pos; + + if (!unescape_string(parser->data, &line)) + goto invalid; + + while (*line == ' ' || *line == '\t') line++; + if (*line && *line != ';') goto invalid; + + parser->data_size = (lstrlenW(parser->data) + 1) * sizeof(WCHAR); + + set_state(parser, SET_VALUE); + return line; + +invalid: + free_parser_data(parser); + set_state(parser, LINE_START); + return line; +} + +/* handler for parser DWORD_DATA state */ +static WCHAR *dword_data_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line = pos; + + parser->data = heap_xalloc(sizeof(DWORD)); + + if (!convert_hex_to_dword(line, parser->data)) + goto invalid; + + parser->data_size = sizeof(DWORD); + + set_state(parser, SET_VALUE); + return line; + +invalid: + free_parser_data(parser); + set_state(parser, LINE_START); + return line; +} + +/* handler for parser HEX_DATA state */ +static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line = pos; + + if (!convert_hex_csv_to_hex(parser, &line)) + goto invalid; + + if (parser->backslash) + { + set_state(parser, EOL_BACKSLASH); + return line; + } + + prepare_hex_string_data(parser); + + set_state(parser, SET_VALUE); + return line; + +invalid: + free_parser_data(parser); + set_state(parser, LINE_START); + return line; +} + +/* handler for parser EOL_BACKSLASH state */ +static WCHAR *eol_backslash_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *p = pos; + + while (*p == ' ' || *p == '\t') p++; + if (*p && *p != ';') goto invalid; + + set_state(parser, HEX_MULTILINE); + return pos; + +invalid: + free_parser_data(parser); + set_state(parser, LINE_START); + return p; +} + +/* handler for parser HEX_MULTILINE state */ +static WCHAR *hex_multiline_state(struct parser *parser, WCHAR *pos) +{ + WCHAR *line; + + if (!(line = get_line(parser->file))) + { + prepare_hex_string_data(parser); + set_state(parser, SET_VALUE); + return pos; + } + + while (*line == ' ' || *line == '\t') line++; + if (!*line || *line == ';') return line; + + if (!isxdigitW(*line)) goto invalid; + + set_state(parser, HEX_DATA); + return line; + +invalid: + free_parser_data(parser); + set_state(parser, LINE_START); + return line; +} + +/* handler for parser UNKNOWN_DATA state */ +static WCHAR *unknown_data_state(struct parser *parser, WCHAR *pos) +{ + FIXME("Unknown registry data type [0x%x]\n", parser->data_type); + + set_state(parser, LINE_START); + return pos; +} + +/* handler for parser SET_VALUE state */ +static WCHAR *set_value_state(struct parser *parser, WCHAR *pos) +{ + RegSetValueExW(parser->hkey, parser->value_name, 0, parser->data_type, + parser->data, parser->data_size); + + free_parser_data(parser); + + if (parser->reg_version == REG_VERSION_31) + set_state(parser, PARSE_WIN31_LINE); + else + set_state(parser, LINE_START); + + return pos; +} + +#define REG_VAL_BUF_SIZE 4096 + +static WCHAR *get_lineA(FILE *fp) +{ + static WCHAR *lineW; + static size_t size; + static char *buf, *next; + char *line; + + heap_free(lineW); + + if (!fp) goto cleanup; + + if (!size) + { + size = REG_VAL_BUF_SIZE; + buf = heap_xalloc(size); + *buf = 0; + next = buf; + } + line = next; + + while (next) + { + char *p = strpbrk(line, "\r\n"); + if (!p) + { + size_t len, count; + len = strlen(next); + memmove(buf, next, len + 1); + if (size - len < 3) + { + size *= 2; + buf = heap_xrealloc(buf, size); + } + if (!(count = fread(buf + len, 1, size - len - 1, fp))) + { + next = NULL; + lineW = GetWideString(buf); + return lineW; + } + buf[len + count] = 0; + next = buf; + line = buf; + continue; + } + next = p + 1; + if (*p == '\r' && *(p + 1) == '\n') next++; + *p = 0; + lineW = GetWideString(line); + return lineW; + } + +cleanup: + lineW = NULL; + if (size) heap_free(buf); + size = 0; + return NULL; +} + +static WCHAR *get_lineW(FILE *fp) +{ + static size_t size; + static WCHAR *buf, *next; + WCHAR *line; + + if (!fp) goto cleanup; + + if (!size) + { + size = REG_VAL_BUF_SIZE; + buf = heap_xalloc(size * sizeof(WCHAR)); + *buf = 0; + next = buf; + } + line = next; + + while (next) + { + static const WCHAR line_endings[] = {'\r','\n',0}; + WCHAR *p = strpbrkW(line, line_endings); + if (!p) + { + size_t len, count; + len = strlenW(next); + memmove(buf, next, (len + 1) * sizeof(WCHAR)); + if (size - len < 3) + { + size *= 2; + buf = heap_xrealloc(buf, size * sizeof(WCHAR)); + } + if (!(count = fread(buf + len, sizeof(WCHAR), size - len - 1, fp))) + { + next = NULL; + return buf; + } + buf[len + count] = 0; + next = buf; + line = buf; + continue; + } + next = p + 1; + if (*p == '\r' && *(p + 1) == '\n') next++; + *p = 0; + return line; + } + +cleanup: + if (size) heap_free(buf); + size = 0; + return NULL; +} + +int reg_import(const WCHAR *filename) +{ + FILE *fp; + static const WCHAR rb_mode[] = {'r','b',0}; + BYTE s[2]; + struct parser parser; + WCHAR *pos; + + fp = _wfopen(filename, rb_mode); + if (!fp) + { + output_message(STRING_FILE_NOT_FOUND, filename); + return 1; + } + + if (fread(s, sizeof(WCHAR), 1, fp) != 1) + goto error; + + parser.is_unicode = (s[0] == 0xff && s[1] == 0xfe); + get_line = parser.is_unicode ? get_lineW : get_lineA; + + parser.file = fp; + parser.two_wchars[0] = s[0]; + parser.two_wchars[1] = s[1]; + parser.reg_version = -1; + parser.hkey = NULL; + parser.key_name = NULL; + parser.value_name = NULL; + parser.parse_type = 0; + parser.data_type = 0; + parser.data = NULL; + parser.data_size = 0; + parser.backslash = FALSE; + parser.state = HEADER; + + pos = parser.two_wchars; + + /* parser main loop */ + while (pos) + pos = (parser_funcs[parser.state])(&parser, pos); + + if (parser.reg_version == REG_VERSION_INVALID) + goto error; + + heap_free(parser.value_name); + close_key(&parser); + + fclose(fp); + return 0; + +error: + fclose(fp); + return 1; +} Propchange: trunk/reactos/base/applications/cmdutils/reg/import.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/base/applications/cmdutils/reg/lang/bg-BG.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/bg-BG.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/bg-BG.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/cs-CZ.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/cs-CZ.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/cs-CZ.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -38,4 +38,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/da-DK.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/da-DK.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/da-DK.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/de-DE.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/de-DE.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/de-DE.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/en-US.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/en-US.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/en-US.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/es-ES.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/es-ES.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/es-ES.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/fr-FR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/fr-FR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/fr-FR.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/it-IT.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/it-IT.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/it-IT.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/ja-JP.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/ja-JP.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/ja-JP.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/ko-KR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/ko-KR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/ko-KR.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/lt-LT.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/lt-LT.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/lt-LT.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/nl-NL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/nl-NL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/nl-NL.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/no-NO.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/no-NO.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/no-NO.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/pl-PL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/pl-PL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/pl-PL.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/pt-PT.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/pt-PT.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/pt-PT.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/ro-RO.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/ro-RO.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/ro-RO.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -39,4 +39,8 @@ STRING_REG_HELP, "TastaÈi «REG /?» pentru mai multe informaÈii.\n" STRING_FUNC_HELP, "TastaÈi «REG %1 /?» pentru mai multe informaÈii.\n" STRING_VALUE_NOT_SET, "(valoare nealocatÄ)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/ru-RU.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/ru-RU.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/ru-RU.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "ÐведиÑе ""REG /?"" Ð´Ð»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑпÑавки по иÑполÑзованиÑ..\n" STRING_FUNC_HELP, "ÐведиÑе ""REG %1 /?"" Ð´Ð»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ ÑпÑавки по иÑполÑзованиÑ..\n" STRING_VALUE_NOT_SET, "(знаÑение не Ñказано)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/sl-SI.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/sl-SI.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/sl-SI.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/sq-AL.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/sq-AL.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/sq-AL.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -37,4 +37,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/sv-SE.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/sv-SE.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/sv-SE.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/tr-TR.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/tr-TR.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/tr-TR.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -35,4 +35,8 @@ STRING_REG_HELP, "Yardım için ""REG /?"" yazınız.\n" STRING_FUNC_HELP, "Yardım için ""REG %1 /?"" yazınız.\n" STRING_VALUE_NOT_SET, "(DeÄer belirlenmemiÅ.)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/uk-UA.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/uk-UA.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/uk-UA.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -33,4 +33,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/zh-CN.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/zh-CN.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/zh-CN.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -35,4 +35,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/lang/zh-TW.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/lang/zh-TW.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/lang/zh-TW.rc [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -35,4 +35,8 @@ STRING_REG_HELP, "Type ""REG /?"" for help.\n" STRING_FUNC_HELP, "Type ""REG %1 /?"" for help.\n" STRING_VALUE_NOT_SET, "(value not set)" + STRING_IMPORT_USAGE, "REG IMPORT file.reg\n" + STRING_FILE_NOT_FOUND, "reg: The file '%1' was not found.\n" + STRING_OPEN_KEY_FAILED, "reg: Unable to open the registry key '%1'.\n" + STRING_ESCAPE_SEQUENCE, "reg: Unrecognized escape sequence [\\%1!c!]\n" } Modified: trunk/reactos/base/applications/cmdutils/reg/reg.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/reg.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/reg.c [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -25,10 +25,7 @@ #include <shlwapi.h> #include <wine/unicode.h> #include <wine/debug.h> -#include <errno.h> #include "reg.h" - -#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A)) WINE_DEFAULT_DEBUG_CHANNEL(reg); @@ -84,6 +81,40 @@ {REG_MULTI_SZ, type_multi_sz}, }; +void *heap_xalloc(size_t size) +{ + void *buf = HeapAlloc(GetProcessHeap(), 0, size); + if (!buf) + { + ERR("Out of memory!\n"); + exit(1); + } + return buf; +} + +void *heap_xrealloc(void *buf, size_t size) +{ + void *new_buf; + + if (buf) + new_buf = HeapReAlloc(GetProcessHeap(), 0, buf, size); + else + new_buf = HeapAlloc(GetProcessHeap(), 0, size); + + if (!new_buf) + { + ERR("Out of memory!\n"); + exit(1); + } + + return new_buf; +} + +BOOL heap_free(void *buf) +{ + return HeapFree(GetProcessHeap(), 0, buf); +} + static void output_writeconsole(const WCHAR *str, DWORD wlen) { DWORD count, ret; @@ -99,12 +130,11 @@ * one in that case. */ len = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, NULL, 0, NULL, NULL); - msgA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char)); - if (!msgA) return; + msgA = heap_xalloc(len); WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, msgA, len, NULL, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE); - HeapFree(GetProcessHeap(), 0, msgA); + heap_free(msgA); } } @@ -125,7 +155,7 @@ LocalFree(str); } -static void __cdecl output_message(unsigned int id, ...) +void __cdecl output_message(unsigned int id, ...) { WCHAR fmt[1024]; __ms_va_list va_args; @@ -188,7 +218,7 @@ (input_path[length] == 0 || input_path[length] == '\\')); } -static HKEY path_get_rootkey(const WCHAR *path) +HKEY path_get_rootkey(const WCHAR *path) { DWORD i; @@ -246,7 +276,7 @@ case REG_EXPAND_SZ: { *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR); - out_data = HeapAlloc(GetProcessHeap(),0,*reg_count); + out_data = heap_xalloc(*reg_count); lstrcpyW((LPWSTR)out_data,data); break; } @@ -256,13 +286,13 @@ { LPWSTR rest; unsigned long val; - val = strtoulW(data, &rest, (tolowerW(data[1]) == 'x') ? 16 : 10); - if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE) || val > ~0u) { + val = wcstoul(data, &rest, (tolowerW(data[1]) == 'x') ? 16 : 10); + if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE)) { output_message(STRING_MISSING_INTEGER); break; } *reg_count = sizeof(DWORD); - out_data = HeapAlloc(GetProcessHeap(),0,*reg_count); + out_data = heap_xalloc(*reg_count); ((LPDWORD)out_data)[0] = val; break; } @@ -271,7 +301,7 @@ BYTE hex0, hex1; int i = 0, destByteIndex = 0, datalen = lstrlenW(data); *reg_count = ((datalen + datalen % 2) / 2) * sizeof(BYTE); - out_data = HeapAlloc(GetProcessHeap(), 0, *reg_count); + out_data = heap_xalloc(*reg_count); if(datalen % 2) { hex1 = hexchar_to_byte(data[i++]); @@ -290,7 +320,7 @@ break; no_hex_data: /* cleanup, print error */ - HeapFree(GetProcessHeap(), 0, out_data); + heap_free(out_data); output_message(STRING_MISSING_HEXDATA); out_data = NULL; break; @@ -298,7 +328,7 @@ case REG_MULTI_SZ: { int i, destindex, len = strlenW(data); - WCHAR *buffer = HeapAlloc(GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR)); + WCHAR *buffer = heap_xalloc((len + 2) * sizeof(WCHAR)); for (i = 0, destindex = 0; i < len; i++, destindex++) { @@ -314,7 +344,7 @@ if (destindex && !buffer[destindex - 1] && (!buffer[destindex] || destindex == 1)) { - HeapFree(GetProcessHeap(), 0, buffer); + heap_free(buffer); output_message(STRING_INVALID_STRING); return NULL; } @@ -402,7 +432,7 @@ } RegSetValueExW(key, value_name, 0, reg_type, reg_data, reg_count); - HeapFree(GetProcessHeap(),0,reg_data); + heap_free(reg_data); } RegCloseKey(key); @@ -454,40 +484,35 @@ if (value_all) { - LPWSTR szValue; - DWORD maxValue; - DWORD count; + DWORD max_value_len = 256, value_len; + WCHAR *value_name; LONG rc; - rc = RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, &maxValue, NULL, NULL, NULL); - if (rc != ERROR_SUCCESS) - { - RegCloseKey(key); - output_message(STRING_GENERAL_FAILURE); - return 1; - } - maxValue++; - szValue = HeapAlloc(GetProcessHeap(),0,maxValue*sizeof(WCHAR)); + value_name = heap_xalloc(max_value_len * sizeof(WCHAR)); while (1) { - count = maxValue; - rc = RegEnumValueW(key, 0, szValue, &count, NULL, NULL, NULL, NULL); + value_len = max_value_len; + rc = RegEnumValueW(key, 0, value_name, &value_len, NULL, NULL, NULL, NULL); if (rc == ERROR_SUCCESS) { - rc = RegDeleteValueW(key, szValue); + rc = RegDeleteValueW(key, value_name); if (rc != ERROR_SUCCESS) { - HeapFree(GetProcessHeap(), 0, szValue); + heap_free(value_name); RegCloseKey(key); output_message(STRING_VALUEALL_FAILED, key_name); return 1; } } + else if (rc == ERROR_MORE_DATA) + { + max_value_len *= 2; + value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR)); + } else break; } - HeapFree(GetProcessHeap(), 0, szValue); + heap_free(value_name); } else if (value_name || value_empty) { @@ -513,16 +538,16 @@ { case REG_SZ: case REG_EXPAND_SZ: - buffer = HeapAlloc(GetProcessHeap(), 0, size_bytes); + buffer = heap_xalloc(size_bytes); strcpyW(buffer, (WCHAR *)src); break; case REG_NONE: case REG_BINARY: { WCHAR *ptr; - WCHAR fmt[] = {'%','0','2','X',0}; - - buffer = HeapAlloc(GetProcessHeap(), 0, (size_bytes * 2 + 1) * sizeof(WCHAR)); + static const WCHAR fmt[] = {'%','0','2','X',0}; + + buffer = heap_xalloc((size_bytes * 2 + 1) * sizeof(WCHAR)); ptr = buffer; for (i = 0; i < size_bytes; i++) ptr += sprintfW(ptr, fmt, src[i]); @@ -533,9 +558,9 @@ case REG_DWORD_BIG_ENDIAN: { const int zero_x_dword = 10; - WCHAR fmt[] = {'0','x','%','x',0}; - - buffer = HeapAlloc(GetProcessHeap(), 0, (zero_x_dword + 1) * sizeof(WCHAR)); + static const WCHAR fmt[] = {'0','x','%','x',0}; + + buffer = heap_xalloc((zero_x_dword + 1) * sizeof(WCHAR)); sprintfW(buffer, fmt, *(DWORD *)src); break; } @@ -548,13 +573,13 @@ if (size_bytes <= two_wchars) { - buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)); + buffer = heap_xalloc(sizeof(WCHAR)); *buffer = 0; return buffer; } tmp_size = size_bytes - two_wchars; /* exclude both null terminators */ - buffer = HeapAlloc(GetProcessHeap(), 0, tmp_size * 2 + sizeof(WCHAR)); + buffer = heap_xalloc(tmp_size * 2 + sizeof(WCHAR)); len = tmp_size / sizeof(WCHAR); for (i = 0, destindex = 0; i < len; i++, destindex++) @@ -588,10 +613,10 @@ static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD data_size) { - WCHAR fmt[] = {' ',' ',' ',' ','%','1',0}; + static const WCHAR fmt[] = {' ',' ',' ',' ','%','1',0}; + static const WCHAR newlineW[] = {'\n',0}; WCHAR defval[32]; WCHAR *reg_data; - WCHAR newlineW[] = {'\n',0}; if (value_name && value_name[0]) output_string(fmt, value_name); @@ -606,7 +631,7 @@ { reg_data = reg_data_to_wchar(type, data, data_size); output_string(fmt, reg_data); - HeapFree(GetProcessHeap(), 0, reg_data); + heap_free(reg_data); } else { @@ -619,25 +644,23 @@ static WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len) { WCHAR *subkey_path; - WCHAR fmt[] = {'%','s','\\','%','s',0}; - - subkey_path = HeapAlloc(GetProcessHeap(), 0, (path_len + subkey_len + 2) * sizeof(WCHAR)); - if (!subkey_path) - { - ERR("Failed to allocate memory for subkey_path\n"); - return NULL; - } + static const WCHAR fmt[] = {'%','s','\\','%','s',0}; + + subkey_path = heap_xalloc((path_len + subkey_len + 2) * sizeof(WCHAR)); sprintfW(subkey_path, fmt, path, subkey_name); + return subkey_path; } static unsigned int num_values_found = 0; +#define MAX_SUBKEY_LEN 257 + static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse) { LONG rc; - DWORD num_subkeys, max_subkey_len, subkey_len; - DWORD max_data_bytes, data_size; + DWORD max_data_bytes = 2048, data_size; + DWORD subkey_len; DWORD type, path_len, i; BYTE *data; WCHAR fmt[] = {'%','1','\n',0}; @@ -645,23 +668,20 @@ WCHAR *subkey_name, *subkey_path; HKEY subkey; - rc = RegQueryInfoKeyW(key, NULL, NULL, NULL, &num_subkeys, &max_subkey_len, - NULL, NULL, NULL, &max_data_bytes, NULL, NULL); - if (rc) - { - ERR("RegQueryInfoKey failed: %d\n", rc); - return 1; - } - - data = HeapAlloc(GetProcessHeap(), 0, max_data_bytes); - if (!data) - { - ERR("Failed to allocate memory for data\n"); - return 1; - } - - data_size = max_data_bytes; - rc = RegQueryValueExW(key, value_name, NULL, &type, data, &data_size); + data = heap_xalloc(max_data_bytes); + + for (;;) + { + data_size = max_data_bytes; + rc = RegQueryValueExW(key, value_name, NULL, &type, data, &data_size); + if (rc == ERROR_MORE_DATA) + { + max_data_bytes = data_size; + data = heap_xrealloc(data, max_data_bytes); + } + else break; + } + if (rc == ERROR_SUCCESS) { output_string(fmt, path); @@ -670,7 +690,7 @@ num_values_found++; } - HeapFree(GetProcessHeap(), 0, data); + heap_free(data); if (!recurse) { @@ -687,19 +707,14 @@ return 0; } - max_subkey_len++; - subkey_name = HeapAlloc(GetProcessHeap(), 0, max_subkey_len * sizeof(WCHAR)); - if (!subkey_name) - { - ERR("Failed to allocate memory for subkey_name\n"); - return 1; - } + subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); path_len = strlenW(path); - for (i = 0; i < num_subkeys; i++) - { - subkey_len = max_subkey_len; + i = 0; + for (;;) + { + subkey_len = MAX_SUBKEY_LEN; rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); if (rc == ERROR_SUCCESS) { @@ -709,20 +724,22 @@ query_value(subkey, value_name, subkey_path, recurse); RegCloseKey(subkey); } - HeapFree(GetProcessHeap(), 0, subkey_path); - } - } - - HeapFree(GetProcessHeap(), 0, subkey_name); + heap_free(subkey_path); + i++; + } + else break; + } + + heap_free(subkey_name); return 0; } static int query_all(HKEY key, WCHAR *path, BOOL recurse) { LONG rc; - DWORD num_subkeys, max_subkey_len, subkey_len; - DWORD num_values, max_value_len, value_len; - DWORD max_data_bytes, data_size; + DWORD max_value_len = 256, value_len; + DWORD max_data_bytes = 2048, data_size; + DWORD subkey_len; DWORD i, type, path_len; WCHAR fmt[] = {'%','1','\n',0}; WCHAR fmt_path[] = {'%','1','\\','%','2','\n',0}; @@ -731,60 +748,52 @@ BYTE *data; HKEY subkey; - rc = RegQueryInfoKeyW(key, NULL, NULL, NULL, &num_subkeys, &max_subkey_len, NULL, - &num_values, &max_value_len, &max_data_bytes, NULL, NULL); - if (rc) - { - ERR("RegQueryInfoKey failed: %d\n", rc); - return 1; - } - output_string(fmt, path); - max_value_len++; - value_name = HeapAlloc(GetProcessHeap(), 0, max_value_len * sizeof(WCHAR)); - if (!value_name) - { - ERR("Failed to allocate memory for value_name\n"); - return 1; - } - - data = HeapAlloc(GetProcessHeap(), 0, max_data_bytes); - if (!data) - { - HeapFree(GetProcessHeap(), 0, value_name); - ERR("Failed to allocate memory for data\n"); - return 1; - } - - for (i = 0; i < num_values; i++) + value_name = heap_xalloc(max_value_len * sizeof(WCHAR)); + data = heap_xalloc(max_data_bytes); + + i = 0; + for (;;) { value_len = max_value_len; data_size = max_data_bytes; rc = RegEnumValueW(key, i, value_name, &value_len, NULL, &type, data, &data_size); if (rc == ERROR_SUCCESS) + { output_value(value_name, type, data, data_size); - } - - HeapFree(GetProcessHeap(), 0, data); - HeapFree(GetProcessHeap(), 0, value_name); - - if (num_values || recurse) + i++; + } + else if (rc == ERROR_MORE_DATA) + { + if (data_size > max_data_bytes) + { + max_data_bytes = data_size; + data = heap_xrealloc(data, max_data_bytes); + } + else + { + max_value_len *= 2; + value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR)); + } + } + else break; + } + + heap_free(data); + heap_free(value_name); + + if (i || recurse) output_string(newlineW); - max_subkey_len++; - subkey_name = HeapAlloc(GetProcessHeap(), 0, max_subkey_len * sizeof(WCHAR)); - if (!subkey_name) - { - ERR("Failed to allocate memory for subkey_name\n"); - return 1; - } + subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); path_len = strlenW(path); - for (i = 0; i < num_subkeys; i++) - { - subkey_len = max_subkey_len; + i = 0; + for (;;) + { + subkey_len = MAX_SUBKEY_LEN; rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); if (rc == ERROR_SUCCESS) { @@ -796,15 +805,17 @@ query_all(subkey, subkey_path, recurse); RegCloseKey(subkey); } - HeapFree(GetProcessHeap(), 0, subkey_path); + heap_free(subkey_path); } else output_string(fmt_path, path, subkey_name); - } - } - - HeapFree(GetProcessHeap(), 0, subkey_name); - - if (num_subkeys && !recurse) + i++; + } + else break; + } + + heap_free(subkey_name); + + if (i && !recurse) output_string(newlineW); return 0; @@ -855,13 +866,13 @@ if (!path) { - long_key = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + long_key = heap_xalloc((len + 1) * sizeof(WCHAR)); strcpyW(long_key, root_rels[i].long_name); return long_key; } len += strlenW(path) + 1; /* add one for the backslash */ - long_key = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + long_key = heap_xalloc((len + 1) * sizeof(WCHAR)); sprintfW(long_key, fmt, root_rels[i].long_name, path); return long_key; } @@ -900,32 +911,38 @@ enum operations { REG_ADD, REG_DELETE, + REG_IMPORT, REG_QUERY, REG_INVALID }; -static const WCHAR addW[] = {'a','d','d',0}; -static const WCHAR deleteW[] = {'d','e','l','e','t','e',0}; -static const WCHAR queryW[] = {'q','u','e','r','y',0}; - static enum operations get_operation(const WCHAR *str, int *op_help) { - if (!lstrcmpiW(str, addW)) - { - *op_help = STRING_ADD_USAGE; - return REG_ADD; - } - - if (!lstrcmpiW(str, deleteW)) - { - *op_help = STRING_DELETE_USAGE; - return REG_DELETE; - } - - if (!lstrcmpiW(str, queryW)) - { - *op_help = STRING_QUERY_USAGE; - return REG_QUERY; + struct op_info { const WCHAR *op; int id; int help_id; }; + + static const WCHAR add[] = {'a','d','d',0}; + static const WCHAR delete[] = {'d','e','l','e','t','e',0}; + static const WCHAR import[] = {'i','m','p','o','r','t',0}; + static const WCHAR query[] = {'q','u','e','r','y',0}; + + static const struct op_info op_array[] = + { + { add, REG_ADD, STRING_ADD_USAGE }, + { delete, REG_DELETE, STRING_DELETE_USAGE }, + { import, REG_IMPORT, STRING_IMPORT_USAGE }, + { query, REG_QUERY, STRING_QUERY_USAGE }, + { NULL, -1, 0 } + }; + + const struct op_info *ptr; + + for (ptr = op_array; ptr->op; ptr++) + { + if (!lstrcmpiW(str, ptr->op)) + { + *op_help = ptr->help_id; + return ptr->id; + } } return REG_INVALID; @@ -966,7 +983,7 @@ if (argc > 2) show_op_help = is_help_switch(argvW[2]); - if (argc == 2 || (show_op_help && argc > 3)) + if (argc == 2 || ((show_op_help || op == REG_IMPORT) && argc > 3)) { output_message(STRING_INVALID_SYNTAX); output_message(STRING_FUNC_HELP, struprW(argvW[1])); @@ -977,6 +994,9 @@ output_message(op_help); return 0; } + + if (op == REG_IMPORT) + return reg_import(argvW[2]); if (!parse_registry_key(argvW[2], &root, &path, &key_name)) return 1; @@ -1061,7 +1081,7 @@ ret = reg_add(root, path, value_name, value_empty, type, separator, data, force); else if (op == REG_DELETE) ret = reg_delete(root, path, key_name, value_name, value_empty, value_all, force); - else if (op == REG_QUERY) + else ret = reg_query(root, path, key_name, value_name, value_empty, recurse); return ret; } Modified: trunk/reactos/base/applications/cmdutils/reg/reg.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/reg.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/reg/reg.h [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -1,7 +1,5 @@ /* - * REG.EXE - Wine-compatible reg program. - * - * Copyright 2008 Andrew Riedi + * Copyright 2017 Hugh McMaster * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,39 +16,21 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#pragma once +#ifndef __REG_H__ +#define __REG_H__ -//#include <windef.h> +#include "resource.h" -/* Translation IDs. */ -#define STRING_USAGE 101 -#define STRING_ADD_USAGE 102 -#define STRING_DELETE_USAGE 103 -#define STRING_QUERY_USAGE 104 -#define STRING_SUCCESS 105 -#define STRING_INVALID_KEY 106 -#define STRING_INVALID_CMDLINE 107 -#define STRING_NO_REMOTE 108 -#define STRING_CANNOT_FIND 109 -#define STRING_UNSUPPORTED_TYPE 110 -#define STRING_MISSING_INTEGER 111 -#define STRING_MISSING_HEXDATA 112 -#define STRING_UNHANDLED_TYPE 113 -#define STRING_OVERWRITE_VALUE 114 -#define STRING_YESNO 115 -#define STRING_YES 116 -#define STRING_NO 117 -#define STRING_CANCELLED 118 -#define STRING_DEFAULT_VALUE 119 -#define STRING_DELETE_VALUE 120 -#define STRING_DELETE_VALUEALL 121 -#define STRING_DELETE_SUBKEY 122 -#define STRING_INVALID_STRING 123 -#define STRING_VALUEALL_FAILED 124 -#define STRING_GENERAL_FAILURE 125 -#define STRING_MATCHES_FOUND 126 -#define STRING_INVALID_SYNTAX 127 -#define STRING_INVALID_OPTION 128 -#define STRING_REG_HELP 129 -#define STRING_FUNC_HELP 130 -#define STRING_VALUE_NOT_SET 131 +#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A)) + +/* reg.c */ +void *heap_xalloc(size_t size); +void *heap_xrealloc(void *buf, size_t size); +BOOL heap_free(void *buf); +void __cdecl output_message(unsigned int id, ...); +HKEY path_get_rootkey(const WCHAR *path); + +/* import.c */ +int reg_import(const WCHAR *filename); + +#endif /* __REG_H__ */ Added: trunk/reactos/base/applications/cmdutils/reg/resource.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/reg/resource.h (added) +++ trunk/reactos/base/applications/cmdutils/reg/resource.h [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -0,0 +1,60 @@ +/* + * REG.EXE - Wine-compatible reg program. + * + * Copyright 2008 Andrew Riedi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma once + +//#include <windef.h> + +/* Translation IDs. */ +#define STRING_USAGE 101 +#define STRING_ADD_USAGE 102 +#define STRING_DELETE_USAGE 103 +#define STRING_QUERY_USAGE 104 +#define STRING_SUCCESS 105 +#define STRING_INVALID_KEY 106 +#define STRING_INVALID_CMDLINE 107 +#define STRING_NO_REMOTE 108 +#define STRING_CANNOT_FIND 109 +#define STRING_UNSUPPORTED_TYPE 110 +#define STRING_MISSING_INTEGER 111 +#define STRING_MISSING_HEXDATA 112 +#define STRING_UNHANDLED_TYPE 113 +#define STRING_OVERWRITE_VALUE 114 +#define STRING_YESNO 115 +#define STRING_YES 116 +#define STRING_NO 117 +#define STRING_CANCELLED 118 +#define STRING_DEFAULT_VALUE 119 +#define STRING_DELETE_VALUE 120 +#define STRING_DELETE_VALUEALL 121 +#define STRING_DELETE_SUBKEY 122 +#define STRING_INVALID_STRING 123 +#define STRING_VALUEALL_FAILED 124 +#define STRING_GENERAL_FAILURE 125 +#define STRING_MATCHES_FOUND 126 +#define STRING_INVALID_SYNTAX 127 +#define STRING_INVALID_OPTION 128 +#define STRING_REG_HELP 129 +#define STRING_FUNC_HELP 130 +#define STRING_VALUE_NOT_SET 131 +#define STRING_IMPORT_USAGE 132 +#define STRING_FILE_NOT_FOUND 133 +#define STRING_OPEN_KEY_FAILED 134 +#define STRING_ESCAPE_SEQUENCE 135 Propchange: trunk/reactos/base/applications/cmdutils/reg/resource.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:33:04 2017 @@ -227,7 +227,7 @@ ReactOS shares the following programs with Winehq. reactos/base/applications/cmdutils/cscript # Synced to WineStaging-2.9 -reactos/base/applications/cmdutils/reg # Synced to WineStaging-2.9 +reactos/base/applications/cmdutils/reg # Synced to WineStaging-2.16 reactos/base/applications/cmdutils/schtasks # Synced to WineStaging-2.9 reactos/base/applications/cmdutils/taskkill # Synced to WineStaging-2.9 reactos/base/applications/cmdutils/wmic # Synced to WineStaging-2.9
7 years, 3 months
1
0
0
0
[akhaldi] 75957: [PSDK] Update winreg.h. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:32:16 2017 New Revision: 75957 URL:
http://svn.reactos.org/svn/reactos?rev=75957&view=rev
Log: [PSDK] Update winreg.h. CORE-13762 Modified: trunk/reactos/sdk/include/psdk/winreg.h Modified: trunk/reactos/sdk/include/psdk/winreg.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/winreg.h?…
============================================================================== --- trunk/reactos/sdk/include/psdk/winreg.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/winreg.h [iso-8859-1] Sun Sep 24 11:32:16 2017 @@ -7,13 +7,16 @@ #include <reason.h> -#define HKEY_CLASSES_ROOT ((HKEY)0x80000000) -#define HKEY_CURRENT_USER ((HKEY)0x80000001) -#define HKEY_LOCAL_MACHINE ((HKEY)0x80000002) -#define HKEY_USERS ((HKEY)0x80000003) -#define HKEY_PERFORMANCE_DATA ((HKEY)0x80000004) -#define HKEY_CURRENT_CONFIG ((HKEY)0x80000005) -#define HKEY_DYN_DATA ((HKEY)0x80000006) +#define HKEY_CLASSES_ROOT ((HKEY)(LONG_PTR)(LONG)0x80000000) +#define HKEY_CURRENT_USER ((HKEY)(LONG_PTR)(LONG)0x80000001) +#define HKEY_LOCAL_MACHINE ((HKEY)(LONG_PTR)(LONG)0x80000002) +#define HKEY_USERS ((HKEY)(LONG_PTR)(LONG)0x80000003) +#define HKEY_PERFORMANCE_DATA ((HKEY)(LONG_PTR)(LONG)0x80000004) +#define HKEY_CURRENT_CONFIG ((HKEY)(LONG_PTR)(LONG)0x80000005) +#define HKEY_DYN_DATA ((HKEY)(LONG_PTR)(LONG)0x80000006) +#define HKEY_PERFORMANCE_TEXT ((HKEY)(LONG_PTR)(LONG)0x80000050) +#define HKEY_PERFORMANCE_NLSTEXT ((HKEY)(LONG_PTR)(LONG)0x80000060) + #define REG_OPTION_VOLATILE 1 #define REG_OPTION_NON_VOLATILE 0 #define REG_CREATED_NEW_KEY 1
7 years, 3 months
1
0
0
0
[akhaldi] 75956: [XMLLITE_WINETEST] Addendum to r75951.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:27:47 2017 New Revision: 75956 URL:
http://svn.reactos.org/svn/reactos?rev=75956&view=rev
Log: [XMLLITE_WINETEST] Addendum to r75951. Modified: trunk/rostests/winetests/xmllite/writer.c Modified: trunk/rostests/winetests/xmllite/writer.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xmllite/writer.…
============================================================================== --- trunk/rostests/winetests/xmllite/writer.c [iso-8859-1] (original) +++ trunk/rostests/winetests/xmllite/writer.c [iso-8859-1] Sun Sep 24 11:27:47 2017 @@ -394,7 +394,7 @@ ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); /* TODO: WriteSurrogateCharEntity */ - /* ???TODO: WriteWhitespace */ + /* ÙÙÙTODO: WriteWhitespace */ hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Failed to flush, hr %#x.\n", hr);
7 years, 3 months
1
0
0
0
[akhaldi] 75955: [FREETYPE] Update to v2.8.1. CORE-13825
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:20:15 2017 New Revision: 75955 URL:
http://svn.reactos.org/svn/reactos?rev=75955&view=rev
Log: [FREETYPE] Update to v2.8.1. CORE-13825 Modified: trunk/reactos/media/doc/3rd Party Files.txt trunk/reactos/sdk/lib/3rdparty/freetype/ChangeLog trunk/reactos/sdk/lib/3rdparty/freetype/README trunk/reactos/sdk/lib/3rdparty/freetype/devel/ftoption.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/config/ftoption.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/freetype.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftautoh.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/fterrdef.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/fterrors.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftglyph.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftimage.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftlcdfil.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftmac.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftmm.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftoutln.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/internal/ftcalc.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/internal/ftobjs.h trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/tttags.h trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afblue.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afblue.dat trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afblue.h trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afcjk.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afhints.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/aflatin.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/aflatin2.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afloader.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afmodule.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afscript.h trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afshaper.c trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afstyles.h trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftbitmap.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftcalc.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftglyph.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftlcdfil.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftmac.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftmm.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftobjs.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftoutln.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftrfork.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftsynth.c trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftutil.c trunk/reactos/sdk/lib/3rdparty/freetype/src/bdf/bdfdrivr.c trunk/reactos/sdk/lib/3rdparty/freetype/src/bdf/bdflib.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cache/ftcbasic.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2blues.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2blues.h trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2fixed.h trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2font.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2ft.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2hints.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2intrp.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cffgload.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cffload.c trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cffparse.c trunk/reactos/sdk/lib/3rdparty/freetype/src/gxvalid/README trunk/reactos/sdk/lib/3rdparty/freetype/src/pcf/README trunk/reactos/sdk/lib/3rdparty/freetype/src/pcf/pcfdrivr.c trunk/reactos/sdk/lib/3rdparty/freetype/src/pcf/pcfread.c trunk/reactos/sdk/lib/3rdparty/freetype/src/pfr/pfrobjs.c trunk/reactos/sdk/lib/3rdparty/freetype/src/psaux/psconv.c trunk/reactos/sdk/lib/3rdparty/freetype/src/psaux/t1decode.c trunk/reactos/sdk/lib/3rdparty/freetype/src/psnames/psmodule.c trunk/reactos/sdk/lib/3rdparty/freetype/src/psnames/pstables.h trunk/reactos/sdk/lib/3rdparty/freetype/src/raster/ftrend1.c trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/pngshim.c trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/sfobjs.c trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttcmap.c trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttcmap.h trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttkern.c trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttpost.c trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttsbit.c trunk/reactos/sdk/lib/3rdparty/freetype/src/smooth/ftgrays.c trunk/reactos/sdk/lib/3rdparty/freetype/src/smooth/ftsmooth.c trunk/reactos/sdk/lib/3rdparty/freetype/src/tools/glnames.py trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttgload.c trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttgxvar.c trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttinterp.c trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttinterp.h trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttobjs.c trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttpload.c trunk/reactos/sdk/lib/3rdparty/freetype/src/type1/t1load.c trunk/reactos/sdk/lib/3rdparty/freetype/src/type1/t1objs.c trunk/reactos/sdk/lib/3rdparty/freetype/src/type42/t42objs.c trunk/reactos/sdk/lib/3rdparty/freetype/src/winfonts/winfnt.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/media/doc/3rd Party Files.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/3rd%20Party%20Fi…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/ChangeLog URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/README URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/devel/ftoption.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/config/ftoption.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/freetype.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftautoh.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/fterrdef.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/fterrors.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftglyph.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftimage.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftlcdfil.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftmac.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftmm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/ftoutln.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/internal/ftcalc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/internal/ftobjs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/include/freetype/tttags.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afblue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afblue.dat URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afblue.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afcjk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afhints.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/aflatin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/aflatin2.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afloader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afmodule.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afscript.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afshaper.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/autofit/afstyles.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftbitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftcalc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftglyph.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftlcdfil.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftmac.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftmm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftobjs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftoutln.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftrfork.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftsynth.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/base/ftutil.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/bdf/bdfdrivr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/bdf/bdflib.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cache/ftcbasic.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2blues.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2blues.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2fixed.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2font.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2ft.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2hints.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cf2intrp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cffgload.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cffload.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/cff/cffparse.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/gxvalid/README URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/pcf/README URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/pcf/pcfdrivr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/pcf/pcfread.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/pfr/pfrobjs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/psaux/psconv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/psaux/t1decode.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/psnames/psmodule.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/psnames/pstables.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/raster/ftrend1.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/pngshim.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/sfobjs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttcmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttcmap.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttkern.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttpost.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/sfnt/ttsbit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/smooth/ftgrays.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/smooth/ftsmooth.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/tools/glnames.py URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttgload.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttgxvar.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttinterp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttinterp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttobjs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/truetype/ttpload.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/type1/t1load.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/type1/t1objs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/type42/t42objs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
Modified: trunk/reactos/sdk/lib/3rdparty/freetype/src/winfonts/winfnt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/3rdparty/freetype/…
7 years, 3 months
1
0
0
0
[akhaldi] 75954: [WINDOWSCODECS_WINETEST] Sync with Wine Staging 2.16. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:19:20 2017 New Revision: 75954 URL:
http://svn.reactos.org/svn/reactos?rev=75954&view=rev
Log: [WINDOWSCODECS_WINETEST] Sync with Wine Staging 2.16. CORE-13762 Modified: trunk/rostests/winetests/windowscodecs/CMakeLists.txt trunk/rostests/winetests/windowscodecs/converter.c trunk/rostests/winetests/windowscodecs/metadata.c Modified: trunk/rostests/winetests/windowscodecs/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/C…
============================================================================== --- trunk/rostests/winetests/windowscodecs/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/CMakeLists.txt [iso-8859-1] Sun Sep 24 11:19:20 2017 @@ -18,7 +18,7 @@ add_executable(windowscodecs_winetest ${SOURCE}) set_module_type(windowscodecs_winetest win32cui) -add_importlibs(windowscodecs_winetest windowscodecs oleaut32 ole32 user32 gdi32 shlwapi msvcrt kernel32) +add_importlibs(windowscodecs_winetest windowscodecs oleaut32 ole32 propsys user32 gdi32 shlwapi msvcrt kernel32) if(MSVC) add_importlibs(windowscodecs_winetest ntdll) Modified: trunk/rostests/winetests/windowscodecs/converter.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/c…
============================================================================== --- trunk/rostests/winetests/windowscodecs/converter.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/converter.c [iso-8859-1] Sun Sep 24 11:19:20 2017 @@ -54,6 +54,9 @@ const bitmap_data *data; } BitmapTestSrc; +extern HRESULT STDMETHODCALLTYPE IWICBitmapFrameEncode_WriteSource_Proxy(IWICBitmapFrameEncode* This, + IWICBitmapSource *pIBitmapSource, WICRect *prc); + static BOOL near_equal(float a, float b) { return fabsf(a - b) < 0.001; @@ -631,6 +634,12 @@ static const WCHAR wszCompressionQuality[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0}; static const WCHAR wszInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0}; static const WCHAR wszFilterOption[] = {'F','i','l','t','e','r','O','p','t','i','o','n',0}; +static const WCHAR wszImageQuality[] = {'I','m','a','g','e','Q','u','a','l','i','t','y',0}; +static const WCHAR wszBitmapTransform[] = {'B','i','t','m','a','p','T','r','a','n','s','f','o','r','m',0}; +static const WCHAR wszLuminance[] = {'L','u','m','i','n','a','n','c','e',0}; +static const WCHAR wszChrominance[] = {'C','h','r','o','m','i','n','a','n','c','e',0}; +static const WCHAR wszJpegYCrCbSubsampling[] = {'J','p','e','g','Y','C','r','C','b','S','u','b','s','a','m','p','l','i','n','g',0}; +static const WCHAR wszSuppressApp0[] = {'S','u','p','p','r','e','s','s','A','p','p','0',0}; static const struct property_opt_test_data testdata_tiff_props[] = { { wszTiffCompressionMethod, VT_UI1, VT_UI1, WICTiffCompressionDontCare }, @@ -641,6 +650,16 @@ static const struct property_opt_test_data testdata_png_props[] = { { wszInterlaceOption, VT_BOOL, VT_BOOL, 0 }, { wszFilterOption, VT_UI1, VT_UI1, WICPngFilterUnspecified, 0.0f, TRUE /* not supported on XP/2k3 */}, + { NULL } +}; + +static const struct property_opt_test_data testdata_jpeg_props[] = { + { wszImageQuality, VT_R4, VT_EMPTY }, + { wszBitmapTransform, VT_UI1, VT_UI1, WICBitmapTransformRotate0 }, + { wszLuminance, VT_I4|VT_ARRAY, VT_EMPTY }, + { wszChrominance, VT_I4|VT_ARRAY, VT_EMPTY }, + { wszJpegYCrCbSubsampling, VT_UI1, VT_UI1, WICJpegYCrCbSubsamplingDefault, 0.0f, TRUE }, /* not supported on XP/2k3 */ + { wszSuppressApp0, VT_BOOL, VT_BOOL, FALSE }, { NULL } }; @@ -768,6 +787,8 @@ test_specific_encoder_properties(options, testdata_tiff_props, all_props, cProperties2); else if (IsEqualCLSID(clsid_encoder, &CLSID_WICPngEncoder)) test_specific_encoder_properties(options, testdata_png_props, all_props, cProperties2); + else if (IsEqualCLSID(clsid_encoder, &CLSID_WICJpegEncoder)) + test_specific_encoder_properties(options, testdata_jpeg_props, all_props, cProperties2); for (i=0; i < cProperties2; i++) { @@ -1367,6 +1388,13 @@ DeleteTestBitmap(src_obj); i++; + } + + if (clsid_decoder == NULL) + { + IStream_Release(stream); + IWICBitmapEncoder_Release(encoder); + return; } if (SUCCEEDED(hr)) @@ -1869,6 +1897,9 @@ test_encoder(&testdata_24bppBGR, &CLSID_WICTiffEncoder, &testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR"); + test_encoder(&testdata_24bppBGR, &CLSID_WICJpegEncoder, + &testdata_24bppBGR, NULL, "JPEG encoder 24bppBGR"); + test_multi_encoder(multiple_frames, &CLSID_WICTiffEncoder, multiple_frames, &CLSID_WICTiffDecoder, NULL, NULL, "TIFF encoder multi-frame", NULL); Modified: trunk/rostests/winetests/windowscodecs/metadata.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/m…
============================================================================== --- trunk/rostests/winetests/windowscodecs/metadata.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/metadata.c [iso-8859-1] Sun Sep 24 11:19:20 2017 @@ -30,10 +30,16 @@ #include <windef.h> #include <winbase.h> +#include <winnls.h> +#include <winreg.h> #include <ole2.h> //#include "wincodec.h" #include <wincodecsdk.h> +#include <propvarutil.h> #include <wine/test.h> + +#include <initguid.h> +DEFINE_GUID(IID_MdbrUnknown, 0x00240e6f,0x3f23,0x4432,0xb0,0xcc,0x48,0xd5,0xbb,0xff,0x6c,0x36); #define expect_blob(propvar, data, length) do { \ ok((propvar).vt == VT_BLOB, "unexpected vt: %i\n", (propvar).vt); \ @@ -1552,13 +1558,207 @@ IWICMetadataBlockReader_Release(blockreader); } + hr = IWICBitmapDecoder_GetMetadataQueryReader(decoder, &queryreader); + ok(hr == S_OK || broken(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION) /* before Vista */, + "GetMetadataQueryReader error %#x\n", hr); + if (SUCCEEDED(hr)) + { + static const struct + { + const char *query; + HRESULT hr; + UINT vt; + } decoder_data[] = + { + { "/logscrdesc/Signature", S_OK, VT_UI1 | VT_VECTOR }, + { "/[0]logscrdesc/Signature", S_OK, VT_UI1 | VT_VECTOR }, + { "/logscrdesc/\\Signature", S_OK, VT_UI1 | VT_VECTOR }, + { "/Logscrdesc/\\signature", S_OK, VT_UI1 | VT_VECTOR }, + { "/logscrdesc/{str=signature}", S_OK, VT_UI1 | VT_VECTOR }, + { "/[0]logscrdesc/{str=signature}", S_OK, VT_UI1 | VT_VECTOR }, + { "/logscrdesc/{wstr=signature}", S_OK, VT_UI1 | VT_VECTOR }, + { "/[0]logscrdesc/{wstr=signature}", S_OK, VT_UI1 | VT_VECTOR }, + { "/appext/Application", S_OK, VT_UI1 | VT_VECTOR }, + { "/appext/{STR=APPlication}", S_OK, VT_UI1 | VT_VECTOR }, + { "/appext/{WSTR=APPlication}", S_OK, VT_UI1 | VT_VECTOR }, + { "/LogSCRdesC", S_OK, VT_UNKNOWN }, + { "/[0]LogSCRdesC", S_OK, VT_UNKNOWN }, + { "/appEXT", S_OK, VT_UNKNOWN }, + { "/[0]appEXT", S_OK, VT_UNKNOWN }, + { "grctlext", WINCODEC_ERR_PROPERTYNOTSUPPORTED, 0 }, + { "/imgdesc", WINCODEC_ERR_PROPERTYNOTFOUND, 0 }, + }; + static const WCHAR rootW[] = {'/',0}; + WCHAR name[256]; + UINT len, i, j; + PROPVARIANT value; + IWICMetadataQueryReader *meta_reader; + + hr = IWICMetadataQueryReader_GetContainerFormat(queryreader, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + + name[0] = 0; + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(queryreader, 256, name, &len); + ok(hr == S_OK, "GetLocation error %#x\n", hr); + ok(len == 2, "expected 2, got %u\n", len); + ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name)); + + for (i = 0; i < sizeof(decoder_data)/sizeof(decoder_data[0]); i++) + { + WCHAR queryW[256]; + + if (winetest_debug > 1) + trace("query: %s\n", decoder_data[i].query); + MultiByteToWideChar(CP_ACP, 0, decoder_data[i].query, -1, queryW, 256); + PropVariantInit(&value); + hr = IWICMetadataQueryReader_GetMetadataByName(queryreader, queryW, &value); + ok(hr == decoder_data[i].hr, "GetMetadataByName(%s) returned %#x, expected %#x\n", wine_dbgstr_w(queryW), hr, decoder_data[i].hr); + ok(value.vt == decoder_data[i].vt, "expected %#x, got %#x\n", decoder_data[i].vt, value.vt); + if (hr == S_OK && value.vt == VT_UNKNOWN) + { + hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataQueryReader, (void **)&meta_reader); + ok(hr == S_OK, "QueryInterface error %#x\n", hr); + + name[0] = 0; + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(meta_reader, 256, name, &len); + ok(hr == S_OK, "GetLocation error %#x\n", hr); + ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len); + ok(!lstrcmpW(name, queryW), "expected %s, got %s\n", wine_dbgstr_w(queryW), wine_dbgstr_w(name)); + + for (j = 0; j < sizeof(decoder_data)/sizeof(decoder_data[0]); j++) + { + MultiByteToWideChar(CP_ACP, 0, decoder_data[j].query, -1, queryW, 256); + + if (CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, queryW, len-1, name, len-1) == CSTR_EQUAL && decoder_data[j].query[len - 1] != 0) + { + if (winetest_debug > 1) + trace("query: %s\n", wine_dbgstr_w(queryW + len - 1)); + PropVariantClear(&value); + hr = IWICMetadataQueryReader_GetMetadataByName(meta_reader, queryW + len - 1, &value); + ok(hr == decoder_data[j].hr, "GetMetadataByName(%s) returned %#x, expected %#x\n", wine_dbgstr_w(queryW + len - 1), hr, decoder_data[j].hr); + ok(value.vt == decoder_data[j].vt, "expected %#x, got %#x\n", decoder_data[j].vt, value.vt); + } + } + + IWICMetadataQueryReader_Release(meta_reader); + } + + PropVariantClear(&value); + } + + IWICMetadataQueryReader_Release(queryreader); + } + hr = IWICBitmapFrameDecode_GetMetadataQueryReader(frame, &queryreader); - ok(hr == S_OK || - broken(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION) /* before Vista */, - "GetMetadataQueryReader failed: %08x\n", hr); - + ok(hr == S_OK || broken(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION) /* before Vista */, + "GetMetadataQueryReader error %#x\n", hr); if (SUCCEEDED(hr)) { + static const struct + { + const char *query; + HRESULT hr; + UINT vt; + } frame_data[] = + { + { "/grctlext/Delay", S_OK, VT_UI2 }, + { "/[0]grctlext/Delay", S_OK, VT_UI2 }, + { "/grctlext/{str=delay}", S_OK, VT_UI2 }, + { "/[0]grctlext/{str=delay}", S_OK, VT_UI2 }, + { "/grctlext/{wstr=delay}", S_OK, VT_UI2 }, + { "/[0]grctlext/{wstr=delay}", S_OK, VT_UI2 }, + { "/imgdesc/InterlaceFlag", S_OK, VT_BOOL }, + { "/imgdesc/{STR=interlaceFLAG}", S_OK, VT_BOOL }, + { "/imgdesc/{WSTR=interlaceFLAG}", S_OK, VT_BOOL }, + { "/grctlext", S_OK, VT_UNKNOWN }, + { "/[0]grctlext", S_OK, VT_UNKNOWN }, + { "/imgdesc", S_OK, VT_UNKNOWN }, + { "/[0]imgdesc", S_OK, VT_UNKNOWN }, + { "/LogSCRdesC", WINCODEC_ERR_PROPERTYNOTFOUND, 0 }, + { "/appEXT", WINCODEC_ERR_PROPERTYNOTFOUND, 0 }, + { "/grctlext/{\\str=delay}", WINCODEC_ERR_WRONGSTATE, 0 }, + { "/grctlext/{str=\\delay}", S_OK, VT_UI2 }, + { "grctlext/Delay", WINCODEC_ERR_PROPERTYNOTSUPPORTED, 0 }, + }; + static const WCHAR rootW[] = {'/',0}; + static const WCHAR guidW[] = {'/','{','g','u','i','d','=','\\',0}; + static const WCHAR imgdescW[] = {'i','m','g','d','e','s','c',0}; + static const WCHAR ImgDescW[] = {'I','m','g','D','e','s','c',0}; + WCHAR name[256], queryW[256]; + UINT len, i; + PROPVARIANT value; + IWICMetadataQueryReader *meta_reader; + + hr = IWICMetadataQueryReader_GetContainerFormat(queryreader, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + + name[0] = 0; + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(queryreader, 256, name, &len); + ok(hr == S_OK, "GetLocation error %#x\n", hr); + ok(len == 2, "expected 2, got %u\n", len); + ok(!lstrcmpW(name, rootW), "expected '/', got %s\n", wine_dbgstr_w(name)); + + for (i = 0; i < sizeof(frame_data)/sizeof(frame_data[0]); i++) + { + if (winetest_debug > 1) + trace("query: %s\n", frame_data[i].query); + MultiByteToWideChar(CP_ACP, 0, frame_data[i].query, -1, queryW, 256); + PropVariantInit(&value); + hr = IWICMetadataQueryReader_GetMetadataByName(queryreader, queryW, &value); + ok(hr == frame_data[i].hr, "GetMetadataByName(%s) returned %#x, expected %#x\n", wine_dbgstr_w(queryW), hr, frame_data[i].hr); + ok(value.vt == frame_data[i].vt, "expected %#x, got %#x\n", frame_data[i].vt, value.vt); + if (hr == S_OK && value.vt == VT_UNKNOWN) + { + hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataQueryReader, (void **)&meta_reader); + ok(hr == S_OK, "QueryInterface error %#x\n", hr); + + name[0] = 0; + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(meta_reader, 256, name, &len); + ok(hr == S_OK, "GetLocation error %#x\n", hr); + ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len); + ok(!lstrcmpW(name, queryW), "expected %s, got %s\n", wine_dbgstr_w(queryW), wine_dbgstr_w(name)); + + IWICMetadataQueryReader_Release(meta_reader); + } + + PropVariantClear(&value); + } + + name[0] = 0; + len = 0xdeadbeef; + hr = WICMapGuidToShortName(&GUID_MetadataFormatIMD, 256, name, &len); + ok(hr == S_OK, "WICMapGuidToShortName error %#x\n", hr); + ok(!lstrcmpW(name, imgdescW), "wrong short name %s\n", wine_dbgstr_w(name)); + + format = GUID_NULL; + hr = WICMapShortNameToGuid(imgdescW, &format); + ok(hr == S_OK, "WICMapGuidToShortName error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_MetadataFormatIMD), "wrong guid %s\n", wine_dbgstr_guid(&format)); + + format = GUID_NULL; + hr = WICMapShortNameToGuid(ImgDescW, &format); + ok(hr == S_OK, "WICMapGuidToShortName error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_MetadataFormatIMD), "wrong guid %s\n", wine_dbgstr_guid(&format)); + + lstrcpyW(queryW, guidW); + StringFromGUID2(&GUID_MetadataFormatIMD, queryW + lstrlenW(queryW) - 1, 39); + memcpy(queryW, guidW, sizeof(guidW) - 2); + if (winetest_debug > 1) + trace("query: %s\n", wine_dbgstr_w(queryW)); + PropVariantInit(&value); + hr = IWICMetadataQueryReader_GetMetadataByName(queryreader, queryW, &value); + ok(hr == S_OK, "GetMetadataByName(%s) error %#x\n", wine_dbgstr_w(queryW), hr); + ok(value.vt == VT_UNKNOWN, "expected VT_UNKNOWN, got %#x\n", value.vt); + PropVariantClear(&value); + IWICMetadataQueryReader_Release(queryreader); } @@ -2252,10 +2452,610 @@ } } +struct metadata_item +{ + const char *schema, *id_str; + UINT id, type, value; +}; + +struct metadata_block +{ + const GUID *metadata_format; + UINT count; + const struct metadata_item *item; +}; + +struct metadata +{ + const GUID *container_format; + UINT count; + const struct metadata_block *block; +}; + +static const struct metadata *current_metadata; +static const struct metadata_block *current_metadata_block; + +static char the_best[] = "The Best"; +static char the_worst[] = "The Worst"; + +static HRESULT WINAPI mdr_QueryInterface(IWICMetadataReader *iface, REFIID iid, void **out) +{ + trace("%p,%s,%p\n", iface, wine_dbgstr_guid(iid), out); + + if (IsEqualIID(iid, &IID_IUnknown) || + IsEqualIID(iid, &IID_IWICMetadataReader)) + { + *out = iface; + return S_OK; + } + + ok(0, "unknown iid %s\n", wine_dbgstr_guid(iid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI mdr_AddRef(IWICMetadataReader *iface) +{ + return 2; +} + +static ULONG WINAPI mdr_Release(IWICMetadataReader *iface) +{ + return 1; +} + +static HRESULT WINAPI mdr_GetMetadataFormat(IWICMetadataReader *iface, GUID *format) +{ + trace("%p,%p\n", iface, format); + + ok(current_metadata_block != NULL, "current_metadata_block can't be NULL\n"); + if (!current_metadata_block) return E_POINTER; + + *format = *current_metadata_block->metadata_format; + return S_OK; +} + +static HRESULT WINAPI mdr_GetMetadataHandlerInfo(IWICMetadataReader *iface, IWICMetadataHandlerInfo **handler) +{ + ok(0, "not implemented\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI mdr_GetCount(IWICMetadataReader *iface, UINT *count) +{ + trace("%p,%p\n", iface, count); + + ok(current_metadata_block != NULL, "current_metadata_block can't be NULL\n"); + if (!current_metadata_block) return E_POINTER; + + *count = current_metadata_block->count; + return S_OK; +} + +static HRESULT WINAPI mdr_GetValueByIndex(IWICMetadataReader *iface, UINT index, PROPVARIANT *schema, PROPVARIANT *id, PROPVARIANT *value) +{ + ok(0, "not implemented\n"); + return E_NOTIMPL; +} + +static char *get_temp_buffer(int size) +{ + static char buf[16][256]; + static int idx; + char *p; + + assert(size < 256); + + p = buf[idx & 0x0f]; + idx++; + return p; +} + +static const char *wine_dbgstr_propvariant(const PROPVARIANT *var) +{ + char *ret; + + if (!var) return "(null)"; + + switch (var->vt) + { + case VT_LPWSTR: + ret = get_temp_buffer(lstrlenW(U(*var).pwszVal) + 16); + sprintf(ret, "(VT_LPWSTR:%s)", wine_dbgstr_w(U(*var).pwszVal)); + break; + + case VT_LPSTR: + ret = get_temp_buffer(lstrlenA(U(*var).pszVal) + 16); + sprintf(ret, "(VT_LPSTR:%s)", U(*var).pszVal); + break; + + default: + ret = get_temp_buffer(16); + sprintf(ret, "(vt:%u)", var->vt); + break; + } + + return ret; +} + +static int propvar_cmp(const PROPVARIANT *v1, LONGLONG value2) +{ + LONGLONG value1; + + if (PropVariantToInt64(v1, &value1) != S_OK) return -1; + + value1 -= value2; + if (value1) return value1 < 0 ? -1 : 1; + return 0; +} + +static HRESULT WINAPI mdr_GetValue(IWICMetadataReader *iface, const PROPVARIANT *schema, const PROPVARIANT *id, PROPVARIANT *value) +{ + UINT i; + + trace("%p,%s,%s,%s\n", iface, wine_dbgstr_propvariant(schema), wine_dbgstr_propvariant(id), wine_dbgstr_propvariant(value)); + + ok(current_metadata_block != NULL, "current_metadata_block can't be NULL\n"); + if (!current_metadata_block) return E_POINTER; + + ok(schema != NULL && id != NULL && value != NULL, "%p, %p, %p should not be NULL\n", schema, id, value); + + for (i = 0; i < current_metadata_block->count; i++) + { + if (schema->vt != VT_EMPTY) + { + if (!current_metadata_block->item[i].schema) + continue; + + switch (schema->vt) + { + case VT_LPSTR: + if (lstrcmpA(U(*schema).pszVal, current_metadata_block->item[i].schema) != 0) + continue; + break; + + case VT_LPWSTR: + { + char schemaA[256]; + WideCharToMultiByte(CP_ACP, 0, U(*schema).pwszVal, -1, schemaA, sizeof(schemaA), NULL, NULL); + if (lstrcmpA(schemaA, current_metadata_block->item[i].schema) != 0) + continue; + break; + } + + default: + ok(0, "unsupported schema vt %u\n", schema->vt); + continue; + } + } + else if (current_metadata_block->item[i].schema) + continue; + + switch (id->vt) + { + case VT_LPSTR: + if (current_metadata_block->item[i].id_str) + { + if (!lstrcmpA(U(*id).pszVal, current_metadata_block->item[i].id_str)) + { + value->vt = VT_LPSTR; + U(*value).pszVal = the_best; + return S_OK; + } + break; + } + break; + + case VT_LPWSTR: + if (current_metadata_block->item[i].id_str) + { + char idA[256]; + WideCharToMultiByte(CP_ACP, 0, U(*id).pwszVal, -1, idA, sizeof(idA), NULL, NULL); + if (!lstrcmpA(idA, current_metadata_block->item[i].id_str)) + { + value->vt = VT_LPSTR; + U(*value).pszVal = the_worst; + return S_OK; + } + break; + } + break; + + case VT_CLSID: + if (IsEqualGUID(U(*id).puuid, &GUID_MetadataFormatXMP) || + IsEqualGUID(U(*id).puuid, &GUID_ContainerFormatTiff)) + { + value->vt = VT_UNKNOWN; + value->punkVal = (IUnknown *)iface; + return S_OK; + } + break; + + default: + if (!propvar_cmp(id, current_metadata_block->item[i].id)) + { + value->vt = current_metadata_block->item[i].type; + U(*value).uiVal = current_metadata_block->item[i].value; + return S_OK; + } + break; + } + } + + return 0xdeadbeef; +} + +static HRESULT WINAPI mdr_GetEnumerator(IWICMetadataReader *iface, IWICEnumMetadataItem **enumerator) +{ + ok(0, "not implemented\n"); + return E_NOTIMPL; +} + +static /* const */ IWICMetadataReaderVtbl mdr_vtbl = +{ + mdr_QueryInterface, + mdr_AddRef, + mdr_Release, + mdr_GetMetadataFormat, + mdr_GetMetadataHandlerInfo, + mdr_GetCount, + mdr_GetValueByIndex, + mdr_GetValue, + mdr_GetEnumerator +}; + +static IWICMetadataReader mdr = { &mdr_vtbl }; + +static HRESULT WINAPI mdbr_QueryInterface(IWICMetadataBlockReader *iface, REFIID iid, void **out) +{ + if (IsEqualIID(iid, &IID_IUnknown) || + IsEqualIID(iid, &IID_IWICMetadataBlockReader)) + { + *out = iface; + return S_OK; + } + + /* Windows 8/10 query for some undocumented IID */ + if (!IsEqualIID(iid, &IID_MdbrUnknown)) + ok(0, "unknown iid %s\n", wine_dbgstr_guid(iid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI mdbr_AddRef(IWICMetadataBlockReader *iface) +{ + return 2; +} + +static ULONG WINAPI mdbr_Release(IWICMetadataBlockReader *iface) +{ + return 1; +} + +static HRESULT WINAPI mdbr_GetContainerFormat(IWICMetadataBlockReader *iface, GUID *format) +{ + trace("%p,%p\n", iface, format); + + ok(current_metadata != NULL, "current_metadata can't be NULL\n"); + if (!current_metadata) return E_POINTER; + + *format = *current_metadata->container_format; + return S_OK; +} + +static HRESULT WINAPI mdbr_GetCount(IWICMetadataBlockReader *iface, UINT *count) +{ + trace("%p,%p\n", iface, count); + + ok(current_metadata != NULL, "current_metadata can't be NULL\n"); + if (!current_metadata) return E_POINTER; + + *count = current_metadata->count; + return S_OK; +} + +static HRESULT WINAPI mdbr_GetReaderByIndex(IWICMetadataBlockReader *iface, UINT index, IWICMetadataReader **out) +{ + trace("%p,%u,%p\n", iface, index, out); + + *out = NULL; + + ok(current_metadata != NULL, "current_metadata can't be NULL\n"); + if (!current_metadata) return E_POINTER; + + if (index < current_metadata->count) + { + current_metadata_block = ¤t_metadata->block[index]; + *out = &mdr; + return S_OK; + } + + current_metadata_block = NULL; + return E_INVALIDARG; +} + +static HRESULT WINAPI mdbr_GetEnumerator(IWICMetadataBlockReader *iface, IEnumUnknown **enumerator) +{ + ok(0, "not implemented\n"); + return E_NOTIMPL; +} + +static /* const */ IWICMetadataBlockReaderVtbl mdbr_vtbl = +{ + mdbr_QueryInterface, + mdbr_AddRef, + mdbr_Release, + mdbr_GetContainerFormat, + mdbr_GetCount, + mdbr_GetReaderByIndex, + mdbr_GetEnumerator +}; + +static IWICMetadataBlockReader mdbr = { &mdbr_vtbl }; + +static const char xmp[] = "
http://ns.adobe.com/xap/1.0/
"; +static const char dc[] = "
http://purl.org/dc/elements/1.1/
"; +static const char tiff[] = "
http://ns.adobe.com/tiff/1.0/
"; + +static const struct metadata_item item1[] = +{ + { NULL, NULL, 1, 2, 3 } +}; + +static const struct metadata_item item2[] = +{ + { NULL, NULL, 1, 2, 3 }, + { "xmp", "Rating", 4, 5, 6 }, + { NULL, "Rating", 7, 8, 9 } +}; + +static const struct metadata_item item3[] = +{ + { NULL, NULL, 1, 2, 3 }, + { NULL, NULL, 4, 5, 6 }, + { NULL, NULL, 7, 8, 9 }, + { NULL, NULL, 10, 11, 12 } +}; + +static const struct metadata_item item4[] = +{ + { NULL, NULL, 1, 2, 3 }, + { xmp, "Rating", 4, 5, 6 }, + { dc, NULL, 7, 8, 9 }, + { tiff, NULL, 10, 11, 12 }, + { NULL, "RATING", 13, 14, 15 }, + { NULL, "R}ATING", 16, 17, 18 }, + { NULL, "xmp", 19, 20, 21 } +}; + +static const struct metadata_block block1[] = +{ + { &GUID_MetadataFormatIfd, 1, item1 } +}; + +static const struct metadata_block block2[] = +{ + { &GUID_MetadataFormatXMP, 1, item1 }, + { &GUID_MetadataFormatIfd, 3, item2 } +}; + +static const struct metadata_block block3[] = +{ + { &GUID_MetadataFormatXMP, 1, item1 }, + { &GUID_MetadataFormatIfd, 3, item2 }, + { &GUID_MetadataFormatXMP, 4, item3 }, + { &GUID_MetadataFormatXMP, 7, item4 }, + { &GUID_MetadataFormatIfd, 7, item4 } +}; + +static const struct metadata data1 = +{ + &GUID_ContainerFormatGif, + 1, block1 +}; + +static const struct metadata data2 = +{ + &GUID_ContainerFormatTiff, + 2, block2 +}; + +static const struct metadata data3 = +{ + &GUID_ContainerFormatPng, + 5, block3 +}; + +static void test_queryreader(void) +{ + static const char q1[] = "/ifd/{uchar=1}"; + static const char q2[] = "/ifd/xmp:{long=4}"; + static const char q3[] = "/ifd/{str=xmp}:{uint=4}"; + static const char q4[] = "/xmp/{char=7}"; + static const char q5[] = "/[1]xmp/{short=7}"; + static const char q6[] = "/[1]ifd/{str=dc}:{uint=7}"; + static const char q7[] = "/[1]ifd/{str=http://purl.org/dc/elements/1.1/}:{longlong=7}"; + static const char q8[] = "/[1]ifd/{str=http://ns.adobe.com/tiff/1.0/}:{int=10}"; + static const char q9[] = "/[2]xmp/xmp:{ulong=4}"; + static const char q10[] = "/[2]xmp/{str=xmp}:{ulong=4}"; + static const char q11[] = "/xmp"; + static const char q12[] = "/ifd/xmp"; + static const char q13[] = "/ifd/xmp/tiff"; + static const char q14[] = "/[0]ifd/[0]xmp/[0]tiff"; + static const char q15[] = "/[*]xmp"; + + static const char q20[] = "/ifd/\\Rating"; + static const char q21[] = "/[0]ifd/Rating"; + static const char q22[] = "/[2]xmp/xmp:{str=Rating}"; + static const char q23[] = "/[2]xmp/xmp:Rating"; + + static const char q24[] = "/[1]ifd/{str=http://ns.adobe.com/xap/1.0/}:Rating"; + static const char q25[] = "/[1]ifd/{str=http://ns.adobe.com/xap/1.0/}:{str=Rating}"; + static const char q26[] = "/[1]ifd/{wstr=\\RATING}"; + static const char q27[] = "/[1]ifd/{str=R\\ATING}"; + static const char q28[] = "/[1]ifd/{str=R\\}ATING}"; + + static const char q40[] = "[0]/ifd/Rating"; + static const char q41[] = "/[+1]ifd/Rating"; + static const char q42[] = "/[-1]ifd/Rating"; + static const char q43[] = "/ifd/{\\str=Rating}"; + static const char q44[] = "/ifd/{badtype=0}"; + static const char q45[] = "/ifd/{uint=0x1234}"; + static const char q46[] = "/ifd/[0]Rating"; + static const char q47[] = "/ifd/[*]Rating"; + static const struct + { + BOOL todo; + const struct metadata *data; + const char *query; + HRESULT hr; + UINT vt, value; + const char *str_value; + } test_data[] = + { + { FALSE, &data1, q1, S_OK, 2, 3, NULL }, + { FALSE, &data2, q2, S_OK, 5, 6, NULL }, + { FALSE, &data2, q3, S_OK, 5, 6, NULL }, + { FALSE, &data3, q4, 0xdeadbeef }, + { FALSE, &data3, q5, S_OK, 8, 9, NULL }, + { FALSE, &data3, q6, 0xdeadbeef }, + { FALSE, &data3, q7, S_OK, 8, 9, NULL }, + { FALSE, &data3, q8, S_OK, 11, 12, NULL }, + { FALSE, &data3, q9, S_OK, 5, 6, NULL }, + { FALSE, &data3, q10, 0xdeadbeef }, + + { FALSE, &data3, q11, S_OK, VT_UNKNOWN, 0, NULL }, + { FALSE, &data3, q12, S_OK, VT_UNKNOWN, 0, NULL }, + { FALSE, &data3, q13, S_OK, VT_UNKNOWN, 0, NULL }, + { FALSE, &data3, q14, S_OK, VT_UNKNOWN, 0, NULL }, + { TRUE, &data3, q15, S_OK, VT_LPSTR, 0, the_worst }, + + { FALSE, &data3, q20, S_OK, VT_LPSTR, 0, the_worst }, + { FALSE, &data3, q21, S_OK, VT_LPSTR, 0, the_worst }, + { FALSE, &data3, q22, S_OK, VT_LPSTR, 0, the_best }, + { FALSE, &data3, q23, S_OK, VT_LPSTR, 0, the_worst }, + { FALSE, &data3, q24, S_OK, VT_LPSTR, 0, the_worst }, + { FALSE, &data3, q25, S_OK, VT_LPSTR, 0, the_best }, + { FALSE, &data3, q26, S_OK, VT_LPSTR, 0, the_worst }, + { FALSE, &data3, q27, S_OK, VT_LPSTR, 0, the_best }, + { FALSE, &data3, q28, S_OK, VT_LPSTR, 0, the_best }, + + { FALSE, &data1, q40, WINCODEC_ERR_PROPERTYNOTSUPPORTED }, + { TRUE, &data1, q41, WINCODEC_ERR_INVALIDQUERYCHARACTER }, + { TRUE, &data1, q42, WINCODEC_ERR_INVALIDQUERYCHARACTER }, + { FALSE, &data1, q43, WINCODEC_ERR_WRONGSTATE }, + { FALSE, &data1, q44, WINCODEC_ERR_WRONGSTATE }, + { TRUE, &data1, q45, DISP_E_TYPEMISMATCH }, + { TRUE, &data1, q46, E_INVALIDARG }, + { TRUE, &data1, q47, WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT }, + }; + WCHAR queryW[256]; + HRESULT hr; + IWICComponentFactory *factory; + IWICMetadataQueryReader *reader; + GUID format; + PROPVARIANT value; + UINT i; + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICComponentFactory, (void **)&factory); + ok(hr == S_OK, "CoCreateInstance error %#x\n", hr); + + hr = IWICComponentFactory_CreateQueryReaderFromBlockReader(factory, &mdbr, &reader); + ok(hr == S_OK, "CreateQueryReaderFromBlockReader error %#x\n", hr); + + for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++) + { + current_metadata = test_data[i].data; + + hr = IWICMetadataQueryReader_GetContainerFormat(reader, &format); + ok(hr == S_OK, "%u: GetContainerFormat error %#x\n", i, hr); + ok(IsEqualGUID(&format, test_data[i].data->container_format), "%u: expected %s, got %s\n", + i, wine_dbgstr_guid(test_data[i].data->container_format), wine_dbgstr_guid(&format)); + + MultiByteToWideChar(CP_ACP, 0, test_data[i].query, -1, queryW, 256); + PropVariantInit(&value); + hr = IWICMetadataQueryReader_GetMetadataByName(reader, queryW, &value); + todo_wine_if(test_data[i].todo) + ok(hr == test_data[i].hr, "%u: expected %#x, got %#x\n", i, test_data[i].hr, hr); + if (hr == S_OK) + { + ok(value.vt == test_data[i].vt, "%u: expected %u, got %u\n", i, test_data[i].vt, value.vt); + if (test_data[i].vt == value.vt) + { + if (value.vt == VT_UNKNOWN) + { + IWICMetadataQueryReader *new_reader; + WCHAR location[256]; + UINT len; + + hr = IUnknown_QueryInterface(value.punkVal, &IID_IWICMetadataQueryReader, (void **)&new_reader); + ok(hr == S_OK, "QueryInterface error %#x\n", hr); + + location[0] = 0; + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(new_reader, 256, location, &len); + ok(hr == S_OK, "GetLocation error %#x\n", hr); + ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len); + ok(!lstrcmpW(location, queryW), "expected %s, got %s\n", wine_dbgstr_w(queryW), wine_dbgstr_w(location)); + + hr = IWICMetadataQueryReader_GetLocation(new_reader, 256, location, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + location[0] = 0; + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(new_reader, 3, location, &len); + ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "got %#x\n", hr); + ok(len == 0xdeadbeef, "got %u\n", len); + ok(!location[0], "got %s\n", wine_dbgstr_w(location)); + + location[0] = 0; + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(new_reader, 0, location, &len); + ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "got %#x\n", hr); + ok(len == 0xdeadbeef, "got %u\n", len); + ok(!location[0], "got %s\n", wine_dbgstr_w(location)); + + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(new_reader, 0, NULL, &len); + ok(hr == S_OK, "GetLocation error %#x\n", hr); + ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len); + + len = 0xdeadbeef; + hr = IWICMetadataQueryReader_GetLocation(new_reader, 3, NULL, &len); + ok(hr == S_OK, "GetLocation error %#x\n", hr); + ok(len == lstrlenW(queryW) + 1, "expected %u, got %u\n", lstrlenW(queryW) + 1, len); + + hr = IWICMetadataQueryReader_GetLocation(new_reader, 0, NULL, NULL); + ok(hr == E_INVALIDARG, "got %#x\n", hr); + + IWICMetadataQueryReader_Release(new_reader); + } + else if (value.vt == VT_LPSTR) + ok(!lstrcmpA(U(value).pszVal, test_data[i].str_value), "%u: expected %s, got %s\n", + i, test_data[i].str_value, U(value).pszVal); + else + ok(U(value).uiVal == test_data[i].value, "%u: expected %u, got %u\n", + i, test_data[i].value, U(value).uiVal); + } + + /* + * Do NOT call PropVariantClear(&value) for fake value types. + */ + } + } + + IWICMetadataQueryReader_Release(reader); + IWICComponentFactory_Release(factory); +} + START_TEST(metadata) { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + test_queryreader(); test_WICMapGuidToShortName(); test_WICMapShortNameToGuid(); test_WICMapSchemaToName();
7 years, 3 months
1
0
0
0
[akhaldi] 75953: [PSDK] Update wincodec.idl and winerror.h. [WINDOWSCODECS] Sync with Wine Staging 2.16. CORE-13762 b2229cc windowscodecs: Add support for CMYK to BGR conversion. 22b69e6 windowscod...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:19:07 2017 New Revision: 75953 URL:
http://svn.reactos.org/svn/reactos?rev=75953&view=rev
Log: [PSDK] Update wincodec.idl and winerror.h. [WINDOWSCODECS] Sync with Wine Staging 2.16. CORE-13762 b2229cc windowscodecs: Add support for CMYK to BGR conversion. 22b69e6 windowscodecs: Move JPEG frame image data initialization from Frame::CopyPixels to Decoder::Initialize. (v2) b635fa0 windowscodecs: Move additional processing out of the JPEG decoding loop. 80649c5 windowscodecs: Fix stride calculation in JPEG decoder. 0d88ec1 windowscodecs: Fix IWICBitmapEncoder::SetPalette for a not initialized case in JPEG encoder. 267bca1 windowscodecs: PNGEncoder: Return 32bppRGBA pixel format by default. 8bae213 windowscodecs: Fix 32bppGrayFloat to 8bppGray conversion. 8648aaf wincodecs: Add encoder options for JPEG. 2eeef78 windowscodecs: Fix a memory leak. c092f1a windowscodecs: Add some tests for IWICMetadataQueryReader. 2271ba8 windowscodecs: Add initial implementation of IWICMetadataQueryReader::GetMetadataByName. d3280c8 windowscodecs: Implement IWICBitmapDecoder::GetMetadataQueryReader in the GIF decoder. c94bf3c windowscodecs: Implement IWICMetadataQueryReader::GetLocation. 3059668 windowscodecs: Use PropVariantCompareEx to compare metadata items. f258903 windowscodecs: Implement IWICMetadataQueryReader::GetContainerFormat. 714175e windowscodecs: Implement WICMapSchemaToName. e1eed88 windowscodecs: Implement WICMapShortNameToGuid. 37ae4f2 windowscodecs: Implement WICMapGuidToShortName. cf1269a windowscodecs: Register WICImagingFactory2 interface. Modified: trunk/reactos/dll/win32/windowscodecs/converter.c trunk/reactos/dll/win32/windowscodecs/gifformat.c trunk/reactos/dll/win32/windowscodecs/imgfactory.c trunk/reactos/dll/win32/windowscodecs/jpegformat.c trunk/reactos/dll/win32/windowscodecs/metadatahandler.c trunk/reactos/dll/win32/windowscodecs/metadataquery.c trunk/reactos/dll/win32/windowscodecs/pngformat.c trunk/reactos/dll/win32/windowscodecs/tiffformat.c trunk/reactos/dll/win32/windowscodecs/wincodecs_private.h trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.idl trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.rgs trunk/reactos/media/doc/README.WINE trunk/reactos/sdk/include/psdk/wincodec.idl trunk/reactos/sdk/include/psdk/winerror.h Modified: trunk/reactos/dll/win32/windowscodecs/converter.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/co…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/converter.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/converter.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -1072,6 +1072,48 @@ } return S_OK; + case format_32bppCMYK: + if (prc) + { + BYTE *srcdata; + UINT srcstride, srcdatasize; + + srcstride = 4 * prc->Width; + srcdatasize = srcstride * prc->Height; + + srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize); + if (!srcdata) return E_OUTOFMEMORY; + + hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata); + if (SUCCEEDED(hr)) + { + INT x, y; + BYTE *src = srcdata, *dst = pbBuffer; + + for (y = 0; y < prc->Height; y++) + { + BYTE *cmyk = src; + BYTE *bgr = dst; + + for (x = 0; x < prc->Width; x++) + { + BYTE c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3]; + bgr[0] = (255 - y) * (255 - k) / 255; /* B */ + bgr[1] = (255 - m) * (255 - k) / 255; /* G */ + bgr[2] = (255 - c) * (255 - k) / 255; /* R */ + cmyk += 4; + bgr += 3; + } + src += srcstride; + dst += cbStride; + } + } + + HeapFree(GetProcessHeap(), 0, srcdata); + return hr; + } + return S_OK; + default: FIXME("Unimplemented conversion path!\n"); return WINCODEC_ERR_UNSUPPORTEDOPERATION; @@ -1209,6 +1251,43 @@ return S_OK; } + if (source_format == format_32bppGrayFloat) + { + hr = S_OK; + + if (prc) + { + srcstride = 4 * prc->Width; + srcdatasize = srcstride * prc->Height; + + srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize); + if (!srcdata) return E_OUTOFMEMORY; + + hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata); + if (SUCCEEDED(hr)) + { + INT x, y; + BYTE *src = srcdata, *dst = pbBuffer; + + for (y=0; y < prc->Height; y++) + { + float *srcpixel = (float*)src; + BYTE *dstpixel = dst; + + for (x=0; x < prc->Width; x++) + *dstpixel++ = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f); + + src += srcstride; + dst += cbStride; + } + } + + HeapFree(GetProcessHeap(), 0, srcdata); + } + + return hr; + } + srcstride = 3 * prc->Width; srcdatasize = srcstride * prc->Height; @@ -1229,12 +1308,7 @@ { float gray = (bgr[2] * 0.2126f + bgr[1] * 0.7152f + bgr[0] * 0.0722f) / 255.0f; - /* conversion from 32bppGrayFloat to 24bppBGR has already applied sRGB gamma */ - if (source_format == format_32bppGrayFloat) - gray *= 255.0f; - else - gray = to_sRGB_component(gray) * 255.0f; - + gray = to_sRGB_component(gray) * 255.0f; dst[x] = (BYTE)floorf(gray + 0.51f); bgr += 3; } Modified: trunk/reactos/dll/win32/windowscodecs/gifformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/gi…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/gifformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/gifformat.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -810,7 +810,7 @@ if (!ppIMetadataQueryReader) return E_INVALIDARG; - return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, ppIMetadataQueryReader); + return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, NULL, ppIMetadataQueryReader); } static HRESULT WINAPI GifFrameDecode_GetColorContexts(IWICBitmapFrameDecode *iface, @@ -1239,8 +1239,13 @@ static HRESULT WINAPI GifDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, IWICMetadataQueryReader **ppIMetadataQueryReader) { + GifDecoder *This = impl_from_IWICBitmapDecoder(iface); + TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader); - return WINCODEC_ERR_UNSUPPORTEDOPERATION; + + if (!ppIMetadataQueryReader) return E_INVALIDARG; + + return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, NULL, ppIMetadataQueryReader); } static HRESULT WINAPI GifDecoder_GetPreview(IWICBitmapDecoder *iface, Modified: trunk/reactos/dll/win32/windowscodecs/imgfactory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/im…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/imgfactory.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/imgfactory.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -1113,7 +1113,7 @@ if (!block_reader || !query_reader) return E_INVALIDARG; - return MetadataQueryReader_CreateInstance(block_reader, query_reader); + return MetadataQueryReader_CreateInstance(block_reader, NULL, query_reader); } static HRESULT WINAPI ComponentFactory_CreateQueryWriterFromBlockWriter(IWICComponentFactory *iface, Modified: trunk/reactos/dll/win32/windowscodecs/jpegformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/jp…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/jpegformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/jpegformat.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -42,6 +42,13 @@ static void *libjpeg_handle; +static const WCHAR wszImageQuality[] = {'I','m','a','g','e','Q','u','a','l','i','t','y',0}; +static const WCHAR wszBitmapTransform[] = {'B','i','t','m','a','p','T','r','a','n','s','f','o','r','m',0}; +static const WCHAR wszLuminance[] = {'L','u','m','i','n','a','n','c','e',0}; +static const WCHAR wszChrominance[] = {'C','h','r','o','m','i','n','a','n','c','e',0}; +static const WCHAR wszJpegYCrCbSubsampling[] = {'J','p','e','g','Y','C','r','C','b','S','u','b','s','a','m','p','l','i','n','g',0}; +static const WCHAR wszSuppressApp0[] = {'S','u','p','p','r','e','s','s','A','p','p','0',0}; + #define MAKE_FUNCPTR(f) static typeof(f) * p##f MAKE_FUNCPTR(jpeg_CreateCompress); MAKE_FUNCPTR(jpeg_CreateDecompress); @@ -130,6 +137,7 @@ struct jpeg_error_mgr jerr; struct jpeg_source_mgr source_mgr; BYTE source_buffer[1024]; + UINT bpp, stride; BYTE *image_data; CRITICAL_SECTION lock; } JpegDecoder; @@ -278,6 +286,8 @@ int ret; LARGE_INTEGER seek; jmp_buf jmpbuf; + UINT data_size, i; + TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOptions); EnterCriticalSection(&This->lock); @@ -354,6 +364,55 @@ ERR("jpeg_start_decompress failed\n"); LeaveCriticalSection(&This->lock); return E_FAIL; + } + + if (This->cinfo.out_color_space == JCS_GRAYSCALE) This->bpp = 8; + else if (This->cinfo.out_color_space == JCS_CMYK) This->bpp = 32; + else This->bpp = 24; + + This->stride = (This->bpp * This->cinfo.output_width + 7) / 8; + data_size = This->stride * This->cinfo.output_height; + + This->image_data = HeapAlloc(GetProcessHeap(), 0, data_size); + if (!This->image_data) + { + LeaveCriticalSection(&This->lock); + return E_OUTOFMEMORY; + } + + while (This->cinfo.output_scanline < This->cinfo.output_height) + { + UINT first_scanline = This->cinfo.output_scanline; + UINT max_rows; + JSAMPROW out_rows[4]; + JDIMENSION ret; + + max_rows = min(This->cinfo.output_height-first_scanline, 4); + for (i=0; i<max_rows; i++) + out_rows[i] = This->image_data + This->stride * (first_scanline+i); + + ret = pjpeg_read_scanlines(&This->cinfo, out_rows, max_rows); + if (ret == 0) + { + ERR("read_scanlines failed\n"); + LeaveCriticalSection(&This->lock); + return E_FAIL; + } + } + + if (This->bpp == 24) + { + /* libjpeg gives us RGB data and we want BGR, so byteswap the data */ + reverse_bgr8(3, This->image_data, + This->cinfo.output_width, This->cinfo.output_height, + This->stride); + } + + if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker) + { + /* Adobe JPEG's have inverted CMYK data. */ + for (i=0; i<data_size; i++) + This->image_data[i] ^= 0xff; } This->initialized = TRUE; @@ -576,98 +635,11 @@ const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { JpegDecoder *This = impl_from_IWICBitmapFrameDecode(iface); - UINT bpp; - UINT stride; - UINT data_size; - UINT max_row_needed; - jmp_buf jmpbuf; - WICRect rect; + TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); - if (!prc) - { - rect.X = 0; - rect.Y = 0; - rect.Width = This->cinfo.output_width; - rect.Height = This->cinfo.output_height; - prc = ▭ - } - else - { - if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->cinfo.output_width || - prc->Y+prc->Height > This->cinfo.output_height) - return E_INVALIDARG; - } - - if (This->cinfo.out_color_space == JCS_GRAYSCALE) bpp = 8; - else if (This->cinfo.out_color_space == JCS_CMYK) bpp = 32; - else bpp = 24; - - stride = bpp * This->cinfo.output_width; - data_size = stride * This->cinfo.output_height; - - max_row_needed = prc->Y + prc->Height; - if (max_row_needed > This->cinfo.output_height) return E_INVALIDARG; - - EnterCriticalSection(&This->lock); - - if (!This->image_data) - { - This->image_data = HeapAlloc(GetProcessHeap(), 0, data_size); - if (!This->image_data) - { - LeaveCriticalSection(&This->lock); - return E_OUTOFMEMORY; - } - } - - This->cinfo.client_data = jmpbuf; - - if (setjmp(jmpbuf)) - { - LeaveCriticalSection(&This->lock); - return E_FAIL; - } - - while (max_row_needed > This->cinfo.output_scanline) - { - UINT first_scanline = This->cinfo.output_scanline; - UINT max_rows; - JSAMPROW out_rows[4]; - UINT i; - JDIMENSION ret; - - max_rows = min(This->cinfo.output_height-first_scanline, 4); - for (i=0; i<max_rows; i++) - out_rows[i] = This->image_data + stride * (first_scanline+i); - - ret = pjpeg_read_scanlines(&This->cinfo, out_rows, max_rows); - - if (ret == 0) - { - ERR("read_scanlines failed\n"); - LeaveCriticalSection(&This->lock); - return E_FAIL; - } - - if (bpp == 24) - { - /* libjpeg gives us RGB data and we want BGR, so byteswap the data */ - reverse_bgr8(3, This->image_data + stride * first_scanline, - This->cinfo.output_width, This->cinfo.output_scanline - first_scanline, - stride); - } - - if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker) - /* Adobe JPEG's have inverted CMYK data. */ - for (i=0; i<data_size; i++) - This->image_data[i] ^= 0xff; - } - - LeaveCriticalSection(&This->lock); - - return copy_pixels(bpp, This->image_data, - This->cinfo.output_width, This->cinfo.output_height, stride, + return copy_pixels(This->bpp, This->image_data, + This->cinfo.output_width, This->cinfo.output_height, This->stride, prc, cbStride, cbBufferSize, pbBuffer); } @@ -681,7 +653,7 @@ if (!ppIMetadataQueryReader) return E_INVALIDARG; - return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, ppIMetadataQueryReader); + return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, NULL, ppIMetadataQueryReader); } static HRESULT WINAPI JpegDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *iface, @@ -1062,7 +1034,7 @@ EnterCriticalSection(&This->lock); - if (This->initialized) + if (This->frame_initialized) hr = IWICPalette_GetColors(palette, 256, This->palette, &This->colors); else hr = WINCODEC_ERR_NOTINITIALIZED; @@ -1399,8 +1371,18 @@ static HRESULT WINAPI JpegEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *pIPalette) { + JpegEncoder *This = impl_from_IWICBitmapEncoder(iface); + HRESULT hr; + TRACE("(%p,%p)\n", iface, pIPalette); - return WINCODEC_ERR_UNSUPPORTEDOPERATION; + + EnterCriticalSection(&This->lock); + + hr = This->initialized ? WINCODEC_ERR_UNSUPPORTEDOPERATION : WINCODEC_ERR_NOTINITIALIZED; + + LeaveCriticalSection(&This->lock); + + return hr; } static HRESULT WINAPI JpegEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail) @@ -1420,6 +1402,7 @@ { JpegEncoder *This = impl_from_IWICBitmapEncoder(iface); HRESULT hr; + PROPBAG2 opts[6] = {{0}}; TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions); @@ -1437,9 +1420,28 @@ return WINCODEC_ERR_NOTINITIALIZED; } + opts[0].pstrName = (LPOLESTR)wszImageQuality; + opts[0].vt = VT_R4; + opts[0].dwType = PROPBAG2_TYPE_DATA; + opts[1].pstrName = (LPOLESTR)wszBitmapTransform; + opts[1].vt = VT_UI1; + opts[1].dwType = PROPBAG2_TYPE_DATA; + opts[2].pstrName = (LPOLESTR)wszLuminance; + opts[2].vt = VT_I4|VT_ARRAY; + opts[2].dwType = PROPBAG2_TYPE_DATA; + opts[3].pstrName = (LPOLESTR)wszChrominance; + opts[3].vt = VT_I4|VT_ARRAY; + opts[3].dwType = PROPBAG2_TYPE_DATA; + opts[4].pstrName = (LPOLESTR)wszJpegYCrCbSubsampling; + opts[4].vt = VT_UI1; + opts[4].dwType = PROPBAG2_TYPE_DATA; + opts[5].pstrName = (LPOLESTR)wszSuppressApp0; + opts[5].vt = VT_BOOL; + opts[5].dwType = PROPBAG2_TYPE_DATA; + if (ppIEncoderOptions) { - hr = CreatePropertyBag2(NULL, 0, ppIEncoderOptions); + hr = CreatePropertyBag2(opts, 6, ppIEncoderOptions); if (FAILED(hr)) { LeaveCriticalSection(&This->lock); Modified: trunk/reactos/dll/win32/windowscodecs/metadatahandler.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/me…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/metadatahandler.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/metadatahandler.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -198,29 +198,6 @@ return hr; } -/* FiXME: Use propsys.PropVariantCompareEx once it's implemented */ -static int propvar_cmp(const PROPVARIANT *v1, const PROPVARIANT *v2) -{ - LONGLONG value1, value2; - - if (v1->vt == VT_LPSTR && v2->vt == VT_LPSTR) - { - return lstrcmpA(v1->u.pszVal, v2->u.pszVal); - } - - if (v1->vt == VT_LPWSTR && v2->vt == VT_LPWSTR) - { - return lstrcmpiW(v1->u.pwszVal, v2->u.pwszVal); - } - - if (PropVariantToInt64(v1, &value1) != S_OK) return -1; - if (PropVariantToInt64(v2, &value2) != S_OK) return -1; - - value1 -= value2; - if (value1) return value1 < 0 ? -1 : 1; - return 0; -} - static HRESULT WINAPI MetadataHandler_GetValue(IWICMetadataWriter *iface, const PROPVARIANT *schema, const PROPVARIANT *id, PROPVARIANT *value) { @@ -228,7 +205,7 @@ HRESULT hr = WINCODEC_ERR_PROPERTYNOTFOUND; MetadataHandler *This = impl_from_IWICMetadataWriter(iface); - TRACE("(%p,%p,%p,%p)\n", iface, schema, id, value); + TRACE("(%p,%s,%s,%p)\n", iface, wine_dbgstr_variant((const VARIANT *)schema), wine_dbgstr_variant((const VARIANT *)id), value); if (!id) return E_INVALIDARG; @@ -238,10 +215,10 @@ { if (schema && This->items[i].schema.vt != VT_EMPTY) { - if (propvar_cmp(schema, &This->items[i].schema) != 0) continue; - } - - if (propvar_cmp(id, &This->items[i].id) != 0) continue; + if (PropVariantCompareEx(schema, &This->items[i].schema, 0, PVCF_USESTRCMPI) != 0) continue; + } + + if (PropVariantCompareEx(id, &This->items[i].id, 0, PVCF_USESTRCMPI) != 0) continue; hr = value ? PropVariantCopy(value, &This->items[i].value) : S_OK; break; Modified: trunk/reactos/dll/win32/windowscodecs/metadataquery.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/me…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/metadataquery.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/metadataquery.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -19,12 +19,15 @@ #include "wincodecs_private.h" +#include <propvarutil.h> + +static const WCHAR *map_shortname_to_schema(const GUID *format, const WCHAR *name); + typedef struct { IWICMetadataQueryReader IWICMetadataQueryReader_iface; - LONG ref; - IWICMetadataBlockReader *block; + WCHAR *root; } QueryReader; static inline QueryReader *impl_from_IWICMetadataQueryReader(IWICMetadataQueryReader *iface) @@ -70,6 +73,7 @@ if (!ref) { IWICMetadataBlockReader_Release(This->block); + HeapFree(GetProcessHeap(), 0, This->root); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -84,20 +88,501 @@ return IWICMetadataBlockReader_GetContainerFormat(This->block, format); } -static HRESULT WINAPI mqr_GetLocation(IWICMetadataQueryReader *iface, - UINT cchMaxLength, WCHAR *wzNamespace, UINT *pcchActualLength) -{ +static HRESULT WINAPI mqr_GetLocation(IWICMetadataQueryReader *iface, UINT len, WCHAR *location, UINT *ret_len) +{ + static const WCHAR rootW[] = { '/',0 }; QueryReader *This = impl_from_IWICMetadataQueryReader(iface); - FIXME("(%p,%u,%p,%p)\n", This, cchMaxLength, wzNamespace, pcchActualLength); - return E_NOTIMPL; -} - -static HRESULT WINAPI mqr_GetMetadataByName(IWICMetadataQueryReader *iface, - LPCWSTR wzName, PROPVARIANT *pvarValue) + const WCHAR *root; + UINT actual_len; + + TRACE("(%p,%u,%p,%p)\n", This, len, location, ret_len); + + if (!ret_len) return E_INVALIDARG; + + root = This->root ? This->root : rootW; + actual_len = lstrlenW(root) + 1; + + if (location) + { + if (len < actual_len) + return WINCODEC_ERR_INSUFFICIENTBUFFER; + + memcpy(location, root, actual_len * sizeof(WCHAR)); + } + + *ret_len = actual_len; + + return S_OK; +} + +struct string_t +{ + const WCHAR *str; + int len; +}; + +static const struct +{ + int len; + WCHAR str[10]; + VARTYPE vt; +} str2vt[] = +{ + { 4, {'c','h','a','r'}, VT_I1 }, + { 5, {'u','c','h','a','r'}, VT_UI1 }, + { 5, {'s','h','o','r','t'}, VT_I2 }, + { 6, {'u','s','h','o','r','t'}, VT_UI2 }, + { 4, {'l','o','n','g'}, VT_I4 }, + { 5, {'u','l','o','n','g'}, VT_UI4 }, + { 3, {'i','n','t'}, VT_I4 }, + { 4, {'u','i','n','t'}, VT_UI4 }, + { 8, {'l','o','n','g','l','o','n','g'}, VT_I8 }, + { 9, {'u','l','o','n','g','l','o','n','g'}, VT_UI8 }, + { 5, {'f','l','o','a','t'}, VT_R4 }, + { 6, {'d','o','u','b','l','e'}, VT_R8 }, + { 3, {'s','t','r'}, VT_LPSTR }, + { 4, {'w','s','t','r'}, VT_LPWSTR }, + { 4, {'g','u','i','d'}, VT_CLSID }, + { 4, {'b','o','o','l'}, VT_BOOL } +}; + +static VARTYPE map_type(struct string_t *str) +{ + UINT i; + + for (i = 0; i < sizeof(str2vt)/sizeof(str2vt[0]); i++) + { + if (str2vt[i].len == str->len) + { + if (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, + str->str, str->len, str2vt[i].str, str2vt[i].len) == CSTR_EQUAL) + return str2vt[i].vt; + } + } + + WARN("type %s is not recognized\n", wine_dbgstr_wn(str->str, str->len)); + + return VT_ILLEGAL; +} + +static HRESULT get_token(struct string_t *elem, PROPVARIANT *id, PROPVARIANT *schema, int *idx) +{ + const WCHAR *start, *end, *p; + WCHAR *bstr; + struct string_t next_elem; + HRESULT hr; + + TRACE("%s, len %d\n", wine_dbgstr_wn(elem->str, elem->len), elem->len); + + PropVariantInit(id); + PropVariantInit(schema); + + if (!elem->len) return S_OK; + + start = elem->str; + + if (*start == '[') + { + WCHAR *idx_end; + + if (start[1] < '0' || start[1] > '9') return DISP_E_TYPEMISMATCH; + + *idx = strtolW(start + 1, &idx_end, 10); + if (idx_end > elem->str + elem->len) return WINCODEC_ERR_INVALIDQUERYREQUEST; + if (*idx_end != ']') return WINCODEC_ERR_INVALIDQUERYREQUEST; + if (*idx < 0) return WINCODEC_ERR_INVALIDQUERYREQUEST; + end = idx_end + 1; + + next_elem.str = end; + next_elem.len = elem->len - (end - start); + hr = get_token(&next_elem, id, schema, idx); + if (hr != S_OK) + { + TRACE("get_token error %#x\n", hr); + return hr; + } + elem->len = (end - start) + next_elem.len; + + TRACE("indexed %s [%d]\n", wine_dbgstr_wn(elem->str, elem->len), *idx); + return S_OK; + } + else if (*start == '{') + { + VARTYPE vt; + PROPVARIANT next_token; + + end = memchrW(start + 1, '=', elem->len - 1); + if (!end) return WINCODEC_ERR_INVALIDQUERYREQUEST; + if (end > elem->str + elem->len) return WINCODEC_ERR_INVALIDQUERYREQUEST; + + next_elem.str = start + 1; + next_elem.len = end - start - 1; + vt = map_type(&next_elem); + TRACE("type %s => %d\n", wine_dbgstr_wn(next_elem.str, next_elem.len), vt); + if (vt == VT_ILLEGAL) return WINCODEC_ERR_WRONGSTATE; + + next_token.vt = VT_BSTR; + next_token.u.bstrVal = SysAllocStringLen(NULL, elem->len - (end - start) + 1); + if (!next_token.u.bstrVal) return E_OUTOFMEMORY; + + bstr = next_token.u.bstrVal; + + end++; + p = end; + while (*end && *end != '}' && end - start < elem->len) + { + if (*end == '\\') end++; + *bstr++ = *end++; + } + if (*end != '}') + { + PropVariantClear(&next_token); + return WINCODEC_ERR_INVALIDQUERYREQUEST; + } + *bstr = 0; + TRACE("schema/id %s\n", wine_dbgstr_w(next_token.u.bstrVal)); + + if (vt == VT_CLSID) + { + id->vt = VT_CLSID; + id->u.puuid = CoTaskMemAlloc(sizeof(GUID)); + if (!id->u.puuid) + { + PropVariantClear(&next_token); + return E_OUTOFMEMORY; + } + + hr = UuidFromStringW(next_token.u.bstrVal, id->u.puuid); + } + else + hr = PropVariantChangeType(id, &next_token, 0, vt); + PropVariantClear(&next_token); + if (hr != S_OK) + { + PropVariantClear(id); + PropVariantClear(schema); + return hr; + } + + end++; + if (*end == ':') + { + PROPVARIANT next_id, next_schema; + int next_idx = 0; + + next_elem.str = end + 1; + next_elem.len = elem->len - (end - start + 1); + hr = get_token(&next_elem, &next_id, &next_schema, &next_idx); + if (hr != S_OK) + { + TRACE("get_token error %#x\n", hr); + return hr; + } + elem->len = (end - start + 1) + next_elem.len; + + TRACE("id %s [%d]\n", wine_dbgstr_wn(elem->str, elem->len), *idx); + + if (next_schema.vt != VT_EMPTY) + { + PropVariantClear(&next_id); + PropVariantClear(&next_schema); + return WINCODEC_ERR_WRONGSTATE; + } + + *schema = *id; + *id = next_id; + + return S_OK; + } + + elem->len = end - start; + return S_OK; + } + + end = memchrW(start, '/', elem->len); + if (!end) end = start + elem->len; + + p = memchrW(start, ':', end - start); + if (p) + { + next_elem.str = p + 1; + next_elem.len = end - p - 1; + + elem->len = p - start; + } + else + elem->len = end - start; + + id->vt = VT_BSTR; + id->u.bstrVal = SysAllocStringLen(NULL, elem->len + 1); + if (!id->u.bstrVal) return E_OUTOFMEMORY; + + bstr = id->u.bstrVal; + p = elem->str; + while (p - elem->str < elem->len) + { + if (*p == '\\') p++; + *bstr++ = *p++; + } + *bstr = 0; + TRACE("%s [%d]\n", wine_dbgstr_variant((VARIANT *)id), *idx); + + if (*p == ':') + { + PROPVARIANT next_id, next_schema; + int next_idx = 0; + + hr = get_token(&next_elem, &next_id, &next_schema, &next_idx); + if (hr != S_OK) + { + TRACE("get_token error %#x\n", hr); + PropVariantClear(id); + PropVariantClear(schema); + return hr; + } + elem->len += next_elem.len + 1; + + TRACE("id %s [%d]\n", wine_dbgstr_wn(elem->str, elem->len), *idx); + + if (next_schema.vt != VT_EMPTY) + { + PropVariantClear(&next_id); + PropVariantClear(&next_schema); + PropVariantClear(id); + PropVariantClear(schema); + return WINCODEC_ERR_WRONGSTATE; + } + + *schema = *id; + *id = next_id; + } + + return S_OK; +} + +static HRESULT find_reader_from_block(IWICMetadataBlockReader *block_reader, UINT index, + GUID *guid, IWICMetadataReader **reader) +{ + HRESULT hr; + GUID format; + IWICMetadataReader *new_reader; + UINT count, i, matched_index; + + *reader = NULL; + + hr = IWICMetadataBlockReader_GetCount(block_reader, &count); + if (hr != S_OK) return hr; + + matched_index = 0; + + for (i = 0; i < count; i++) + { + hr = IWICMetadataBlockReader_GetReaderByIndex(block_reader, i, &new_reader); + if (hr != S_OK) return hr; + + hr = IWICMetadataReader_GetMetadataFormat(new_reader, &format); + if (hr == S_OK) + { + if (IsEqualGUID(&format, guid)) + { + if (matched_index == index) + { + *reader = new_reader; + return S_OK; + } + + matched_index++; + } + } + + IWICMetadataReader_Release(new_reader); + if (hr != S_OK) return hr; + } + + return WINCODEC_ERR_PROPERTYNOTFOUND; +} + +static HRESULT get_next_reader(IWICMetadataReader *reader, UINT index, + GUID *guid, IWICMetadataReader **new_reader) +{ + HRESULT hr; + PROPVARIANT schema, id, value; + + *new_reader = NULL; + + PropVariantInit(&schema); + PropVariantInit(&id); + PropVariantInit(&value); + + if (index) + { + schema.vt = VT_UI2; + schema.u.uiVal = index; + } + + id.vt = VT_CLSID; + id.u.puuid = guid; + hr = IWICMetadataReader_GetValue(reader, &schema, &id, &value); + if (hr != S_OK) return hr; + + if (value.vt == VT_UNKNOWN) + hr = IUnknown_QueryInterface(value.u.punkVal, &IID_IWICMetadataReader, (void **)new_reader); + else + hr = WINCODEC_ERR_UNEXPECTEDMETADATATYPE; + + PropVariantClear(&value); + return hr; +} + +static HRESULT WINAPI mqr_GetMetadataByName(IWICMetadataQueryReader *iface, LPCWSTR query, PROPVARIANT *value) { QueryReader *This = impl_from_IWICMetadataQueryReader(iface); - FIXME("(%p,%s,%p)\n", This, wine_dbgstr_w(wzName), pvarValue); - return WINCODEC_ERR_PROPERTYNOTFOUND; + struct string_t elem; + WCHAR *full_query; + const WCHAR *p; + int index, len; + PROPVARIANT tk_id, tk_schema, new_value; + GUID guid; + IWICMetadataReader *reader; + HRESULT hr = S_OK; + + TRACE("(%p,%s,%p)\n", This, wine_dbgstr_w(query), value); + + len = lstrlenW(query) + 1; + if (This->root) len += lstrlenW(This->root); + full_query = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + full_query[0] = 0; + if (This->root) + lstrcpyW(full_query, This->root); + lstrcatW(full_query, query); + + PropVariantInit(&tk_id); + PropVariantInit(&tk_schema); + PropVariantInit(&new_value); + + reader = NULL; + p = full_query; + + while (*p) + { + if (*p != '/') + { + WARN("query should start with '/'\n"); + hr = WINCODEC_ERR_PROPERTYNOTSUPPORTED; + break; + } + + p++; + + index = 0; + elem.str = p; + elem.len = lstrlenW(p); + hr = get_token(&elem, &tk_id, &tk_schema, &index); + if (hr != S_OK) + { + WARN("get_token error %#x\n", hr); + break; + } + TRACE("parsed %d characters: %s, index %d\n", elem.len, wine_dbgstr_wn(elem.str, elem.len), index); + TRACE("id %s, schema %s\n", wine_dbgstr_variant((VARIANT *)&tk_id), wine_dbgstr_variant((VARIANT *)&tk_schema)); + + if (!elem.len) break; + + if (tk_id.vt == VT_CLSID || (tk_id.vt == VT_BSTR && WICMapShortNameToGuid(tk_id.u.bstrVal, &guid) == S_OK)) + { + WCHAR *root; + + if (tk_schema.vt != VT_EMPTY) + { + FIXME("unsupported schema vt %u\n", tk_schema.vt); + PropVariantClear(&tk_schema); + } + + if (tk_id.vt == VT_CLSID) guid = *tk_id.u.puuid; + + if (reader) + { + IWICMetadataReader *new_reader; + + hr = get_next_reader(reader, index, &guid, &new_reader); + IWICMetadataReader_Release(reader); + reader = new_reader; + } + else + hr = find_reader_from_block(This->block, index, &guid, &reader); + + if (hr != S_OK) break; + + root = SysAllocStringLen(NULL, elem.str + elem.len - full_query + 2); + if (!root) + { + hr = E_OUTOFMEMORY; + break; + } + lstrcpynW(root, full_query, p - full_query + elem.len + 1); + + PropVariantClear(&new_value); + new_value.vt = VT_UNKNOWN; + hr = MetadataQueryReader_CreateInstance(This->block, root, (IWICMetadataQueryReader **)&new_value.u.punkVal); + SysFreeString(root); + if (hr != S_OK) break; + } + else + { + PROPVARIANT schema, id; + + if (!reader) + { + hr = WINCODEC_ERR_INVALIDQUERYREQUEST; + break; + } + + if (tk_schema.vt == VT_BSTR) + { + hr = IWICMetadataReader_GetMetadataFormat(reader, &guid); + if (hr != S_OK) break; + + schema.vt = VT_LPWSTR; + schema.u.pwszVal = (LPWSTR)map_shortname_to_schema(&guid, tk_schema.u.bstrVal); + if (!schema.u.pwszVal) + schema.u.pwszVal = tk_schema.u.bstrVal; + } + else + schema = tk_schema; + + if (tk_id.vt == VT_BSTR) + { + id.vt = VT_LPWSTR; + id.u.pwszVal = tk_id.u.bstrVal; + } + else + id = tk_id; + + PropVariantClear(&new_value); + hr = IWICMetadataReader_GetValue(reader, &schema, &id, &new_value); + if (hr != S_OK) break; + } + + p += elem.len; + + PropVariantClear(&tk_id); + PropVariantClear(&tk_schema); + } + + if (reader) + IWICMetadataReader_Release(reader); + + PropVariantClear(&tk_id); + PropVariantClear(&tk_schema); + + if (hr == S_OK) + *value = new_value; + else + PropVariantClear(&new_value); + + HeapFree(GetProcessHeap(), 0, full_query); + + return hr; } static HRESULT WINAPI mqr_GetEnumerator(IWICMetadataQueryReader *iface, @@ -118,7 +603,7 @@ mqr_GetEnumerator }; -HRESULT MetadataQueryReader_CreateInstance(IWICMetadataBlockReader *mbr, IWICMetadataQueryReader **out) +HRESULT MetadataQueryReader_CreateInstance(IWICMetadataBlockReader *mbr, const WCHAR *root, IWICMetadataQueryReader **out) { QueryReader *obj; @@ -131,6 +616,8 @@ IWICMetadataBlockReader_AddRef(mbr); obj->block = mbr; + + obj->root = root ? heap_strdupW(root) : NULL; *out = &obj->IWICMetadataQueryReader_iface; @@ -250,14 +737,14 @@ { if (!len) return E_INVALIDARG; - len = min(len - 1, strlenW(guid2name[i].name)); + len = min(len - 1, lstrlenW(guid2name[i].name)); memcpy(name, guid2name[i].name, len * sizeof(WCHAR)); name[len] = 0; - if (len < strlenW(guid2name[i].name)) + if (len < lstrlenW(guid2name[i].name)) return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } - if (ret_len) *ret_len = strlenW(guid2name[i].name) + 1; + if (ret_len) *ret_len = lstrlenW(guid2name[i].name) + 1; return S_OK; } } @@ -265,7 +752,7 @@ return WINCODEC_ERR_PROPERTYNOTFOUND; } -HRESULT WINAPI WICMapShortNameToGuid(const WCHAR *name, GUID *guid) +HRESULT WINAPI WICMapShortNameToGuid(PCWSTR name, GUID *guid) { UINT i; @@ -275,7 +762,7 @@ for (i = 0; i < sizeof(guid2name)/sizeof(guid2name[0]); i++) { - if (!strcmpiW(name, guid2name[i].name)) + if (!lstrcmpiW(name, guid2name[i].name)) { *guid = *guid2name[i].guid; return S_OK; @@ -372,7 +859,27 @@ { MPReg, MPReg_scheme } }; -HRESULT WINAPI WICMapSchemaToName(REFGUID format, const WCHAR *schema, UINT len, WCHAR *name, UINT *ret_len) +static const WCHAR *map_shortname_to_schema(const GUID *format, const WCHAR *name) +{ + UINT i; + + /* It appears that the only metadata formats + * that support schemas are xmp and xmpstruct. + */ + if (!IsEqualGUID(format, &GUID_MetadataFormatXMP) && + !IsEqualGUID(format, &GUID_MetadataFormatXMPStruct)) + return NULL; + + for (i = 0; i < sizeof(name2schema)/sizeof(name2schema[0]); i++) + { + if (!lstrcmpW(name2schema[i].name, name)) + return name2schema[i].schema; + } + + return NULL; +} + +HRESULT WINAPI WICMapSchemaToName(REFGUID format, LPWSTR schema, UINT len, WCHAR *name, UINT *ret_len) { UINT i; @@ -390,13 +897,13 @@ for (i = 0; i < sizeof(name2schema)/sizeof(name2schema[0]); i++) { - if (!strcmpW(name2schema[i].schema, schema)) + if (!lstrcmpW(name2schema[i].schema, schema)) { if (name) { if (!len) return E_INVALIDARG; - len = min(len - 1, strlenW(name2schema[i].name)); + len = min(len - 1, lstrlenW(name2schema[i].name)); memcpy(name, name2schema[i].name, len * sizeof(WCHAR)); name[len] = 0; @@ -404,7 +911,7 @@ return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } - if (ret_len) *ret_len = strlenW(name2schema[i].name) + 1; + if (ret_len) *ret_len = lstrlenW(name2schema[i].name) + 1; return S_OK; } } Modified: trunk/reactos/dll/win32/windowscodecs/pngformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/pn…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/pngformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/pngformat.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -1085,7 +1085,7 @@ if (!ppIMetadataQueryReader) return E_INVALIDARG; - return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, ppIMetadataQueryReader); + return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, NULL, ppIMetadataQueryReader); } static HRESULT WINAPI PngDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *iface, @@ -1307,6 +1307,7 @@ }; static const struct png_pixelformat formats[] = { + {&GUID_WICPixelFormat32bppBGRA, 32, 8, PNG_COLOR_TYPE_RGB_ALPHA, 0, 1}, {&GUID_WICPixelFormat24bppBGR, 24, 8, PNG_COLOR_TYPE_RGB, 0, 1}, {&GUID_WICPixelFormatBlackWhite, 1, 1, PNG_COLOR_TYPE_GRAY, 0, 0}, {&GUID_WICPixelFormat2bppGray, 2, 2, PNG_COLOR_TYPE_GRAY, 0, 0}, @@ -1314,7 +1315,6 @@ {&GUID_WICPixelFormat8bppGray, 8, 8, PNG_COLOR_TYPE_GRAY, 0, 0}, {&GUID_WICPixelFormat16bppGray, 16, 16, PNG_COLOR_TYPE_GRAY, 0, 0}, {&GUID_WICPixelFormat32bppBGR, 32, 8, PNG_COLOR_TYPE_RGB, 1, 1}, - {&GUID_WICPixelFormat32bppBGRA, 32, 8, PNG_COLOR_TYPE_RGB_ALPHA, 0, 1}, {&GUID_WICPixelFormat48bppRGB, 48, 16, PNG_COLOR_TYPE_RGB, 0, 0}, {&GUID_WICPixelFormat64bppRGBA, 64, 16, PNG_COLOR_TYPE_RGB_ALPHA, 0, 0}, {&GUID_WICPixelFormat1bppIndexed, 1, 1, PNG_COLOR_TYPE_PALETTE, 0, 0}, Modified: trunk/reactos/dll/win32/windowscodecs/tiffformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ti…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/tiffformat.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/tiffformat.c [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -1373,7 +1373,7 @@ if (!ppIMetadataQueryReader) return E_INVALIDARG; - return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, ppIMetadataQueryReader); + return MetadataQueryReader_CreateInstance(&This->IWICMetadataBlockReader_iface, NULL, ppIMetadataQueryReader); } static HRESULT WINAPI TiffFrameDecode_GetColorContexts(IWICBitmapFrameDecode *iface, Modified: trunk/reactos/dll/win32/windowscodecs/wincodecs_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/wi…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/wincodecs_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/wincodecs_private.h [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -251,9 +251,17 @@ extern HRESULT GCEReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN; extern HRESULT APEReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN; extern HRESULT GifCommentReader_CreateInstance(REFIID iid, void **ppv) DECLSPEC_HIDDEN; - -extern HRESULT MetadataQueryReader_CreateInstance(IWICMetadataBlockReader *mbr, IWICMetadataQueryReader **out) DECLSPEC_HIDDEN; - +extern HRESULT MetadataQueryReader_CreateInstance(IWICMetadataBlockReader *, const WCHAR *, IWICMetadataQueryReader **) DECLSPEC_HIDDEN; extern HRESULT stream_initialize_from_filehandle(IWICStream *iface, HANDLE hfile) DECLSPEC_HIDDEN; +static inline WCHAR *heap_strdupW(const WCHAR *src) +{ + WCHAR *dst; + SIZE_T len; + if (!src) return NULL; + len = (strlenW(src) + 1) * sizeof(WCHAR); + if ((dst = HeapAlloc(GetProcessHeap(), 0, len))) memcpy(dst, src, len); + return dst; +} + #endif /* WINCODECS_PRIVATE_H */ Modified: trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/wi…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.idl [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.idl [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -35,6 +35,13 @@ coclass WICImagingFactory { interface IWICImagingFactory; } [ + helpstring("WIC Imaging Factory 2"), + threading(both), + uuid(317d06e8-5f24-433d-bdf7-79ce68d8abc2) +] +coclass WICImagingFactory2 { interface IWICImagingFactory2; } + +[ helpstring("WIC BMP Decoder"), threading(both), uuid(6b462062-7cbf-400d-9fdb-813dd10f2778) Modified: trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.rgs URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/wi…
============================================================================== --- trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.rgs [iso-8859-1] (original) +++ trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.rgs [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -143,6 +143,10 @@ { InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } } + '{317D06E8-5F24-433D-BDF7-79CE68D8ABC2}' = s 'WIC Imaging Factory 2' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } + } '{6B462062-7CBF-400D-9FDB-813DD10F2778}' = s 'WIC BMP Decoder' { InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } @@ -160,10 +164,6 @@ InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } } '{381DDA3C-9CE9-4834-A23E-1F98F8FC52BE}' = s 'WIC GIF Decoder' - { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } - } - '{114F5598-0B22-40A0-86A1-C83EA495ADBD}' = s 'WIC GIF Encoder' { InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Both' } } Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -196,7 +196,7 @@ reactos/dll/win32/vssapi # Synced to WineStaging-2.9 reactos/dll/win32/wbemdisp # Synced to WineStaging-2.16 reactos/dll/win32/wbemprox # Synced to WineStaging-2.16 -reactos/dll/win32/windowscodecs # Synced to WineStaging-2.9 +reactos/dll/win32/windowscodecs # Synced to WineStaging-2.16 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9 reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.16 reactos/dll/win32/wing32 # Synced to WineStaging-2.9 Modified: trunk/reactos/sdk/include/psdk/wincodec.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/wincodec.…
============================================================================== --- trunk/reactos/sdk/include/psdk/wincodec.idl [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/wincodec.idl [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -146,6 +146,14 @@ WICComponentEnumerateDisabled = 0x80000000 } WICComponentEnumerateOptions; +typedef enum WICJpegYCrCbSubsamplingOption { + WICJpegYCrCbSubsamplingDefault = 0x00000000, + WICJpegYCrCbSubsampling420 = 0x00000001, + WICJpegYCrCbSubsampling422 = 0x00000002, + WICJpegYCrCbSubsampling444 = 0x00000003, + WICJpegYCrCbSubsampling440 = 0x00000004 +} WICJpegYCrCbSubsamplingOption; + typedef enum WICPixelFormatNumericRepresentation { WICPixelFormatNumericRepresentationUnspecified = 0x00000000, WICPixelFormatNumericRepresentationIndexed = 0x00000001, @@ -241,23 +249,6 @@ typedef UINT32 WICColor; -cpp_quote("#define WINCODEC_ERR_WRONGSTATE 0x88982f04") -cpp_quote("#define WINCODEC_ERR_VALUEOUTOFRANGE 0x88982f05") -cpp_quote("#define WINCODEC_ERR_NOTINITIALIZED 0x88982f0c") -cpp_quote("#define WINCODEC_ERR_ALREADYLOCKED 0x88982f0d") -cpp_quote("#define WINCODEC_ERR_PROPERTYNOTFOUND 0x88982f40") -cpp_quote("#define WINCODEC_ERR_CODECNOTHUMBNAIL 0x88982f44") -cpp_quote("#define WINCODEC_ERR_PALETTEUNAVAILABLE 0x88982f45") -cpp_quote("#define WINCODEC_ERR_COMPONENTNOTFOUND 0x88982f50") -cpp_quote("#define WINCODEC_ERR_BADIMAGE 0x88982f60") -cpp_quote("#define WINCODEC_ERR_FRAMEMISSING 0x88982f62") -cpp_quote("#define WINCODEC_ERR_BADMETADATAHEADER 0x88982f63") -cpp_quote("#define WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT 0x88982f80") -cpp_quote("#define WINCODEC_ERR_UNSUPPORTEDOPERATION 0x88982f81") -cpp_quote("#define WINCODEC_ERR_INSUFFICIENTBUFFER 0x88982f8c") -cpp_quote("#define WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE 0x88982f8e") -cpp_quote("#define WINCODEC_ERR_WIN32ERROR 0x88982f94") - interface IWICPalette; [ @@ -1024,8 +1015,8 @@ cpp_quote("HRESULT WINAPI WICCreateBitmapFromSectionEx(UINT width, UINT height, REFWICPixelFormatGUID format, HANDLE section, UINT stride, UINT offset, WICSectionAccessLevel access, IWICBitmap **bitmap);") cpp_quote("HRESULT WINAPI WICMapGuidToShortName(REFGUID,UINT,WCHAR *,UINT *);") -cpp_quote("HRESULT WINAPI WICMapShortNameToGuid(const WCHAR *,GUID *);") -cpp_quote("HRESULT WINAPI WICMapSchemaToName(REFGUID,const WCHAR *,UINT,WCHAR *,UINT *);") +cpp_quote("HRESULT WINAPI WICMapShortNameToGuid(PCWSTR,GUID *);") +cpp_quote("HRESULT WINAPI WICMapSchemaToName(REFGUID,LPWSTR,UINT,WCHAR *,UINT *);") cpp_quote("DEFINE_GUID(CLSID_WICBmpDecoder, 0x6b462062,0x7cbf,0x400d,0x9f,0xdb,0x81,0x3d,0xd1,0x0f,0x27,0x78);") cpp_quote("DEFINE_GUID(CLSID_WICPngDecoder, 0x389ea17b,0x5078,0x4cde,0xb6,0xef,0x25,0xc1,0x51,0x75,0xc7,0x51);") Modified: trunk/reactos/sdk/include/psdk/winerror.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/winerror.…
============================================================================== --- trunk/reactos/sdk/include/psdk/winerror.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/winerror.h [iso-8859-1] Sun Sep 24 11:19:07 2017 @@ -3268,7 +3268,46 @@ #define SCARD_W_CACHE_ITEM_STALE _HRESULT_TYPEDEF_(0x80100071L) #define SCARD_W_CACHE_ITEM_TOO_BIG _HRESULT_TYPEDEF_(0x80100072L) +#define WINCODEC_ERR_WRONGSTATE _HRESULT_TYPEDEF_(0x88982f04) +#define WINCODEC_ERR_VALUEOUTOFRANGE _HRESULT_TYPEDEF_(0x88982f05) #define WINCODEC_ERR_UNKNOWNIMAGEFORMAT _HRESULT_TYPEDEF_(0x88982f07) +#define WINCODEC_ERR_UNSUPPORTEDVERSION _HRESULT_TYPEDEF_(0x88982f0b) +#define WINCODEC_ERR_NOTINITIALIZED _HRESULT_TYPEDEF_(0x88982f0c) +#define WINCODEC_ERR_ALREADYLOCKED _HRESULT_TYPEDEF_(0x88982f0d) +#define WINCODEC_ERR_PROPERTYNOTFOUND _HRESULT_TYPEDEF_(0x88982f40) +#define WINCODEC_ERR_PROPERTYNOTSUPPORTED _HRESULT_TYPEDEF_(0x88982f41) +#define WINCODEC_ERR_PROPERTYSIZE _HRESULT_TYPEDEF_(0x88982f42) +#define WINCODEC_ERR_CODECPRESENT _HRESULT_TYPEDEF_(0x88982f43) +#define WINCODEC_ERR_CODECNOTHUMBNAIL _HRESULT_TYPEDEF_(0x88982f44) +#define WINCODEC_ERR_PALETTEUNAVAILABLE _HRESULT_TYPEDEF_(0x88982f45) +#define WINCODEC_ERR_CODECTOOMANYSCANLINES _HRESULT_TYPEDEF_(0x88982f46) +#define WINCODEC_ERR_INTERNALERROR _HRESULT_TYPEDEF_(0x88982f48) +#define WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS _HRESULT_TYPEDEF_(0x88982f49) +#define WINCODEC_ERR_COMPONENTNOTFOUND _HRESULT_TYPEDEF_(0x88982f50) +#define WINCODEC_ERR_IMAGESIZEOUTOFRANGE _HRESULT_TYPEDEF_(0x88982f51) +#define WINCODEC_ERR_TOOMUCHMETADATA _HRESULT_TYPEDEF_(0x88982f52) +#define WINCODEC_ERR_BADIMAGE _HRESULT_TYPEDEF_(0x88982f60) +#define WINCODEC_ERR_BADHEADER _HRESULT_TYPEDEF_(0x88982f61) +#define WINCODEC_ERR_FRAMEMISSING _HRESULT_TYPEDEF_(0x88982f62) +#define WINCODEC_ERR_BADMETADATAHEADER _HRESULT_TYPEDEF_(0x88982f63) +#define WINCODEC_ERR_BADSTREAMDATA _HRESULT_TYPEDEF_(0x88982f70) +#define WINCODEC_ERR_STREAMWRITE _HRESULT_TYPEDEF_(0x88982f71) +#define WINCODEC_ERR_STREAMREAD _HRESULT_TYPEDEF_(0x88982f72) +#define WINCODEC_ERR_STREAMNOTAVAILABLE _HRESULT_TYPEDEF_(0x88982f73) +#define WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT _HRESULT_TYPEDEF_(0x88982f80) +#define WINCODEC_ERR_UNSUPPORTEDOPERATION _HRESULT_TYPEDEF_(0x88982f81) +#define WINCODEC_ERR_INVALIDREGISTRATION _HRESULT_TYPEDEF_(0x88982f8a) +#define WINCODEC_ERR_COMPONENTINITIALIZEFAILURE _HRESULT_TYPEDEF_(0x88982f8b) +#define WINCODEC_ERR_INSUFFICIENTBUFFER _HRESULT_TYPEDEF_(0x88982f8c) +#define WINCODEC_ERR_DUPLICATEMETADATAPRESENT _HRESULT_TYPEDEF_(0x88982f8d) +#define WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE _HRESULT_TYPEDEF_(0x88982f8e) +#define WINCODEC_ERR_UNEXPECTEDSIZE _HRESULT_TYPEDEF_(0x88982f8f) +#define WINCODEC_ERR_INVALIDQUERYREQUEST _HRESULT_TYPEDEF_(0x88982f90) +#define WINCODEC_ERR_UNEXPECTEDMETADATATYPE _HRESULT_TYPEDEF_(0x88982f91) +#define WINCODEC_ERR_REQUESTONLYVALIDATMETADATAROOT _HRESULT_TYPEDEF_(0x88982f92) +#define WINCODEC_ERR_INVALIDQUERYCHARACTER _HRESULT_TYPEDEF_(0x88982f93) +#define WINCODEC_ERR_WIN32ERROR _HRESULT_TYPEDEF_(0x88982f94) +#define WINCODEC_ERR_INVALIDPROGRESSIVELEVEL _HRESULT_TYPEDEF_(0x88982f95) #define ERROR_AUDITING_DISABLED _HRESULT_TYPEDEF_(0xC0090001L) #define ERROR_ALL_SIDS_FILTERED _HRESULT_TYPEDEF_(0xC0090002L)
7 years, 3 months
1
0
0
0
[akhaldi] 75952: [PSDK] Update propidl.idl. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:18:52 2017 New Revision: 75952 URL:
http://svn.reactos.org/svn/reactos?rev=75952&view=rev
Log: [PSDK] Update propidl.idl. CORE-13762 Modified: trunk/reactos/sdk/include/psdk/propidl.idl Modified: trunk/reactos/sdk/include/psdk/propidl.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/propidl.i…
============================================================================== --- trunk/reactos/sdk/include/psdk/propidl.idl [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/propidl.idl [iso-8859-1] Sun Sep 24 11:18:52 2017 @@ -141,6 +141,8 @@ [case(VT_BSTR_BLOB)] BSTRBLOB bstrblobVal; [case(VT_LPSTR)] LPSTR pszVal; [case(VT_LPWSTR)] LPWSTR pwszVal; + [case(VT_UNKNOWN)] IUnknown *punkVal; + [case(VT_DISPATCH)] IDispatch *pdispVal; [case(VT_UI1|VT_VECTOR)] CAUB caub; [case(VT_I2|VT_VECTOR)] CAI cai; [case(VT_UI2|VT_VECTOR)] CAUI caui;
7 years, 3 months
1
0
0
0
[akhaldi] 75951: [XMLLITE_WINETEST] Sync with Wine Staging 2.16. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:18:47 2017 New Revision: 75951 URL:
http://svn.reactos.org/svn/reactos?rev=75951&view=rev
Log: [XMLLITE_WINETEST] Sync with Wine Staging 2.16. CORE-13762 Modified: trunk/rostests/winetests/xmllite/reader.c trunk/rostests/winetests/xmllite/writer.c Modified: trunk/rostests/winetests/xmllite/reader.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xmllite/reader.…
============================================================================== --- trunk/rostests/winetests/xmllite/reader.c [iso-8859-1] (original) +++ trunk/rostests/winetests/xmllite/reader.c [iso-8859-1] Sun Sep 24 11:18:47 2017 @@ -801,7 +801,6 @@ { XmlNodeType nodetype; IXmlReader *reader; - IStream *stream; HRESULT hr; hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL); @@ -820,12 +819,7 @@ hr = IXmlReader_Read(reader, &nodetype); ok(hr == S_FALSE, "got %08x\n", hr); } - - stream = create_stream_on_data("xml", sizeof("xml")); - - hr = IXmlReader_SetInput(reader, (IUnknown *)stream); - ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); - + set_input_string(reader, "xml"); TEST_READER_STATE(reader, XmlReadState_Initial); nodetype = XmlNodeType_Element; @@ -843,7 +837,6 @@ ok(FAILED(hr), "got %08x\n", hr); ok(nodetype == XmlNodeType_None, "Unexpected node type %d\n", nodetype); - IStream_Release(stream); IXmlReader_Release(reader); } @@ -1287,7 +1280,6 @@ IXmlReader *reader; const WCHAR *str; XmlNodeType type; - IStream *stream; UINT len, count; HRESULT hr; @@ -1297,9 +1289,7 @@ hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, DtdProcessing_Parse); ok(hr == S_OK, "got 0x%8x\n", hr); - stream = create_stream_on_data(test_public_dtd, sizeof(test_public_dtd)); - hr = IXmlReader_SetInput(reader, (IUnknown*)stream); - ok(hr == S_OK, "got %08x\n", hr); + set_input_string(reader, test_public_dtd); read_node(reader, XmlNodeType_DocumentType); @@ -1340,7 +1330,6 @@ ok(len == lstrlenW(dtdnameW), "got %u\n", len); ok(!lstrcmpW(str, dtdnameW), "got %s\n", wine_dbgstr_w(str)); } - IStream_Release(stream); IXmlReader_Release(reader); } @@ -1354,7 +1343,6 @@ IXmlReader *reader; const WCHAR *str; XmlNodeType type; - IStream *stream; UINT len, count; HRESULT hr; @@ -1364,9 +1352,7 @@ hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, DtdProcessing_Parse); ok(hr == S_OK, "got 0x%8x\n", hr); - stream = create_stream_on_data(test_system_dtd, sizeof(test_system_dtd)); - hr = IXmlReader_SetInput(reader, (IUnknown*)stream); - ok(hr == S_OK, "got %08x\n", hr); + set_input_string(reader, test_system_dtd); read_node(reader, XmlNodeType_DocumentType); @@ -1400,7 +1386,6 @@ read_node(reader, XmlNodeType_Comment); - IStream_Release(stream); IXmlReader_Release(reader); } @@ -1714,11 +1699,8 @@ while (test->xml) { XmlNodeType type; - IStream *stream; - - stream = create_stream_on_data(test->xml, strlen(test->xml)+1); - hr = IXmlReader_SetInput(reader, (IUnknown*)stream); - ok(hr == S_OK, "got %08x\n", hr); + + set_input_string(reader, test->xml); type = XmlNodeType_None; hr = IXmlReader_Read(reader, &type); @@ -1764,7 +1746,6 @@ reader_value(reader, test->value); } - IStream_Release(stream); test++; } @@ -1791,11 +1772,8 @@ while (test->xml) { XmlNodeType type; - IStream *stream; - - stream = create_stream_on_data(test->xml, strlen(test->xml)+1); - hr = IXmlReader_SetInput(reader, (IUnknown*)stream); - ok(hr == S_OK, "got %08x\n", hr); + + set_input_string(reader, test->xml); type = XmlNodeType_None; hr = IXmlReader_Read(reader, &type); @@ -1837,7 +1815,6 @@ reader_value(reader, test->value); } - IStream_Release(stream); test++; } @@ -1867,12 +1844,9 @@ while (test->xml) { XmlNodeType type; - IStream *stream; BOOL ret; - stream = create_stream_on_data(test->xml, strlen(test->xml)+1); - hr = IXmlReader_SetInput(reader, (IUnknown*)stream); - ok(hr == S_OK, "got %08x\n", hr); + set_input_string(reader, test->xml); type = XmlNodeType_None; hr = IXmlReader_Read(reader, &type); @@ -1882,7 +1856,6 @@ ret = IXmlReader_IsEmptyElement(reader); ok(ret == test->empty, "got %d, expected %d. xml=%s\n", ret, test->empty, test->xml); - IStream_Release(stream); test++; } @@ -1925,11 +1898,8 @@ while (test->xml) { XmlNodeType type; - IStream *stream; - - stream = create_stream_on_data(test->xml, strlen(test->xml)+1); - hr = IXmlReader_SetInput(reader, (IUnknown*)stream); - ok(hr == S_OK, "got %08x\n", hr); + + set_input_string(reader, test->xml); hr = IXmlReader_Read(reader, NULL); @@ -1967,7 +1937,6 @@ reader_value(reader, test->value); } - IStream_Release(stream); test++; } @@ -2024,11 +1993,8 @@ for (i = 0; i < sizeof(prefix_tests)/sizeof(prefix_tests[0]); i++) { XmlNodeType type; - IStream *stream; - - stream = create_stream_on_data(prefix_tests[i].xml, strlen(prefix_tests[i].xml) + 1); - hr = IXmlReader_SetInput(reader, (IUnknown *)stream); - ok(hr == S_OK, "got %08x\n", hr); + + set_input_string(reader, prefix_tests[i].xml); hr = IXmlReader_Read(reader, &type); ok(hr == S_OK, "Read() failed, %#x\n", hr); @@ -2056,8 +2022,6 @@ /* back to the element, check prefix */ move_to_element(reader); reader_prefix(reader, prefix_tests[i].prefix1); - - IStream_Release(stream); } IXmlReader_Release(reader); @@ -2103,11 +2067,9 @@ ok(hr == S_OK, "S_OK, got %08x\n", hr); for (i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); i++) { - IStream *stream = create_stream_on_data(uri_tests[i].xml, strlen(uri_tests[i].xml) + 1); unsigned int j = 0; - hr = IXmlReader_SetInput(reader, (IUnknown *)stream); - ok(hr == S_OK, "got %08x\n", hr); + set_input_string(reader, uri_tests[i].xml); type = ~0u; while (IXmlReader_Read(reader, &type) == S_OK) { @@ -2152,8 +2114,6 @@ j++; } ok(type == XmlNodeType_None, "Unexpected node type %d\n", type); - - IStream_Release(stream); } IXmlReader_Release(reader); @@ -2229,17 +2189,12 @@ for (i = 0; i < sizeof(encoding_testsA)/sizeof(encoding_testsA[0]); i++) { - stream = create_stream_on_data(encoding_testsA[i], strlen(encoding_testsA[i])); - - hr = IXmlReader_SetInput(reader, (IUnknown *)stream); - ok(hr == S_OK, "got %08x\n", hr); + set_input_string(reader, encoding_testsA[i]); type = XmlNodeType_None; hr = IXmlReader_Read(reader, &type); ok(hr == S_OK, "got %08x\n", hr); ok(type != XmlNodeType_None, "Unexpected node type %d\n", type); - - IStream_Release(stream); } for (i = 0; i < sizeof(encoding_testsW)/sizeof(encoding_testsW[0]); i++) @@ -2617,6 +2572,90 @@ next_attribute(reader); ok(name == reader_name(reader, "attr"), "attr pointer changed\n"); ok(value == reader_value(reader, "value"), "value pointer changed\n"); + + IXmlReader_Release(reader); +} + +static void test_attribute_by_name(void) +{ + static const char *xml = "<a><elem xmlns=\"myns\" a=\"value a\" b=\"value b\" xmlns:ns=\"ns uri\" " + "ns:c=\"value c\" c=\"value c2\"/></a>"; + static const WCHAR xmlns_uriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/', + '2','0','0','0','/','x','m','l','n','s','/',0}; + static const WCHAR nsuriW[] = {'n','s',' ','u','r','i',0}; + static const WCHAR xmlnsW[] = {'x','m','l','n','s',0}; + static const WCHAR mynsW[] = {'m','y','n','s',0}; + static const WCHAR nsW[] = {'n','s',0}; + static const WCHAR emptyW[] = {0}; + static const WCHAR aW[] = {'a',0}; + static const WCHAR bW[] = {'b',0}; + static const WCHAR cW[] = {'c',0}; + IXmlReader *reader; + HRESULT hr; + + hr = CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL); + ok(hr == S_OK, "Failed to create reader, hr %#x.\n", hr); + + set_input_string(reader, xml); + + hr = IXmlReader_MoveToAttributeByName(reader, NULL, NULL); + ok(hr == E_INVALIDARG || broken(hr == S_FALSE) /* WinXP */, "Unexpected hr %#x.\n", hr); + + hr = IXmlReader_MoveToAttributeByName(reader, emptyW, NULL); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + read_node(reader, XmlNodeType_Element); + + hr = IXmlReader_MoveToAttributeByName(reader, emptyW, NULL); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + read_node(reader, XmlNodeType_Element); + + hr = IXmlReader_MoveToAttributeByName(reader, NULL, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IXmlReader_MoveToAttributeByName(reader, NULL, xmlns_uriW); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IXmlReader_MoveToAttributeByName(reader, emptyW, xmlns_uriW); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IXmlReader_MoveToAttributeByName(reader, xmlnsW, NULL); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IXmlReader_MoveToAttributeByName(reader, xmlnsW, xmlns_uriW); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + reader_value(reader, "myns"); + + hr = IXmlReader_MoveToAttributeByName(reader, aW, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + reader_value(reader, "value a"); + + hr = IXmlReader_MoveToAttributeByName(reader, bW, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + reader_value(reader, "value b"); + + hr = IXmlReader_MoveToAttributeByName(reader, aW, mynsW); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IXmlReader_MoveToAttributeByName(reader, nsW, NULL); + ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); + + hr = IXmlReader_MoveToAttributeByName(reader, nsW, xmlns_uriW); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + reader_value(reader, "ns uri"); + + hr = IXmlReader_MoveToAttributeByName(reader, bW, emptyW); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + reader_value(reader, "value b"); + + hr = IXmlReader_MoveToAttributeByName(reader, cW, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + reader_value(reader, "value c2"); + + hr = IXmlReader_MoveToAttributeByName(reader, cW, nsuriW); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + reader_value(reader, "value c"); IXmlReader_Release(reader); } @@ -2648,4 +2687,5 @@ test_max_element_depth(); test_reader_position(); test_string_pointers(); -} + test_attribute_by_name(); +} Modified: trunk/rostests/winetests/xmllite/writer.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xmllite/writer.…
============================================================================== --- trunk/rostests/winetests/xmllite/writer.c [iso-8859-1] (original) +++ trunk/rostests/winetests/xmllite/writer.c [iso-8859-1] Sun Sep 24 11:18:47 2017 @@ -39,6 +39,8 @@ #include <initguid.h> DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a); +static const WCHAR aW[] = {'a',0}; + #define EXPECT_REF(obj, ref) _expect_ref((IUnknown *)obj, ref, __LINE__) static void _expect_ref(IUnknown *obj, ULONG ref, int line) { @@ -46,6 +48,25 @@ IUnknown_AddRef(obj); refcount = IUnknown_Release(obj); ok_(__FILE__, line)(refcount == ref, "expected refcount %d, got %d\n", ref, refcount); +} + +static void check_output_raw(IStream *stream, const void *expected, SIZE_T size, int line) +{ + SIZE_T content_size; + HGLOBAL hglobal; + HRESULT hr; + char *ptr; + + hr = GetHGlobalFromStream(stream, &hglobal); + ok_(__FILE__, line)(hr == S_OK, "Failed to get the stream handle, hr %#x.\n", hr); + + content_size = GlobalSize(hglobal); + ok_(__FILE__, line)(size <= content_size, "Unexpected test output size.\n"); + ptr = GlobalLock(hglobal); + if (size <= content_size) + ok_(__FILE__, line)(!memcmp(expected, ptr, size), "Unexpected output content.\n"); + + GlobalUnlock(hglobal); } static void check_output(IStream *stream, const char *expected, BOOL todo, int line) @@ -74,6 +95,15 @@ } #define CHECK_OUTPUT(stream, expected) check_output(stream, expected, FALSE, __LINE__) #define CHECK_OUTPUT_TODO(stream, expected) check_output(stream, expected, TRUE, __LINE__) +#define CHECK_OUTPUT_RAW(stream, expected, size) check_output_raw(stream, expected, size, __LINE__) + +static void writer_set_property(IXmlWriter *writer, XmlWriterProperty property) +{ + HRESULT hr; + + hr = IXmlWriter_SetProperty(writer, property, TRUE); + ok(hr == S_OK, "Failed to set writer property, hr %#x.\n", hr); +} /* used to test all Write* methods for consistent error state */ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr) @@ -292,11 +322,93 @@ IXmlWriter_Release(writer); } +static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output) +{ + HRESULT hr; + + hr = IXmlWriter_SetOutput(writer, output); + ok(hr == S_OK, "Failed to set output, hr %#x.\n", hr); + + /* TODO: WriteAttributes */ + + hr = IXmlWriter_WriteAttributeString(writer, NULL, aW, NULL, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteCData(writer, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteCharEntity(writer, 0x100); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteChars(writer, aW, 1); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteComment(writer, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + /* TODO: WriteDocType */ + + hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteEndDocument(writer); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteEndElement(writer); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteFullEndElement(writer); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteName(writer, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteNmToken(writer, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + /* TODO: WriteNode */ + /* TODO: WriteNodeShallow */ + + hr = IXmlWriter_WriteProcessingInstruction(writer, aW, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, aW, NULL); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteRaw(writer, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteRawChars(writer, aW, 1); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteString(writer, aW); + ok(hr == MX_E_ENCODING, "Unexpected hr %#x.\n", hr); + + /* TODO: WriteSurrogateCharEntity */ + /* ???TODO: WriteWhitespace */ + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Failed to flush, hr %#x.\n", hr); +} + static void test_writeroutput(void) { static const WCHAR utf16W[] = {'u','t','f','-','1','6',0}; static const WCHAR usasciiW[] = {'u','s','-','a','s','c','i','i',0}; + static const WCHAR dummyW[] = {'d','u','m','m','y',0}; + static const WCHAR utf16_outputW[] = {0xfeff,'<','a'}; IXmlWriterOutput *output; + IXmlWriter *writer; + IStream *stream; IUnknown *unk; HRESULT hr; @@ -339,6 +451,59 @@ hr = CreateXmlWriterOutputWithEncodingName(&testoutput, NULL, usasciiW, &output); ok(hr == S_OK, "got %08x\n", hr); IUnknown_Release(output); + + /* Output with codepage 1200. */ + hr = CreateXmlWriter(&IID_IXmlWriter, (void **)&writer, NULL); + ok(hr == S_OK, "Failed to create writer, hr %#x.\n", hr); + + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); + ok(hr == S_OK, "Failed to create stream, hr %#x.\n", hr); + + hr = CreateXmlWriterOutputWithEncodingCodePage((IUnknown *)stream, NULL, 1200, &output); + ok(hr == S_OK, "Failed to create writer output, hr %#x.\n", hr); + + hr = IXmlWriter_SetOutput(writer, output); + ok(hr == S_OK, "Failed to set writer output, hr %#x.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + ok(hr == S_OK, "Write failed, hr %#x.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Failed to flush, hr %#x.\n", hr); + + CHECK_OUTPUT_RAW(stream, utf16_outputW, sizeof(utf16_outputW)); + + IStream_Release(stream); + + /* Create output with meaningless code page value. */ + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); + ok(hr == S_OK, "Failed to create stream, hr %#x.\n", hr); + + output = NULL; + hr = CreateXmlWriterOutputWithEncodingCodePage((IUnknown *)stream, NULL, ~0u, &output); + ok(hr == S_OK, "Failed to create writer output, hr %#x.\n", hr); + + test_invalid_output_encoding(writer, output); + CHECK_OUTPUT(stream, ""); + + IStream_Release(stream); + IUnknown_Release(output); + + /* Same, with invalid encoding name. */ + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); + ok(hr == S_OK, "got 0x%08x\n", hr); + + output = NULL; + hr = CreateXmlWriterOutputWithEncodingName((IUnknown *)stream, NULL, dummyW, &output); + ok(hr == S_OK, "got %08x\n", hr); + + test_invalid_output_encoding(writer, output); + CHECK_OUTPUT(stream, ""); + + IStream_Release(stream); + IUnknown_Release(output); + + IXmlWriter_Release(writer); } static void test_writestartdocument(void) @@ -483,8 +648,7 @@ stream = writer_set_output(writer); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -548,7 +712,6 @@ static const WCHAR versionW[] = {'v','e','r','s','i','o','n','=','"','1','.','0','"',0}; static const WCHAR utf16W[] = {'u','t','f','-','1','6',0}; static const WCHAR xmlW[] = {'x','m','l',0}; - static const WCHAR aW[] = {'a',0}; IXmlWriterOutput *output; unsigned char *ptr; IXmlWriter *writer; @@ -565,8 +728,7 @@ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); hr = IXmlWriter_SetOutput(writer, output); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -650,6 +812,8 @@ hr = IXmlWriter_SetOutput(writer, output); ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_Indent); + hr = IXmlWriter_WriteElementString(writer, NULL, aW, NULL, NULL); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -660,7 +824,8 @@ ok(hr == S_OK, "got 0x%08x\n", hr); ptr = GlobalLock(hglobal); - ok(ptr[0] == 0xff && ptr[1] == 0xfe, "got %x,%x\n", ptr[0], ptr[1]); + ok(ptr[0] == 0xff && ptr[1] == 0xfe && ptr[2] == '<', "Unexpected output: %#x,%#x,%#x\n", + ptr[0], ptr[1], ptr[2]); GlobalUnlock(hglobal); IUnknown_Release(output); @@ -672,7 +837,6 @@ static void test_writestartelement(void) { static const WCHAR valueW[] = {'v','a','l','u','e',0}; - static const char *str = "<a><b>value</b>"; static const WCHAR aW[] = {'a',0}; static const WCHAR bW[] = {'b',0}; IXmlWriter *writer; @@ -734,10 +898,14 @@ hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, valueW); ok(hr == S_OK, "got 0x%08x\n", hr); - hr = IXmlWriter_Flush(writer); - ok(hr == S_OK, "got 0x%08x\n", hr); - - CHECK_OUTPUT(stream, str); + hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "got 0x%08x\n", hr); + + CHECK_OUTPUT(stream, + "<a><b>value</b><b />"); IStream_Release(stream); IXmlWriter_Release(writer); @@ -848,8 +1016,7 @@ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); hr = IXmlWriter_WriteComment(writer, aW); ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr); @@ -896,8 +1063,7 @@ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); hr = IXmlWriter_WriteCData(writer, aW); ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr); @@ -1095,11 +1261,8 @@ stream = writer_set_output(writer); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); - - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + writer_set_property(writer, XmlWriterProperty_Indent); hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -1125,8 +1288,35 @@ " <b />\r\n" "</a>"); - IXmlWriter_Release(writer); - IStream_Release(stream); + IStream_Release(stream); + + /* WriteElementString */ + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartElement(writer, NULL, aW, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteElementString(writer, NULL, bW, NULL, NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_WriteEndElement(writer); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + CHECK_OUTPUT(stream, + "<a>\r\n" + " <b />\r\n" + " <b />\r\n" + "</a>"); + + IStream_Release(stream); + + IXmlWriter_Release(writer); } static void test_WriteAttributeString(void) @@ -1147,8 +1337,7 @@ stream = writer_set_output(writer); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -1227,11 +1416,8 @@ /* standalone element */ stream = writer_set_output(writer); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); - - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + writer_set_property(writer, XmlWriterProperty_Indent); hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -1255,11 +1441,8 @@ /* nested elements */ stream = writer_set_output(writer); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); - - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_Indent, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + writer_set_property(writer, XmlWriterProperty_Indent); hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -1301,8 +1484,7 @@ /* without indentation */ stream = writer_set_output(writer); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -1342,8 +1524,7 @@ hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); - hr = IXmlWriter_SetProperty(writer, XmlWriterProperty_OmitXmlDeclaration, TRUE); - ok(hr == S_OK, "got 0x%08x\n", hr); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); hr = IXmlWriter_WriteString(writer, aW); ok(hr == E_UNEXPECTED, "got 0x%08x\n", hr);
7 years, 3 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
29
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Results per page:
10
25
50
100
200