Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 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
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
November 2020
- 73 participants
- 650 discussions
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50206
Signed-off-by: Austin English <austinenglish(a)gmail.com>
---
configure | 2 ++
configure.ac | 1 +
dlls/dcomp/Makefile.in | 8 ++++++++
dlls/dcomp/dcomp.spec | 23 ++++++++++++++++++++++
dlls/dcomp/main.c | 44 ++++++++++++++++++++++++++++++++++++++++++
dlls/dcomp/version.rc | 26 +++++++++++++++++++++++++
6 files changed, 104 insertions(+)
create mode 100644 dlls/dcomp/Makefile.in
create mode 100644 dlls/dcomp/dcomp.spec
create mode 100644 dlls/dcomp/main.c
create mode 100644 dlls/dcomp/version.rc
diff --git a/configure b/configure
index e6596361ff1..9139ed9a247 100755
--- a/configure
+++ b/configure
@@ -1244,6 +1244,7 @@ enable_davclnt
enable_dbgeng
enable_dbghelp
enable_dciman32
+enable_dcomp
enable_ddraw
enable_ddrawex
enable_devenum
@@ -20413,6 +20414,7 @@ wine_fn_config_makefile dlls/dbgeng/tests enable_tests
wine_fn_config_makefile dlls/dbghelp enable_dbghelp
wine_fn_config_makefile dlls/dbghelp/tests enable_tests
wine_fn_config_makefile dlls/dciman32 enable_dciman32
+wine_fn_config_makefile dlls/dcomp enable_dcomp
wine_fn_config_makefile dlls/ddeml.dll16 enable_win16
wine_fn_config_makefile dlls/ddraw enable_ddraw
wine_fn_config_makefile dlls/ddraw/tests enable_tests
diff --git a/configure.ac b/configure.ac
index 705ab04295d..6b548b5ba56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3192,6 +3192,7 @@ WINE_CONFIG_MAKEFILE(dlls/dbgeng/tests)
WINE_CONFIG_MAKEFILE(dlls/dbghelp)
WINE_CONFIG_MAKEFILE(dlls/dbghelp/tests)
WINE_CONFIG_MAKEFILE(dlls/dciman32)
+WINE_CONFIG_MAKEFILE(dlls/dcomp)
WINE_CONFIG_MAKEFILE(dlls/ddeml.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/ddraw)
WINE_CONFIG_MAKEFILE(dlls/ddraw/tests)
diff --git a/dlls/dcomp/Makefile.in b/dlls/dcomp/Makefile.in
new file mode 100644
index 00000000000..6d75a87980f
--- /dev/null
+++ b/dlls/dcomp/Makefile.in
@@ -0,0 +1,8 @@
+MODULE = dcomp.dll
+
+EXTRADLLFLAGS = -mno-cygwin
+
+C_SRCS = \
+ main.c
+
+RC_SRCS = version.rc
diff --git a/dlls/dcomp/dcomp.spec b/dlls/dcomp/dcomp.spec
new file mode 100644
index 00000000000..10eb10c29ff
--- /dev/null
+++ b/dlls/dcomp/dcomp.spec
@@ -0,0 +1,23 @@
+@ stub DCOMP_1017
+@ stub CompileEffectDescription
+@ stub DCOMP_1019
+@ stub CreateEffectDescription
+@ stub DCompositionAttachMouseDragToHwnd
+@ stub DCompositionAttachMouseWheelToHwnd
+@ stub DCompositionCreateDevice2
+@ stub DCompositionCreateDevice3
+@ stub DCompositionCreateDevice
+@ stub DCompositionCreateSurfaceHandle
+@ stub DeserializeEffectDescription
+@ stub DCOMP_1028
+@ stub DllCanUnloadNow
+@ stub DllGetActivationFactory
+@ stub DCOMP_1031
+@ stub DllGetClassObject
+@ stub DCOMP_1033
+@ stub DwmEnableMMCSS
+@ stub DwmFlush
+@ stub DwmpEnableDDASupport
+@ stub SerializeEffectDescription
+@ stub DCOMP_1038
+@ stub DCOMP_1039
diff --git a/dlls/dcomp/main.c b/dlls/dcomp/main.c
new file mode 100644
index 00000000000..b0b911a9bf5
--- /dev/null
+++ b/dlls/dcomp/main.c
@@ -0,0 +1,44 @@
+/*
+ * DirectComposition Library
+ *
+ * Copyright 2020 Austin English
+ *
+ * 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 <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dcomp);
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
+
+ switch (fdwReason)
+ {
+ case DLL_WINE_PREATTACH:
+ return FALSE; /* prefer native version */
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinstDLL);
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
diff --git a/dlls/dcomp/version.rc b/dlls/dcomp/version.rc
new file mode 100644
index 00000000000..a76f2675829
--- /dev/null
+++ b/dlls/dcomp/version.rc
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2020 Austin English
+ *
+ * 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
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine dcomp"
+#define WINE_FILENAME_STR "dcomp.dll"
+#define WINE_FILEVERSION 10,0,14393,0
+#define WINE_FILEVERSION_STR "10.0.14393.0"
+#define WINE_PRODUCTVERSION 10,0,14393,0
+#define WINE_PRODUCTVERSION_STR "10.0.14393.0"
+
+#include "wine/wine_common_ver.rc"
--
2.28.0
1
0
[PATCH 1/4] qcap/tests: Add some tests for smart tee streaming using the strmbase infrastructure.
by Zebediah Figura 30 Nov '20
by Zebediah Figura 30 Nov '20
30 Nov '20
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/qcap/tests/smartteefilter.c | 268 ++++++++++++++++++++++++++++++-
1 file changed, 264 insertions(+), 4 deletions(-)
diff --git a/dlls/qcap/tests/smartteefilter.c b/dlls/qcap/tests/smartteefilter.c
index 1019fd3c1ba..bd51743de76 100644
--- a/dlls/qcap/tests/smartteefilter.c
+++ b/dlls/qcap/tests/smartteefilter.c
@@ -2278,6 +2278,9 @@ struct testfilter
struct strmbase_sink sink;
const AM_MEDIA_TYPE *sink_mt;
AM_MEDIA_TYPE source_mt;
+ HANDLE sample_event, eos_event, segment_event;
+ BOOL preview;
+ unsigned int got_begin_flush, got_end_flush;
};
static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface)
@@ -2298,6 +2301,9 @@ static struct strmbase_pin *testfilter_get_pin(struct strmbase_filter *iface, un
static void testfilter_destroy(struct strmbase_filter *iface)
{
struct testfilter *filter = impl_from_strmbase_filter(iface);
+ CloseHandle(filter->sample_event);
+ CloseHandle(filter->eos_event);
+ CloseHandle(filter->segment_event);
strmbase_source_cleanup(&filter->source);
strmbase_sink_cleanup(&filter->sink);
strmbase_filter_cleanup(&filter->filter);
@@ -2327,7 +2333,9 @@ static HRESULT testsource_get_media_type(struct strmbase_pin *iface, unsigned in
static void test_sink_allocator(IPin *pin)
{
- ALLOCATOR_PROPERTIES req_props = {1, 5000, 1, 0}, ret_props;
+ /* FIXME: We shouldn't need more than one sample, but Wine currently uses
+ * the same allocator for all three pins. */
+ ALLOCATOR_PROPERTIES req_props = {3, 256, 1, 0}, ret_props;
IMemAllocator *req_allocator, *ret_allocator;
IMemInputPin *input;
HRESULT hr;
@@ -2359,9 +2367,6 @@ static void test_sink_allocator(IPin *pin)
hr = IMemAllocator_SetProperties(req_allocator, &req_props, &ret_props);
ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IMemAllocator_Commit(req_allocator);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
-
IMemAllocator_Release(req_allocator);
IMemInputPin_Release(input);
}
@@ -2429,6 +2434,88 @@ static HRESULT testsink_get_media_type(struct strmbase_pin *iface, unsigned int
static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample *sample)
{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ REFERENCE_TIME start, stop;
+ BYTE *data, expect[200];
+ LONG size, i;
+ HRESULT hr;
+
+ size = IMediaSample_GetSize(sample);
+ ok(size == 256, "Got size %u.\n", size);
+ size = IMediaSample_GetActualDataLength(sample);
+ ok(size == 200, "Got valid size %u.\n", size);
+
+ hr = IMediaSample_GetPointer(sample, &data);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ for (i = 0; i < size; ++i)
+ expect[i] = i;
+ ok(!memcmp(data, expect, size), "Data didn't match.\n");
+
+ hr = IMediaSample_GetTime(sample, &start, &stop);
+ if (filter->preview)
+ {
+ ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#x.\n", hr);
+ }
+ else
+ {
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(start == 30000, "Got start time %s.\n", wine_dbgstr_longlong(start));
+ ok(stop == 40000, "Got stop time %s.\n", wine_dbgstr_longlong(stop));
+ }
+
+ hr = IMediaSample_GetMediaTime(sample, &start, &stop);
+ if (filter->preview)
+ {
+ todo_wine ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#x.\n", hr);
+ }
+ else
+ {
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(start == 10000, "Got start time %s.\n", wine_dbgstr_longlong(start));
+ ok(stop == 20000, "Got stop time %s.\n", wine_dbgstr_longlong(stop));
+ }
+
+ hr = IMediaSample_IsDiscontinuity(sample);
+ todo_wine_if (filter->preview) ok(hr == filter->preview ? S_FALSE : S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_IsPreroll(sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_IsSyncPoint(sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ SetEvent(filter->sample_event);
+
+ return S_OK;
+}
+
+static HRESULT testsink_new_segment(struct strmbase_sink *iface,
+ REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ ok(start == 10000, "Got start %s.\n", wine_dbgstr_longlong(start));
+ ok(stop == 20000, "Got stop %s.\n", wine_dbgstr_longlong(stop));
+ ok(rate == 1.0, "Got rate %.16e.\n", rate);
+ SetEvent(filter->segment_event);
+ return S_OK;
+}
+
+static HRESULT testsink_eos(struct strmbase_sink *iface)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ SetEvent(filter->eos_event);
+ return S_OK;
+}
+
+static HRESULT testsink_begin_flush(struct strmbase_sink *iface)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ ++filter->got_begin_flush;
+ return S_OK;
+}
+
+static HRESULT testsink_end_flush(struct strmbase_sink *iface)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ ++filter->got_end_flush;
return S_OK;
}
@@ -2438,6 +2525,10 @@ static const struct strmbase_sink_ops testsink_ops =
.base.pin_query_accept = testsink_query_accept,
.base.pin_get_media_type = testsink_get_media_type,
.pfnReceive = testsink_Receive,
+ .sink_new_segment = testsink_new_segment,
+ .sink_eos = testsink_eos,
+ .sink_begin_flush = testsink_begin_flush,
+ .sink_end_flush = testsink_end_flush,
};
static void testfilter_init(struct testfilter *filter)
@@ -2447,6 +2538,9 @@ static void testfilter_init(struct testfilter *filter)
strmbase_filter_init(&filter->filter, NULL, &clsid, &testfilter_ops);
strmbase_source_init(&filter->source, &filter->filter, L"source", &testsource_ops);
strmbase_sink_init(&filter->sink, &filter->filter, L"sink", &testsink_ops, NULL);
+ filter->sample_event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ filter->segment_event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ filter->eos_event = CreateEventW(NULL, FALSE, FALSE, NULL);
}
static void test_source_media_types(AM_MEDIA_TYPE req_mt, const AM_MEDIA_TYPE *source_mt, IPin *source)
@@ -2791,6 +2885,171 @@ static void test_connect_pin(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
+static void test_streaming(void)
+{
+ static const AM_MEDIA_TYPE req_mt =
+ {
+ .majortype = {0x111},
+ .subtype = {0x222},
+ .formattype = {0x333},
+ };
+ IBaseFilter *filter = create_smart_tee();
+ struct testfilter testsource, testsink1, testsink2;
+ IPin *sink, *capture, *preview;
+ REFERENCE_TIME start, stop;
+ IMemAllocator *allocator;
+ IMediaControl *control;
+ IFilterGraph2 *graph;
+ IMediaSample *sample;
+ IMemInputPin *input;
+ LONG size, i;
+ HRESULT hr;
+ BYTE *data;
+ ULONG ref;
+
+ testfilter_init(&testsource);
+ testfilter_init(&testsink1);
+ testfilter_init(&testsink2);
+ testsink2.preview = TRUE;
+ CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IFilterGraph2, (void **)&graph);
+ IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source");
+ IFilterGraph2_AddFilter(graph, &testsink1.filter.IBaseFilter_iface, L"sink1");
+ IFilterGraph2_AddFilter(graph, &testsink2.filter.IBaseFilter_iface, L"sink2");
+ IFilterGraph2_AddFilter(graph, filter, L"sample grabber");
+ IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
+ IBaseFilter_FindPin(filter, L"Input", &sink);
+ IPin_QueryInterface(sink, &IID_IMemInputPin, (void **)&input);
+ IBaseFilter_FindPin(filter, L"Capture", &capture);
+ IBaseFilter_FindPin(filter, L"Preview", &preview);
+
+ hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_ConnectDirect(graph, capture, &testsink1.sink.pin.IPin_iface, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_ConnectDirect(graph, preview, &testsink2.sink.pin.IPin_iface, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_ReceiveCanBlock(input);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_GetAllocator(input, &allocator);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr);
+
+ hr = IMediaControl_Pause(control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ if (hr != S_OK)
+ {
+ IMemAllocator_Commit(allocator);
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ }
+
+ hr = IMediaSample_GetPointer(sample, &data);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ size = IMediaSample_GetSize(sample);
+ ok(size == 256, "Got size %d.\n", size);
+ for (i = 0; i < 200; ++i)
+ data[i] = i;
+ hr = IMediaSample_SetActualDataLength(sample, 200);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ start = 10000;
+ stop = 20000;
+ hr = IMediaSample_SetMediaTime(sample, &start, &stop);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ start = 30000;
+ stop = 40000;
+ hr = IMediaSample_SetTime(sample, &start, &stop);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_SetDiscontinuity(sample, TRUE);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_SetPreroll(sample, TRUE);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_SetSyncPoint(sample, TRUE);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_Receive(input, sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.sample_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.sample_event, 1000), "Wait timed out.\n");
+
+ hr = IPin_NewSegment(sink, 10000, 20000, 1.0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.segment_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.segment_event, 1000), "Wait timed out.\n");
+
+ hr = IPin_EndOfStream(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.eos_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.eos_event, 1000), "Wait timed out.\n");
+
+ hr = IPin_EndOfStream(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.eos_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.eos_event, 1000), "Wait timed out.\n");
+
+ ok(!testsink1.got_begin_flush, "Got %u calls to IPin::BeginFlush().\n", testsink1.got_begin_flush);
+ ok(!testsink2.got_begin_flush, "Got %u calls to IPin::BeginFlush().\n", testsink2.got_begin_flush);
+ hr = IPin_BeginFlush(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(testsink1.got_begin_flush == 1, "Got %u calls to IPin::BeginFlush().\n", testsink1.got_begin_flush);
+ ok(testsink2.got_begin_flush == 1, "Got %u calls to IPin::BeginFlush().\n", testsink2.got_begin_flush);
+
+ hr = IMemInputPin_Receive(input, sample);
+ todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+
+ hr = IPin_EndOfStream(sink);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ /* No EOS events are sent downstream, however. */
+
+ ok(!testsink1.got_end_flush, "Got %u calls to IPin::EndFlush().\n", testsink1.got_end_flush);
+ ok(!testsink2.got_end_flush, "Got %u calls to IPin::EndFlush().\n", testsink2.got_end_flush);
+ hr = IPin_EndFlush(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(testsink1.got_end_flush == 1, "Got %u calls to IPin::EndFlush().\n", testsink1.got_end_flush);
+ ok(testsink2.got_end_flush == 1, "Got %u calls to IPin::EndFlush().\n", testsink2.got_end_flush);
+
+ hr = IMemInputPin_Receive(input, sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.sample_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.sample_event, 1000), "Wait timed out.\n");
+
+ hr = IMediaControl_Stop(control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_Receive(input, sample);
+ todo_wine ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr);
+
+ hr = IPin_EndOfStream(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ /* No EOS events are sent downstream, however. */
+
+ IMediaSample_Release(sample);
+ IMemAllocator_Release(allocator);
+ IMemInputPin_Release(input);
+ IPin_Release(sink);
+ IPin_Release(capture);
+ IPin_Release(preview);
+ IMediaControl_Release(control);
+ ref = IFilterGraph2_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(filter);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&testsource.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&testsink1.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&testsink2.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
START_TEST(smartteefilter)
{
CoInitialize(NULL);
@@ -2805,6 +3064,7 @@ START_TEST(smartteefilter)
test_enum_media_types();
test_unconnected_filter_state();
test_connect_pin();
+ test_streaming();
test_smart_tee_filter();
--
2.29.2
1
3
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/directory.c | 21 +++----
programs/cmd/wcmdmain.c | 116 +++++++++++++--------------------------
2 files changed, 46 insertions(+), 91 deletions(-)
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c
index df3ed4387ee..24b18bfa81b 100644
--- a/programs/cmd/directory.c
+++ b/programs/cmd/directory.c
@@ -252,11 +252,6 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
int concurrentDirs = 0;
BOOL done_header = FALSE;
- static const WCHAR fmt2[] = {'%','1','!','-','1','3','s','!','\0'};
- static const WCHAR fmt3[] = {'%','1','!','-','2','3','s','!','\0'};
- static const WCHAR fmt4[] = {'%','1','\0'};
- static const WCHAR fmt5[] = {'%','1','%','2','\0'};
-
dir_count = 0;
file_count = 0;
entry_count = 0;
@@ -405,13 +400,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (!bare) {
WCMD_output (L"%1!10s! %2!8s! <DIR> ", datestring, timestring);
- if (shortname) WCMD_output (fmt2, fd[i].cAlternateFileName);
- if (usernames) WCMD_output (fmt3, username);
- WCMD_output(fmt4,fd[i].cFileName);
+ if (shortname) WCMD_output(L"%1!-13s!", fd[i].cAlternateFileName);
+ if (usernames) WCMD_output(L"%1!-23s!", username);
+ WCMD_output(L"%1",fd[i].cFileName);
} else {
if (!((lstrcmpW(fd[i].cFileName, L".") == 0) ||
(lstrcmpW(fd[i].cFileName, L"..") == 0))) {
- WCMD_output(fmt5, recurse?inputparms->dirName:L"", fd[i].cFileName);
+ WCMD_output(L"%1%2", recurse ? inputparms->dirName : L"", fd[i].cFileName);
} else {
addNewLine = FALSE;
}
@@ -425,11 +420,11 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (!bare) {
WCMD_output (L"%1!10s! %2!8s! %3!10s! ", datestring, timestring,
WCMD_filesize64(file_size.QuadPart));
- if (shortname) WCMD_output (fmt2, fd[i].cAlternateFileName);
- if (usernames) WCMD_output (fmt3, username);
- WCMD_output(fmt4,fd[i].cFileName);
+ if (shortname) WCMD_output(L"%1!-13s!", fd[i].cAlternateFileName);
+ if (usernames) WCMD_output(L"%1!-23s!", username);
+ WCMD_output(L"%1",fd[i].cFileName);
} else {
- WCMD_output(fmt5, recurse ? inputparms->dirName : L"", fd[i].cFileName);
+ WCMD_output(L"%1%2", recurse ? inputparms->dirName : L"", fd[i].cFileName);
}
}
}
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 3484f05ae73..cacb7ea7751 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -46,11 +46,6 @@ int defaultColor = 7;
BOOL echo_mode = TRUE;
WCHAR anykey[100], version_string[100];
-static const WCHAR envPathExt[] = {'P','A','T','H','E','X','T','\0'};
-static const WCHAR dfltPathExt[] = {'.','b','a','t',';',
- '.','c','o','m',';',
- '.','c','m','d',';',
- '.','e','x','e','\0'};
static BOOL opt_c, opt_k, opt_s, unicodeOutput = FALSE;
@@ -334,12 +329,10 @@ static void WCMD_show_prompt (BOOL newLine) {
WCHAR out_string[MAX_PATH], curdir[MAX_PATH], prompt_string[MAX_PATH];
WCHAR *p, *q;
DWORD len;
- static const WCHAR envPrompt[] = {'P','R','O','M','P','T','\0'};
- len = GetEnvironmentVariableW(envPrompt, prompt_string, ARRAY_SIZE(prompt_string));
+ len = GetEnvironmentVariableW(L"PROMPT", prompt_string, ARRAY_SIZE(prompt_string));
if ((len == 0) || (len >= ARRAY_SIZE(prompt_string))) {
- static const WCHAR dfltPrompt[] = {'$','P','$','G','\0'};
- lstrcpyW (prompt_string, dfltPrompt);
+ lstrcpyW(prompt_string, L"$P$G");
}
p = prompt_string;
q = out_string;
@@ -554,13 +547,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
WCHAR thisVarContents[MAXSTRING];
WCHAR savedchar = 0x00;
int len;
-
- static const WCHAR ErrorLvl[] = {'E','R','R','O','R','L','E','V','E','L','\0'};
- static const WCHAR Date[] = {'D','A','T','E','\0'};
- static const WCHAR Time[] = {'T','I','M','E','\0'};
- static const WCHAR Cd[] = {'C','D','\0'};
- static const WCHAR Random[] = {'R','A','N','D','O','M','\0'};
- WCHAR Delims[] = {'%',':','\0'}; /* First char gets replaced appropriately */
+ WCHAR Delims[] = L"%:"; /* First char gets replaced appropriately */
WINE_TRACE("Expanding: %s (%c)\n", wine_dbgstr_w(start), startchar);
@@ -614,24 +601,22 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
/* Expand to contents, if unchanged, return */
/* Handle DATE, TIME, ERRORLEVEL and CD replacements allowing */
/* override if existing env var called that name */
- if (WCMD_is_magic_envvar(thisVar, ErrorLvl)) {
- static const WCHAR fmt[] = {'%','d','\0'};
- wsprintfW(thisVarContents, fmt, errorlevel);
+ if (WCMD_is_magic_envvar(thisVar, L"ERRORLEVEL")) {
+ wsprintfW(thisVarContents, L"%d", errorlevel);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Date)) {
+ } else if (WCMD_is_magic_envvar(thisVar, L"DATE")) {
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL,
NULL, thisVarContents, MAXSTRING);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Time)) {
+ } else if (WCMD_is_magic_envvar(thisVar, L"TIME")) {
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL,
NULL, thisVarContents, MAXSTRING);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Cd)) {
+ } else if (WCMD_is_magic_envvar(thisVar, L"CD")) {
GetCurrentDirectoryW(MAXSTRING, thisVarContents);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Random)) {
- static const WCHAR fmt[] = {'%','d','\0'};
- wsprintfW(thisVarContents, fmt, rand() % 32768);
+ } else if (WCMD_is_magic_envvar(thisVar, L"RANDOM")) {
+ wsprintfW(thisVarContents, L"%d", rand() % 32768);
len = lstrlenW(thisVarContents);
} else {
@@ -1042,8 +1027,6 @@ void WCMD_run_program (WCHAR *command, BOOL called)
BOOL explicit_path = FALSE;
BOOL status;
DWORD len;
- static const WCHAR envPath[] = {'P','A','T','H','\0'};
- static const WCHAR delims[] = {'/','\\',':','\0'};
/* Quick way to get the filename is to extract the first argument. */
WINE_TRACE("Running '%s' (%d)\n", wine_dbgstr_w(command), called);
@@ -1056,13 +1039,11 @@ void WCMD_run_program (WCHAR *command, BOOL called)
}
/* Calculate the search path and stem to search for */
- if (wcspbrk (firstParam, delims) == NULL) { /* No explicit path given, search path */
- static const WCHAR curDir[] = {'.',';','\0'};
- lstrcpyW(pathtosearch, curDir);
- len = GetEnvironmentVariableW(envPath, &pathtosearch[2], ARRAY_SIZE(pathtosearch)-2);
+ if (wcspbrk(firstParam, L"/\\:") == NULL) { /* No explicit path given, search path */
+ lstrcpyW(pathtosearch, L".;");
+ len = GetEnvironmentVariableW(L"PATH", &pathtosearch[2], ARRAY_SIZE(pathtosearch)-2);
if ((len == 0) || (len >= ARRAY_SIZE(pathtosearch) - 2)) {
- static const WCHAR curDir[] = {'.','\0'};
- lstrcpyW (pathtosearch, curDir);
+ lstrcpyW(pathtosearch, L".");
}
if (wcschr(firstParam, '.') != NULL) extensionsupplied = TRUE;
if (lstrlenW(firstParam) >= MAX_PATH)
@@ -1088,9 +1069,9 @@ void WCMD_run_program (WCHAR *command, BOOL called)
}
/* Now extract PATHEXT */
- len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
+ len = GetEnvironmentVariableW(L"PATHEXT", pathext, ARRAY_SIZE(pathext));
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
- lstrcpyW (pathext, dfltPathExt);
+ lstrcpyW(pathext, L".bat;.com;.cmd;.exe");
}
/* Loop through the search path, dir by dir */
@@ -1163,9 +1144,8 @@ void WCMD_run_program (WCHAR *command, BOOL called)
if (!found) {
HANDLE h;
WIN32_FIND_DATAW finddata;
- static const WCHAR allFiles[] = {'.','*','\0'};
- lstrcatW(thisDir,allFiles);
+ lstrcatW(thisDir, L".*");
h = FindFirstFileW(thisDir, &finddata);
FindClose(h);
if (h != INVALID_HANDLE_VALUE) {
@@ -1201,13 +1181,11 @@ void WCMD_run_program (WCHAR *command, BOOL called)
DWORD console;
HINSTANCE hinst;
WCHAR *ext = wcsrchr( thisDir, '.' );
- static const WCHAR batExt[] = {'.','b','a','t','\0'};
- static const WCHAR cmdExt[] = {'.','c','m','d','\0'};
WINE_TRACE("Found as %s\n", wine_dbgstr_w(thisDir));
/* Special case BAT and CMD */
- if (ext && (!wcsicmp(ext, batExt) || !wcsicmp(ext, cmdExt))) {
+ if (ext && (!wcsicmp(ext, L".bat") || !wcsicmp(ext, L".cmd"))) {
BOOL oldinteractive = interactive;
interactive = FALSE;
WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE);
@@ -1349,7 +1327,6 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
(*cmdList)->nextcommand->prevDelim == CMD_PIPE) {
WCHAR temp_path[MAX_PATH];
- static const WCHAR cmdW[] = {'C','M','D','\0'};
/* Remember piping is in action */
WINE_TRACE("Output needs to be piped\n");
@@ -1357,15 +1334,14 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
/* Generate a unique temporary filename */
GetTempPathW(ARRAY_SIZE(temp_path), temp_path);
- GetTempFileNameW(temp_path, cmdW, 0, (*cmdList)->nextcommand->pipeFile);
+ GetTempFileNameW(temp_path, L"CMD", 0, (*cmdList)->nextcommand->pipeFile);
WINE_TRACE("Using temporary file of %s\n",
wine_dbgstr_w((*cmdList)->nextcommand->pipeFile));
}
/* If piped output, send stdout to the pipe by appending >filename to redirects */
if (piped) {
- static const WCHAR redirOut[] = {'%','s',' ','>',' ','%','s','\0'};
- wsprintfW (new_redir, redirOut, redirects, (*cmdList)->nextcommand->pipeFile);
+ wsprintfW (new_redir, L"%s > %s", redirects, (*cmdList)->nextcommand->pipeFile);
WINE_TRACE("Redirects now %s\n", wine_dbgstr_w(new_redir));
} else {
lstrcpyW(new_redir, redirects);
@@ -1395,8 +1371,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
lstrcpyW(envvar, L"=");
lstrcatW(envvar, cmd);
if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) {
- static const WCHAR fmt[] = {'%','s','\\','\0'};
- wsprintfW(cmd, fmt, cmd);
+ wsprintfW(cmd, L"%s\\", cmd);
WINE_TRACE("No special directory settings, using dir of %s\n", wine_dbgstr_w(cmd));
}
WINE_TRACE("Got directory %s as %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(cmd));
@@ -1675,11 +1650,10 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
*/
WCHAR *WCMD_LoadMessage(UINT id) {
static WCHAR msg[2048];
- static const WCHAR failedMsg[] = {'F','a','i','l','e','d','!','\0'};
if (!LoadStringW(GetModuleHandleW(NULL), id, msg, ARRAY_SIZE(msg))) {
WINE_FIXME("LoadString failed with %d\n", GetLastError());
- lstrcpyW(msg, failedMsg);
+ lstrcpyW(msg, L"Failed!");
}
return msg;
}
@@ -2440,11 +2414,6 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
BOOL promptNewLine = TRUE;
BOOL opt_q;
int opt_t = 0;
- static const WCHAR offW[] = {'O','F','F','\0'};
- static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'};
- static const WCHAR defaultpromptW[] = {'$','P','$','G','\0'};
- static const WCHAR comspecW[] = {'C','O','M','S','P','E','C',0};
- static const WCHAR cmdW[] = {'\\','c','m','d','.','e','x','e',0};
WCHAR comspec[MAX_PATH];
CMD_LIST *toExecute = NULL; /* Commands left to be executed */
RTL_OSVERSIONINFOEXW osv;
@@ -2452,11 +2421,11 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
STARTUPINFOW startupInfo;
const WCHAR *arg;
- if (!GetEnvironmentVariableW(comspecW, comspec, ARRAY_SIZE(comspec)))
+ if (!GetEnvironmentVariableW(L"COMSPEC", comspec, ARRAY_SIZE(comspec)))
{
- GetSystemDirectoryW(comspec, ARRAY_SIZE(comspec) - ARRAY_SIZE(cmdW));
- lstrcatW(comspec, cmdW);
- SetEnvironmentVariableW(comspecW, comspec);
+ GetSystemDirectoryW(comspec, ARRAY_SIZE(comspec) - ARRAY_SIZE(L"\\cmd.exe"));
+ lstrcatW(comspec, L"\\cmd.exe");
+ SetEnvironmentVariableW(L"COMSPEC", comspec);
}
srand(time(NULL));
@@ -2528,13 +2497,13 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
while (*arg && wcschr(L" \t,=;", *arg)) arg++;
if (opt_q) {
- WCMD_echo(offW);
+ WCMD_echo(L"OFF");
}
/* Until we start to read from the keyboard, stay as non-interactive */
interactive = FALSE;
- SetEnvironmentVariableW(promptW, defaultpromptW);
+ SetEnvironmentVariableW(L"PROMPT", L"$P$G");
if (opt_c || opt_k) {
int len;
@@ -2592,9 +2561,9 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
BOOL found = FALSE;
/* Now extract PATHEXT */
- len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
+ len = GetEnvironmentVariableW(L"PATHEXT", pathext, ARRAY_SIZE(pathext));
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
- lstrcpyW (pathext, dfltPathExt);
+ lstrcpyW(pathext, L".bat;.com;.cmd;.exe");
}
/* If the supplied parameter has any directory information, look there */
@@ -2681,8 +2650,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
/* Save cwd into appropriate env var (Must be before the /c processing */
GetCurrentDirectoryW(ARRAY_SIZE(string), string);
if (IsCharAlphaW(string[0]) && string[1] == ':') {
- static const WCHAR fmt[] = {'=','%','c',':','\0'};
- wsprintfW(envvar, fmt, string[0]);
+ wsprintfW(envvar, L"=%c:", string[0]);
SetEnvironmentVariableW(envvar, string);
WINE_TRACE("Set %s to %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(string));
}
@@ -2726,26 +2694,20 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
HKEY key;
DWORD type;
DWORD value=0, size=4;
- static const WCHAR regKeyW[] = {'S','o','f','t','w','a','r','e','\\',
- 'M','i','c','r','o','s','o','f','t','\\',
- 'C','o','m','m','a','n','d',' ','P','r','o','c','e','s','s','o','r','\0'};
- static const WCHAR dfltColorW[] = {'D','e','f','a','u','l','t','C','o','l','o','r','\0'};
+ static const WCHAR regKeyW[] = L"Software\\Microsoft\\Command Processor";
if (RegOpenKeyExW(HKEY_CURRENT_USER, regKeyW,
0, KEY_READ, &key) == ERROR_SUCCESS) {
WCHAR strvalue[4];
/* See if DWORD or REG_SZ */
- if (RegQueryValueExW(key, dfltColorW, NULL, &type,
- NULL, NULL) == ERROR_SUCCESS) {
+ if (RegQueryValueExW(key, L"DefaultColor", NULL, &type, NULL, NULL) == ERROR_SUCCESS) {
if (type == REG_DWORD) {
size = sizeof(DWORD);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)&value, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)&value, &size);
} else if (type == REG_SZ) {
size = ARRAY_SIZE(strvalue);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)strvalue, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)strvalue, &size);
value = wcstoul(strvalue, NULL, 10);
}
}
@@ -2757,16 +2719,14 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCHAR strvalue[4];
/* See if DWORD or REG_SZ */
- if (RegQueryValueExW(key, dfltColorW, NULL, &type,
+ if (RegQueryValueExW(key, L"DefaultColor", NULL, &type,
NULL, NULL) == ERROR_SUCCESS) {
if (type == REG_DWORD) {
size = sizeof(DWORD);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)&value, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)&value, &size);
} else if (type == REG_SZ) {
size = ARRAY_SIZE(strvalue);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)strvalue, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)strvalue, &size);
value = wcstoul(strvalue, NULL, 10);
}
}
--
2.26.2
1
0
29 Nov '20
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/builtins.c | 386 ++++++++++++++++------------------------
1 file changed, 149 insertions(+), 237 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index e4b1fed613f..e99dd24ac72 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -39,67 +39,59 @@ extern BOOL echo_mode;
extern BOOL interactive;
struct env_stack *pushd_directories;
-const WCHAR wildcardsW[] = {'*','?','\0'};
-const WCHAR slashstarW[] = {'\\','*','\0'};
-const WCHAR deviceW[] = {'\\','\\','.','\\','\0'};
const WCHAR inbuilt[][10] = {
- {'C','A','L','L','\0'},
- {'C','D','\0'},
- {'C','H','D','I','R','\0'},
- {'C','L','S','\0'},
- {'C','O','P','Y','\0'},
- {'C','T','T','Y','\0'},
- {'D','A','T','E','\0'},
- {'D','E','L','\0'},
- {'D','I','R','\0'},
- {'E','C','H','O','\0'},
- {'E','R','A','S','E','\0'},
- {'F','O','R','\0'},
- {'G','O','T','O','\0'},
- {'H','E','L','P','\0'},
- {'I','F','\0'},
- {'L','A','B','E','L','\0'},
- {'M','D','\0'},
- {'M','K','D','I','R','\0'},
- {'M','O','V','E','\0'},
- {'P','A','T','H','\0'},
- {'P','A','U','S','E','\0'},
- {'P','R','O','M','P','T','\0'},
- {'R','E','M','\0'},
- {'R','E','N','\0'},
- {'R','E','N','A','M','E','\0'},
- {'R','D','\0'},
- {'R','M','D','I','R','\0'},
- {'S','E','T','\0'},
- {'S','H','I','F','T','\0'},
- {'S','T','A','R','T','\0'},
- {'T','I','M','E','\0'},
- {'T','I','T','L','E','\0'},
- {'T','Y','P','E','\0'},
- {'V','E','R','I','F','Y','\0'},
- {'V','E','R','\0'},
- {'V','O','L','\0'},
- {'E','N','D','L','O','C','A','L','\0'},
- {'S','E','T','L','O','C','A','L','\0'},
- {'P','U','S','H','D','\0'},
- {'P','O','P','D','\0'},
- {'A','S','S','O','C','\0'},
- {'C','O','L','O','R','\0'},
- {'F','T','Y','P','E','\0'},
- {'M','O','R','E','\0'},
- {'C','H','O','I','C','E','\0'},
- {'M','K','L','I','N','K','\0'},
- {'E','X','I','T','\0'}
+ L"CALL",
+ L"CD",
+ L"CHDIR",
+ L"CLS",
+ L"COPY",
+ L"CTTY",
+ L"DATE",
+ L"DEL",
+ L"DIR",
+ L"ECHO",
+ L"ERASE",
+ L"FOR",
+ L"GOTO",
+ L"HELP",
+ L"IF",
+ L"LABEL",
+ L"MD",
+ L"MKDIR",
+ L"MOVE",
+ L"PATH",
+ L"PAUSE",
+ L"PROMPT",
+ L"REM",
+ L"REN",
+ L"RENAME",
+ L"RD",
+ L"RMDIR",
+ L"SET",
+ L"SHIFT",
+ L"START",
+ L"TIME",
+ L"TITLE",
+ L"TYPE",
+ L"VERIFY",
+ L"VER",
+ L"VOL",
+ L"ENDLOCAL",
+ L"SETLOCAL",
+ L"PUSHD",
+ L"POPD",
+ L"ASSOC",
+ L"COLOR",
+ L"FTYPE",
+ L"MORE",
+ L"CHOICE",
+ L"MKLINK",
+ L"EXIT"
};
static const WCHAR externals[][10] = {
- {'A','T','T','R','I','B','\0'},
- {'X','C','O','P','Y','\0'}
+ L"ATTRIB",
+ L"XCOPY"
};
-static const WCHAR onW[] = {'O','N','\0'};
-static const WCHAR offW[] = {'O','F','F','\0'};
-static const WCHAR parmY[] = {'/','Y','\0'};
-static const WCHAR parmNoY[] = {'/','-','Y','\0'};
-static const WCHAR eqeqW[] = {'=','=','\0'};
static HINSTANCE hinst;
struct env_stack *saved_environment;
@@ -261,11 +253,6 @@ void WCMD_change_tty (void) {
*/
void WCMD_choice (const WCHAR * args) {
-
- static const WCHAR bellW[] = {7,0};
- static const WCHAR commaW[] = {',',0};
- static const WCHAR bracket_open[] = {'[',0};
- static const WCHAR bracket_close[] = {']','?',0};
WCHAR answer[16];
WCHAR buffer[16];
WCHAR *ptr = NULL;
@@ -381,15 +368,15 @@ void WCMD_choice (const WCHAR * args) {
if (!opt_n) {
/* print a list of all allowed answers inside brackets */
- WCMD_output_asis(bracket_open);
+ WCMD_output_asis(L"[");
ptr = opt_c;
answer[1] = 0;
while ((answer[0] = *ptr++)) {
WCMD_output_asis(answer);
if (*ptr)
- WCMD_output_asis(commaW);
+ WCMD_output_asis(L",");
}
- WCMD_output_asis(bracket_close);
+ WCMD_output_asis(L"]?");
}
while (TRUE) {
@@ -417,7 +404,7 @@ void WCMD_choice (const WCHAR * args) {
{
/* key not allowed: play the bell */
WINE_TRACE("key not allowed: %s\n", wine_dbgstr_w(answer));
- WCMD_output_asis(bellW);
+ WCMD_output_asis(L"\a");
}
}
}
@@ -598,7 +585,6 @@ void WCMD_copy(WCHAR * args) {
WCHAR copycmd[4];
DWORD len;
BOOL dstisdevice = FALSE;
- static const WCHAR copyCmdW[] = {'C','O','P','Y','C','M','D','\0'};
typedef struct _COPY_FILES
{
@@ -787,11 +773,11 @@ void WCMD_copy(WCHAR * args) {
/* If COPYCMD is set, then we force the overwrite with /Y and ask for
* confirmation with /-Y. If COPYCMD is neither of those, then we use the
* default behavior. */
- len = GetEnvironmentVariableW(copyCmdW, copycmd, ARRAY_SIZE(copycmd));
+ len = GetEnvironmentVariableW(L"COPYCMD", copycmd, ARRAY_SIZE(copycmd));
if (len && len < ARRAY_SIZE(copycmd)) {
- if (!lstrcmpiW (copycmd, parmY))
+ if (!lstrcmpiW(copycmd, L"/Y"))
prompt = FALSE;
- else if (!lstrcmpiW (copycmd, parmNoY))
+ else if (!lstrcmpiW(copycmd, L"/-Y"))
prompt = TRUE;
}
}
@@ -851,7 +837,7 @@ void WCMD_copy(WCHAR * args) {
} else if (!destisdirectory) {
/* We have been asked to copy to a filename. Default to ascii IF the
source contains wildcards (true even if only one match) */
- if (wcspbrk(sourcelist->name, wildcardsW) != NULL) {
+ if (wcspbrk(sourcelist->name, L"*?") != NULL) {
anyconcats = TRUE; /* We really are concatenating to a single file */
if (destination->binarycopy == -1) {
destination->binarycopy = 0;
@@ -870,7 +856,7 @@ void WCMD_copy(WCHAR * args) {
wine_dbgstr_w(destname), appendfirstsource);
/* Remember if the destination is a device */
- if (wcsncmp(destination->name, deviceW, lstrlenW(deviceW)) == 0) {
+ if (wcsncmp(destination->name, L"\\\\.\\", lstrlenW(L"\\\\.\\")) == 0) {
WINE_TRACE("Destination is a device\n");
dstisdevice = TRUE;
}
@@ -914,13 +900,13 @@ void WCMD_copy(WCHAR * args) {
GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart);
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath));
- } else if ((wcspbrk(srcpath, wildcardsW) == NULL) &&
+ } else if ((wcspbrk(srcpath, L"*?") == NULL) &&
(attributes != INVALID_FILE_ATTRIBUTES) &&
(attributes & FILE_ATTRIBUTE_DIRECTORY)) {
/* We need to know where the filename part starts, so append \* and
recalculate the full resulting path */
- lstrcatW(thiscopy->name, slashstarW);
+ lstrcatW(thiscopy->name, L"\\*");
GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart);
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath));
}
@@ -929,7 +915,7 @@ void WCMD_copy(WCHAR * args) {
wine_dbgstr_w(srcpath), anyconcats);
/* If the source is a device, just use it, otherwise search */
- if (wcsncmp(srcpath, deviceW, lstrlenW(deviceW)) == 0) {
+ if (wcsncmp(srcpath, L"\\\\.\\", lstrlenW(L"\\\\.\\")) == 0) {
WINE_TRACE("Source is a device\n");
srcisdevice = TRUE;
srcname = &srcpath[4]; /* After the \\.\ prefix */
@@ -1148,7 +1134,6 @@ void WCMD_create_dir (WCHAR *args) {
* and a bitmask of unwanted attributes (*wantClear).
*/
static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) {
- static const WCHAR parmA[] = {'/','A','\0'};
WCHAR *p;
/* both are strictly 'out' parameters */
@@ -1156,7 +1141,7 @@ static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) {
*wantClear=0;
/* For each /A argument */
- for (p=wcsstr(quals, parmA); p != NULL; p=wcsstr(p, parmA)) {
+ for (p=wcsstr(quals, L"/A"); p != NULL; p=wcsstr(p, L"/A")) {
/* Skip /A itself */
p += 2;
@@ -1198,10 +1183,7 @@ static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) {
* (If /P supplied, del will prompt for individual files later.)
*/
static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted) {
- static const WCHAR parmP[] = {'/','P','\0'};
- static const WCHAR parmQ[] = {'/','Q','\0'};
-
- if ((wcsstr(quals, parmQ) == NULL) && (wcsstr(quals, parmP) == NULL)) {
+ if ((wcsstr(quals, L"/Q") == NULL) && (wcsstr(quals, L"/P") == NULL)) {
WCHAR drive[10];
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
@@ -1216,13 +1198,12 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
if ((lstrcmpW(fname, L"*") == 0) && (*ext == 0x00 || (lstrcmpW(ext, L".*") == 0))) {
WCHAR question[MAXSTRING];
- static const WCHAR fmt[] = {'%','s',' ','\0'};
/* Caller uses this to suppress "file not found" warning later */
*pPrompted = TRUE;
/* Ask for confirmation */
- wsprintfW(question, fmt, fpath);
+ wsprintfW(question, L"%s ", fpath);
return WCMD_ask_confirm(question, TRUE, NULL);
}
}
@@ -1236,10 +1217,6 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
* Returns TRUE if a file was deleted.
*/
static BOOL WCMD_delete_one (const WCHAR *thisArg) {
-
- static const WCHAR parmP[] = {'/','P','\0'};
- static const WCHAR parmS[] = {'/','S','\0'};
- static const WCHAR parmF[] = {'/','F','\0'};
DWORD wanted_attrs;
DWORD unwanted_attrs;
BOOL found = FALSE;
@@ -1276,10 +1253,9 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
&& (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
WCHAR modifiedParm[MAX_PATH];
- static const WCHAR slashStar[] = {'\\','*','\0'};
lstrcpyW(modifiedParm, argCopy);
- lstrcatW(modifiedParm, slashStar);
+ lstrcatW(modifiedParm, L"\\*");
FindClose(hff);
found = TRUE;
WCMD_delete_one(modifiedParm);
@@ -1303,7 +1279,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
&& ((fd.dwFileAttributes & unwanted_attrs) == 0);
/* /P means prompt for each file */
- if (ok && wcsstr (quals, parmP) != NULL) {
+ if (ok && wcsstr(quals, L"/P") != NULL) {
WCHAR* question;
/* Ask for confirmation */
@@ -1318,7 +1294,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
/* If file is read only, and /A:r or /F supplied, delete it */
if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY &&
((wanted_attrs & FILE_ATTRIBUTE_READONLY) ||
- wcsstr (quals, parmF) != NULL)) {
+ wcsstr(quals, L"/F") != NULL)) {
SetFileAttributesW(fpath, fd.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
}
@@ -1332,7 +1308,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
}
/* Now recurse into all subdirectories handling the parameter in the same way */
- if (wcsstr (quals, parmS) != NULL) {
+ if (wcsstr(quals, L"/S") != NULL) {
WCHAR thisDir[MAX_PATH];
int cPos;
@@ -1505,15 +1481,15 @@ void WCMD_echo (const WCHAR *args)
count = lstrlenW(trimmed);
if (count == 0 && origcommand[0]!='.' && origcommand[0]!=':'
&& origcommand[0]!=';' && origcommand[0]!='/') {
- if (echo_mode) WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), onW);
- else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), offW);
+ if (echo_mode) WCMD_output(WCMD_LoadMessage(WCMD_ECHOPROMPT), L"ON");
+ else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), L"OFF");
heap_free(trimmed);
return;
}
- if (lstrcmpiW(trimmed, onW) == 0)
+ if (lstrcmpiW(trimmed, L"ON") == 0)
echo_mode = TRUE;
- else if (lstrcmpiW(trimmed, offW) == 0)
+ else if (lstrcmpiW(trimmed, L"OFF") == 0)
echo_mode = FALSE;
else {
WCMD_output_asis (args);
@@ -1665,12 +1641,10 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
static const WCHAR tokensW[] = {'t','o','k','e','n','s','='};
static const WCHAR delimsW[] = {'d','e','l','i','m','s','='};
static const WCHAR usebackqW[] = {'u','s','e','b','a','c','k','q'};
- static const WCHAR forf_defaultdelims[] = {' ', '\t', '\0'};
- static const WCHAR forf_defaulttokens[] = {'1', '\0'};
/* Initialize to defaults */
- lstrcpyW(delims, forf_defaultdelims);
- lstrcpyW(tokens, forf_defaulttokens);
+ lstrcpyW(delims, L" \t");
+ lstrcpyW(tokens, L"1");
*eol = 0;
*skip = 0;
*usebackq = FALSE;
@@ -1768,7 +1742,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
/* Build a generic search and add all directories on the list of directories
still to walk */
lstrcpyW(fullitem, dirsToWalk->dirName);
- lstrcatW(fullitem, slashstarW);
+ lstrcatW(fullitem, L"\\*");
hff = FindFirstFileW(fullitem, &fd);
if (hff != INVALID_HANDLE_VALUE) {
do {
@@ -2072,10 +2046,6 @@ static HANDLE WCMD_forf_getinputhandle(BOOL usebackq, WCHAR *itemstr, BOOL iscmd
WCHAR temp_cmd[MAXSTRING];
WCHAR *trimmed = NULL;
HANDLE hinput = INVALID_HANDLE_VALUE;
- static const WCHAR redirOutW[] = {'>','%','s','\0'};
- static const WCHAR cmdW[] = {'C','M','D','\0'};
- static const WCHAR cmdslashcW[] = {'C','M','D','.','E','X','E',' ',
- '/','C',' ','%','s','\0'};
/* Remove leading and trailing character (but there may be trailing whitespace too) */
if ((iscmd && (itemstr[0] == '`' && usebackq)) ||
@@ -2093,11 +2063,11 @@ static HANDLE WCMD_forf_getinputhandle(BOOL usebackq, WCHAR *itemstr, BOOL iscmd
if (iscmd) {
/* Get temp filename */
GetTempPathW(ARRAY_SIZE(temp_str), temp_str);
- GetTempFileNameW(temp_str, cmdW, 0, temp_file);
+ GetTempFileNameW(temp_str, L"CMD", 0, temp_file);
/* Redirect output to the temporary file */
- wsprintfW(temp_str, redirOutW, temp_file);
- wsprintfW(temp_cmd, cmdslashcW, itemstr);
+ wsprintfW(temp_str, L">%s", temp_file);
+ wsprintfW(temp_cmd, L"CMD.EXE /C %s", itemstr);
WINE_TRACE("Issuing '%s' with redirs '%s'\n",
wine_dbgstr_w(temp_cmd), wine_dbgstr_w(temp_str));
WCMD_execute (temp_cmd, temp_str, NULL, FALSE);
@@ -2299,7 +2269,6 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
* If the parameter within the set has a wildcard then search for matching files
* otherwise do a literal substitution.
*/
- static const WCHAR wildcards[] = {'*','?','\0'};
/* Take a copy of the item returned from WCMD_parameter as it is held in a
static buffer which can be overwritten during parsing of the for body */
@@ -2327,7 +2296,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
lstrcpyW(fullitem, item);
}
- if (wcspbrk (fullitem, wildcards)) {
+ if (wcspbrk(fullitem, L"*?")) {
hff = FindFirstFileW(fullitem, &fd);
if (hff != INVALID_HANDLE_VALUE) {
do {
@@ -2469,7 +2438,6 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
/* If /L is provided, now run the for loop */
if (useNumbers) {
WCHAR thisNum[20];
- static const WCHAR fmt[] = {'%','d','\0'};
WINE_TRACE("FOR /L provided range from %d to %d step %d\n",
numbers[0], numbers[2], numbers[1]);
@@ -2477,7 +2445,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
(numbers[1]<0)? i>=numbers[2] : i<=numbers[2];
i=i + numbers[1]) {
- swprintf(thisNum, ARRAY_SIZE(thisNum), fmt, i);
+ swprintf(thisNum, ARRAY_SIZE(thisNum), L"%d", i);
WINE_TRACE("Processing FOR number %s\n", wine_dbgstr_w(thisNum));
thisCmdStart = cmdStart;
@@ -2556,9 +2524,8 @@ void WCMD_give_help (const WCHAR *args)
if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
args, -1, externals[i], -1) == CSTR_EQUAL) {
WCHAR cmd[128];
- static const WCHAR helpW[] = {' ', '/','?','\0'};
lstrcpyW(cmd, args);
- lstrcatW(cmd, helpW);
+ lstrcatW(cmd, L" /?");
WCMD_run_program(cmd, FALSE);
return;
}
@@ -2581,14 +2548,13 @@ void WCMD_goto (CMD_LIST **cmdList) {
WCHAR string[MAX_PATH];
WCHAR *labelend = NULL;
- const WCHAR labelEndsW[] = {'>','<','|','&',' ',':','\t','\0'};
+ const WCHAR labelEndsW[] = L"><|& :\t";
/* Do not process any more parts of a processed multipart or multilines command */
if (cmdList) *cmdList = NULL;
if (context != NULL) {
WCHAR *paramStart = param1, *str;
- static const WCHAR eofW[] = {':','e','o','f','\0'};
if (param1[0] == 0x00) {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG));
@@ -2596,7 +2562,7 @@ void WCMD_goto (CMD_LIST **cmdList) {
}
/* Handle special :EOF label */
- if (lstrcmpiW (eofW, param1) == 0) {
+ if (lstrcmpiW(L":eof", param1) == 0) {
context -> skip_rest = TRUE;
return;
}
@@ -2678,7 +2644,6 @@ void WCMD_pushd (const WCHAR *args)
{
struct env_stack *curdir;
WCHAR *thisdir;
- static const WCHAR parmD[] = {'/','D','\0'};
if (wcschr(args, '/') != NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
@@ -2696,7 +2661,7 @@ void WCMD_pushd (const WCHAR *args)
}
/* Change directory using CD code with /D parameter */
- lstrcpyW(quals, parmD);
+ lstrcpyW(quals, L"/D");
GetCurrentDirectoryW (1024, thisdir);
errorlevel = 0;
WCMD_setshow_default(args);
@@ -2758,15 +2723,9 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
WCHAR *endptr_leftOp, *endptr_rightOp;
long int leftOperand_int, rightOperand_int;
BOOL int_operands;
- static const WCHAR lssW[] = {'l','s','s','\0'};
- static const WCHAR leqW[] = {'l','e','q','\0'};
- static const WCHAR equW[] = {'e','q','u','\0'};
- static const WCHAR neqW[] = {'n','e','q','\0'};
- static const WCHAR geqW[] = {'g','e','q','\0'};
- static const WCHAR gtrW[] = {'g','t','r','\0'};
/* == is a special case, as it always compares strings */
- if (!lstrcmpiW(operator, eqeqW))
+ if (!lstrcmpiW(operator, L"=="))
return caseInsensitive ? lstrcmpiW(leftOperand, rightOperand) == 0
: lstrcmpW (leftOperand, rightOperand) == 0;
@@ -2776,7 +2735,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
int_operands = (!*endptr_leftOp) && (!*endptr_rightOp);
/* Perform actual (integer or string) comparison */
- if (!lstrcmpiW(operator, lssW)) {
+ if (!lstrcmpiW(operator, L"lss")) {
if (int_operands)
return leftOperand_int < rightOperand_int;
else
@@ -2784,7 +2743,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) < 0;
}
- if (!lstrcmpiW(operator, leqW)) {
+ if (!lstrcmpiW(operator, L"leq")) {
if (int_operands)
return leftOperand_int <= rightOperand_int;
else
@@ -2792,7 +2751,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) <= 0;
}
- if (!lstrcmpiW(operator, equW)) {
+ if (!lstrcmpiW(operator, L"equ")) {
if (int_operands)
return leftOperand_int == rightOperand_int;
else
@@ -2800,7 +2759,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) == 0;
}
- if (!lstrcmpiW(operator, neqW)) {
+ if (!lstrcmpiW(operator, L"neq")) {
if (int_operands)
return leftOperand_int != rightOperand_int;
else
@@ -2808,7 +2767,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) != 0;
}
- if (!lstrcmpiW(operator, geqW)) {
+ if (!lstrcmpiW(operator, L"geq")) {
if (int_operands)
return leftOperand_int >= rightOperand_int;
else
@@ -2816,7 +2775,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) >= 0;
}
- if (!lstrcmpiW(operator, gtrW)) {
+ if (!lstrcmpiW(operator, L"gtr")) {
if (int_operands)
return leftOperand_int > rightOperand_int;
else
@@ -2830,18 +2789,13 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
{
WCHAR condition[MAX_PATH];
- static const WCHAR notW[] = {'n','o','t','\0'};
- static const WCHAR errlvlW[] = {'e','r','r','o','r','l','e','v','e','l','\0'};
- static const WCHAR existW[] = {'e','x','i','s','t','\0'};
- static const WCHAR defdW[] = {'d','e','f','i','n','e','d','\0'};
- static const WCHAR parmI[] = {'/','I','\0'};
- int caseInsensitive = (wcsstr(quals, parmI) != NULL);
-
- *negate = !lstrcmpiW(param1,notW);
+ int caseInsensitive = (wcsstr(quals, L"/I") != NULL);
+
+ *negate = !lstrcmpiW(param1,L"not");
lstrcpyW(condition, (*negate ? param2 : param1));
WINE_TRACE("Condition: %s\n", wine_dbgstr_w(condition));
- if (!lstrcmpiW (condition, errlvlW)) {
+ if (!lstrcmpiW(condition, L"errorlevel")) {
WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE);
WCHAR *endptr;
long int param_int = wcstol(param, &endptr, 10);
@@ -2849,7 +2803,7 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
*test = ((long int)errorlevel >= param_int);
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE);
}
- else if (!lstrcmpiW (condition, existW)) {
+ else if (!lstrcmpiW(condition, L"exist")) {
WIN32_FIND_DATAW fd;
HANDLE hff;
WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE);
@@ -2864,7 +2818,7 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE);
}
- else if (!lstrcmpiW (condition, defdW)) {
+ else if (!lstrcmpiW(condition, L"defined")) {
*test = (GetEnvironmentVariableW(WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE),
NULL, 0) > 0);
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE);
@@ -2882,8 +2836,8 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
while (*p == ' ' || *p == '\t')
p++;
- if (!wcsncmp(p, eqeqW, lstrlenW(eqeqW)))
- lstrcpyW(operator, eqeqW);
+ if (!wcsncmp(p, L"==", lstrlenW(L"==")))
+ lstrcpyW(operator, L"==");
else {
lstrcpyW(operator, WCMD_parameter(p, 0, ¶mStart, FALSE, FALSE));
if (!*operator) goto syntax_err;
@@ -3026,23 +2980,22 @@ void WCMD_move (void)
/* Default whether automatic overwriting is on. If we are interactive then
we prompt by default, otherwise we overwrite by default
/-Y has the highest priority, then /Y and finally the COPYCMD env. variable */
- if (wcsstr (quals, parmNoY))
+ if (wcsstr(quals, L"/-Y"))
force = FALSE;
- else if (wcsstr (quals, parmY))
+ else if (wcsstr(quals, L"/Y"))
force = TRUE;
else {
- static const WCHAR copyCmdW[] = {'C','O','P','Y','C','M','D','\0'};
/* By default, we will force the overwrite in batch mode and ask for
* confirmation in interactive mode. */
force = !interactive;
/* If COPYCMD is set, then we force the overwrite with /Y and ask for
* confirmation with /-Y. If COPYCMD is neither of those, then we use the
* default behavior. */
- len = GetEnvironmentVariableW(copyCmdW, copycmd, ARRAY_SIZE(copycmd));
+ len = GetEnvironmentVariableW(L"COPYCMD", copycmd, ARRAY_SIZE(copycmd));
if (len && len < ARRAY_SIZE(copycmd)) {
- if (!lstrcmpiW (copycmd, parmY))
+ if (!lstrcmpiW(copycmd, L"/Y"))
force = TRUE;
- else if (!lstrcmpiW (copycmd, parmNoY))
+ else if (!lstrcmpiW(copycmd, L"/-Y"))
force = FALSE;
}
}
@@ -3111,8 +3064,6 @@ void WCMD_remove_dir (WCHAR *args) {
int argno = 0;
int argsProcessed = 0;
WCHAR *argN = args;
- static const WCHAR parmS[] = {'/','S','\0'};
- static const WCHAR parmQ[] = {'/','Q','\0'};
/* Loop through all args */
while (argN) {
@@ -3124,7 +3075,7 @@ void WCMD_remove_dir (WCHAR *args) {
/* If subdirectory search not supplied, just try to remove
and report error if it fails (eg if it contains a file) */
- if (wcsstr (quals, parmS) == NULL) {
+ if (wcsstr(quals, L"/S") == NULL) {
if (!RemoveDirectoryW(thisArg)) WCMD_print_error ();
/* Otherwise use ShFileOp to recursively remove a directory */
@@ -3133,13 +3084,12 @@ void WCMD_remove_dir (WCHAR *args) {
SHFILEOPSTRUCTW lpDir;
/* Ask first */
- if (wcsstr (quals, parmQ) == NULL) {
+ if (wcsstr(quals, L"/Q") == NULL) {
BOOL ok;
WCHAR question[MAXSTRING];
- static const WCHAR fmt[] = {'%','s',' ','\0'};
/* Ask for confirmation */
- wsprintfW(question, fmt, thisArg);
+ wsprintfW(question, L"%s ", thisArg);
ok = WCMD_ask_confirm(question, TRUE, NULL);
/* Abort if answer is 'N' */
@@ -3310,12 +3260,6 @@ void WCMD_setlocal (const WCHAR *s) {
struct env_stack *env_copy;
WCHAR cwd[MAX_PATH];
BOOL newdelay;
- static const WCHAR ondelayW[] = {'E','N','A','B','L','E','D','E','L','A',
- 'Y','E','D','E','X','P','A','N','S','I',
- 'O','N','\0'};
- static const WCHAR offdelayW[] = {'D','I','S','A','B','L','E','D','E','L',
- 'A','Y','E','D','E','X','P','A','N','S',
- 'I','O','N','\0'};
/* setlocal does nothing outside of batch programs */
if (!context) return;
@@ -3324,9 +3268,9 @@ void WCMD_setlocal (const WCHAR *s) {
/* ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION could be parm1 or parm2
(if both ENABLEEXTENSIONS and ENABLEDELAYEDEXPANSION supplied for example) */
- if (!wcsicmp(param1, ondelayW) || !wcsicmp(param2, ondelayW)) {
+ if (!wcsicmp(param1, L"ENABLEDELAYEDEXPANSION") || !wcsicmp(param2, L"ENABLEDELAYEDEXPANSION")) {
newdelay = TRUE;
- } else if (!wcsicmp(param1, offdelayW) || !wcsicmp(param2, offdelayW)) {
+ } else if (!wcsicmp(param1, L"DISABLEDELAYEDEXPANSION") || !wcsicmp(param2, L"DISABLEDELAYEDEXPANSION")) {
newdelay = FALSE;
} else {
newdelay = delayedsubst;
@@ -3422,9 +3366,8 @@ void WCMD_endlocal (void) {
if (IsCharAlphaW(temp->u.cwd)) {
WCHAR envvar[4];
WCHAR cwd[MAX_PATH];
- static const WCHAR fmt[] = {'=','%','c',':','\0'};
- wsprintfW(envvar, fmt, temp->u.cwd);
+ wsprintfW(envvar, L"=%c:", temp->u.cwd);
if (GetEnvironmentVariableW(envvar, cwd, MAX_PATH)) {
WINE_TRACE("Resetting cwd to %s\n", wine_dbgstr_w(cwd));
SetCurrentDirectoryW(cwd);
@@ -3449,7 +3392,6 @@ void WCMD_setshow_default (const WCHAR *args) {
WCHAR *pos;
WIN32_FIND_DATAW fd;
HANDLE hff;
- static const WCHAR parmD[] = {'/','D','\0'};
WINE_TRACE("Request change to directory '%s'\n", wine_dbgstr_w(args));
@@ -3457,7 +3399,7 @@ void WCMD_setshow_default (const WCHAR *args) {
if (lstrlenW(args) >= 2 &&
CompareStringW(LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
- args, 2, parmD, -1) == CSTR_EQUAL) {
+ args, 2, L"/D", -1) == CSTR_EQUAL) {
args += 2;
while (*args && (*args==' ' || *args=='\t'))
args++;
@@ -3492,14 +3434,13 @@ void WCMD_setshow_default (const WCHAR *args) {
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
WCHAR ext[MAX_PATH];
- static const WCHAR fmt[] = {'%','s','%','s','%','s','\0'};
/* Convert path into actual directory spec */
GetFullPathNameW(string, ARRAY_SIZE(fpath), fpath, NULL);
_wsplitpath(fpath, drive, dir, fname, ext);
/* Rebuild path */
- wsprintfW(string, fmt, drive, dir, fd.cFileName);
+ wsprintfW(string, L"%s%s%s", drive, dir, fd.cFileName);
break;
}
} while (FindNextFileW(hff, &fd) != 0);
@@ -3521,7 +3462,7 @@ void WCMD_setshow_default (const WCHAR *args) {
/* Restore old directory if drive letter would change, and
CD x:\directory /D (or pushd c:\directory) not supplied */
- if ((wcsstr(quals, parmD) == NULL) &&
+ if ((wcsstr(quals, L"/D") == NULL) &&
(param1[1] == ':') && (toupper(param1[0]) != toupper(cwd[0]))) {
SetCurrentDirectoryW(cwd);
}
@@ -3555,12 +3496,11 @@ void WCMD_setshow_date (void) {
WCHAR curdate[64], buffer[64];
DWORD count;
- static const WCHAR parmT[] = {'/','T','\0'};
if (!*param1) {
if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, NULL, NULL, curdate, ARRAY_SIZE(curdate))) {
WCMD_output (WCMD_LoadMessage(WCMD_CURRENTDATE), curdate);
- if (wcsstr (quals, parmT) == NULL) {
+ if (wcsstr(quals, L"/T") == NULL) {
WCMD_output (WCMD_LoadMessage(WCMD_NEWDATE));
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
if (count > 2) {
@@ -3905,11 +3845,10 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
case '=':
{
- WCHAR intFormat[] = {'%','d','\0'};
WCHAR result[MAXSTRING];
/* Build the result, then push it onto the stack */
- swprintf(result, ARRAY_SIZE(result), intFormat, var1);
+ swprintf(result, ARRAY_SIZE(result), L"%d", var1);
WINE_TRACE("Assigning %s a value %s\n", wine_dbgstr_w((*varstack)->variable),
wine_dbgstr_w(result));
SetEnvironmentVariableW((*varstack)->variable, result);
@@ -3932,8 +3871,7 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
*/
static int WCMD_handleExpression(WCHAR **expr, int *ret, int depth)
{
- static const WCHAR mathDelims[] = {' ','\t','(',')','!','~','-','*','/','%',
- '+','<','>','&','^','|','=',',','\0' };
+ static const WCHAR mathDelims[] = L" \t()!~-*/%+<>&^|=,";
int rc = 0;
WCHAR *pos;
BOOL lastwasnumber = FALSE; /* FALSE makes a minus at the start of the expression easier to handle */
@@ -4165,8 +4103,6 @@ void WCMD_setshow_env (WCHAR *s) {
LPVOID env;
WCHAR *p;
BOOL status;
- static const WCHAR parmP[] = {'/','P','\0'};
- static const WCHAR parmA[] = {'/','A','\0'};
WCHAR string[MAXSTRING];
if (param1[0] == 0x00 && quals[0] == 0x00) {
@@ -4178,7 +4114,7 @@ void WCMD_setshow_env (WCHAR *s) {
/* See if /P supplied, and if so echo the prompt, and read in a reply */
if (CompareStringW(LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
- s, 2, parmP, -1) == CSTR_EQUAL) {
+ s, 2, L"/P", -1) == CSTR_EQUAL) {
DWORD count;
s += 2;
@@ -4214,7 +4150,7 @@ void WCMD_setshow_env (WCHAR *s) {
/* See if /A supplied, and if so calculate the results of all the expressions */
} else if (CompareStringW(LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
- s, 2, parmA, -1) == CSTR_EQUAL) {
+ s, 2, L"/A", -1) == CSTR_EQUAL) {
/* /A supplied, so evaluate expressions and set variables appropriately */
/* Syntax is set /a var=1,var2=var+4 etc, and it echos back the result */
/* of the final computation */
@@ -4246,8 +4182,7 @@ void WCMD_setshow_env (WCHAR *s) {
/* If we have no context (interactive or cmd.exe /c) print the final result */
if (!context) {
- static const WCHAR fmt[] = {'%','d','\0'};
- swprintf(string, ARRAY_SIZE(string), fmt, result);
+ swprintf(string, ARRAY_SIZE(string), L"%d", result);
WCMD_output_asis(string);
}
@@ -4295,13 +4230,11 @@ void WCMD_setshow_path (const WCHAR *args) {
WCHAR string[1024];
DWORD status;
- static const WCHAR pathW[] = {'P','A','T','H','\0'};
- static const WCHAR pathEqW[] = {'P','A','T','H','=','\0'};
if (!*param1 && !*param2) {
- status = GetEnvironmentVariableW(pathW, string, ARRAY_SIZE(string));
+ status = GetEnvironmentVariableW(L"PATH", string, ARRAY_SIZE(string));
if (status != 0) {
- WCMD_output_asis ( pathEqW);
+ WCMD_output_asis(L"PATH=");
WCMD_output_asis ( string);
WCMD_output_asis(L"\r\n");
}
@@ -4311,7 +4244,7 @@ void WCMD_setshow_path (const WCHAR *args) {
}
else {
if (*args == '=') args++; /* Skip leading '=' */
- status = SetEnvironmentVariableW(pathW, args);
+ status = SetEnvironmentVariableW(L"PATH", args);
if (!status) WCMD_print_error();
}
}
@@ -4325,18 +4258,17 @@ void WCMD_setshow_path (const WCHAR *args) {
void WCMD_setshow_prompt (void) {
WCHAR *s;
- static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'};
if (!*param1) {
- SetEnvironmentVariableW(promptW, NULL);
+ SetEnvironmentVariableW(L"PROMPT", NULL);
}
else {
s = param1;
while ((*s == '=') || (*s == ' ') || (*s == '\t')) s++;
if (!*s) {
- SetEnvironmentVariableW(promptW, NULL);
+ SetEnvironmentVariableW(L"PROMPT", NULL);
}
- else SetEnvironmentVariableW(promptW, s);
+ else SetEnvironmentVariableW(L"PROMPT", s);
}
}
@@ -4352,13 +4284,12 @@ void WCMD_setshow_time (void) {
WCHAR curtime[64], buffer[64];
DWORD count;
SYSTEMTIME st;
- static const WCHAR parmT[] = {'/','T','\0'};
if (!*param1) {
GetLocalTime(&st);
if (GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, curtime, ARRAY_SIZE(curtime))) {
WCMD_output (WCMD_LoadMessage(WCMD_CURRENTTIME), curtime);
- if (wcsstr (quals, parmT) == NULL) {
+ if (wcsstr(quals, L"/T") == NULL) {
WCMD_output (WCMD_LoadMessage(WCMD_NEWTIME));
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
if (count > 2) {
@@ -4411,11 +4342,6 @@ void WCMD_shift (const WCHAR *args) {
*/
void WCMD_start(WCHAR *args)
{
- static const WCHAR exeW[] = {'\\','c','o','m','m','a','n','d',
- '\\','s','t','a','r','t','.','e','x','e',0};
- static const WCHAR startDelims[] = { ' ', '\t', '/', '\0' };
- static const WCHAR prefixQuote[] = {'"','\\','"','\0'};
- static const WCHAR postfixQuote[] = {'\\','"','"','\0'};
int argno;
int have_title;
WCHAR file[MAX_PATH];
@@ -4424,7 +4350,7 @@ void WCMD_start(WCHAR *args)
PROCESS_INFORMATION pi;
GetWindowsDirectoryW( file, MAX_PATH );
- lstrcatW( file, exeW );
+ lstrcatW(file, L"\\command\\start.exe");
cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) );
lstrcpyW( cmdline, file );
lstrcatW(cmdline, L" ");
@@ -4468,7 +4394,7 @@ void WCMD_start(WCHAR *args)
WCHAR *thisArg, *argN;
argN = NULL;
- thisArg = WCMD_parameter_with_delims(args, argno, &argN, FALSE, FALSE, startDelims);
+ thisArg = WCMD_parameter_with_delims(args, argno, &argN, FALSE, FALSE, L" \t/");
/* No more parameters */
if (!argN)
@@ -4484,12 +4410,12 @@ void WCMD_start(WCHAR *args)
cmdline_params[argN - args] = '\0';
/* Add quoted title */
- lstrcatW(cmdline_params, prefixQuote);
+ lstrcatW(cmdline_params, L"\"\\\"");
lstrcatW(cmdline_params, thisArg);
- lstrcatW(cmdline_params, postfixQuote);
+ lstrcatW(cmdline_params, L"\\\"\"");
/* Concatenate remaining command-line */
- thisArg = WCMD_parameter_with_delims(args, argno, &argN, TRUE, FALSE, startDelims);
+ thisArg = WCMD_parameter_with_delims(args, argno, &argN, TRUE, FALSE, L" \t/");
lstrcatW(cmdline_params, argN + lstrlenW(thisArg));
break;
@@ -4579,8 +4505,7 @@ void WCMD_type (WCHAR *args) {
errorlevel = 1;
} else {
if (writeHeaders) {
- static const WCHAR fmt[] = {'\n','%','1','\n','\n','\n','\0'};
- WCMD_output_stderr(fmt, thisArg);
+ WCMD_output_stderr(L"\n%1\n\n\n", thisArg);
}
while (WCMD_ReadFile(h, buffer, ARRAY_SIZE(buffer) - 1, &count)) {
if (count == 0) break; /* ReadFile reports success on EOF! */
@@ -4606,15 +4531,10 @@ void WCMD_more (WCHAR *args) {
WCHAR moreStrPage[100];
WCHAR buffer[512];
DWORD count;
- static const WCHAR moreStart[] = {'-','-',' ','\0'};
- static const WCHAR moreFmt[] = {'%','s',' ','-','-','\n','\0'};
- static const WCHAR moreFmt2[] = {'%','s',' ','(','%','2','.','2','d','%','%',
- ')',' ','-','-','\n','\0'};
- static const WCHAR conInW[] = {'C','O','N','I','N','$','\0'};
/* Prefix the NLS more with '-- ', then load the text */
errorlevel = 0;
- lstrcpyW(moreStr, moreStart);
+ lstrcpyW(moreStr, L"-- ");
LoadStringW(hinst, WCMD_MORESTR, &moreStr[3], ARRAY_SIZE(moreStr)-3);
if (param1[0] == 0x00) {
@@ -4624,7 +4544,7 @@ void WCMD_more (WCHAR *args) {
more are satisfied by the next line from the input (file). To
avoid this, ensure stdin is to the console */
HANDLE hstdin = GetStdHandle(STD_INPUT_HANDLE);
- HANDLE hConIn = CreateFileW(conInW, GENERIC_READ | GENERIC_WRITE,
+ HANDLE hConIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
WINE_TRACE("No parms - working probably in pipe mode\n");
@@ -4632,7 +4552,7 @@ void WCMD_more (WCHAR *args) {
/* Warning: No easy way of ending the stream (ctrl+z on windows) so
once you get in this bit unless due to a pipe, it's going to end badly... */
- wsprintfW(moreStrPage, moreFmt, moreStr);
+ wsprintfW(moreStrPage, L"%s --\n", moreStr);
WCMD_enter_paged_mode(moreStrPage);
while (WCMD_ReadFile(hstdin, buffer, ARRAY_SIZE(buffer)-1, &count)) {
@@ -4663,7 +4583,7 @@ void WCMD_more (WCHAR *args) {
if (needsPause) {
/* Wait */
- wsprintfW(moreStrPage, moreFmt2, moreStr, 100);
+ wsprintfW(moreStrPage, L"%s (%2.2d%%) --\n", moreStr, 100);
WCMD_leave_paged_mode();
WCMD_output_asis(moreStrPage);
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
@@ -4694,7 +4614,7 @@ void WCMD_more (WCHAR *args) {
curPos += count;
/* Update % count (would be used in WCMD_output_asis as prompt) */
- wsprintfW(moreStrPage, moreFmt2, moreStr, (int) min(99, (curPos * 100)/fileLen));
+ wsprintfW(moreStrPage, L"%s (%2.2d%%) --\n", moreStr, (int) min(99, (curPos * 100)/fileLen));
WCMD_output_asis (buffer);
}
@@ -4720,15 +4640,15 @@ void WCMD_verify (const WCHAR *args) {
count = lstrlenW(args);
if (count == 0) {
- if (verify_mode) WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), onW);
- else WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), offW);
+ if (verify_mode) WCMD_output(WCMD_LoadMessage(WCMD_VERIFYPROMPT), L"ON");
+ else WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), L"OFF");
return;
}
- if (lstrcmpiW(args, onW) == 0) {
+ if (lstrcmpiW(args, L"ON") == 0) {
verify_mode = TRUE;
return;
}
- else if (lstrcmpiW(args, offW) == 0) {
+ else if (lstrcmpiW(args, L"OFF") == 0) {
verify_mode = FALSE;
return;
}
@@ -4770,12 +4690,11 @@ int WCMD_volume(BOOL set_label, const WCHAR *path)
status = GetVolumeInformationW(NULL, label, ARRAY_SIZE(label), &serial, NULL, NULL, NULL, 0);
}
else {
- static const WCHAR fmt[] = {'%','s','\\','\0'};
if ((path[1] != ':') || (lstrlenW(path) != 2)) {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
return 0;
}
- wsprintfW (curdir, fmt, path);
+ wsprintfW (curdir, L"%s\\", path);
status = GetVolumeInformationW(curdir, label, ARRAY_SIZE(label), &serial, NULL, NULL, NULL, 0);
}
if (!status) {
@@ -4817,11 +4736,9 @@ int WCMD_volume(BOOL set_label, const WCHAR *path)
*/
void WCMD_exit (CMD_LIST **cmdList) {
-
- static const WCHAR parmB[] = {'/','B','\0'};
int rc = wcstol(param1, NULL, 10); /* Note: wcstol of empty parameter is 0 */
- if (context && lstrcmpiW(quals, parmB) == 0) {
+ if (context && lstrcmpiW(quals, L"/B") == 0) {
errorlevel = rc;
context -> skip_rest = TRUE;
*cmdList = NULL;
@@ -4846,8 +4763,6 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
WCHAR keyValue[MAXSTRING];
DWORD valueLen = MAXSTRING;
HKEY readKey;
- static const WCHAR shOpCmdW[] = {'\\','S','h','e','l','l','\\',
- 'O','p','e','n','\\','C','o','m','m','a','n','d','\0'};
/* See if parameter includes '=' */
errorlevel = 0;
@@ -4882,7 +4797,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
{
WCHAR subkey[MAXSTRING];
lstrcpyW(subkey, keyName);
- if (!assoc) lstrcatW(subkey, shOpCmdW);
+ if (!assoc) lstrcatW(subkey, L"\\Shell\\Open\\Command");
if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) {
@@ -4915,7 +4830,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
/* Set up key name */
lstrcpyW(subkey, keyValue);
- if (!assoc) lstrcatW(subkey, shOpCmdW);
+ if (!assoc) lstrcatW(subkey, L"\\Shell\\Open\\Command");
if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) {
@@ -4951,7 +4866,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
/* Set up key name */
lstrcpyW(subkey, args);
- if (!assoc) lstrcatW(subkey, shOpCmdW);
+ if (!assoc) lstrcatW(subkey, L"\\Shell\\Open\\Command");
/* If nothing after '=' then clear value - only valid for ASSOC */
if (*newValue == 0x00) {
@@ -5066,9 +4981,6 @@ void WCMD_mklink(WCHAR *args)
BOOL ret = FALSE;
WCHAR file1[MAX_PATH];
WCHAR file2[MAX_PATH];
- static const WCHAR optD[] = {'/', 'D', '\0'};
- static const WCHAR optH[] = {'/', 'H', '\0'};
- static const WCHAR optJ[] = {'/', 'J', '\0'};
if (param1[0] == 0x00 || param2[0] == 0x00) {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG));
@@ -5084,11 +4996,11 @@ void WCMD_mklink(WCHAR *args)
WINE_TRACE("mklink: Processing arg '%s'\n", wine_dbgstr_w(thisArg));
- if(lstrcmpiW(thisArg, optD) == 0)
+ if (lstrcmpiW(thisArg, L"/D") == 0)
isdir = TRUE;
- else if(lstrcmpiW(thisArg, optH) == 0)
+ else if (lstrcmpiW(thisArg, L"/H") == 0)
hard = TRUE;
- else if(lstrcmpiW(thisArg, optJ) == 0)
+ else if (lstrcmpiW(thisArg, L"/J") == 0)
junction = TRUE;
else {
if(!file1[0])
--
2.26.2
1
0
29 Nov '20
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/batch.c | 20 +++++------
programs/cmd/builtins.c | 72 +++++++++++++++++-----------------------
programs/cmd/directory.c | 34 +++++++++----------
programs/cmd/wcmd.h | 8 -----
programs/cmd/wcmdmain.c | 21 +++++-------
5 files changed, 66 insertions(+), 89 deletions(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index a08648d8c26..37cdff42188 100644
--- a/programs/cmd/batch.c
+++ b/programs/cmd/batch.c
@@ -516,13 +516,13 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
doneModifier = TRUE;
if (exists) {
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
/* Format the time */
FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime);
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime,
NULL, thisoutput, MAX_PATH);
- lstrcatW(thisoutput, spaceW);
+ lstrcatW(thisoutput, L" ");
datelen = lstrlenW(thisoutput);
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime,
NULL, (thisoutput+datelen), MAX_PATH-datelen);
@@ -538,7 +538,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
doneModifier = TRUE;
if (exists) {
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
wsprintfW(thisoutput, L"%u", fullsize);
lstrcatW(finaloutput, thisoutput);
}
@@ -546,7 +546,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 4. Handle 's' : Use short paths (File doesn't have to exist) */
if (wmemchr(firstModifier, 's', modifierLen) != NULL) {
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
/* Convert fullfilename's path to a short path - Save filename away as
only path is valid, name may not exist which causes GetShortPathName
@@ -563,7 +563,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* Note this overrides d,p,n,x */
if (wmemchr(firstModifier, 'f', modifierLen) != NULL) {
doneModifier = TRUE;
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
lstrcatW(finaloutput, fullfilename);
} else {
@@ -580,7 +580,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 5. Handle 'd' : Drive Letter */
if (wmemchr(firstModifier, 'd', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -592,7 +592,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 6. Handle 'p' : Path */
if (wmemchr(firstModifier, 'p', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -604,7 +604,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 7. Handle 'n' : Name */
if (wmemchr(firstModifier, 'n', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -616,7 +616,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
/* 8. Handle 'x' : Ext */
if (wmemchr(firstModifier, 'x', modifierLen) != NULL) {
if (addSpace) {
- lstrcatW(finaloutput, spaceW);
+ lstrcatW(finaloutput, L" ");
addSpace = FALSE;
}
@@ -629,7 +629,7 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
if (!doneFileModifier &&
wmemchr(firstModifier, 's', modifierLen) != NULL) {
doneModifier = TRUE;
- if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW);
+ if (finaloutput[0] != 0x00) lstrcatW(finaloutput, L" ");
lstrcatW(finaloutput, fullfilename);
}
}
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index c6dce091c69..e4b1fed613f 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -39,12 +39,6 @@ extern BOOL echo_mode;
extern BOOL interactive;
struct env_stack *pushd_directories;
-const WCHAR dotW[] = {'.','\0'};
-const WCHAR dotdotW[] = {'.','.','\0'};
-const WCHAR nullW[] = {'\0'};
-const WCHAR starW[] = {'*','\0'};
-const WCHAR slashW[] = {'\\','\0'};
-const WCHAR equalW[] = {'=','\0'};
const WCHAR wildcardsW[] = {'*','?','\0'};
const WCHAR slashstarW[] = {'\\','*','\0'};
const WCHAR deviceW[] = {'\\','\\','.','\\','\0'};
@@ -410,7 +404,7 @@ void WCMD_choice (const WCHAR * args) {
ptr = wcschr(opt_c, answer[0]);
if (ptr) {
WCMD_output_asis(answer);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
if (have_console)
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), oldmode);
@@ -807,8 +801,8 @@ void WCMD_copy(WCHAR * args) {
if (destination == NULL) {
WINE_TRACE("No destination supplied, so need to calculate it\n");
- lstrcpyW(destname, dotW);
- lstrcatW(destname, slashW);
+ lstrcpyW(destname, L".");
+ lstrcatW(destname, L"\\");
destination = heap_xalloc(sizeof(COPY_FILES));
if (destination == NULL) goto exitreturn;
@@ -835,7 +829,7 @@ void WCMD_copy(WCHAR * args) {
(attributes & FILE_ATTRIBUTE_DIRECTORY))) {
destisdirectory = TRUE;
- if (!ends_with_backslash( destname )) lstrcatW(destname, slashW);
+ if (!ends_with_backslash(destname)) lstrcatW(destname, L"\\");
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(destname));
}
}
@@ -916,7 +910,7 @@ void WCMD_copy(WCHAR * args) {
/* We need to know where the filename part starts, so append * and
recalculate the full resulting path */
- lstrcatW(thiscopy->name, starW);
+ lstrcatW(thiscopy->name, L"*");
GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart);
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath));
@@ -1208,7 +1202,6 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
static const WCHAR parmQ[] = {'/','Q','\0'};
if ((wcsstr(quals, parmQ) == NULL) && (wcsstr(quals, parmP) == NULL)) {
- static const WCHAR anyExt[]= {'.','*','\0'};
WCHAR drive[10];
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
@@ -1220,8 +1213,7 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
_wsplitpath(fpath, drive, dir, fname, ext);
/* Only prompt for * and *.*, not *a, a*, *.a* etc */
- if ((lstrcmpW(fname, starW) == 0) &&
- (*ext == 0x00 || (lstrcmpW(ext, anyExt) == 0))) {
+ if ((lstrcmpW(fname, L"*") == 0) && (*ext == 0x00 || (lstrcmpW(ext, L".*") == 0))) {
WCHAR question[MAXSTRING];
static const WCHAR fmt[] = {'%','s',' ','\0'};
@@ -1375,8 +1367,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
do {
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (lstrcmpW(fd.cFileName, dotdotW) != 0) &&
- (lstrcmpW(fd.cFileName, dotW) != 0)) {
+ (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0)) {
DIRECTORY_STACK *nextDir;
WCHAR subParm[MAX_PATH];
@@ -1384,7 +1375,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
/* Work out search parameter in sub dir */
lstrcpyW (subParm, thisDir);
lstrcatW (subParm, fd.cFileName);
- lstrcatW (subParm, slashW);
+ lstrcatW (subParm, L"\\");
lstrcatW (subParm, fname);
lstrcatW (subParm, ext);
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(subParm));
@@ -1526,7 +1517,7 @@ void WCMD_echo (const WCHAR *args)
echo_mode = FALSE;
else {
WCMD_output_asis (args);
- WCMD_output_asis (newlineW);
+ WCMD_output_asis(L"\r\n");
}
heap_free(trimmed);
}
@@ -1783,8 +1774,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
do {
WINE_TRACE("Looking for subdirectories\n");
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (lstrcmpW(fd.cFileName, dotdotW) != 0) &&
- (lstrcmpW(fd.cFileName, dotW) != 0))
+ (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0))
{
/* Allocate memory, add to list */
DIRECTORY_STACK *toWalk = heap_xalloc(sizeof(DIRECTORY_STACK));
@@ -1794,7 +1784,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
remainingDirs = toWalk;
toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(dirsToWalk->dirName) + 2 + lstrlenW(fd.cFileName)));
lstrcpyW(toWalk->dirName, dirsToWalk->dirName);
- lstrcatW(toWalk->dirName, slashW);
+ lstrcatW(toWalk->dirName, L"\\");
lstrcatW(toWalk->dirName, fd.cFileName);
WINE_TRACE("Added to stack %s (%p->%p)\n", wine_dbgstr_w(toWalk->dirName),
toWalk, toWalk->next);
@@ -2329,7 +2319,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
as it is fully qualified in the /R case */
if (dirsToWalk) {
lstrcpyW(fullitem, dirsToWalk->dirName);
- lstrcatW(fullitem, slashW);
+ lstrcatW(fullitem, L"\\");
lstrcatW(fullitem, item);
} else {
WCHAR *prefix = wcsrchr(item, '\\');
@@ -2347,15 +2337,14 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
/* Handle as files or dirs appropriately, but ignore . and .. */
if (isDirectory == expandDirs &&
- (lstrcmpW(fd.cFileName, dotdotW) != 0) &&
- (lstrcmpW(fd.cFileName, dotW) != 0))
+ (lstrcmpW(fd.cFileName, L"..") != 0) && (lstrcmpW(fd.cFileName, L".") != 0))
{
thisCmdStart = cmdStart;
WINE_TRACE("Processing FOR filename %s\n", wine_dbgstr_w(fd.cFileName));
if (doRecurse) {
lstrcpyW(fullitem, dirsToWalk->dirName);
- lstrcatW(fullitem, slashW);
+ lstrcatW(fullitem, L"\\");
lstrcatW(fullitem, fd.cFileName);
} else {
if (prefixlen) lstrcpynW(fullitem, item, prefixlen + 1);
@@ -2867,7 +2856,7 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
int len = lstrlenW(param);
/* FindFirstFile does not like a directory path ending in '\', append a '.' */
- if (len && param[len-1] == '\\') lstrcatW(param, dotW);
+ if (len && param[len-1] == '\\') lstrcatW(param, L".");
hff = FindFirstFileW(param, &fd);
*test = (hff != INVALID_HANDLE_VALUE );
@@ -2982,7 +2971,7 @@ void WCMD_move (void)
/* If no destination supplied, assume current directory */
if (param2[0] == 0x00) {
- lstrcpyW(param2, dotW);
+ lstrcpyW(param2, L".");
}
/* If 2nd parm is directory, then use original filename */
@@ -3017,7 +3006,7 @@ void WCMD_move (void)
if (attribs != INVALID_FILE_ATTRIBUTES &&
(attribs & FILE_ATTRIBUTE_DIRECTORY)) {
lstrcpyW(dest, output);
- lstrcatW(dest, slashW);
+ lstrcatW(dest, L"\\");
lstrcatW(dest, fd.cFileName);
} else {
lstrcpyW(dest, output);
@@ -3477,7 +3466,7 @@ void WCMD_setshow_default (const WCHAR *args) {
GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd);
if (!*args) {
- lstrcatW (cwd, newlineW);
+ lstrcatW(cwd, L"\r\n");
WCMD_output_asis (cwd);
}
else {
@@ -3544,7 +3533,7 @@ void WCMD_setshow_default (const WCHAR *args) {
drive */
if ((string[1] == ':') && IsCharAlphaW(string[0])) {
WCHAR env[4];
- lstrcpyW(env, equalW);
+ lstrcpyW(env, L"=");
memcpy(env+1, string, 2 * sizeof(WCHAR));
env[3] = 0x00;
WINE_TRACE("Setting '%s' to '%s'\n", wine_dbgstr_w(env), wine_dbgstr_w(string));
@@ -3596,7 +3585,7 @@ static int __cdecl WCMD_compare( const void *a, const void *b )
int r;
const WCHAR * const *str_a = a, * const *str_b = b;
r = CompareStringW( LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
- *str_a, wcscspn(*str_a, equalW), *str_b, wcscspn(*str_b, equalW) );
+ *str_a, wcscspn(*str_a, L"="), *str_b, wcscspn(*str_b, L"=") );
if( r == CSTR_LESS_THAN ) return -1;
if( r == CSTR_GREATER_THAN ) return 1;
return 0;
@@ -3641,7 +3630,7 @@ static int WCMD_setshow_sortenv(const WCHAR *s, const WCHAR *stub)
/* Don't display special internal variables */
if (str[i][0] != '=') {
WCMD_output_asis(str[i]);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
displayedcount++;
}
}
@@ -4314,7 +4303,7 @@ void WCMD_setshow_path (const WCHAR *args) {
if (status != 0) {
WCMD_output_asis ( pathEqW);
WCMD_output_asis ( string);
- WCMD_output_asis ( newlineW);
+ WCMD_output_asis(L"\r\n");
}
else {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOPATH));
@@ -4438,7 +4427,7 @@ void WCMD_start(WCHAR *args)
lstrcatW( file, exeW );
cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) );
lstrcpyW( cmdline, file );
- lstrcatW( cmdline, spaceW );
+ lstrcatW(cmdline, L" ");
cmdline_params = cmdline + lstrlenW(cmdline);
/* The start built-in has some special command-line parsing properties
@@ -4866,8 +4855,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
if (newValue) accessOptions |= KEY_WRITE;
/* Open a key to HKEY_CLASSES_ROOT for enumerating */
- if (RegOpenKeyExW(HKEY_CLASSES_ROOT, nullW, 0,
- accessOptions, &key) != ERROR_SUCCESS) {
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"", 0, accessOptions, &key) != ERROR_SUCCESS) {
WINE_FIXME("Unexpected failure opening HKCR key: %d\n", GetLastError());
return;
}
@@ -4901,12 +4889,12 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
valueLen = ARRAY_SIZE(keyValue);
rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen);
WCMD_output_asis(keyName);
- WCMD_output_asis(equalW);
+ WCMD_output_asis(L"=");
/* If no default value found, leave line empty after '=' */
if (rc == ERROR_SUCCESS) {
WCMD_output_asis(keyValue);
}
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
RegCloseKey(readKey);
}
}
@@ -4933,10 +4921,10 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
rc = RegQueryValueExW(readKey, NULL, NULL, NULL, (LPBYTE)keyValue, &valueLen);
WCMD_output_asis(args);
- WCMD_output_asis(equalW);
+ WCMD_output_asis(L"=");
/* If no default value found, leave line empty after '=' */
if (rc == ERROR_SUCCESS) WCMD_output_asis(keyValue);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
RegCloseKey(readKey);
} else {
@@ -5005,9 +4993,9 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
errorlevel = 2;
} else {
WCMD_output_asis(args);
- WCMD_output_asis(equalW);
+ WCMD_output_asis(L"=");
WCMD_output_asis(newValue);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
}
}
}
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c
index 2d35f8eb1d1..df3ed4387ee 100644
--- a/programs/cmd/directory.c
+++ b/programs/cmd/directory.c
@@ -310,7 +310,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Output the results */
if (!bare) {
- if (level != 0 && (entry_count > 0)) WCMD_output_asis (newlineW);
+ if (level != 0 && (entry_count > 0)) WCMD_output_asis(L"\r\n");
if (!recurse || ((entry_count > 0) && done_header==FALSE)) {
WCMD_output (L"Directory of %1\n\n", real_path);
done_header = TRUE;
@@ -397,7 +397,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if ((cur_width + widest) > max_width) {
cur_width = 0;
} else {
- WCMD_output(L"%1!*s!", cur_width - tmp_width, nullW);
+ WCMD_output(L"%1!*s!", cur_width - tmp_width, L"");
}
} else if (fd[i].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
@@ -409,9 +409,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,fd[i].cFileName);
} else {
- if (!((lstrcmpW(fd[i].cFileName, dotW) == 0) ||
- (lstrcmpW(fd[i].cFileName, dotdotW) == 0))) {
- WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName);
+ if (!((lstrcmpW(fd[i].cFileName, L".") == 0) ||
+ (lstrcmpW(fd[i].cFileName, L"..") == 0))) {
+ WCMD_output(fmt5, recurse?inputparms->dirName:L"", fd[i].cFileName);
} else {
addNewLine = FALSE;
}
@@ -429,11 +429,11 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,fd[i].cFileName);
} else {
- WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName);
+ WCMD_output(fmt5, recurse ? inputparms->dirName : L"", fd[i].cFileName);
}
}
}
- if (addNewLine) WCMD_output_asis (newlineW);
+ if (addNewLine) WCMD_output_asis(L"\r\n");
cur_width = 0;
}
@@ -467,15 +467,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Build path to search */
lstrcpyW(string, inputparms->dirName);
- lstrcatW(string, starW);
+ lstrcatW(string, L"*");
WINE_TRACE("Recursive, looking for '%s'\n", wine_dbgstr_w(string));
hff = FindFirstFileW(string, &finddata);
if (hff != INVALID_HANDLE_VALUE) {
do {
if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
- (lstrcmpW(finddata.cFileName, dotdotW) != 0) &&
- (lstrcmpW(finddata.cFileName, dotW) != 0)) {
+ (lstrcmpW(finddata.cFileName, L"..") != 0) &&
+ (lstrcmpW(finddata.cFileName, L".") != 0)) {
DIRECTORY_STACK *thisDir;
int dirsToCopy = concurrentDirs;
@@ -488,7 +488,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Work out search parameter in sub dir */
lstrcpyW (string, inputparms->dirName);
lstrcatW (string, finddata.cFileName);
- lstrcatW (string, slashW);
+ lstrcatW(string, L"\\");
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string));
/* Allocate memory, add to list */
@@ -762,7 +762,7 @@ void WCMD_directory (WCHAR *args)
argno = 0;
argN = args;
GetCurrentDirectoryW(MAX_PATH, cwd);
- lstrcatW(cwd, slashW);
+ lstrcatW(cwd, L"\\");
/* Loop through all args, calculating full effective directory */
fullParms = NULL;
@@ -781,7 +781,7 @@ void WCMD_directory (WCHAR *args)
if (!GetEnvironmentVariableW(envvar, fullname, MAX_PATH)) {
wsprintfW(fullname, L"%c:", thisArg[0]);
}
- lstrcatW(fullname, slashW);
+ lstrcatW(fullname, L"\\");
lstrcatW(fullname, &thisArg[2]);
} else if (thisArg[0] == '\\') {
memcpy(fullname, cwd, 2 * sizeof(WCHAR));
@@ -802,13 +802,13 @@ void WCMD_directory (WCHAR *args)
if ((wcschr(path, '*') == NULL) && (wcschr(path, '%') == NULL)) {
status = GetFileAttributesW(path);
if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) {
- if (!ends_with_backslash( path )) lstrcatW( path, slashW );
- lstrcatW (path, starW);
+ if (!ends_with_backslash(path)) lstrcatW(path, L"\\");
+ lstrcatW(path, L"*");
}
} else {
/* Special case wildcard search with no extension (ie parameters ending in '.') as
GetFullPathName strips off the additional '.' */
- if (fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, dotW);
+ if (fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, L".");
}
WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));
@@ -841,7 +841,7 @@ void WCMD_directory (WCHAR *args)
fullParms = heap_xalloc(sizeof(DIRECTORY_STACK));
fullParms->next = NULL;
fullParms->dirName = heap_strdupW(cwd);
- fullParms->fileName = heap_strdupW(starW);
+ fullParms->fileName = heap_strdupW(L"*");
}
lastDrive = '?';
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index 9ae87ea7064..65a89ac26d7 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -271,14 +271,6 @@ extern BOOL delayedsubst;
#define WCMD_EXIT 46
/* Some standard messages */
-extern const WCHAR newlineW[];
-extern const WCHAR spaceW[];
-extern const WCHAR nullW[];
-extern const WCHAR dotW[];
-extern const WCHAR dotdotW[];
-extern const WCHAR starW[];
-extern const WCHAR slashW[];
-extern const WCHAR equalW[];
extern WCHAR anykey[];
extern WCHAR version_string[];
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 2b55a39dca3..3484f05ae73 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -46,8 +46,6 @@ int defaultColor = 7;
BOOL echo_mode = TRUE;
WCHAR anykey[100], version_string[100];
-const WCHAR newlineW[] = {'\r','\n','\0'};
-const WCHAR spaceW[] = {' ','\0'};
static const WCHAR envPathExt[] = {'P','A','T','H','E','X','T','\0'};
static const WCHAR dfltPathExt[] = {'.','b','a','t',';',
'.','c','o','m',';',
@@ -319,8 +317,7 @@ void WCMD_print_error (void) {
WCMD_output_asis_len(lpMsgBuf, lstrlenW(lpMsgBuf),
GetStdHandle(STD_ERROR_HANDLE));
LocalFree (lpMsgBuf);
- WCMD_output_asis_len (newlineW, lstrlenW(newlineW),
- GetStdHandle(STD_ERROR_HANDLE));
+ WCMD_output_asis_len(L"\r\n", lstrlenW(L"\r\n"), GetStdHandle(STD_ERROR_HANDLE));
return;
}
@@ -731,7 +728,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
/* search and replace manipulation */
} else {
- WCHAR *equalspos = wcsstr(colonpos, equalW);
+ WCHAR *equalspos = wcsstr(colonpos, L"=");
WCHAR *replacewith = equalspos+1;
WCHAR *found = NULL;
WCHAR *searchIn;
@@ -1151,7 +1148,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
}
/* 1. If extension supplied, see if that file exists */
- lstrcatW(thisDir, slashW);
+ lstrcatW(thisDir, L"\\");
lstrcatW(thisDir, stemofsearch);
pos = &thisDir[lstrlenW(thisDir)]; /* Pos = end of name */
@@ -1395,7 +1392,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
/* According to MSDN CreateProcess docs, special env vars record
the current directory on each drive, in the form =C:
so see if one specified, and if so go back to it */
- lstrcpyW(envvar, equalW);
+ lstrcpyW(envvar, L"=");
lstrcatW(envvar, cmd);
if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) {
static const WCHAR fmt[] = {'%','s','\\','\0'};
@@ -1607,7 +1604,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WCMD_type (parms_start);
break;
case WCMD_VER:
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
WCMD_version ();
break;
case WCMD_VERIFY:
@@ -1886,7 +1883,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
if (lstrlenW(extraSpace) == MAXSTRING -1) {
WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_TRUNCATEDLINE));
WCMD_output_asis_stderr(extraSpace);
- WCMD_output_asis_stderr(newlineW);
+ WCMD_output_asis_stderr(L"\r\n");
}
/* Replace env vars if in a batch context */
@@ -1914,9 +1911,9 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
curPos, min_len, echoSlash, len) != CSTR_EQUAL)
{
- WCMD_output_asis(spaceW);
+ WCMD_output_asis(L" ");
}
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
}
/* Skip repeated 'no echo' characters */
@@ -2354,7 +2351,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Continue to echo commands IF echo is on and in batch program */
if (context && echo_mode && *curPos && *curPos != '@') {
WCMD_output_asis(extraSpace);
- WCMD_output_asis(newlineW);
+ WCMD_output_asis(L"\r\n");
}
/* Skip repeated 'no echo' characters and whitespace */
--
2.26.2
1
0
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/builtins.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 934e55ac587..c6dce091c69 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1968,6 +1968,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
BOOL thisduplicate = FALSE;
BOOL anyduplicates = FALSE;
int totalfound;
+ static WCHAR emptyW[] = L"";
/* Skip lines if requested */
if (*forf_skip) {
@@ -1998,7 +1999,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
for (varoffset=0;
varidx >= 0 && varoffset<totalfound && (((varidx%26) + varoffset) < 26);
varoffset++) {
- forloopcontext.variable[varidx + varoffset] = (WCHAR *)nullW;
+ forloopcontext.variable[varidx + varoffset] = emptyW;
}
/* Loop extracting the tokens
@@ -2048,7 +2049,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
int i;
for (i=varidx; i<MAX_FOR_VARIABLES; i++) {
if ((forloopcontext.variable[i] != oldcontext.variable[i]) &&
- (forloopcontext.variable[i] != nullW)) {
+ (forloopcontext.variable[i] != emptyW)) {
heap_free(forloopcontext.variable[i]);
}
}
--
2.26.2
1
0
Signed-off-by: Esme Povirk <esme(a)codeweavers.com>
---
dlls/windowscodecs/Makefile.in | 2 +-
dlls/windowscodecs/encoder.c | 26 +
dlls/windowscodecs/icnsencoder.c | 296 ++++++++++
dlls/windowscodecs/icnsformat.c | 742 -------------------------
dlls/windowscodecs/main.c | 14 +
dlls/windowscodecs/regsvr.c | 2 +-
dlls/windowscodecs/unix_lib.c | 3 +
dlls/windowscodecs/wincodecs_private.h | 4 +
8 files changed, 345 insertions(+), 744 deletions(-)
create mode 100644 dlls/windowscodecs/icnsencoder.c
delete mode 100644 dlls/windowscodecs/icnsformat.c
diff --git a/dlls/windowscodecs/Makefile.in b/dlls/windowscodecs/Makefile.in
index 2ab89eac84c..774257f11c7 100644
--- a/dlls/windowscodecs/Makefile.in
+++ b/dlls/windowscodecs/Makefile.in
@@ -18,7 +18,7 @@ C_SRCS = \
encoder.c \
fliprotate.c \
gifformat.c \
- icnsformat.c \
+ icnsencoder.c \
icoformat.c \
imgfactory.c \
info.c \
diff --git a/dlls/windowscodecs/encoder.c b/dlls/windowscodecs/encoder.c
index b17895a6c9c..72a83822b50 100644
--- a/dlls/windowscodecs/encoder.c
+++ b/dlls/windowscodecs/encoder.c
@@ -220,6 +220,31 @@ static HRESULT WINAPI CommonEncoderFrame_SetSize(IWICBitmapFrameEncode *iface,
EnterCriticalSection(&This->parent->lock);
+ if (This->parent->encoder_info.flags & ENCODER_FLAGS_ICNS_SIZE)
+ {
+ if (uiWidth != uiHeight)
+ {
+ WARN("cannot generate ICNS icon from %dx%d image\n", uiWidth, uiHeight);
+ hr = E_INVALIDARG;
+ goto end;
+ }
+
+ switch (uiWidth)
+ {
+ case 16:
+ case 32:
+ case 48:
+ case 128:
+ case 256:
+ case 512:
+ break;
+ default:
+ WARN("cannot generate ICNS icon from %dx%d image\n", uiWidth, uiHeight);
+ hr = E_INVALIDARG;
+ goto end;
+ }
+ }
+
if (!This->initialized || This->frame_created)
{
hr = WINCODEC_ERR_WRONGSTATE;
@@ -231,6 +256,7 @@ static HRESULT WINAPI CommonEncoderFrame_SetSize(IWICBitmapFrameEncode *iface,
hr = S_OK;
}
+end:
LeaveCriticalSection(&This->parent->lock);
return hr;
diff --git a/dlls/windowscodecs/icnsencoder.c b/dlls/windowscodecs/icnsencoder.c
new file mode 100644
index 00000000000..82fa8fde380
--- /dev/null
+++ b/dlls/windowscodecs/icnsencoder.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2010 Damjan Jovanovic
+ *
+ * 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
+ */
+
+#if 0
+#pragma makedep unix
+#endif
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+
+#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
+#define GetCurrentProcess GetCurrentProcess_Mac
+#define GetCurrentThread GetCurrentThread_Mac
+#define LoadResource LoadResource_Mac
+#define AnimatePalette AnimatePalette_Mac
+#define EqualRgn EqualRgn_Mac
+#define FillRgn FillRgn_Mac
+#define FrameRgn FrameRgn_Mac
+#define GetPixel GetPixel_Mac
+#define InvertRgn InvertRgn_Mac
+#define LineTo LineTo_Mac
+#define OffsetRgn OffsetRgn_Mac
+#define PaintRgn PaintRgn_Mac
+#define Polygon Polygon_Mac
+#define ResizePalette ResizePalette_Mac
+#define SetRectRgn SetRectRgn_Mac
+#define EqualRect EqualRect_Mac
+#define FillRect FillRect_Mac
+#define FrameRect FrameRect_Mac
+#define GetCursor GetCursor_Mac
+#define InvertRect InvertRect_Mac
+#define OffsetRect OffsetRect_Mac
+#define PtInRect PtInRect_Mac
+#define SetCursor SetCursor_Mac
+#define SetRect SetRect_Mac
+#define ShowCursor ShowCursor_Mac
+#define UnionRect UnionRect_Mac
+#include <ApplicationServices/ApplicationServices.h>
+#undef GetCurrentProcess
+#undef GetCurrentThread
+#undef LoadResource
+#undef AnimatePalette
+#undef EqualRgn
+#undef FillRgn
+#undef FrameRgn
+#undef GetPixel
+#undef InvertRgn
+#undef LineTo
+#undef OffsetRgn
+#undef PaintRgn
+#undef Polygon
+#undef ResizePalette
+#undef SetRectRgn
+#undef EqualRect
+#undef FillRect
+#undef FrameRect
+#undef GetCursor
+#undef InvertRect
+#undef OffsetRect
+#undef PtInRect
+#undef SetCursor
+#undef SetRect
+#undef ShowCursor
+#undef UnionRect
+#endif
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winternl.h"
+#include "winbase.h"
+#include "objbase.h"
+
+#include "wincodecs_private.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
+
+#if defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
+
+typedef struct IcnsEncoder {
+ struct encoder encoder;
+ IStream *stream;
+ IconFamilyHandle icns_family;
+ struct encoder_frame frame;
+ OSType icns_type;
+ BYTE* icns_image;
+ int lines_written;
+} IcnsEncoder;
+
+static inline IcnsEncoder *impl_from_encoder(struct encoder *iface)
+{
+ return CONTAINING_RECORD(iface, IcnsEncoder, encoder);
+}
+
+void CDECL IcnsEncoder_destroy(struct encoder *iface)
+{
+ IcnsEncoder *This = impl_from_encoder(iface);
+
+ free(This->icns_image);
+
+ if (This->icns_family)
+ DisposeHandle((Handle)This->icns_family);
+
+ RtlFreeHeap(GetProcessHeap(), 0, This);
+}
+
+HRESULT CDECL IcnsEncoder_get_supported_format(struct encoder *iface,
+ GUID *pixel_format, DWORD *bpp, BOOL *indexed)
+{
+ *pixel_format = GUID_WICPixelFormat32bppBGRA;
+ *bpp = 32;
+ *indexed = FALSE;
+ return S_OK;
+}
+
+HRESULT CDECL IcnsEncoder_create_frame(struct encoder *iface, const struct encoder_frame *frame)
+{
+ IcnsEncoder *This = impl_from_encoder(iface);
+
+ This->frame = *frame;
+
+ switch (frame->width)
+ {
+ case 16: This->icns_type = kIconServices16PixelDataARGB; break;
+ case 32: This->icns_type = kIconServices32PixelDataARGB; break;
+ case 48: This->icns_type = kIconServices48PixelDataARGB; break;
+ case 128: This->icns_type = kIconServices128PixelDataARGB; break;
+ case 256: This->icns_type = kIconServices256PixelDataARGB; break;
+ case 512: This->icns_type = kIconServices512PixelDataARGB; break;
+ default:
+ ERR("cannot generate ICNS icon from %dx%d image\n", frame->width, frame->height);
+ return E_INVALIDARG;
+ }
+ This->icns_image = malloc(frame->width * frame->height * 4);
+ if (!This->icns_image)
+ {
+ WARN("failed to allocate image buffer\n");
+ return E_FAIL;
+ }
+ This->lines_written = 0;
+
+ return S_OK;
+}
+
+static HRESULT CDECL IcnsEncoder_write_lines(struct encoder* iface,
+ BYTE *data, DWORD line_count, DWORD stride)
+{
+ IcnsEncoder *This = impl_from_encoder(iface);
+ UINT i;
+
+ for (i = 0; i < line_count; i++)
+ {
+ BYTE *src_row, *dst_row;
+ UINT j;
+ src_row = data + stride * i;
+ dst_row = This->icns_image + (This->lines_written + i)*(This->frame.width*4);
+ /* swap bgr -> rgb */
+ for (j = 0; j < This->frame.width*4; j += 4)
+ {
+ dst_row[j] = src_row[j+3];
+ dst_row[j+1] = src_row[j+2];
+ dst_row[j+2] = src_row[j+1];
+ dst_row[j+3] = src_row[j];
+ }
+ }
+ This->lines_written += line_count;
+
+ return S_OK;
+}
+
+static HRESULT CDECL IcnsEncoder_commit_frame(struct encoder *iface)
+{
+ IcnsEncoder *This = impl_from_encoder(iface);
+ Handle handle;
+ OSErr ret;
+ HRESULT hr = S_OK;
+
+ ret = PtrToHand(This->icns_image, &handle, This->frame.width * This->frame.height * 4);
+ if (ret != noErr || !handle)
+ {
+ WARN("PtrToHand failed with error %d\n", ret);
+ return E_FAIL;
+ }
+
+ ret = SetIconFamilyData(This->icns_family, This->icns_type, handle);
+ DisposeHandle(handle);
+
+ if (ret != noErr)
+ {
+ WARN("SetIconFamilyData failed for image with error %d\n", ret);
+ return E_FAIL;
+ }
+
+ free(This->icns_image);
+ This->icns_image = NULL;
+
+ return S_OK;
+}
+
+static HRESULT CDECL IcnsEncoder_initialize(struct encoder *iface, IStream *stream)
+{
+ IcnsEncoder *This = impl_from_encoder(iface);
+
+ This->icns_family = (IconFamilyHandle)NewHandle(0);
+ if (!This->icns_family)
+ {
+ WARN("error creating icns family\n");
+ return E_FAIL;
+ }
+
+ This->stream = stream;
+
+ return S_OK;
+}
+
+static HRESULT CDECL IcnsEncoder_commit_file(struct encoder *iface)
+{
+ IcnsEncoder *This = impl_from_encoder(iface);
+ size_t buffer_size;
+ HRESULT hr = S_OK;
+ ULONG byteswritten;
+
+ buffer_size = GetHandleSize((Handle)This->icns_family);
+ hr = stream_write(This->stream, *This->icns_family, buffer_size, &byteswritten);
+ if (FAILED(hr) || byteswritten != buffer_size)
+ {
+ WARN("writing file failed, hr = 0x%08X\n", hr);
+ return E_FAIL;
+ }
+
+ return S_OK;
+}
+
+static const struct encoder_funcs IcnsEncoder_vtable = {
+ IcnsEncoder_initialize,
+ IcnsEncoder_get_supported_format,
+ IcnsEncoder_create_frame,
+ IcnsEncoder_write_lines,
+ IcnsEncoder_commit_frame,
+ IcnsEncoder_commit_file,
+ IcnsEncoder_destroy
+};
+
+HRESULT CDECL icns_encoder_create(struct encoder_info *info, struct encoder **result)
+{
+ IcnsEncoder *This;
+
+ TRACE("\n");
+
+ This = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(IcnsEncoder));
+ if (!This) return E_OUTOFMEMORY;
+
+ This->encoder.vtable = &IcnsEncoder_vtable;
+ This->stream = NULL;
+ This->icns_family = NULL;
+ This->icns_image = NULL;
+
+ *result = &This->encoder;
+ info->flags = ENCODER_FLAGS_MULTI_FRAME|ENCODER_FLAGS_ICNS_SIZE;
+ info->container_format = GUID_WineContainerFormatIcns;
+ info->clsid = CLSID_WICIcnsEncoder;
+ info->encoder_options[0] = ENCODER_OPTION_END;
+
+ return S_OK;
+}
+
+#else /* !defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) ||
+ MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 */
+
+HRESULT CDECL icns_encoder_create(struct encoder_info *info, struct encoder **result)
+{
+ ERR("Trying to save ICNS picture, but ICNS support is not compiled in.\n");
+ return E_FAIL;
+}
+
+#endif
diff --git a/dlls/windowscodecs/icnsformat.c b/dlls/windowscodecs/icnsformat.c
deleted file mode 100644
index c74e4b24d71..00000000000
--- a/dlls/windowscodecs/icnsformat.c
+++ /dev/null
@@ -1,742 +0,0 @@
-/*
- * Copyright 2010 Damjan Jovanovic
- *
- * 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 "config.h"
-#include "wine/port.h"
-
-#include <stdarg.h>
-
-#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
-#define GetCurrentProcess GetCurrentProcess_Mac
-#define GetCurrentThread GetCurrentThread_Mac
-#define LoadResource LoadResource_Mac
-#define AnimatePalette AnimatePalette_Mac
-#define EqualRgn EqualRgn_Mac
-#define FillRgn FillRgn_Mac
-#define FrameRgn FrameRgn_Mac
-#define GetPixel GetPixel_Mac
-#define InvertRgn InvertRgn_Mac
-#define LineTo LineTo_Mac
-#define OffsetRgn OffsetRgn_Mac
-#define PaintRgn PaintRgn_Mac
-#define Polygon Polygon_Mac
-#define ResizePalette ResizePalette_Mac
-#define SetRectRgn SetRectRgn_Mac
-#define EqualRect EqualRect_Mac
-#define FillRect FillRect_Mac
-#define FrameRect FrameRect_Mac
-#define GetCursor GetCursor_Mac
-#define InvertRect InvertRect_Mac
-#define OffsetRect OffsetRect_Mac
-#define PtInRect PtInRect_Mac
-#define SetCursor SetCursor_Mac
-#define SetRect SetRect_Mac
-#define ShowCursor ShowCursor_Mac
-#define UnionRect UnionRect_Mac
-#include <ApplicationServices/ApplicationServices.h>
-#undef GetCurrentProcess
-#undef GetCurrentThread
-#undef LoadResource
-#undef AnimatePalette
-#undef EqualRgn
-#undef FillRgn
-#undef FrameRgn
-#undef GetPixel
-#undef InvertRgn
-#undef LineTo
-#undef OffsetRgn
-#undef PaintRgn
-#undef Polygon
-#undef ResizePalette
-#undef SetRectRgn
-#undef EqualRect
-#undef FillRect
-#undef FrameRect
-#undef GetCursor
-#undef InvertRect
-#undef OffsetRect
-#undef PtInRect
-#undef SetCursor
-#undef SetRect
-#undef ShowCursor
-#undef UnionRect
-#endif
-
-#define COBJMACROS
-
-#include "windef.h"
-#include "winbase.h"
-#include "objbase.h"
-
-#include "wincodecs_private.h"
-
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
-
-#if defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) && \
- MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
-
-typedef struct IcnsEncoder {
- IWICBitmapEncoder IWICBitmapEncoder_iface;
- LONG ref;
- IStream *stream;
- IconFamilyHandle icns_family;
- BOOL any_frame_committed;
- int outstanding_commits;
- BOOL committed;
- CRITICAL_SECTION lock;
-} IcnsEncoder;
-
-static inline IcnsEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
-{
- return CONTAINING_RECORD(iface, IcnsEncoder, IWICBitmapEncoder_iface);
-}
-
-typedef struct IcnsFrameEncode {
- IWICBitmapFrameEncode IWICBitmapFrameEncode_iface;
- IcnsEncoder *encoder;
- LONG ref;
- BOOL initialized;
- UINT size;
- OSType icns_type;
- BYTE* icns_image;
- int lines_written;
- BOOL committed;
-} IcnsFrameEncode;
-
-static inline IcnsFrameEncode *impl_from_IWICBitmapFrameEncode(IWICBitmapFrameEncode *iface)
-{
- return CONTAINING_RECORD(iface, IcnsFrameEncode, IWICBitmapFrameEncode_iface);
-}
-
-static HRESULT WINAPI IcnsFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid,
- void **ppv)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
-
- if (!ppv) return E_INVALIDARG;
-
- if (IsEqualIID(&IID_IUnknown, iid) ||
- IsEqualIID(&IID_IWICBitmapFrameEncode, iid))
- {
- *ppv = &This->IWICBitmapFrameEncode_iface;
- }
- else
- {
- *ppv = NULL;
- return E_NOINTERFACE;
- }
-
- IUnknown_AddRef((IUnknown*)*ppv);
- return S_OK;
-}
-
-static ULONG WINAPI IcnsFrameEncode_AddRef(IWICBitmapFrameEncode *iface)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("(%p) refcount=%u\n", iface, ref);
-
- return ref;
-}
-
-static ULONG WINAPI IcnsFrameEncode_Release(IWICBitmapFrameEncode *iface)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("(%p) refcount=%u\n", iface, ref);
-
- if (ref == 0)
- {
- if (!This->committed)
- {
- EnterCriticalSection(&This->encoder->lock);
- This->encoder->outstanding_commits--;
- LeaveCriticalSection(&This->encoder->lock);
- }
- HeapFree(GetProcessHeap(), 0, This->icns_image);
-
- IWICBitmapEncoder_Release(&This->encoder->IWICBitmapEncoder_iface);
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- return ref;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
- IPropertyBag2 *pIEncoderOptions)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr = S_OK;
-
- TRACE("(%p,%p)\n", iface, pIEncoderOptions);
-
- EnterCriticalSection(&This->encoder->lock);
-
- if (This->initialized)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
- This->initialized = TRUE;
-
-end:
- LeaveCriticalSection(&This->encoder->lock);
- return hr;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_SetSize(IWICBitmapFrameEncode *iface,
- UINT uiWidth, UINT uiHeight)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr = S_OK;
-
- TRACE("(%p,%u,%u)\n", iface, uiWidth, uiHeight);
-
- EnterCriticalSection(&This->encoder->lock);
-
- if (!This->initialized || This->icns_image)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
-
- if (uiWidth != uiHeight)
- {
- WARN("cannot generate ICNS icon from %dx%d image\n", uiWidth, uiHeight);
- hr = E_INVALIDARG;
- goto end;
- }
-
- switch (uiWidth)
- {
- case 16:
- case 32:
- case 48:
- case 128:
- case 256:
- case 512:
- break;
- default:
- WARN("cannot generate ICNS icon from %dx%d image\n", This->size, This->size);
- hr = E_INVALIDARG;
- goto end;
- }
-
- This->size = uiWidth;
-
-end:
- LeaveCriticalSection(&This->encoder->lock);
- return hr;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_SetResolution(IWICBitmapFrameEncode *iface,
- double dpiX, double dpiY)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr = S_OK;
-
- TRACE("(%p,%0.2f,%0.2f)\n", iface, dpiX, dpiY);
-
- EnterCriticalSection(&This->encoder->lock);
-
- if (!This->initialized || This->icns_image)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
-
-end:
- LeaveCriticalSection(&This->encoder->lock);
- return S_OK;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface,
- WICPixelFormatGUID *pPixelFormat)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr = S_OK;
-
- TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat));
-
- EnterCriticalSection(&This->encoder->lock);
-
- if (!This->initialized || This->icns_image)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
-
- memcpy(pPixelFormat, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID));
-
-end:
- LeaveCriticalSection(&This->encoder->lock);
- return S_OK;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_SetColorContexts(IWICBitmapFrameEncode *iface,
- UINT cCount, IWICColorContext **ppIColorContext)
-{
- FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
- return E_NOTIMPL;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_SetPalette(IWICBitmapFrameEncode *iface,
- IWICPalette *pIPalette)
-{
- FIXME("(%p,%p): stub\n", iface, pIPalette);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_SetThumbnail(IWICBitmapFrameEncode *iface,
- IWICBitmapSource *pIThumbnail)
-{
- FIXME("(%p,%p): stub\n", iface, pIThumbnail);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
- UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr = S_OK;
- UINT i;
-
- TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels);
-
- EnterCriticalSection(&This->encoder->lock);
-
- if (!This->initialized || !This->size)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
- if (lineCount == 0 || lineCount + This->lines_written > This->size)
- {
- hr = E_INVALIDARG;
- goto end;
- }
-
- if (!This->icns_image)
- {
- switch (This->size)
- {
- case 16: This->icns_type = kIconServices16PixelDataARGB; break;
- case 32: This->icns_type = kIconServices32PixelDataARGB; break;
- case 48: This->icns_type = kIconServices48PixelDataARGB; break;
- case 128: This->icns_type = kIconServices128PixelDataARGB; break;
- case 256: This->icns_type = kIconServices256PixelDataARGB; break;
- case 512: This->icns_type = kIconServices512PixelDataARGB; break;
- default:
- WARN("cannot generate ICNS icon from %dx%d image\n", This->size, This->size);
- hr = E_INVALIDARG;
- goto end;
- }
- This->icns_image = HeapAlloc(GetProcessHeap(), 0, This->size * This->size * 4);
- if (!This->icns_image)
- {
- WARN("failed to allocate image buffer\n");
- hr = E_FAIL;
- goto end;
- }
- }
-
- for (i = 0; i < lineCount; i++)
- {
- BYTE *src_row, *dst_row;
- UINT j;
- src_row = pbPixels + cbStride * i;
- dst_row = This->icns_image + (This->lines_written + i)*(This->size*4);
- /* swap bgr -> rgb */
- for (j = 0; j < This->size*4; j += 4)
- {
- dst_row[j] = src_row[j+3];
- dst_row[j+1] = src_row[j+2];
- dst_row[j+2] = src_row[j+1];
- dst_row[j+3] = src_row[j];
- }
- }
- This->lines_written += lineCount;
-
-end:
- LeaveCriticalSection(&This->encoder->lock);
- return hr;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
- IWICBitmapSource *pIBitmapSource, WICRect *prc)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- HRESULT hr;
-
- TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
-
- if (!This->initialized)
- return WINCODEC_ERR_WRONGSTATE;
-
- hr = configure_write_source(iface, pIBitmapSource, prc,
- &GUID_WICPixelFormat32bppBGRA, This->size, This->size,
- 1.0, 1.0);
-
- if (SUCCEEDED(hr))
- {
- hr = write_source(iface, pIBitmapSource, prc,
- &GUID_WICPixelFormat32bppBGRA, 32, FALSE, This->size, This->size);
- }
-
- return hr;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_Commit(IWICBitmapFrameEncode *iface)
-{
- IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
- Handle handle;
- OSErr ret;
- HRESULT hr = S_OK;
-
- TRACE("(%p)\n", iface);
-
- EnterCriticalSection(&This->encoder->lock);
-
- if (!This->icns_image || This->lines_written != This->size || This->committed)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
-
- ret = PtrToHand(This->icns_image, &handle, This->size * This->size * 4);
- if (ret != noErr || !handle)
- {
- WARN("PtrToHand failed with error %d\n", ret);
- hr = E_FAIL;
- goto end;
- }
-
- ret = SetIconFamilyData(This->encoder->icns_family, This->icns_type, handle);
- DisposeHandle(handle);
-
- if (ret != noErr)
- {
- WARN("SetIconFamilyData failed for image with error %d\n", ret);
- hr = E_FAIL;
- goto end;
- }
-
- This->committed = TRUE;
- This->encoder->any_frame_committed = TRUE;
- This->encoder->outstanding_commits--;
-
-end:
- LeaveCriticalSection(&This->encoder->lock);
- return hr;
-}
-
-static HRESULT WINAPI IcnsFrameEncode_GetMetadataQueryWriter(IWICBitmapFrameEncode *iface,
- IWICMetadataQueryWriter **ppIMetadataQueryWriter)
-{
- FIXME("(%p, %p): stub\n", iface, ppIMetadataQueryWriter);
- return E_NOTIMPL;
-}
-
-static const IWICBitmapFrameEncodeVtbl IcnsEncoder_FrameVtbl = {
- IcnsFrameEncode_QueryInterface,
- IcnsFrameEncode_AddRef,
- IcnsFrameEncode_Release,
- IcnsFrameEncode_Initialize,
- IcnsFrameEncode_SetSize,
- IcnsFrameEncode_SetResolution,
- IcnsFrameEncode_SetPixelFormat,
- IcnsFrameEncode_SetColorContexts,
- IcnsFrameEncode_SetPalette,
- IcnsFrameEncode_SetThumbnail,
- IcnsFrameEncode_WritePixels,
- IcnsFrameEncode_WriteSource,
- IcnsFrameEncode_Commit,
- IcnsFrameEncode_GetMetadataQueryWriter
-};
-
-static HRESULT WINAPI IcnsEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid,
- void **ppv)
-{
- IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
- TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
-
- if (!ppv) return E_INVALIDARG;
-
- if (IsEqualIID(&IID_IUnknown, iid) ||
- IsEqualIID(&IID_IWICBitmapEncoder, iid))
- {
- *ppv = &This->IWICBitmapEncoder_iface;
- }
- else
- {
- *ppv = NULL;
- return E_NOINTERFACE;
- }
-
- IUnknown_AddRef((IUnknown*)*ppv);
- return S_OK;
-}
-
-static ULONG WINAPI IcnsEncoder_AddRef(IWICBitmapEncoder *iface)
-{
- IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
- ULONG ref = InterlockedIncrement(&This->ref);
-
- TRACE("(%p) refcount=%u\n", iface, ref);
-
- return ref;
-}
-
-static ULONG WINAPI IcnsEncoder_Release(IWICBitmapEncoder *iface)
-{
- IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
- ULONG ref = InterlockedDecrement(&This->ref);
-
- TRACE("(%p) refcount=%u\n", iface, ref);
-
- if (ref == 0)
- {
- This->lock.DebugInfo->Spare[0] = 0;
- DeleteCriticalSection(&This->lock);
- if (This->icns_family)
- DisposeHandle((Handle)This->icns_family);
- if (This->stream)
- IStream_Release(This->stream);
- HeapFree(GetProcessHeap(), 0, This);
- }
-
- return ref;
-}
-
-static HRESULT WINAPI IcnsEncoder_Initialize(IWICBitmapEncoder *iface,
- IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
-{
- IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
- HRESULT hr = S_OK;
-
- TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
-
- EnterCriticalSection(&This->lock);
-
- if (This->icns_family)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
- This->icns_family = (IconFamilyHandle)NewHandle(0);
- if (!This->icns_family)
- {
- WARN("error creating icns family\n");
- hr = E_FAIL;
- goto end;
- }
- IStream_AddRef(pIStream);
- This->stream = pIStream;
-
-end:
- LeaveCriticalSection(&This->lock);
-
- return hr;
-}
-
-static HRESULT WINAPI IcnsEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
- GUID *pguidContainerFormat)
-{
- FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat));
- return E_NOTIMPL;
-}
-
-static HRESULT WINAPI IcnsEncoder_GetEncoderInfo(IWICBitmapEncoder *iface,
- IWICBitmapEncoderInfo **ppIEncoderInfo)
-{
- FIXME("(%p,%p): stub\n", iface, ppIEncoderInfo);
- return E_NOTIMPL;
-}
-
-static HRESULT WINAPI IcnsEncoder_SetColorContexts(IWICBitmapEncoder *iface,
- UINT cCount, IWICColorContext **ppIColorContext)
-{
- FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
- return E_NOTIMPL;
-}
-
-static HRESULT WINAPI IcnsEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *pIPalette)
-{
- TRACE("(%p,%p)\n", iface, pIPalette);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI IcnsEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail)
-{
- TRACE("(%p,%p)\n", iface, pIThumbnail);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI IcnsEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmapSource *pIPreview)
-{
- TRACE("(%p,%p)\n", iface, pIPreview);
- return WINCODEC_ERR_UNSUPPORTEDOPERATION;
-}
-
-static HRESULT WINAPI IcnsEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
- IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
-{
- IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
- HRESULT hr = S_OK;
- IcnsFrameEncode *frameEncode = NULL;
-
- TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
-
- EnterCriticalSection(&This->lock);
-
- if (!This->icns_family)
- {
- hr = WINCODEC_ERR_NOTINITIALIZED;
- goto end;
- }
-
- if (ppIEncoderOptions)
- {
- hr = CreatePropertyBag2(NULL, 0, ppIEncoderOptions);
- if (FAILED(hr))
- goto end;
- }
-
- frameEncode = HeapAlloc(GetProcessHeap(), 0, sizeof(IcnsFrameEncode));
- if (frameEncode == NULL)
- {
- hr = E_OUTOFMEMORY;
- goto end;
- }
- frameEncode->IWICBitmapFrameEncode_iface.lpVtbl = &IcnsEncoder_FrameVtbl;
- frameEncode->encoder = This;
- frameEncode->ref = 1;
- frameEncode->initialized = FALSE;
- frameEncode->size = 0;
- frameEncode->icns_image = NULL;
- frameEncode->lines_written = 0;
- frameEncode->committed = FALSE;
- *ppIFrameEncode = &frameEncode->IWICBitmapFrameEncode_iface;
- This->outstanding_commits++;
- IWICBitmapEncoder_AddRef(&This->IWICBitmapEncoder_iface);
-
-end:
- LeaveCriticalSection(&This->lock);
-
- return hr;
-}
-
-static HRESULT WINAPI IcnsEncoder_Commit(IWICBitmapEncoder *iface)
-{
- IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
- size_t buffer_size;
- HRESULT hr = S_OK;
- ULONG byteswritten;
-
- TRACE("(%p)\n", iface);
-
- EnterCriticalSection(&This->lock);
-
- if (!This->any_frame_committed || This->outstanding_commits > 0 || This->committed)
- {
- hr = WINCODEC_ERR_WRONGSTATE;
- goto end;
- }
-
- buffer_size = GetHandleSize((Handle)This->icns_family);
- hr = IStream_Write(This->stream, *This->icns_family, buffer_size, &byteswritten);
- if (FAILED(hr) || byteswritten != buffer_size)
- {
- WARN("writing file failed, hr = 0x%08X\n", hr);
- hr = E_FAIL;
- goto end;
- }
-
- This->committed = TRUE;
-
-end:
- LeaveCriticalSection(&This->lock);
- return hr;
-}
-
-static HRESULT WINAPI IcnsEncoder_GetMetadataQueryWriter(IWICBitmapEncoder *iface,
- IWICMetadataQueryWriter **ppIMetadataQueryWriter)
-{
- FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryWriter);
- return E_NOTIMPL;
-}
-
-static const IWICBitmapEncoderVtbl IcnsEncoder_Vtbl = {
- IcnsEncoder_QueryInterface,
- IcnsEncoder_AddRef,
- IcnsEncoder_Release,
- IcnsEncoder_Initialize,
- IcnsEncoder_GetContainerFormat,
- IcnsEncoder_GetEncoderInfo,
- IcnsEncoder_SetColorContexts,
- IcnsEncoder_SetPalette,
- IcnsEncoder_SetThumbnail,
- IcnsEncoder_SetPreview,
- IcnsEncoder_CreateNewFrame,
- IcnsEncoder_Commit,
- IcnsEncoder_GetMetadataQueryWriter
-};
-
-HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv)
-{
- IcnsEncoder *This;
- HRESULT ret;
-
- TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
-
- *ppv = NULL;
-
- This = HeapAlloc(GetProcessHeap(), 0, sizeof(IcnsEncoder));
- if (!This) return E_OUTOFMEMORY;
-
- This->IWICBitmapEncoder_iface.lpVtbl = &IcnsEncoder_Vtbl;
- This->ref = 1;
- This->stream = NULL;
- This->icns_family = NULL;
- This->any_frame_committed = FALSE;
- This->outstanding_commits = 0;
- This->committed = FALSE;
- InitializeCriticalSection(&This->lock);
- This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IcnsEncoder.lock");
-
- ret = IWICBitmapEncoder_QueryInterface(&This->IWICBitmapEncoder_iface, iid, ppv);
- IWICBitmapEncoder_Release(&This->IWICBitmapEncoder_iface);
-
- return ret;
-}
-
-#else /* !defined(HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H) ||
- MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 */
-
-HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv)
-{
- ERR("Trying to save ICNS picture, but ICNS support is not compiled in.\n");
- return E_FAIL;
-}
-
-#endif
diff --git a/dlls/windowscodecs/main.c b/dlls/windowscodecs/main.c
index b8ffb216186..bfdde3e3891 100644
--- a/dlls/windowscodecs/main.c
+++ b/dlls/windowscodecs/main.c
@@ -307,3 +307,17 @@ HRESULT JpegEncoder_CreateInstance(REFIID iid, void** ppv)
return hr;
}
+
+HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv)
+{
+ HRESULT hr;
+ struct encoder *encoder;
+ struct encoder_info encoder_info;
+
+ hr = get_unix_encoder(&CLSID_WICIcnsEncoder, &encoder_info, &encoder);
+
+ if (SUCCEEDED(hr))
+ hr = CommonEncoder_CreateInstance(encoder, &encoder_info, iid, ppv);
+
+ return hr;
+}
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index 38c252c2760..365f44979fc 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -1532,7 +1532,7 @@ static struct regsvr_encoder const encoder_list[] = {
"ICNS Encoder",
"1.0.0.0",
&GUID_VendorWine,
- NULL, /* no container format guid */
+ &GUID_WineContainerFormatIcns,
"image/icns",
".icns",
icns_encode_formats
diff --git a/dlls/windowscodecs/unix_lib.c b/dlls/windowscodecs/unix_lib.c
index f94340fc971..268a1cd9d16 100644
--- a/dlls/windowscodecs/unix_lib.c
+++ b/dlls/windowscodecs/unix_lib.c
@@ -92,6 +92,9 @@ HRESULT CDECL encoder_create(const CLSID *encoder_clsid, struct encoder_info *in
if (IsEqualGUID(encoder_clsid, &CLSID_WICJpegEncoder))
return jpeg_encoder_create(info, result);
+ if (IsEqualGUID(encoder_clsid, &CLSID_WICIcnsEncoder))
+ return icns_encoder_create(info, result);
+
return E_NOTIMPL;
}
diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h
index 3814edb32bb..ebd2d20dfe7 100644
--- a/dlls/windowscodecs/wincodecs_private.h
+++ b/dlls/windowscodecs/wincodecs_private.h
@@ -31,6 +31,8 @@ DEFINE_GUID(CLSID_WICIcnsEncoder, 0x312fb6f1,0xb767,0x409d,0x8a,0x6d,0x0f,0xc1,0
DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22);
+DEFINE_GUID(GUID_WineContainerFormatIcns, 0xe4cd3e69,0x4436,0x4363,0x98,0x1d,0xcc,0xf0,0x5a,0x87,0x4c,0x73);
+
DEFINE_GUID(GUID_VendorWine, 0xddf46da1,0x7dc1,0x404e,0x98,0xf2,0xef,0xa4,0x8d,0xfc,0x95,0x0a);
extern IID IID_IMILBitmap;
@@ -353,6 +355,7 @@ enum encoder_option
};
#define ENCODER_FLAGS_MULTI_FRAME 0x1
+#define ENCODER_FLAGS_ICNS_SIZE 0x2
struct encoder_info
{
@@ -407,6 +410,7 @@ HRESULT CDECL jpeg_decoder_create(struct decoder_info *info, struct decoder **re
HRESULT CDECL png_encoder_create(struct encoder_info *info, struct encoder **result);
HRESULT CDECL tiff_encoder_create(struct encoder_info *info, struct encoder **result);
HRESULT CDECL jpeg_encoder_create(struct encoder_info *info, struct encoder **result);
+HRESULT CDECL icns_encoder_create(struct encoder_info *info, struct encoder **result);
struct unix_funcs
{
--
2.17.1
1
0
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/rpcrt4/cpsf.c | 38 ++++++++----------------
dlls/rpcrt4/rpc_binding.c | 3 +-
dlls/rpcrt4/rpc_epmap.c | 3 +-
dlls/rpcrt4/rpc_transport.c | 59 +++++++++++++------------------------
dlls/rpcrt4/tests/rpc.c | 3 +-
dlls/rpcrt4/tests/server.c | 20 +++++--------
6 files changed, 44 insertions(+), 82 deletions(-)
diff --git a/dlls/rpcrt4/cpsf.c b/dlls/rpcrt4/cpsf.c
index 881894a1be5..006e6bce62f 100644
--- a/dlls/rpcrt4/cpsf.c
+++ b/dlls/rpcrt4/cpsf.c
@@ -41,11 +41,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
static void format_clsid( WCHAR *buffer, const CLSID *clsid )
{
- static const WCHAR clsid_formatW[] = {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X','-',
- '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
- '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','}',0};
-
- swprintf( buffer, 39, clsid_formatW, clsid->Data1, clsid->Data2, clsid->Data3,
+ swprintf( buffer, 39, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+ clsid->Data1, clsid->Data2, clsid->Data3,
clsid->Data4[0], clsid->Data4[1], clsid->Data4[2], clsid->Data4[3],
clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7] );
@@ -222,15 +219,6 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
const ProxyFileInfo **pProxyFileList,
const CLSID *pclsid)
{
- static const WCHAR bothW[] = {'B','o','t','h',0};
- static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
- static const WCHAR clsid32W[] = {'P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0};
- static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0};
- static const WCHAR psfactoryW[] = {'P','S','F','a','c','t','o','r','y','B','u','f','f','e','r',0};
- static const WCHAR numformatW[] = {'%','u',0};
- static const WCHAR nummethodsW[] = {'N','u','m','M','e','t','h','o','d','s',0};
- static const WCHAR inprocserverW[] = {'I','n','P','r','o','c','S','e','r','v','e','r','3','2',0};
- static const WCHAR threadingmodelW[] = {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0};
WCHAR clsid[39], keyname[50], module[MAX_PATH];
HKEY key, subkey;
DWORD len;
@@ -257,15 +245,15 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
TRACE("registering %s %s => %s\n",
debugstr_a(name), debugstr_guid(proxy->header.piid), debugstr_w(clsid));
- lstrcpyW( keyname, interfaceW );
+ lstrcpyW( keyname, L"Interface\\" );
format_clsid( keyname + lstrlenW(keyname), proxy->header.piid );
if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) {
WCHAR num[10];
if (name)
RegSetValueExA(key, NULL, 0, REG_SZ, (const BYTE *)name, strlen(name)+1);
- RegSetValueW( key, clsid32W, REG_SZ, clsid, 0 );
- swprintf(num, ARRAY_SIZE(num), numformatW, proxy->header.DispatchTableCount);
- RegSetValueW( key, nummethodsW, REG_SZ, num, 0 );
+ RegSetValueW( key, L"ProxyStubClsid32", REG_SZ, clsid, 0 );
+ swprintf(num, ARRAY_SIZE(num), L"%u", proxy->header.DispatchTableCount);
+ RegSetValueW( key, L"NumMethods", REG_SZ, num, 0 );
RegCloseKey(key);
}
}
@@ -273,16 +261,16 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
}
/* register clsid to point to module */
- lstrcpyW( keyname, clsidW );
+ lstrcpyW( keyname, L"CLSID\\" );
lstrcatW( keyname, clsid );
len = GetModuleFileNameW(hDll, module, ARRAY_SIZE(module));
if (len && len < sizeof(module)) {
TRACE("registering CLSID %s => %s\n", debugstr_w(clsid), debugstr_w(module));
if (RegCreateKeyW(HKEY_CLASSES_ROOT, keyname, &key) == ERROR_SUCCESS) {
- RegSetValueExW(key, NULL, 0, REG_SZ, (const BYTE *)psfactoryW, sizeof(psfactoryW));
- if (RegCreateKeyW(key, inprocserverW, &subkey) == ERROR_SUCCESS) {
+ RegSetValueExW(key, NULL, 0, REG_SZ, (const BYTE *)L"PSFactoryBuffer", sizeof(L"PSFactoryBuffer"));
+ if (RegCreateKeyW(key, L"InProcServer32", &subkey) == ERROR_SUCCESS) {
RegSetValueExW(subkey, NULL, 0, REG_SZ, (LPBYTE)module, (lstrlenW(module)+1)*sizeof(WCHAR));
- RegSetValueExW(subkey, threadingmodelW, 0, REG_SZ, (const BYTE *)bothW, sizeof(bothW));
+ RegSetValueExW(subkey, L"ThreadingModel", 0, REG_SZ, (const BYTE *)L"Both", sizeof(L"Both"));
RegCloseKey(subkey);
}
RegCloseKey(key);
@@ -299,8 +287,6 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
const ProxyFileInfo **pProxyFileList,
const CLSID *pclsid)
{
- static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
- static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0};
WCHAR keyname[50];
WCHAR clsid[39];
@@ -321,7 +307,7 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
TRACE("unregistering %s %s\n", debugstr_a(name), debugstr_guid(proxy->header.piid));
- lstrcpyW( keyname, interfaceW );
+ lstrcpyW( keyname, L"Interface\\" );
format_clsid( keyname + lstrlenW(keyname), proxy->header.piid );
RegDeleteTreeW(HKEY_CLASSES_ROOT, keyname);
}
@@ -329,7 +315,7 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
}
/* unregister clsid */
- lstrcpyW( keyname, clsidW );
+ lstrcpyW( keyname, L"CLSID\\" );
lstrcatW( keyname, clsid );
RegDeleteTreeW(HKEY_CLASSES_ROOT, keyname);
diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c
index e8cdb933474..56502e4eb34 100644
--- a/dlls/rpcrt4/rpc_binding.c
+++ b/dlls/rpcrt4/rpc_binding.c
@@ -676,7 +676,6 @@ RPC_STATUS WINAPI RpcStringBindingParseW( RPC_WSTR StringBinding, RPC_WSTR *ObjU
RPC_WSTR *Endpoint, RPC_WSTR *Options)
{
const WCHAR *data, *next;
- static const WCHAR ep_opt[] = {'e','n','d','p','o','i','n','t','=',0};
BOOL endpoint_already_found = FALSE;
TRACE("(%s,%p,%p,%p,%p,%p)\n", debugstr_w(StringBinding),
@@ -740,7 +739,7 @@ RPC_STATUS WINAPI RpcStringBindingParseW( RPC_WSTR StringBinding, RPC_WSTR *ObjU
else HeapFree(GetProcessHeap(), 0, opt);
endpoint_already_found = TRUE;
} else {
- if (wcsncmp(opt, ep_opt, lstrlenW(ep_opt)) == 0) {
+ if (wcsncmp(opt, L"endpoint=", lstrlenW(L"endpoint=")) == 0) {
/* endpoint option */
if (endpoint_already_found) goto fail;
if (Endpoint) *Endpoint = unescape_string_binding_componentW(next+1, -1);
diff --git a/dlls/rpcrt4/rpc_epmap.c b/dlls/rpcrt4/rpc_epmap.c
index 6444f29e79f..35af454ce95 100644
--- a/dlls/rpcrt4/rpc_epmap.c
+++ b/dlls/rpcrt4/rpc_epmap.c
@@ -78,7 +78,6 @@ static const struct epm_endpoints
static BOOL start_rpcss(void)
{
- static const WCHAR rpcssW[] = {'R','p','c','S','s',0};
SC_HANDLE scm, service;
SERVICE_STATUS_PROCESS status;
BOOL ret = FALSE;
@@ -90,7 +89,7 @@ static BOOL start_rpcss(void)
ERR( "failed to open service manager\n" );
return FALSE;
}
- if (!(service = OpenServiceW( scm, rpcssW, SERVICE_START | SERVICE_QUERY_STATUS )))
+ if (!(service = OpenServiceW( scm, L"RpcSs", SERVICE_START | SERVICE_QUERY_STATUS )))
{
ERR( "failed to open RpcSs service\n" );
CloseServiceHandle( scm );
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index 243c4780bf7..4f2c6642792 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -1874,7 +1874,6 @@ static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor)
static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
{
- static const WCHAR wszUserAgent[] = {'M','S','R','P','C',0};
LPWSTR proxy = NULL;
LPWSTR user = NULL;
LPWSTR password = NULL;
@@ -1912,12 +1911,9 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
for (option = httpc->common.NetworkOptions; option;
option = (wcschr(option, ',') ? wcschr(option, ',')+1 : NULL))
{
- static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
- static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
-
- if (!wcsnicmp(option, wszRpcProxy, ARRAY_SIZE(wszRpcProxy)-1))
+ if (!wcsnicmp(option, L"RpcProxy=", ARRAY_SIZE(L"RpcProxy=")-1))
{
- const WCHAR *value_start = option + ARRAY_SIZE(wszRpcProxy)-1;
+ const WCHAR *value_start = option + ARRAY_SIZE(L"RpcProxy=")-1;
const WCHAR *value_end;
const WCHAR *p;
@@ -1934,9 +1930,9 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
servername = RPCRT4_strndupW(value_start, value_end-value_start);
}
- else if (!wcsnicmp(option, wszHttpProxy, ARRAY_SIZE(wszHttpProxy)-1))
+ else if (!wcsnicmp(option, L"HttpProxy=", ARRAY_SIZE(L"HttpProxy=")-1))
{
- const WCHAR *value_start = option + ARRAY_SIZE(wszHttpProxy)-1;
+ const WCHAR *value_start = option + ARRAY_SIZE(L"HttpProxy=")-1;
const WCHAR *value_end;
value_end = wcschr(option, ',');
@@ -1949,7 +1945,7 @@ static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
FIXME("unhandled option %s\n", debugstr_w(option));
}
- httpc->app_info = InternetOpenW(wszUserAgent, proxy ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_PRECONFIG,
+ httpc->app_info = InternetOpenW(L"MSRPC", proxy ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, INTERNET_FLAG_ASYNC);
if (!httpc->app_info)
{
@@ -2062,11 +2058,9 @@ static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data,
static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
{
- static const WCHAR fmtW[] =
- {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
- WCHAR header[ARRAY_SIZE(fmtW) + 10];
+ WCHAR header[ARRAY_SIZE(L"Content-Length: %u\r\n") + 10];
- swprintf(header, ARRAY_SIZE(header), fmtW, len);
+ swprintf(header, ARRAY_SIZE(header), L"Content-Length: %u\r\n", len);
if ((HttpAddRequestHeadersW(request, header, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD))) return RPC_S_OK;
return RPC_S_SERVER_UNAVAILABLE;
}
@@ -2379,12 +2373,6 @@ static void destroy_authinfo(struct authinfo *info)
HeapFree(GetProcessHeap(), 0, info);
}
-static const WCHAR basicW[] = {'B','a','s','i','c',0};
-static const WCHAR ntlmW[] = {'N','T','L','M',0};
-static const WCHAR passportW[] = {'P','a','s','s','p','o','r','t',0};
-static const WCHAR digestW[] = {'D','i','g','e','s','t',0};
-static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
-
static const struct
{
const WCHAR *str;
@@ -2393,11 +2381,11 @@ static const struct
}
auth_schemes[] =
{
- { basicW, ARRAY_SIZE(basicW) - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC },
- { ntlmW, ARRAY_SIZE(ntlmW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM },
- { passportW, ARRAY_SIZE(passportW) - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT },
- { digestW, ARRAY_SIZE(digestW) - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST },
- { negotiateW, ARRAY_SIZE(negotiateW) - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE }
+ { L"Basic", ARRAY_SIZE(L"Basic") - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC },
+ { L"NTLM", ARRAY_SIZE(L"NTLM") - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM },
+ { L"Passport", ARRAY_SIZE(L"Passport") - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT },
+ { L"Digest", ARRAY_SIZE(L"Digest") - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST },
+ { L"Negotiate", ARRAY_SIZE(L"Negotiate") - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE }
};
static DWORD auth_scheme_from_header( const WCHAR *header )
@@ -2458,7 +2446,7 @@ static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername,
case RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE:
{
- static SEC_WCHAR ntlmW[] = {'N','T','L','M',0}, negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
+ static SEC_WCHAR ntlmW[] = L"NTLM", negotiateW[] = L"Negotiate";
SECURITY_STATUS ret;
SecBufferDesc out_desc, in_desc;
SecBuffer out, in;
@@ -2634,7 +2622,6 @@ static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDL
static RPC_STATUS authorize_request(RpcConnection_http *httpc, HINTERNET request)
{
- static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':','\r','\n',0};
struct authinfo *info = NULL;
RPC_STATUS status;
BOOL ret;
@@ -2658,7 +2645,7 @@ static RPC_STATUS authorize_request(RpcConnection_http *httpc, HINTERNET request
}
if (info->scheme != RPC_C_HTTP_AUTHN_SCHEME_BASIC)
- HttpAddRequestHeadersW(request, authW, -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
+ HttpAddRequestHeadersW(request, L"Authorization:\r\n", -1, HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDREQ_FLAG_ADD);
destroy_authinfo(info);
return status;
@@ -2691,8 +2678,8 @@ static BOOL is_secure(RpcConnection_http *httpc)
static RPC_STATUS set_auth_cookie(RpcConnection_http *httpc, const WCHAR *value)
{
- static WCHAR httpW[] = {'h','t','t','p',0};
- static WCHAR httpsW[] = {'h','t','t','p','s',0};
+ static WCHAR httpW[] = L"http";
+ static WCHAR httpsW[] = L"https";
URL_COMPONENTSW uc;
DWORD len;
WCHAR *url;
@@ -2737,12 +2724,8 @@ static RPC_STATUS set_auth_cookie(RpcConnection_http *httpc, const WCHAR *value)
static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
{
RpcConnection_http *httpc = (RpcConnection_http *)Connection;
- static const WCHAR wszVerbIn[] = {'R','P','C','_','I','N','_','D','A','T','A',0};
- static const WCHAR wszVerbOut[] = {'R','P','C','_','O','U','T','_','D','A','T','A',0};
- static const WCHAR wszRpcProxyPrefix[] = {'/','r','p','c','/','r','p','c','p','r','o','x','y','.','d','l','l','?',0};
- static const WCHAR wszColon[] = {':',0};
- static const WCHAR wszAcceptType[] = {'a','p','p','l','i','c','a','t','i','o','n','/','r','p','c',0};
- LPCWSTR wszAcceptTypes[] = { wszAcceptType, NULL };
+ static const WCHAR wszRpcProxyPrefix[] = L"/rpc/rpcproxy.dll?";
+ LPCWSTR wszAcceptTypes[] = { L"application/rpc", NULL };
DWORD flags;
WCHAR *url;
RPC_STATUS status;
@@ -2777,7 +2760,7 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
memcpy(url, wszRpcProxyPrefix, sizeof(wszRpcProxyPrefix));
MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+ARRAY_SIZE(wszRpcProxyPrefix)-1,
strlen(Connection->NetworkAddr)+1);
- lstrcatW(url, wszColon);
+ lstrcatW(url, L":");
MultiByteToWideChar(CP_ACP, 0, Connection->Endpoint, -1, url+lstrlenW(url), strlen(Connection->Endpoint)+1);
secure = is_secure(httpc);
@@ -2794,7 +2777,7 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
HeapFree(GetProcessHeap(), 0, url);
return status;
}
- httpc->in_request = HttpOpenRequestW(httpc->session, wszVerbIn, url, NULL, NULL, wszAcceptTypes,
+ httpc->in_request = HttpOpenRequestW(httpc->session, L"RPC_IN_DATA", url, NULL, NULL, wszAcceptTypes,
flags, (DWORD_PTR)httpc->async_data);
if (!httpc->in_request)
{
@@ -2820,7 +2803,7 @@ static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection* Connection)
drain_content(httpc->in_request, httpc->async_data, httpc->cancel_event);
}
- httpc->out_request = HttpOpenRequestW(httpc->session, wszVerbOut, url, NULL, NULL, wszAcceptTypes,
+ httpc->out_request = HttpOpenRequestW(httpc->session, L"RPC_OUT_DATA", url, NULL, NULL, wszAcceptTypes,
flags, (DWORD_PTR)httpc->async_data);
HeapFree(GetProcessHeap(), 0, url);
if (!httpc->out_request)
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index ce16145119b..0b9e71ec0a2 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -1165,7 +1165,6 @@ enum firewall_op
static HRESULT set_firewall( enum firewall_op op )
{
- static const WCHAR testW[] = {'r','p','c','r','t','4','_','t','e','s','t',0};
HRESULT hr, init;
INetFwMgr *mgr = NULL;
INetFwPolicy *policy = NULL;
@@ -1205,7 +1204,7 @@ static HRESULT set_firewall( enum firewall_op op )
hr = INetFwAuthorizedApplication_put_ProcessImageFileName( app, image );
if (hr != S_OK) goto done;
- name = SysAllocString( testW );
+ name = SysAllocString( L"rpcrt4_test" );
hr = INetFwAuthorizedApplication_put_Name( app, name );
SysFreeString( name );
ok( hr == S_OK, "got %08x\n", hr );
diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c
index d6655688314..7b340a11f87 100644
--- a/dlls/rpcrt4/tests/server.c
+++ b/dlls/rpcrt4/tests/server.c
@@ -245,9 +245,6 @@ static void (__cdecl *test_handle)(ctx_handle_t ctx_handle);
/* type check statements generated in header file */
fnprintf *p_printf = printf;
-static const WCHAR helloW[] = { 'H','e','l','l','o',0 };
-static const WCHAR worldW[] = { 'W','o','r','l','d','!',0 };
-
static BOOL is_interp;
static void set_interp_interface(void)
@@ -833,10 +830,10 @@ void __cdecl s_get_namesw(int *n, wstr_array_t *names)
wstr_array_t list;
list = MIDL_user_allocate(2 * sizeof(list[0]));
- list[0] = MIDL_user_allocate(sizeof(helloW));
- lstrcpyW(list[0], helloW);
- list[1] = MIDL_user_allocate(sizeof(worldW));
- lstrcpyW(list[1], worldW);
+ list[0] = MIDL_user_allocate(sizeof(L"Hello"));
+ lstrcpyW(list[0], L"Hello");
+ list[1] = MIDL_user_allocate(sizeof(L"World!"));
+ lstrcpyW(list[1], L"World!");
*names = list;
*n = 2;
@@ -1157,7 +1154,7 @@ static void
basic_tests(void)
{
char string[] = "I am a string";
- WCHAR wstring[] = {'I',' ','a','m',' ','a',' ','w','s','t','r','i','n','g', 0};
+ WCHAR wstring[] = L"I am a wstring";
int f[5] = {1, 3, 0, -2, -4};
vector_t a = {1, 3, 7};
vector_t vec1 = {4, -2, 1}, vec2 = {-5, 2, 3}, *pvec2 = &vec2;
@@ -1599,8 +1596,8 @@ pointer_tests(void)
namesw = NULL;
get_namesw(&n, &namesw);
ok(n == 2, "expected 2, got %d\n", n);
- ok(!lstrcmpW(namesw[0], helloW), "expected Hello, got %s\n", wine_dbgstr_w(namesw[0]));
- ok(!lstrcmpW(namesw[1], worldW), "expected World!, got %s\n", wine_dbgstr_w(namesw[1]));
+ ok(!lstrcmpW(namesw[0], L"Hello"), "expected Hello, got %s\n", wine_dbgstr_w(namesw[0]));
+ ok(!lstrcmpW(namesw[1], L"World!"), "expected World!, got %s\n", wine_dbgstr_w(namesw[1]));
MIDL_user_free(namesw[0]);
MIDL_user_free(namesw[1]);
MIDL_user_free(namesw);
@@ -2464,7 +2461,6 @@ enum firewall_op
static HRESULT set_firewall( enum firewall_op op )
{
- static const WCHAR testW[] = {'r','p','c','r','t','4','_','t','e','s','t',0};
HRESULT hr, init;
INetFwMgr *mgr = NULL;
INetFwPolicy *policy = NULL;
@@ -2504,7 +2500,7 @@ static HRESULT set_firewall( enum firewall_op op )
hr = INetFwAuthorizedApplication_put_ProcessImageFileName( app, image );
if (hr != S_OK) goto done;
- name = SysAllocString( testW );
+ name = SysAllocString( L"rpcrt4_test" );
hr = INetFwAuthorizedApplication_put_Name( app, name );
SysFreeString( name );
ok( hr == S_OK, "got %08x\n", hr );
--
2.26.2
2
3
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleaut32/oleaut.c | 81 ++++++++++---------------------
dlls/oleaut32/olefont.c | 2 +-
dlls/oleaut32/usrmarshal.c | 3 +-
dlls/oleaut32/varformat.c | 98 +++++++++++++++-----------------------
4 files changed, 66 insertions(+), 118 deletions(-)
diff --git a/dlls/oleaut32/oleaut.c b/dlls/oleaut32/oleaut.c
index a026c2bc374..08e6bc6e3f2 100644
--- a/dlls/oleaut32/oleaut.c
+++ b/dlls/oleaut32/oleaut.c
@@ -1138,39 +1138,23 @@ HCURSOR WINAPI OleIconToCursor( HINSTANCE hinstExe, HICON hIcon)
*/
HRESULT WINAPI GetAltMonthNames(LCID lcid, LPOLESTR **str)
{
- static const WCHAR ar_month1W[] = {0x645,0x62d,0x631,0x645,0};
- static const WCHAR ar_month2W[] = {0x635,0x641,0x631,0};
- static const WCHAR ar_month3W[] = {0x631,0x628,0x64a,0x639,' ',0x627,0x644,0x627,0x648,0x644,0};
- static const WCHAR ar_month4W[] = {0x631,0x628,0x64a,0x639,' ',0x627,0x644,0x62b,0x627,0x646,0x64a,0};
- static const WCHAR ar_month5W[] = {0x62c,0x645,0x627,0x62f,0x649,' ',0x627,0x644,0x627,0x648,0x644,0x649,0};
- static const WCHAR ar_month6W[] = {0x62c,0x645,0x627,0x62f,0x649,' ',0x627,0x644,0x62b,0x627,0x646,0x64a,0x629,0};
- static const WCHAR ar_month7W[] = {0x631,0x62c,0x628,0};
- static const WCHAR ar_month8W[] = {0x634,0x639,0x628,0x627,0x646,0};
- static const WCHAR ar_month9W[] = {0x631,0x645,0x636,0x627,0x646,0};
- static const WCHAR ar_month10W[] = {0x634,0x648,0x627,0x643,0};
- static const WCHAR ar_month11W[] = {0x630,0x648,' ',0x627,0x644,0x642,0x639,0x62f,0x629,0};
- static const WCHAR ar_month12W[] = {0x630,0x648,' ',0x627,0x644,0x62d,0x62c,0x629,0};
-
static const WCHAR *arabic_hijri[] =
{
- ar_month1W,
- ar_month2W,
- ar_month3W,
- ar_month4W,
- ar_month5W,
- ar_month6W,
- ar_month7W,
- ar_month8W,
- ar_month9W,
- ar_month10W,
- ar_month11W,
- ar_month12W,
+ L"\x0645\x062d\x0631\x0645",
+ L"\x0635\x0641\x0631",
+ L"\x0631\x0628\x064a\x0639 \x0627\x0644\x0627\x0648\x0644",
+ L"\x0631\x0628\x064a\x0639 \x0627\x0644\x062b\x0627\x0646\x064a",
+ L"\x062c\x0645\x0627\x062f\x0649 \x0627\x0644\x0627\x0648\x0644\x0649",
+ L"\x062c\x0645\x0627\x062f\x0649 \x0627\x0644\x062b\x0627\x0646\x064a\x0629",
+ L"\x0631\x062c\x0628",
+ L"\x0634\x0639\x0628\x0627\x0646",
+ L"\x0631\x0645\x0636\x0627\x0646",
+ L"\x0634\x0648\x0627\x0643",
+ L"\x0630\x0648 \x0627\x0644\x0642\x0639\x062f\x0629",
+ L"\x0630\x0648 \x0627\x0644\x062d\x062c\x0629",
NULL
};
- static const WCHAR pl_month9W[] = {'w','r','z','e',0x15b,'n','i','a',0};
- static const WCHAR pl_month10W[] = {'p','a',0x17a,'d','z','i','e','r','n','i','k','a',0};
-
static const WCHAR *polish_genitive_names[] =
{
L"stycznia",
@@ -1181,40 +1165,27 @@ HRESULT WINAPI GetAltMonthNames(LCID lcid, LPOLESTR **str)
L"czerwca",
L"lipca",
L"sierpnia",
- pl_month9W,
- pl_month10W,
+ L"wrze\x015bnia",
+ L"pa\x017a" "dziernika",
L"listopada",
L"grudnia",
NULL
};
- static const WCHAR ru_month1W[] = {0x44f,0x43d,0x432,0x430,0x440,0x44f,0};
- static const WCHAR ru_month2W[] = {0x444,0x435,0x432,0x440,0x430,0x43b,0x44f,0};
- static const WCHAR ru_month3W[] = {0x43c,0x430,0x440,0x442,0x430,0};
- static const WCHAR ru_month4W[] = {0x430,0x43f,0x440,0x435,0x43b,0x44f,0};
- static const WCHAR ru_month5W[] = {0x43c,0x430,0x44f,0};
- static const WCHAR ru_month6W[] = {0x438,0x44e,0x43d,0x44f,0};
- static const WCHAR ru_month7W[] = {0x438,0x44e,0x43b,0x44f,0};
- static const WCHAR ru_month8W[] = {0x430,0x432,0x433,0x443,0x441,0x442,0x430,0};
- static const WCHAR ru_month9W[] = {0x441,0x435,0x43d,0x442,0x44f,0x431,0x440,0x44f,0};
- static const WCHAR ru_month10W[] = {0x43e,0x43a,0x442,0x44f,0x431,0x440,0x44f,0};
- static const WCHAR ru_month11W[] = {0x43d,0x43e,0x44f,0x431,0x440,0x44f,0};
- static const WCHAR ru_month12W[] = {0x434,0x435,0x43a,0x430,0x431,0x440,0x44f,0};
-
static const WCHAR *russian_genitive_names[] =
{
- ru_month1W,
- ru_month2W,
- ru_month3W,
- ru_month4W,
- ru_month5W,
- ru_month6W,
- ru_month7W,
- ru_month8W,
- ru_month9W,
- ru_month10W,
- ru_month11W,
- ru_month12W,
+ L"\x044f\x043d\x0432\x0430\x0440\x044f",
+ L"\x0444\x0435\x0432\x0440\x0430\x043b\x044f",
+ L"\x043c\x0430\x0440\x0442\x0430",
+ L"\x0430\x043f\x0440\x0435\x043b\x044f",
+ L"\x043c\x0430\x044f",
+ L"\x0438\x044e\x043d\x044f",
+ L"\x0438\x044e\x043b\x044f",
+ L"\x0430\x0432\x0433\x0443\x0441\x0442\x0430",
+ L"\x0441\x0435\x043d\x0442\x044f\x0431\x0440\x044f",
+ L"\x043e\x043a\x0442\x044f\x0431\x0440\x044f",
+ L"\x043d\x043e\x044f\x0431\x0440\x044f",
+ L"\x0434\x0435\x043a\x0430\x0431\x0440\x044f",
NULL
};
diff --git a/dlls/oleaut32/olefont.c b/dlls/oleaut32/olefont.c
index 1fd67f9b1b7..f071d00c602 100644
--- a/dlls/oleaut32/olefont.c
+++ b/dlls/oleaut32/olefont.c
@@ -338,7 +338,7 @@ HRESULT WINAPI OleCreateFontIndirect(
*ppvObj = 0;
if (!lpFontDesc) {
- static WCHAR fname[] = { 'S','y','s','t','e','m',0 };
+ static WCHAR fname[] = L"System";
fd.cbSizeofstruct = sizeof(fd);
fd.lpstrName = fname;
diff --git a/dlls/oleaut32/usrmarshal.c b/dlls/oleaut32/usrmarshal.c
index 163b48f6f46..5eeafb8e378 100644
--- a/dlls/oleaut32/usrmarshal.c
+++ b/dlls/oleaut32/usrmarshal.c
@@ -2261,7 +2261,6 @@ HRESULT __RPC_STUB IPropertyBag_Read_Stub(
DWORD varType,
IUnknown *pUnkObj)
{
- static const WCHAR emptyWstr[] = {0};
IDispatch *disp;
HRESULT hr;
TRACE("(%p, %s, %p, %p, %x, %p)\n", This, debugstr_w(pszPropName), pVar,
@@ -2287,7 +2286,7 @@ HRESULT __RPC_STUB IPropertyBag_Read_Stub(
V_UNKNOWN(pVar) = pUnkObj;
break;
case VT_BSTR:
- V_BSTR(pVar) = SysAllocString(emptyWstr);
+ V_BSTR(pVar) = SysAllocString(L"");
break;
case VT_SAFEARRAY:
FIXME("Safearray support not yet implemented.\n");
diff --git a/dlls/oleaut32/varformat.c b/dlls/oleaut32/varformat.c
index 4fbb2ffa068..e88bf0bc365 100644
--- a/dlls/oleaut32/varformat.c
+++ b/dlls/oleaut32/varformat.c
@@ -44,10 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(variant);
*/
#define LCID_US MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT)
-static const WCHAR szPercent_d[] = { '%','d','\0' };
-static const WCHAR szPercentZeroTwo_d[] = { '%','0','2','d','\0' };
-static const WCHAR szPercentZeroStar_d[] = { '%','0','*','d','\0' };
-
/******************************************************************************
* Variant-Formats {OLEAUT32}
*
@@ -272,7 +268,6 @@ typedef struct tagFMT_DATE_HEADER
#define FMT_STR_COPY_SKIP 0x41 /* Copy len chars or skip if no char */
/* Named Formats and their tokenised values */
-static const WCHAR szGeneralDate[] = { 'G','e','n','e','r','a','l',' ','D','a','t','e','\0' };
static const BYTE fmtGeneralDate[0x0a] =
{
0x0a,FMT_TYPE_DATE,sizeof(FMT_SHORT_HEADER),
@@ -280,7 +275,6 @@ static const BYTE fmtGeneralDate[0x0a] =
FMT_DATE_GENERAL,FMT_GEN_END
};
-static const WCHAR szShortDate[] = { 'S','h','o','r','t',' ','D','a','t','e','\0' };
static const BYTE fmtShortDate[0x0a] =
{
0x0a,FMT_TYPE_DATE,sizeof(FMT_SHORT_HEADER),
@@ -288,7 +282,6 @@ static const BYTE fmtShortDate[0x0a] =
FMT_DATE_SHORT,FMT_GEN_END
};
-static const WCHAR szMediumDate[] = { 'M','e','d','i','u','m',' ','D','a','t','e','\0' };
static const BYTE fmtMediumDate[0x0a] =
{
0x0a,FMT_TYPE_DATE,sizeof(FMT_SHORT_HEADER),
@@ -296,7 +289,6 @@ static const BYTE fmtMediumDate[0x0a] =
FMT_DATE_MEDIUM,FMT_GEN_END
};
-static const WCHAR szLongDate[] = { 'L','o','n','g',' ','D','a','t','e','\0' };
static const BYTE fmtLongDate[0x0a] =
{
0x0a,FMT_TYPE_DATE,sizeof(FMT_SHORT_HEADER),
@@ -304,7 +296,6 @@ static const BYTE fmtLongDate[0x0a] =
FMT_DATE_LONG,FMT_GEN_END
};
-static const WCHAR szShortTime[] = { 'S','h','o','r','t',' ','T','i','m','e','\0' };
static const BYTE fmtShortTime[0x0c] =
{
0x0c,FMT_TYPE_DATE,sizeof(FMT_SHORT_HEADER),
@@ -312,7 +303,6 @@ static const BYTE fmtShortTime[0x0c] =
FMT_DATE_TIME_UNK2,FMT_DATE_TIME_SEP,FMT_DATE_MIN_0,FMT_GEN_END
};
-static const WCHAR szMediumTime[] = { 'M','e','d','i','u','m',' ','T','i','m','e','\0' };
static const BYTE fmtMediumTime[0x11] =
{
0x11,FMT_TYPE_DATE,sizeof(FMT_SHORT_HEADER),
@@ -321,7 +311,6 @@ static const BYTE fmtMediumTime[0x11] =
FMT_GEN_INLINE,0x01,' ','\0',FMT_DATE_AMPM_SYS1,FMT_GEN_END
};
-static const WCHAR szLongTime[] = { 'L','o','n','g',' ','T','i','m','e','\0' };
static const BYTE fmtLongTime[0x0d] =
{
0x0a,FMT_TYPE_DATE,sizeof(FMT_SHORT_HEADER),
@@ -329,7 +318,6 @@ static const BYTE fmtLongTime[0x0d] =
FMT_DATE_TIME_SYS,FMT_GEN_END
};
-static const WCHAR szTrueFalse[] = { 'T','r','u','e','/','F','a','l','s','e','\0' };
static const BYTE fmtTrueFalse[0x0d] =
{
0x0d,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x0,0x0,0x0,
@@ -337,7 +325,6 @@ static const BYTE fmtTrueFalse[0x0d] =
FMT_NUM_TRUE_FALSE,FMT_GEN_END
};
-static const WCHAR szYesNo[] = { 'Y','e','s','/','N','o','\0' };
static const BYTE fmtYesNo[0x0d] =
{
0x0d,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x0,0x0,0x0,
@@ -345,7 +332,6 @@ static const BYTE fmtYesNo[0x0d] =
FMT_NUM_YES_NO,FMT_GEN_END
};
-static const WCHAR szOnOff[] = { 'O','n','/','O','f','f','\0' };
static const BYTE fmtOnOff[0x0d] =
{
0x0d,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x0,0x0,0x0,
@@ -353,13 +339,11 @@ static const BYTE fmtOnOff[0x0d] =
FMT_NUM_ON_OFF,FMT_GEN_END
};
-static const WCHAR szGeneralNumber[] = { 'G','e','n','e','r','a','l',' ','N','u','m','b','e','r','\0' };
static const BYTE fmtGeneralNumber[sizeof(FMT_HEADER)] =
{
sizeof(FMT_HEADER),FMT_TYPE_GENERAL,sizeof(FMT_HEADER),0x0,0x0,0x0
};
-static const WCHAR szCurrency[] = { 'C','u','r','r','e','n','c','y','\0' };
static const BYTE fmtCurrency[0x26] =
{
0x26,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x12,0x0,0x0,
@@ -374,7 +358,6 @@ static const BYTE fmtCurrency[0x26] =
FMT_GEN_END
};
-static const WCHAR szFixed[] = { 'F','i','x','e','d','\0' };
static const BYTE fmtFixed[0x11] =
{
0x11,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x0,0x0,0x0,
@@ -382,7 +365,6 @@ static const BYTE fmtFixed[0x11] =
FMT_NUM_COPY_ZERO,0x1,FMT_NUM_DECIMAL,FMT_NUM_COPY_ZERO,0x2,FMT_GEN_END
};
-static const WCHAR szStandard[] = { 'S','t','a','n','d','a','r','d','\0' };
static const BYTE fmtStandard[0x11] =
{
0x11,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x0,0x0,0x0,
@@ -390,7 +372,6 @@ static const BYTE fmtStandard[0x11] =
FMT_NUM_COPY_ZERO,0x1,FMT_NUM_DECIMAL,FMT_NUM_COPY_ZERO,0x2,FMT_GEN_END
};
-static const WCHAR szPercent[] = { 'P','e','r','c','e','n','t','\0' };
static const BYTE fmtPercent[0x15] =
{
0x15,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x0,0x0,0x0,
@@ -399,7 +380,6 @@ static const BYTE fmtPercent[0x15] =
FMT_GEN_INLINE,0x1,'%','\0',FMT_GEN_END
};
-static const WCHAR szScientific[] = { 'S','c','i','e','n','t','i','f','i','c','\0' };
static const BYTE fmtScientific[0x13] =
{
0x13,FMT_TYPE_NUMBER,sizeof(FMT_HEADER),0x0,0x0,0x0,
@@ -416,22 +396,22 @@ typedef struct tagNAMED_FORMAT
/* Format name to tokenised format. Must be kept sorted by name */
static const NAMED_FORMAT VARIANT_NamedFormats[] =
{
- { szCurrency, fmtCurrency },
- { szFixed, fmtFixed },
- { szGeneralDate, fmtGeneralDate },
- { szGeneralNumber, fmtGeneralNumber },
- { szLongDate, fmtLongDate },
- { szLongTime, fmtLongTime },
- { szMediumDate, fmtMediumDate },
- { szMediumTime, fmtMediumTime },
- { szOnOff, fmtOnOff },
- { szPercent, fmtPercent },
- { szScientific, fmtScientific },
- { szShortDate, fmtShortDate },
- { szShortTime, fmtShortTime },
- { szStandard, fmtStandard },
- { szTrueFalse, fmtTrueFalse },
- { szYesNo, fmtYesNo }
+ { L"Currency", fmtCurrency },
+ { L"Fixed", fmtFixed },
+ { L"General Date", fmtGeneralDate },
+ { L"General Number", fmtGeneralNumber },
+ { L"Long Date", fmtLongDate },
+ { L"Long Time", fmtLongTime },
+ { L"Medium Date", fmtMediumDate },
+ { L"Medium Time", fmtMediumTime },
+ { L"On/Off", fmtOnOff },
+ { L"Percent", fmtPercent },
+ { L"Scientific", fmtScientific },
+ { L"Short Date", fmtShortDate },
+ { L"Short Time", fmtShortTime },
+ { L"Standard", fmtStandard },
+ { L"True/False", fmtTrueFalse },
+ { L"Yes/No", fmtYesNo }
};
typedef const NAMED_FORMAT *LPCNAMED_FORMAT;
@@ -1415,13 +1395,13 @@ VARIANT_FormatNumber_Bool:
if (exponent < 0)
{
*pBuff++ = '-';
- swprintf(pBuff, ARRAY_SIZE(buff) - (pBuff - buff), szPercentZeroStar_d, pToken[1], -exponent);
+ swprintf(pBuff, ARRAY_SIZE(buff) - (pBuff - buff), L"%0*d", pToken[1], -exponent);
}
else
{
if (*pToken == FMT_NUM_EXP_POS_L || *pToken == FMT_NUM_EXP_POS_U)
*pBuff++ = '+';
- swprintf(pBuff, ARRAY_SIZE(buff) - (pBuff - buff), szPercentZeroStar_d, pToken[1], exponent);
+ swprintf(pBuff, ARRAY_SIZE(buff) - (pBuff - buff), L"%0*d", pToken[1], exponent);
}
while (*pBuff)
pBuff++;
@@ -1697,12 +1677,12 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
break;
case FMT_DATE_DAY:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.st.wDay;
break;
case FMT_DATE_DAY_0:
- szPrintFmt = szPercentZeroTwo_d;
+ szPrintFmt = L"%02d";
dwVal = udate.st.wDay;
break;
@@ -1736,7 +1716,7 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
break;
case FMT_DATE_DAY_WEEK:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
if (pToken[1])
dwVal = udate.st.wDayOfWeek + 2 - pToken[1];
else
@@ -1749,19 +1729,19 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
break;
case FMT_DATE_WEEK_YEAR:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.wDayOfYear / 7 + 1;
pToken += 2;
FIXME("Ignoring nFirstDay of %d, nFirstWeek of %d\n", pToken[0], pToken[1]);
break;
case FMT_DATE_MON:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.st.wMonth;
break;
case FMT_DATE_MON_0:
- szPrintFmt = szPercentZeroTwo_d;
+ szPrintFmt = L"%02d";
dwVal = udate.st.wMonth;
break;
@@ -1780,58 +1760,58 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
break;
case FMT_DATE_YEAR_DOY:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.wDayOfYear;
break;
case FMT_DATE_YEAR_0:
- szPrintFmt = szPercentZeroTwo_d;
+ szPrintFmt = L"%02d";
dwVal = udate.st.wYear % 100;
break;
case FMT_DATE_YEAR_LONG:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.st.wYear;
break;
case FMT_DATE_MIN:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.st.wMinute;
break;
case FMT_DATE_MIN_0:
- szPrintFmt = szPercentZeroTwo_d;
+ szPrintFmt = L"%02d";
dwVal = udate.st.wMinute;
break;
case FMT_DATE_SEC:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.st.wSecond;
break;
case FMT_DATE_SEC_0:
- szPrintFmt = szPercentZeroTwo_d;
+ szPrintFmt = L"%02d";
dwVal = udate.st.wSecond;
break;
case FMT_DATE_HOUR:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.st.wHour;
break;
case FMT_DATE_HOUR_0:
case FMT_DATE_TIME_UNK2:
- szPrintFmt = szPercentZeroTwo_d;
+ szPrintFmt = L"%02d";
dwVal = udate.st.wHour;
break;
case FMT_DATE_HOUR_12:
- szPrintFmt = szPercent_d;
+ szPrintFmt = L"%d";
dwVal = udate.st.wHour ? udate.st.wHour > 12 ? udate.st.wHour - 12 : udate.st.wHour : 12;
break;
case FMT_DATE_HOUR_12_0:
- szPrintFmt = szPercentZeroTwo_d;
+ szPrintFmt = L"%02d";
dwVal = udate.st.wHour ? udate.st.wHour > 12 ? udate.st.wHour - 12 : udate.st.wHour : 12;
break;
@@ -1918,7 +1898,7 @@ static HRESULT VARIANT_FormatString(LPVARIANT pVarIn, LPOLESTR lpszFormat,
LPBYTE rgbTok, ULONG dwFlags,
BSTR *pbstrOut, LCID lcid)
{
- static WCHAR szEmpty[] = { '\0' };
+ static WCHAR szEmpty[] = L"";
WCHAR buff[256], *pBuff = buff;
WCHAR *pSrc;
FMT_HEADER *header = (FMT_HEADER*)rgbTok;
@@ -2189,7 +2169,7 @@ HRESULT WINAPI VarFormat(LPVARIANT pVarIn, LPOLESTR lpszFormat,
*/
HRESULT WINAPI VarFormatDateTime(LPVARIANT pVarIn, INT nFormat, ULONG dwFlags, BSTR *pbstrOut)
{
- static WCHAR szEmpty[] = { '\0' };
+ static WCHAR szEmpty[] = L"";
const BYTE* lpFmt = NULL;
TRACE("%s,%d,0x%08x,%p)\n", debugstr_variant(pVarIn), nFormat, dwFlags, pbstrOut);
@@ -2345,8 +2325,6 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
HRESULT WINAPI VarFormatPercent(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT nParens,
INT nGrouping, ULONG dwFlags, BSTR *pbstrOut)
{
- static const WCHAR szPercent[] = { '%','\0' };
- static const WCHAR szPercentBracket[] = { '%',')','\0' };
WCHAR buff[256];
HRESULT hRet;
VARIANT vDbl;
@@ -2382,7 +2360,7 @@ HRESULT WINAPI VarFormatPercent(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
dwLen -= bBracket;
memcpy(buff, *pbstrOut, dwLen * sizeof(WCHAR));
- lstrcpyW(buff + dwLen, bBracket ? szPercentBracket : szPercent);
+ lstrcpyW(buff + dwLen, bBracket ? L"%)" : L"%");
SysFreeString(*pbstrOut);
*pbstrOut = SysAllocString(buff);
if (!*pbstrOut)
--
2.26.2
1
0
28 Nov '20
Signed-off-by: Derek Lesho <dlesho(a)codeweavers.com>
---
v3:
- Rebase against 133ba763e1f419dc23fd58ac82c6d8a73014ae22.
- Remove accidental inclusion of test.mp3.
---
dlls/mf/tests/Makefile.in | 2 -
dlls/mf/tests/mf.c | 601 +++++++++++++++++++++++++++++++-------
dlls/mf/tests/resource.rc | 22 --
3 files changed, 499 insertions(+), 126 deletions(-)
delete mode 100644 dlls/mf/tests/resource.rc
diff --git a/dlls/mf/tests/Makefile.in b/dlls/mf/tests/Makefile.in
index 5eb9ee4d4e3..614eb4fbc9e 100644
--- a/dlls/mf/tests/Makefile.in
+++ b/dlls/mf/tests/Makefile.in
@@ -3,5 +3,3 @@ IMPORTS = mf mfplat mfuuid ole32 user32
C_SRCS = \
mf.c
-
-RC_SRCS = resource.rc
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c
index fda80974724..092735466be 100644
--- a/dlls/mf/tests/mf.c
+++ b/dlls/mf/tests/mf.c
@@ -44,6 +44,7 @@ DEFINE_GUID(MFVideoFormat_ABGR32, 0x00000020, 0x0000, 0x0010, 0x80, 0x00, 0x00,
#include "mmdeviceapi.h"
#include "audioclient.h"
#include "evr.h"
+#include "propvarutil.h"
#include "wine/test.h"
@@ -97,34 +98,6 @@ static HWND create_window(void)
0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
}
-static WCHAR *load_resource(const WCHAR *name)
-{
- static WCHAR pathW[MAX_PATH];
- DWORD written;
- HANDLE file;
- HRSRC res;
- void *ptr;
-
- GetTempPathW(ARRAY_SIZE(pathW), pathW);
- lstrcatW(pathW, name);
-
- file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0,
- NULL, CREATE_ALWAYS, 0, 0);
- ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n",
- wine_dbgstr_w(pathW), GetLastError());
-
- res = FindResourceW(NULL, name, (LPCWSTR)RT_RCDATA);
- ok(res != 0, "couldn't find resource\n");
- ptr = LockResource(LoadResource(GetModuleHandleA(NULL), res));
- WriteFile(file, ptr, SizeofResource(GetModuleHandleA(NULL), res),
- &written, NULL);
- ok(written == SizeofResource(GetModuleHandleA(NULL), res),
- "couldn't write resource\n" );
- CloseHandle(file);
-
- return pathW;
-}
-
static HRESULT WINAPI test_unk_QueryInterface(IUnknown *iface, REFIID riid, void **obj)
{
if (IsEqualIID(riid, &IID_IUnknown))
@@ -1447,26 +1420,316 @@ static const IMFSampleGrabberSinkCallbackVtbl test_grabber_callback_vtbl =
test_grabber_callback_OnShutdown,
};
+struct test_source
+{
+ IMFMediaSource IMFMediaSource_iface;
+ LONG refcount;
+};
+
+static struct test_source *impl_from_IMFMediaSource(IMFMediaSource *iface)
+{
+ return CONTAINING_RECORD(iface, struct test_source, IMFMediaSource_iface);
+}
+
+static HRESULT WINAPI test_source_QueryInterface(IMFMediaSource *iface, REFIID riid, void **out)
+{
+ if (IsEqualIID(riid, &IID_IMFMediaSource)
+ || IsEqualIID(riid, &IID_IMFMediaEventGenerator)
+ || IsEqualIID(riid, &IID_IUnknown))
+ {
+ *out = iface;
+ }
+ else
+ {
+ *out = NULL;
+ return E_NOINTERFACE;
+ }
+
+ IMFMediaSource_AddRef(iface);
+ return S_OK;
+}
+
+static ULONG WINAPI test_source_AddRef(IMFMediaSource *iface)
+{
+ struct test_source *source = impl_from_IMFMediaSource(iface);
+ return InterlockedIncrement(&source->refcount);
+}
+
+static ULONG WINAPI test_source_Release(IMFMediaSource *iface)
+{
+ struct test_source *source = impl_from_IMFMediaSource(iface);
+ ULONG refcount = InterlockedDecrement(&source->refcount);
+
+ if (!refcount)
+ HeapFree(GetProcessHeap(), 0, source);
+
+ return refcount;
+}
+
+static HRESULT WINAPI test_source_GetEvent(IMFMediaSource *iface, DWORD flags, IMFMediaEvent **event)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_BeginGetEvent(IMFMediaSource *iface, IMFAsyncCallback *callback, IUnknown *state)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_EndGetEvent(IMFMediaSource *iface, IMFAsyncResult *result, IMFMediaEvent **event)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_QueueEvent(IMFMediaSource *iface, MediaEventType event_type, REFGUID ext_type,
+ HRESULT hr, const PROPVARIANT *value)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_GetCharacteristics(IMFMediaSource *iface, DWORD *flags)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_CreatePresentationDescriptor(IMFMediaSource *iface, IMFPresentationDescriptor **pd)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_Start(IMFMediaSource *iface, IMFPresentationDescriptor *pd, const GUID *time_format,
+ const PROPVARIANT *start_position)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_Stop(IMFMediaSource *iface)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_Pause(IMFMediaSource *iface)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI test_source_Shutdown(IMFMediaSource *iface)
+{
+ ok(0, "Unexpected call.\n");
+ return E_NOTIMPL;
+}
+
+static const IMFMediaSourceVtbl test_source_vtbl =
+{
+ test_source_QueryInterface,
+ test_source_AddRef,
+ test_source_Release,
+ test_source_GetEvent,
+ test_source_BeginGetEvent,
+ test_source_EndGetEvent,
+ test_source_QueueEvent,
+ test_source_GetCharacteristics,
+ test_source_CreatePresentationDescriptor,
+ test_source_Start,
+ test_source_Stop,
+ test_source_Pause,
+ test_source_Shutdown,
+};
+
+static IMFMediaSource *create_test_source(void)
+{
+ struct test_source *source;
+
+ source = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*source));
+ source->IMFMediaSource_iface.lpVtbl = &test_source_vtbl;
+ source->refcount = 1;
+
+ return &source->IMFMediaSource_iface;
+}
+
static void test_topology_loader(void)
{
+ static const struct resolution_test
+ {
+ union
+ {
+ WAVEFORMATEX input_type;
+ MPEGLAYER3WAVEFORMAT mp3_input_type;
+ };
+ WAVEFORMATEX output_type;
+ MF_CONNECT_METHOD method;
+ HRESULT expected_result;
+ BOOL expect_decoder, expect_converter, wine_todo;
+ }
+ resolution_tests[] =
+ {
+ {
+ .input_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .output_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .method = MF_CONNECT_DIRECT,
+ .expected_result = S_OK,
+ .expect_decoder = FALSE,
+ .expect_converter = FALSE,
+ .wine_todo = FALSE,
+ },
+ {
+ .input_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .output_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 48000,
+ .nAvgBytesPerSec = 48000, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .method = MF_CONNECT_DIRECT,
+ .expected_result = MF_E_INVALIDMEDIATYPE,
+ .expect_decoder = FALSE,
+ .expect_converter = FALSE,
+ .wine_todo = FALSE,
+ },
+ {
+ .input_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .output_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 48000,
+ .nAvgBytesPerSec = 48000, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .method = MF_CONNECT_ALLOW_CONVERTER,
+ .expected_result = S_OK,
+ .expect_decoder = FALSE,
+ .expect_converter = TRUE,
+ .wine_todo = TRUE,
+ },
+ /* Test MF_TOPONODE_CONNECT_METHOD:
+ - 0x1 (MF_CONNECT_ALLOW_CONVERTER) allows converters
+ - 0x3 (MF_CONNECT_ALLOW_DECODER) allows converters and decoders
+ - 0x2 allows neither */
+ {
+ .mp3_input_type = {
+ {
+ .wFormatTag = WAVE_FORMAT_MPEGLAYER3, .nChannels = 2, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 16000, .nBlockAlign = 1, .wBitsPerSample = 0, .cbSize = MPEGLAYER3_WFX_EXTRA_BYTES,
+ },
+ .wID = MPEGLAYER3_ID_MPEG,
+ .fdwFlags = 0,
+ .nBlockSize = 417,
+ .nFramesPerBlock = 0,
+ .nCodecDelay = 0,
+ },
+ .output_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .method = MF_CONNECT_DIRECT,
+ .expected_result = MF_E_INVALIDMEDIATYPE,
+ .expect_decoder = FALSE,
+ .expect_converter = FALSE,
+ .wine_todo = TRUE,
+ },
+ {
+ .mp3_input_type = {
+ {
+ .wFormatTag = WAVE_FORMAT_MPEGLAYER3, .nChannels = 2, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 16000, .nBlockAlign = 1, .wBitsPerSample = 0, .cbSize = MPEGLAYER3_WFX_EXTRA_BYTES,
+ },
+ .wID = MPEGLAYER3_ID_MPEG,
+ .fdwFlags = 0,
+ .nBlockSize = 417,
+ .nFramesPerBlock = 0,
+ .nCodecDelay = 0,
+ },
+ .output_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 2, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .method = MF_CONNECT_ALLOW_CONVERTER,
+ .expected_result = MF_E_TRANSFORM_NOT_POSSIBLE_FOR_CURRENT_MEDIATYPE_COMBINATION,
+ .expect_decoder = FALSE,
+ .expect_converter = FALSE,
+ .wine_todo = TRUE,
+ },
+ {
+ .mp3_input_type = {
+ {
+ .wFormatTag = WAVE_FORMAT_MPEGLAYER3, .nChannels = 2, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 16000, .nBlockAlign = 1, .wBitsPerSample = 0, .cbSize = MPEGLAYER3_WFX_EXTRA_BYTES,
+ },
+ .wID = MPEGLAYER3_ID_MPEG,
+ .fdwFlags = 0,
+ .nBlockSize = 417,
+ .nFramesPerBlock = 0,
+ .nCodecDelay = 0,
+ },
+ .output_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 2, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .method = 2,
+ .expected_result = MF_E_INVALIDMEDIATYPE,
+ .expect_decoder = FALSE,
+ .expect_converter = FALSE,
+ .wine_todo = TRUE,
+ },
+ {
+ .mp3_input_type = {
+ {
+ .wFormatTag = WAVE_FORMAT_MPEGLAYER3, .nChannels = 2, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 16000, .nBlockAlign = 1, .wBitsPerSample = 0, .cbSize = MPEGLAYER3_WFX_EXTRA_BYTES,
+ },
+ .wID = MPEGLAYER3_ID_MPEG,
+ .fdwFlags = 0,
+ .nBlockSize = 417,
+ .nFramesPerBlock = 0,
+ .nCodecDelay = 0,
+ },
+ .output_type = {
+ .wFormatTag = WAVE_FORMAT_PCM, .nChannels = 1, .nSamplesPerSec = 44100,
+ .nAvgBytesPerSec = 44100, .nBlockAlign = 1, .wBitsPerSample = 8, .cbSize = 0,
+ },
+ .method = MF_CONNECT_ALLOW_DECODER,
+ .expected_result = S_OK,
+ .expect_decoder = TRUE,
+ .expect_converter = FALSE,
+ .wine_todo = TRUE,
+ },
+ };
+
IMFSampleGrabberSinkCallback test_grabber_callback = { &test_grabber_callback_vtbl };
+ IMFTopologyNode *src_node, *sink_node, *src_node2, *sink_node2, *mft_node;
IMFTopology *topology, *topology2, *full_topology;
- IMFTopologyNode *src_node, *sink_node;
+ unsigned int count, value, index;
IMFPresentationDescriptor *pd;
- IMFSourceResolver *resolver;
IMFActivate *sink_activate;
IMFStreamSink *stream_sink;
- unsigned int count, value;
+ MF_TOPOLOGY_TYPE node_type;
IMFMediaType *media_type;
IMFStreamDescriptor *sd;
- MF_OBJECT_TYPE obj_type;
+ IMFTransform *transform;
IMFMediaSource *source;
IMFTopoLoader *loader;
- IMFByteStream *stream;
- IMFAttributes *attr;
+ IUnknown *node_object;
+ BOOL compare_result;
IMFMediaSink *sink;
- WCHAR *filename;
- BOOL selected;
+ WORD node_count;
+ unsigned int i;
+ TOPOID node_id;
HRESULT hr;
GUID guid;
@@ -1487,44 +1750,41 @@ static void test_topology_loader(void)
todo_wine
ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#x.\n", hr);
- hr = MFCreateSourceResolver(&resolver);
- ok(hr == S_OK, "Failed to create source resolver, hr %#x.\n", hr);
+ /* Add source node. */
+ hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &src_node);
+ ok(hr == S_OK, "Failed to create topology node, hr %#x.\n", hr);
- filename = load_resource(L"test.wav");
+ /* when a decoder is involved, windows requires this attribute to be present */
+ source = create_test_source();
- hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &stream);
- ok(hr == S_OK, "Failed to create file stream, hr %#x.\n", hr);
+ hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_SOURCE, (IUnknown *)source);
+ ok(hr == S_OK, "Failed to set node source, hr %#x.\n", hr);
- IMFByteStream_QueryInterface(stream, &IID_IMFAttributes, (void **)&attr);
- IMFAttributes_SetString(attr, &MF_BYTESTREAM_CONTENT_TYPE, L"audio/wav");
- IMFAttributes_Release(attr);
+ IMFMediaSource_Release(source);
- hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, stream, NULL, MF_RESOLUTION_MEDIASOURCE, NULL,
- &obj_type, (IUnknown **)&source);
- ok(hr == S_OK || broken(FAILED(hr)) /* Vista */, "Failed to create source, hr %#x.\n", hr);
- if (FAILED(hr))
- return;
+ hr = MFCreateMediaType(&media_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
- hr = IMFMediaSource_CreatePresentationDescriptor(source, &pd);
- ok(hr == S_OK, "Failed to create descriptor, hr %#x.\n", hr);
- if (FAILED(hr))
- return;
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
+ ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
- hr = IMFPresentationDescriptor_GetStreamDescriptorByIndex(pd, 0, &selected, &sd);
- ok(hr == S_OK, "Failed to get stream descriptor, hr %#x.\n", hr);
+ hr = MFCreateStreamDescriptor(0, 1, &media_type, &sd);
+ ok(hr == S_OK, "Failed to create stream descriptor, hr %#x.\n");
- /* Add source node. */
- hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &src_node);
- ok(hr == S_OK, "Failed to create topology node, hr %#x.\n", hr);
+ hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_STREAM_DESCRIPTOR, (IUnknown *)sd);
+ ok(hr == S_OK, "Failed to set node sd, hr %#x.\n", hr);
- hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_SOURCE, (IUnknown *)source);
- ok(hr == S_OK, "Failed to set node source, hr %#x.\n", hr);
+ hr = MFCreatePresentationDescriptor(1, &sd, &pd);
+ ok(hr == S_OK, "Failed to create presentation descriptor, hr %#x.\n");
hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_PRESENTATION_DESCRIPTOR, (IUnknown *)pd);
ok(hr == S_OK, "Failed to set node pd, hr %#x.\n", hr);
- hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_STREAM_DESCRIPTOR, (IUnknown *)sd);
- ok(hr == S_OK, "Failed to set node sd, hr %#x.\n", hr);
+ IMFPresentationDescriptor_Release(pd);
+ IMFStreamDescriptor_Release(sd);
+ IMFMediaType_Release(media_type);
hr = IMFTopology_AddNode(topology, src_node);
ok(hr == S_OK, "Failed to add a node, hr %#x.\n", hr);
@@ -1534,7 +1794,9 @@ todo_wine
todo_wine
ok(hr == MF_E_TOPO_UNSUPPORTED, "Unexpected hr %#x.\n", hr);
- /* Add grabber sink. */
+ hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &sink_node);
+ ok(hr == S_OK, "Failed to create output node, hr %#x.\n", hr);
+
hr = MFCreateMediaType(&media_type);
ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
@@ -1546,13 +1808,11 @@ todo_wine
hr = MFCreateSampleGrabberSinkActivate(media_type, &test_grabber_callback, &sink_activate);
ok(hr == S_OK, "Failed to create grabber sink, hr %#x.\n", hr);
- IMFMediaType_Release(media_type);
-
- hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &sink_node);
- ok(hr == S_OK, "Failed to create output node, hr %#x.\n", hr);
-
hr = IMFTopologyNode_SetObject(sink_node, (IUnknown *)sink_activate);
ok(hr == S_OK, "Failed to set object, hr %#x.\n", hr);
+
+ IMFMediaType_Release(media_type);
+
hr = IMFTopology_AddNode(topology, sink_node);
ok(hr == S_OK, "Failed to add sink node, hr %#x.\n", hr);
@@ -1567,55 +1827,192 @@ todo_wine
hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL);
ok(hr == MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED, "Unexpected hr %#x.\n", hr);
- hr = IMFActivate_ActivateObject(sink_activate, &IID_IMFMediaSink, (void **)&sink);
- ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
+ for (i = 0; i < ARRAY_SIZE(resolution_tests); i++)
+ {
+ IMFMediaType *input_type, *output_type;
+ IMFMediaTypeHandler *mth;
- hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ /* TODO: remove once MFInitMediaTypeFromWaveFormatEx gains support for non-zero cbSize */
+ if(resolution_tests[i].wine_todo && !strcmp(winetest_platform, "wine"))
+ {
+ todo_wine ok(0, "Skipping test %u on wine.\n", i);
+ continue;
+ }
- hr = IMFTopologyNode_SetObject(sink_node, (IUnknown *)stream_sink);
- ok(hr == S_OK, "Failed to set object, hr %#x.\n", hr);
+ hr = MFCreateMediaType(&input_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
- IMFStreamSink_Release(stream_sink);
+ hr = MFInitMediaTypeFromWaveFormatEx(input_type, &resolution_tests[i].input_type, sizeof(WAVEFORMATEX) + resolution_tests[i].input_type.cbSize);
+ ok(hr == S_OK, "MFInitMediaTypeFromWaveFormatEx failed, hr %#x.\n", hr);
- hr = IMFTopology_GetCount(topology, &count);
- ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
- ok(count == 0, "Unexpected count %u.\n", count);
+ hr = MFCreateMediaType(&output_type);
+ ok(hr == S_OK, "Failed to create media type, hr %#x.\n", hr);
- hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL);
- ok(hr == S_OK, "Failed to resolve topology, hr %#x.\n", hr);
- ok(full_topology != topology, "Unexpected instance.\n");
+ hr = MFInitMediaTypeFromWaveFormatEx(output_type, &resolution_tests[i].output_type, sizeof(WAVEFORMATEX) + resolution_tests[i].output_type.cbSize);
+ ok(hr == S_OK, "MFInitMediaTypeFromWaveFormatEx failed, hr %#x.\n", hr);
- hr = IMFTopology_GetCount(topology, &count);
- ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
- ok(count == 0, "Unexpected count %u.\n", count);
+ hr = MFCreateStreamDescriptor(0, 1, &input_type, &sd);
+ ok(hr == S_OK, "Failed to create stream descriptor, hr %#x.\n", hr);
- hr = IMFTopology_GetCount(full_topology, &count);
- ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
+ hr = IMFStreamDescriptor_GetMediaTypeHandler(sd, &mth);
+ ok(hr == S_OK, "Failed to get media type handler, hr %#x.\n", hr);
+
+ hr = IMFMediaTypeHandler_SetCurrentMediaType(mth, input_type);
+ ok(hr == S_OK, "Failed to set current media type, hr %#x.\n", hr);
+
+ IMFMediaTypeHandler_Release(mth);
+
+ hr = MFCreatePresentationDescriptor(1, &sd, &pd);
+ ok(hr == S_OK, "Failed to create presentation descriptor, hr %#x.\n", hr);
+
+ hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_PRESENTATION_DESCRIPTOR, (IUnknown *)pd);
+ ok(hr == S_OK, "Failed to set node pd, hr %#x.\n", hr);
+
+ IMFPresentationDescriptor_Release(pd);
+
+ hr = IMFTopologyNode_SetUnknown(src_node, &MF_TOPONODE_STREAM_DESCRIPTOR, (IUnknown *)sd);
+ ok(hr == S_OK, "Failed to set node sd, hr %#x.\n", hr);
+
+ IMFStreamDescriptor_Release(sd);
+
+ hr = MFCreateSampleGrabberSinkActivate(output_type, &test_grabber_callback, &sink_activate);
+ ok(hr == S_OK, "Failed to create grabber sink, hr %#x.\n", hr);
+
+ hr = IMFActivate_ActivateObject(sink_activate, &IID_IMFMediaSink, (void **)&sink);
+ ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
+
+ hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ IMFMediaSink_Release(sink);
+
+ hr = IMFTopologyNode_SetObject(sink_node, (IUnknown *)stream_sink);
+ ok(hr == S_OK, "Failed to set object, hr %#x.\n", hr);
+
+ IMFStreamSink_Release(stream_sink);
+
+ hr = IMFTopologyNode_SetUINT32(sink_node, &MF_TOPONODE_CONNECT_METHOD, resolution_tests[i].method);
+ ok(hr == S_OK, "Failed to set connect method, hr %#x.\n", hr);
+
+ hr = IMFTopology_GetCount(topology, &count);
+ ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
+ ok(count == 0, "Unexpected count %u.\n", count);
+
+ hr = IMFTopoLoader_Load(loader, topology, &full_topology, NULL);
+todo_wine_if(resolution_tests[i].wine_todo)
+ ok(hr == resolution_tests[i].expected_result, "Unexpected hr %#x on test %u.\n", hr, i);
+ ok(full_topology != topology, "Unexpected instance.\n");
+
+ if (resolution_tests[i].expected_result == S_OK && hr == S_OK)
+ {
+ hr = IMFTopology_GetCount(full_topology, &count);
+ ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
todo_wine
- ok(count == 1, "Unexpected count %u.\n", count);
+ ok(count == 1, "Unexpected count %u.\n", count);
- hr = IMFTopology_GetItemByIndex(full_topology, 0, &guid, NULL);
+ hr = IMFTopology_GetItemByIndex(full_topology, 0, &guid, NULL);
todo_wine {
- ok(hr == S_OK, "Failed to get attribute key, hr %#x.\n", hr);
- ok(IsEqualGUID(&guid, &MF_TOPOLOGY_RESOLUTION_STATUS), "Unexpected key %s.\n", wine_dbgstr_guid(&guid));
+ ok(hr == S_OK, "Failed to get attribute key, hr %#x.\n", hr);
+ ok(IsEqualGUID(&guid, &MF_TOPOLOGY_RESOLUTION_STATUS), "Unexpected key %s.\n", wine_dbgstr_guid(&guid));
}
- value = 0xdeadbeef;
- hr = IMFTopology_GetUINT32(full_topology, &MF_TOPOLOGY_RESOLUTION_STATUS, &value);
+ value = 0xdeadbeef;
+ hr = IMFTopology_GetUINT32(full_topology, &MF_TOPOLOGY_RESOLUTION_STATUS, &value);
todo_wine {
- ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
- ok(value == MF_TOPOLOGY_RESOLUTION_SUCCEEDED, "Unexpected value %#x.\n", value);
+ ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
+ ok(value == MF_TOPOLOGY_RESOLUTION_SUCCEEDED, "Unexpected value %#x.\n", value);
}
- hr = IMFTopoLoader_Load(loader, full_topology, &topology2, NULL);
- ok(hr == S_OK, "Failed to resolve topology, hr %#x.\n", hr);
- ok(full_topology != topology2, "Unexpected instance.\n");
- IMFTopology_Release(topology2);
- IMFTopology_Release(full_topology);
+ hr = IMFTopology_GetNodeCount(full_topology, &node_count);
+ ok(hr == S_OK, "Failed to get node count, hr %#x.\n", hr);
+ ok(node_count == 2 + resolution_tests[i].expect_decoder + resolution_tests[i].expect_converter, "Unexpected node count %u.\n", node_count);
+
+ hr = IMFTopologyNode_GetTopoNodeID(src_node, &node_id);
+ ok(hr == S_OK, "Failed to get source node id, hr %#x.\n", hr);
+
+ hr = IMFTopology_GetNodeByID(full_topology, node_id, &src_node2);
+ ok(hr == S_OK, "Failed to get source in resolved topology, hr %#x.\n", hr);
+
+ hr = IMFTopologyNode_GetTopoNodeID(sink_node, &node_id);
+ ok(hr == S_OK, "Failed to get sink node id, hr %#x.\n", hr);
+
+ hr = IMFTopology_GetNodeByID(full_topology, node_id, &sink_node2);
+ ok(hr == S_OK, "Failed to get sink in resolved topology, hr %#x.\n", hr);
+
+ if (resolution_tests[i].expect_decoder || resolution_tests[i].expect_converter)
+ {
+ hr = IMFTopologyNode_GetOutput(src_node2, 0, &mft_node, &index);
+ ok(hr == S_OK, "Failed to get transform node in resolved topology, hr %#x.\n", hr);
+ ok(index == 0, "Unexpected stream index %u.\n", index);
+
+ hr = IMFTopologyNode_GetNodeType(mft_node, &node_type);
+ ok(hr == S_OK, "Failed to get transform node type in resolved topology, hr %#x.\n", hr);
+ ok(node_type == MF_TOPOLOGY_TRANSFORM_NODE, "Unexpected node type %u, expected MF_TOPOLOGY_TRANSFORM_NODE.\n", node_type);
+
+ hr = IMFTopologyNode_GetObject(mft_node, &node_object);
+ ok(hr == S_OK, "Failed to get object of transform node, hr %#x.\n", hr);
+
+ hr = IUnknown_QueryInterface(node_object, &IID_IMFTransform, (void**) &transform);
+ ok(hr == S_OK, "Failed to get IMFTransform from transform node's object, hr %#x.\n", hr);
+ IUnknown_Release(node_object);
+
+ hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type);
+ ok(hr == S_OK, "Failed to get transform input type, hr %#x.\n", hr);
+
+ hr = IMFMediaType_Compare(media_type, (IMFAttributes *)input_type, MF_ATTRIBUTES_MATCH_ALL_ITEMS, &compare_result);
+ ok(hr == S_OK, "Failed to compare media types, hr %#x.\n", hr);
+ ok(compare_result, "Input type of first transform doesn't match source node type.\n");
+
+ IMFTopologyNode_Release(mft_node);
+ IMFMediaType_Release(media_type);
+ IMFTransform_Release(transform);
+
+ hr = IMFTopologyNode_GetInput(sink_node2, 0, &mft_node, &index);
+ ok(hr == S_OK, "Failed to get transform node in resolved topology, hr %#x.\n", hr);
+ ok(index == 0, "Unexpected stream index %u.\n", index);
+
+ hr = IMFTopologyNode_GetNodeType(mft_node, &node_type);
+ ok(hr == S_OK, "Failed to get transform node type in resolved topology, hr %#x.\n", hr);
+ ok(node_type == MF_TOPOLOGY_TRANSFORM_NODE, "Unexpected node type %u, expected MF_TOPOLOGY_TRANSFORM_NODE.\n", node_type);
+
+ hr = IMFTopologyNode_GetObject(mft_node, &node_object);
+ ok(hr == S_OK, "Failed to get object of transform node, hr %#x.\n", hr);
+
+ hr = IUnknown_QueryInterface(node_object, &IID_IMFTransform, (void**) &transform);
+ ok(hr == S_OK, "Failed to get IMFTransform from transform node's object, hr %#x.\n", hr);
+ IUnknown_Release(node_object);
+
+ hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type);
+ ok(hr == S_OK, "Failed to get transform output type, hr %#x.\n", hr);
+
+ hr = IMFMediaType_Compare(media_type, (IMFAttributes *)output_type, MF_ATTRIBUTES_MATCH_ALL_ITEMS, &compare_result);
+ ok(hr == S_OK, "Failed to compare media types, hr %#x.\n", hr);
+ ok(compare_result, "Output type of last transform doesn't match sink node type.\n");
+
+ IMFTopologyNode_Release(mft_node);
+ IMFMediaType_Release(media_type);
+ IMFTransform_Release(transform);
+ }
+
+ IMFTopologyNode_Release(sink_node2);
+
+ hr = IMFTopoLoader_Load(loader, full_topology, &topology2, NULL);
+ ok(hr == S_OK, "Failed to resolve topology, hr %#x.\n", hr);
+ ok(full_topology != topology2, "Unexpected instance.\n");
+
+ IMFTopology_Release(topology2);
+ IMFTopology_Release(full_topology);
+ }
+
+ hr = IMFTopology_GetCount(topology, &count);
+ ok(hr == S_OK, "Failed to get attribute count, hr %#x.\n", hr);
+ ok(count == 0, "Unexpected count %u.\n", count);
+
+ IMFActivate_ShutdownObject(sink_activate);
+ IMFActivate_Release(sink_activate);
+ IMFMediaType_Release(input_type);
+ IMFMediaType_Release(output_type);
+ }
- IMFMediaSource_Release(source);
- IMFSourceResolver_Release(resolver);
- IMFByteStream_Release(stream);
IMFTopoLoader_Release(loader);
hr = MFShutdown();
diff --git a/dlls/mf/tests/resource.rc b/dlls/mf/tests/resource.rc
deleted file mode 100644
index f54212a8c8f..00000000000
--- a/dlls/mf/tests/resource.rc
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2019 Nikolay Sivov for CodeWeavers
- *
- * 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"
-
-/* @makedep: test.wav */
-test.wav RCDATA test.wav
--
2.29.2
2
7