Nikolay Sivov : scrrun: Add a stub for pipe-based text stream.

Alexandre Julliard julliard at winehq.org
Thu Feb 17 15:34:00 CST 2022


Module: wine
Branch: master
Commit: 5a66eab725423951860676aef49feeb3668eb20c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5a66eab725423951860676aef49feeb3668eb20c

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Feb 17 16:11:56 2022 +0300

scrrun: Add a stub for pipe-based text stream.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/scrrun/filesystem.c       | 138 ++++++++++++++++++++++++++++++++++++++---
 dlls/scrrun/tests/filesystem.c |  23 ++++---
 2 files changed, 145 insertions(+), 16 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index d16ecb722dc..4794437a71d 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -706,20 +706,21 @@ static HRESULT WINAPI textstream_SkipLine(ITextStream *iface)
 
 static HRESULT WINAPI textstream_Close(ITextStream *iface)
 {
-    struct textstream *This = impl_from_ITextStream(iface);
+    struct textstream *stream = impl_from_ITextStream(iface);
     HRESULT hr = S_OK;
 
-    TRACE("(%p)\n", This);
+    TRACE("%p.\n", iface);
 
-    if(!CloseHandle(This->file))
+    if (!CloseHandle(stream->file))
         hr = S_FALSE;
 
-    This->file = NULL;
+    stream->file = NULL;
 
     return hr;
 }
 
-static const ITextStreamVtbl textstreamvtbl = {
+static const ITextStreamVtbl textstreamvtbl =
+{
     textstream_QueryInterface,
     textstream_AddRef,
     textstream_Release,
@@ -742,6 +743,114 @@ static const ITextStreamVtbl textstreamvtbl = {
     textstream_Close
 };
 
+static HRESULT WINAPI pipestream_get_Line(ITextStream *iface, LONG *line)
+{
+    FIXME("%p, %p.\n", iface, line);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_get_Column(ITextStream *iface, LONG *column)
+{
+    FIXME("%p, %p.\n", iface, column);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_get_AtEndOfStream(ITextStream *iface, VARIANT_BOOL *eos)
+{
+    FIXME("%p, %p.\n", iface, eos);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_get_AtEndOfLine(ITextStream *iface, VARIANT_BOOL *eol)
+{
+    FIXME("%p, %p.\n", iface, eol);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_Read(ITextStream *iface, LONG len, BSTR *text)
+{
+    FIXME("%p, %ld, %p.\n", iface, len, text);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_ReadLine(ITextStream *iface, BSTR *text)
+{
+    FIXME("%p, %p.\n", iface, text);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_ReadAll(ITextStream *iface, BSTR *text)
+{
+    FIXME("%p, %p.\n", iface, text);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_Write(ITextStream *iface, BSTR text)
+{
+    FIXME("%p, %s.\n", iface, debugstr_w(text));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_WriteLine(ITextStream *iface, BSTR text)
+{
+    FIXME("%p, %s.\n", iface, debugstr_w(text));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_WriteBlankLines(ITextStream *iface, LONG lines)
+{
+    FIXME("%p, %ld.\n", iface, lines);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_Skip(ITextStream *iface, LONG count)
+{
+    FIXME("%p, %ld.\n", iface, count);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI pipestream_SkipLine(ITextStream *iface)
+{
+    FIXME("%p.\n", iface);
+
+    return E_NOTIMPL;
+}
+
+static const ITextStreamVtbl pipestreamvtbl =
+{
+    textstream_QueryInterface,
+    textstream_AddRef,
+    textstream_Release,
+    textstream_GetTypeInfoCount,
+    textstream_GetTypeInfo,
+    textstream_GetIDsOfNames,
+    textstream_Invoke,
+    pipestream_get_Line,
+    pipestream_get_Column,
+    pipestream_get_AtEndOfStream,
+    pipestream_get_AtEndOfLine,
+    pipestream_Read,
+    pipestream_ReadLine,
+    pipestream_ReadAll,
+    pipestream_Write,
+    pipestream_WriteLine,
+    pipestream_WriteBlankLines,
+    pipestream_Skip,
+    pipestream_SkipLine,
+    textstream_Close
+};
+
 static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMode mode, Tristate format, ITextStream **ret)
 {
     static const unsigned short utf16bom = 0xfeff;
@@ -839,11 +948,24 @@ static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMod
     return S_OK;
 }
 
-HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **stream)
+HRESULT WINAPI DoOpenPipeStream(HANDLE pipe, IOMode mode, ITextStream **ret)
 {
-    FIXME("%p, %d, %p.\n", pipe, mode, stream);
+    struct textstream *stream;
 
-    return E_NOTIMPL;
+    TRACE("%p, %d, %p.\n", pipe, mode, ret);
+
+    if (!(stream = calloc(1, sizeof(*stream))))
+        return E_OUTOFMEMORY;
+
+    stream->ITextStream_iface.lpVtbl = &pipestreamvtbl;
+    stream->ref = 1;
+    stream->mode = mode;
+    stream->file = pipe;
+
+    init_classinfo(&CLSID_TextStream, (IUnknown *)&stream->ITextStream_iface, &stream->classinfo);
+    *ret = &stream->ITextStream_iface;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI drive_QueryInterface(IDrive *iface, REFIID riid, void **obj)
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index 098060a90bb..894b6251f34 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -2613,7 +2613,6 @@ static void test_DoOpenPipeStream(void)
     ok(ret, "Failed to create pipes.\n");
 
     hr = pDoOpenPipeStream(piperead, ForReading, &stream_read);
-    todo_wine
     ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
     if (SUCCEEDED(hr))
     {
@@ -2624,9 +2623,13 @@ static void test_DoOpenPipeStream(void)
         ok(written == sizeof(testdata), "Write to anonymous pipe wrote %ld bytes.\n", written);
 
         hr = ITextStream_Read(stream_read, 4, &str);
+        todo_wine
         ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
-        ok(!wcscmp(str, L"test"), "Unexpected data read %s.\n", wine_dbgstr_w(str));
-        SysFreeString(str);
+        if (SUCCEEDED(hr))
+        {
+            ok(!wcscmp(str, L"test"), "Unexpected data read %s.\n", wine_dbgstr_w(str));
+            SysFreeString(str);
+        }
 
         ITextStream_Release(stream_read);
     }
@@ -2635,7 +2638,6 @@ static void test_DoOpenPipeStream(void)
     ok(ret, "Unexpected return value.\n");
     /* Stream takes ownership. */
     ret = CloseHandle(piperead);
-    todo_wine
     ok(!ret, "Unexpected return value.\n");
 
     /* Streams on both ends. */
@@ -2644,32 +2646,37 @@ static void test_DoOpenPipeStream(void)
 
     stream_read = NULL;
     hr = pDoOpenPipeStream(piperead, ForReading, &stream_read);
-    todo_wine
     ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
 
     stream_write = NULL;
     hr = pDoOpenPipeStream(pipewrite, ForWriting, &stream_write);
-    todo_wine
     ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
 
     if (SUCCEEDED(hr))
     {
         str = SysAllocString(L"data");
         hr = ITextStream_Write(stream_write, str);
+        todo_wine
         ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
 
         hr = ITextStream_Write(stream_read, str);
+        todo_wine
         ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#lx.\n", hr);
 
         SysFreeString(str);
 
         hr = ITextStream_Read(stream_write, 1, &str);
+        todo_wine
         ok(hr == CTL_E_BADFILEMODE, "Unexpected hr %#lx.\n", hr);
 
         hr = ITextStream_Read(stream_read, 4, &str);
+        todo_wine
         ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
-        ok(!wcscmp(str, L"data"), "Unexpected data.\n");
-        SysFreeString(str);
+        if (SUCCEEDED(hr))
+        {
+            ok(!wcscmp(str, L"data"), "Unexpected data.\n");
+            SysFreeString(str);
+        }
     }
 
     if (stream_read)




More information about the wine-cvs mailing list